DaanHoogland commented on code in PR #8022:
URL: https://github.com/apache/cloudstack/pull/8022#discussion_r1344268840


##########
api/src/main/java/org/apache/cloudstack/api/command/user/template/UpdateVnfTemplateCmd.java:
##########
@@ -0,0 +1,77 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.template;
+
+import com.cloud.network.VNF;
+
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.user.UserCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.cloudstack.storage.template.VnfTemplateUtils;
+
+import java.util.List;
+import java.util.Map;
+
+@APICommand(name = "updateVnfTemplate", description = "Updates a template to 
VNF template or attributes of a VNF template.",
+        responseObject = TemplateResponse.class, responseView = 
ResponseView.Restricted,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User})
+public class UpdateVnfTemplateCmd extends UpdateTemplateCmd implements UserCmd 
{
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.VNF_NICS,
+            type = CommandType.MAP,
+            description = "VNF nics in key/value pairs using format 
details[i].keyname=keyvalue. "

Review Comment:
   ```suggestion
               description = "VNF nics in key/value pairs using format 
vnfnics[i].keyname=keyvalue. "
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/admin/template/UpdateVnfTemplateCmdByAdmin.java:
##########
@@ -0,0 +1,30 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.template;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.admin.AdminCmd;
+import org.apache.cloudstack.api.command.user.template.UpdateVnfTemplateCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+
+@APICommand(name = "updateVnfTemplate",
+        description = "Updates a template to VNF template or attributes of a 
VNF template.",
+        responseObject = TemplateResponse.class, responseView = 
ResponseView.Full,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)

Review Comment:
   ```suggestion
   @APICommand(name = "updateVnfTemplate",
           description = "Updates a template to VNF template or attributes of a 
VNF template.",
           responseObject = TemplateResponse.class, responseView = 
ResponseView.Full,
           requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
           since="4.19.0")
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/user/vm/DeployVnfApplianceCmd.java:
##########
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.vm;
+
+import com.cloud.vm.VirtualMachine;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ResponseObject;
+import org.apache.cloudstack.api.command.user.UserCmd;
+import org.apache.cloudstack.api.response.UserVmResponse;
+
+@APICommand(name = "deployVnfAppliance",
+        description = "Creates and automatically starts a VNF appliance based 
on a service offering, disk offering, and template.",
+        responseObject = UserVmResponse.class,
+        responseView = ResponseObject.ResponseView.Restricted,
+        entityType = {VirtualMachine.class},
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = true,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User})

Review Comment:
   ```suggestion
   @APICommand(name = "deployVnfAppliance",
           description = "Creates and automatically starts a VNF appliance 
based on a service offering, disk offering, and template.",
           responseObject = UserVmResponse.class,
           responseView = ResponseObject.ResponseView.Restricted,
           entityType = {VirtualMachine.class},
           requestHasSensitiveInfo = false, responseHasSensitiveInfo = true,
           authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User},
           since="4.19.0")
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/admin/template/ListVnfTemplatesCmdByAdmin.java:
##########
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.template;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.admin.AdminCmd;
+import org.apache.cloudstack.api.command.user.template.ListVnfTemplatesCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+
+import com.cloud.template.VirtualMachineTemplate;
+
+@APICommand(name = "listVnfTemplates", description = "List all public, 
private, and privileged VNF templates.",
+        responseObject = TemplateResponse.class, entityType = 
{VirtualMachineTemplate.class}, responseView = ResponseView.Full,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)

Review Comment:
   ```suggestion
   @APICommand(name = "listVnfTemplates", description = "List all public, 
private, and privileged VNF templates.",
           responseObject = TemplateResponse.class, entityType = 
{VirtualMachineTemplate.class}, responseView = ResponseView.Full,
           requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
           since="4.19.0")
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/admin/template/RegisterVnfTemplateCmdByAdmin.java:
##########
@@ -0,0 +1,30 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.template;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.admin.AdminCmd;
+import org.apache.cloudstack.api.command.user.template.RegisterVnfTemplateCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+
+@APICommand(name = "registerVnfTemplate",
+        description = "Registers an existing VNF template into the CloudStack 
cloud. ",
+        responseObject = TemplateResponse.class, responseView = 
ResponseView.Full,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)

Review Comment:
   ```suggestion
   @APICommand(name = "registerVnfTemplate",
           description = "Registers an existing VNF template into the 
CloudStack cloud. ",
           responseObject = TemplateResponse.class, responseView = 
ResponseView.Full,
           requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
           since="4.19.0")
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/user/template/UpdateVnfTemplateCmd.java:
##########
@@ -0,0 +1,77 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.template;
+
+import com.cloud.network.VNF;
+
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.user.UserCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.cloudstack.storage.template.VnfTemplateUtils;
+
+import java.util.List;
+import java.util.Map;
+
+@APICommand(name = "updateVnfTemplate", description = "Updates a template to 
VNF template or attributes of a VNF template.",
+        responseObject = TemplateResponse.class, responseView = 
ResponseView.Restricted,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User})
+public class UpdateVnfTemplateCmd extends UpdateTemplateCmd implements UserCmd 
{
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.VNF_NICS,
+            type = CommandType.MAP,
+            description = "VNF nics in key/value pairs using format 
details[i].keyname=keyvalue. "
+                    + " Example: 
vnfnics[0].deviceid=0&&vnfnics[0].name=FirstNIC&&vnfnics[0].required=true"
+                    + "&&vnfnics[1].deviceid=1&&vnfnics[1].name=SecondNIC")
+    protected Map vnfNics;
+
+    @Parameter(name = ApiConstants.VNF_DETAILS,
+            type = CommandType.MAP,
+            description = "VNF details in key/value pairs using format 
details[i].keyname=keyvalue. "
+                    + "Example: 
vnfdetails[0].vendor=xxx&&details[0].version=2.0")

Review Comment:
   ```suggestion
               description = "VNF details in key/value pairs using format 
vnfdetails[i].keyname=keyvalue. "
                       + "Example: 
vnfdetails[0].vendor=xxx&&vnfdetails[0].version=2.0")
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/user/template/DeleteVnfTemplateCmd.java:
##########
@@ -0,0 +1,46 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.template;
+
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.SuccessResponse;
+
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.user.Account;
+
+@APICommand(name = "deleteVnfTemplate",
+        responseObject = SuccessResponse.class,
+        description = "Deletes a VNF template from the system. All virtual 
machines using the deleted template will not be affected.",
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User})

Review Comment:
   ```suggestion
   @APICommand(name = "deleteVnfTemplate",
           responseObject = SuccessResponse.class,
           description = "Deletes a VNF template from the system. All virtual 
machines using the deleted template will not be affected.",
           requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
           authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User},
            since="4.19.0")
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/user/template/RegisterVnfTemplateCmd.java:
##########
@@ -0,0 +1,78 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.template;
+
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.network.VNF;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.user.UserCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.cloudstack.storage.template.VnfTemplateUtils;
+
+@APICommand(name = "registerVnfTemplate",
+        description = "Registers an existing VNF template into the CloudStack 
cloud. ",
+        responseObject = TemplateResponse.class, responseView = 
ResponseView.Restricted,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User})
+public class RegisterVnfTemplateCmd extends RegisterTemplateCmd implements 
UserCmd {
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.VNF_NICS,
+            type = CommandType.MAP,
+            description = "VNF nics in key/value pairs using format 
details[i].keyname=keyvalue. "

Review Comment:
   ```suggestion
               description = "VNF nics in key/value pairs using format 
vnfnics[i].keyname=keyvalue. "
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/user/template/ListVnfTemplatesCmd.java:
##########
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.template;
+
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.user.UserCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+
+import com.cloud.template.VirtualMachineTemplate;
+
+@APICommand(name = "listVnfTemplates", description = "List all public, 
private, and privileged VNF templates.",
+        responseObject = TemplateResponse.class, entityType = 
{VirtualMachineTemplate.class}, responseView = ResponseView.Restricted,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User})

Review Comment:
   ```suggestion
   @APICommand(name = "listVnfTemplates", description = "List all public, 
private, and privileged VNF templates.",
           responseObject = TemplateResponse.class, entityType = 
{VirtualMachineTemplate.class}, responseView = ResponseView.Restricted,
           requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
           authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User},
           since="4.19.0")
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/user/template/RegisterVnfTemplateCmd.java:
##########
@@ -0,0 +1,78 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.template;
+
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.network.VNF;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.user.UserCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.cloudstack.storage.template.VnfTemplateUtils;
+
+@APICommand(name = "registerVnfTemplate",
+        description = "Registers an existing VNF template into the CloudStack 
cloud. ",
+        responseObject = TemplateResponse.class, responseView = 
ResponseView.Restricted,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User})
+public class RegisterVnfTemplateCmd extends RegisterTemplateCmd implements 
UserCmd {
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.VNF_NICS,
+            type = CommandType.MAP,
+            description = "VNF nics in key/value pairs using format 
details[i].keyname=keyvalue. "
+                    + " Example: 
vnfnics[0].deviceid=0&&vnfnics[0].name=FirstNIC&&vnfnics[0].required=true"
+                    + "&&vnfnics[1].deviceid=1&&vnfnics[1].name=SecondNIC")
+    protected Map vnfNics;
+
+    @Parameter(name = ApiConstants.VNF_DETAILS,
+            type = CommandType.MAP,
+            description = "VNF details in key/value pairs using format 
details[i].keyname=keyvalue. "
+                    + "Example: 
vnfdetails[0].vendor=xxx&&details[0].version=2.0")

Review Comment:
   ```suggestion
               description = "VNF details in key/value pairs using format 
vnfdetails[i].keyname=keyvalue. "
                       + "Example: 
vnfdetails[0].vendor=xxx&&vnfdetails[0].version=2.0")
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java:
##########
@@ -41,7 +42,8 @@ public class UpdateTemplateCmd extends 
BaseUpdateTemplateOrIsoCmd implements Use
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
-    @Parameter(name = "templatetype", type = CommandType.STRING, description = 
"the type of the template")
+    @Parameter(name = ApiConstants.TEMPLATE_TYPE, type = CommandType.STRING,
+            description = "the type of the template. Valid options are: 
USER/VNF (for all users) and SYSTEM/ROUTING/BUILTIN (for admins only).")

Review Comment:
   ```suggestion
       @Parameter(name = ApiConstants.TEMPLATE_TYPE, type = CommandType.STRING,
               description = "the type of the template. Valid options are: 
USER/VNF (for all users) and SYSTEM/ROUTING/BUILTIN (for admins only).",
           since="4.19.0")
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/user/template/UpdateVnfTemplateCmd.java:
##########
@@ -0,0 +1,77 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.template;
+
+import com.cloud.network.VNF;
+
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.user.UserCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.cloudstack.storage.template.VnfTemplateUtils;
+
+import java.util.List;
+import java.util.Map;
+
+@APICommand(name = "updateVnfTemplate", description = "Updates a template to 
VNF template or attributes of a VNF template.",
+        responseObject = TemplateResponse.class, responseView = 
ResponseView.Restricted,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User})

Review Comment:
   ```suggestion
   @APICommand(name = "updateVnfTemplate", description = "Updates a template to 
VNF template or attributes of a VNF template.",
           responseObject = TemplateResponse.class, responseView = 
ResponseView.Restricted,
           requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
           authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User},
           since="4.19.0")
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/user/template/RegisterVnfTemplateCmd.java:
##########
@@ -0,0 +1,78 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.template;
+
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.network.VNF;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.user.UserCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.cloudstack.storage.template.VnfTemplateUtils;
+
+@APICommand(name = "registerVnfTemplate",
+        description = "Registers an existing VNF template into the CloudStack 
cloud. ",
+        responseObject = TemplateResponse.class, responseView = 
ResponseView.Restricted,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User})

Review Comment:
   ```suggestion
   @APICommand(name = "registerVnfTemplate",
           description = "Registers an existing VNF template into the 
CloudStack cloud. ",
           responseObject = TemplateResponse.class, responseView = 
ResponseView.Restricted,
           requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
           authorized = {RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User},
           since="4.19.0")
   ```



##########
test/integration/smoke/test_vnf_templates.py:
##########
@@ -0,0 +1,338 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Smoke tests for VNF templates/appliances
+"""
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.base import (Account,
+                             Domain,
+                             Configurations,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Network,
+                             NetworkOffering,
+                             VnfTemplate,
+                             Zone)
+from marvin.lib.common import get_zone, get_template
+from nose.plugins.attrib import attr
+
+import time
+
+VNF_NICS = [{"deviceid": "0", "name": "WAN", "required": "true", 
"description": "Public WAN"},
+          {"deviceid": "1", "name": "LAN-1", "required": "true", 
"description": "Private LAN-1"}]
+NEW_VNF_NICS = [{"deviceid": "0", "name": "WAN", "required": "true", 
"description": "Public WAN"},
+          {"deviceid": "1", "name": "LAN-1", "required": "true", 
"description": "Private LAN-1"},
+          {"deviceid": "2", "name": "LAN-2", "required": "false", 
"description": "Private LAN-2"}]
+VNF_DETAILS = [{"access_methods": "console,https,http", "username": "root"}]
+NEW_VNF_DETAILS = [{"access_methods": "console,https,http", "username": 
"root", "password": "cloudstack"}]
+
+class TestVnfTemplates(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+
+        testClient = super(TestVnfTemplates, cls).getClsTestClient()
+        cls.apiclient = testClient.getApiClient()
+        cls._cleanup = []
+        cls.services = testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+
+        cls.domain = Domain.create(
+            cls.apiclient,
+            cls.services["domain"]
+        )
+        cls.account = Account.create(
+            cls.apiclient,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
+        cls.user = cls.account.user[0]
+        cls.user_apiclient = cls.testClient.getUserApiClient(
+            cls.user.username, cls.domain.name
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        cls._cleanup = [
+            cls.service_offering,
+            cls.domain,
+            cls.account
+        ]
+
+        cls.vnf_template_config = {
+            "name": "pfsense",
+            "displaytext": "pfsense",
+            "format": "QCOW2",
+            "url": cls.template.url,
+            "requireshvm": "True",
+            "ispublic": "True",
+            "isextractable": "True",
+            "hypervisor": cls.hypervisor,
+            "zoneid": cls.zone.id,
+            "ostype": "FreeBSD 12 (64-bit)",
+            "directdownload": False
+        }
+
+        cls.initial_setting = Configurations.list(
+            cls.apiclient,
+            name="vnf.template.appliance.enabled")[0].value
+
+        Configurations.update(cls.apiclient, "vnf.template.appliance.enabled", 
"true")
+
+        cls.vnf_templates = []
+
+    @classmethod
+    def tearDownClass(cls):
+        Configurations.update(cls.apiclient, "vnf.template.appliance.enabled", 
cls.initial_setting)
+        super(TestVnfTemplates, cls).tearDownClass()
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.cleanup = []
+
+    def tearDown(self):
+        super(TestVnfTemplates, self).tearDown()
+
+    @attr(tags=["advanced"], required_hardware="false")
+    def test_01_register_vnf_template(self):
+        """Test register VNF template
+        """
+        self.vnf_template = VnfTemplate.register(self.user_apiclient,
+                                                 self.vnf_template_config,
+                                                 zoneid=self.zone.id,
+                                                 hypervisor=self.hypervisor,
+                                                 vnfnics=VNF_NICS,
+                                                 vnfdetails=VNF_DETAILS)

Review Comment:
   I think these (tests 1 and 5) should be part of setup and teardown. In this 
way the order of the tests matters, which can lead to issues of intermittend 
failures. Tests, even integration tests should be atomic.



##########
ui/src/views/image/RegisterOrUploadTemplate.vue:
##########
@@ -1,3 +1,4 @@
+

Review Comment:
   ```suggestion
   ```



##########
api/src/main/java/org/apache/cloudstack/api/command/admin/vm/DeployVnfApplianceCmdByAdmin.java:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.vm;
+
+import com.cloud.vm.VirtualMachine;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ResponseObject;
+import org.apache.cloudstack.api.command.admin.AdminCmd;
+import org.apache.cloudstack.api.command.user.vm.DeployVnfApplianceCmd;
+import org.apache.cloudstack.api.response.UserVmResponse;
+
+@APICommand(name = "deployVnfAppliance",
+        description = "Creates and automatically starts a VNF appliance based 
on a service offering, disk offering, and template.",
+        responseObject = UserVmResponse.class,
+        responseView = ResponseObject.ResponseView.Full,
+        entityType = {VirtualMachine.class},
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)

Review Comment:
   ```suggestion
   @APICommand(name = "deployVnfAppliance",
           description = "Creates and automatically starts a VNF appliance 
based on a service offering, disk offering, and template.",
           responseObject = UserVmResponse.class,
           responseView = ResponseObject.ResponseView.Full,
           entityType = {VirtualMachine.class},
           requestHasSensitiveInfo = false, responseHasSensitiveInfo = true,
           since="4.19.0")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to