You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "DaanHoogland (via GitHub)" <gi...@apache.org> on 2023/10/02 05:50:39 UTC
[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #8022: New feature: VNF templates and appliances integration
DaanHoogland commented on code in PR #8022:
URL: https://github.com/apache/cloudstack/pull/8022#discussion_r1342294948
##########
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"]
+ )
Review Comment:
```suggestion
cls.domain = Domain.create(
cls.apiclient,
cls.services["domain"]
)
cls._cleanup.append(cls.domain)
```
##########
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
+ ]
Review Comment:
```suggestion
```
##########
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
+ )
Review Comment:
```suggestion
cls.account = Account.create(
cls.apiclient,
cls.services["account"],
admin=True,
domainid=cls.domain.id
)
cls._cleanup.append(cls.account)
```
##########
server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java:
##########
@@ -418,6 +430,18 @@ public UserVmResponse newUserVmResponse(ResponseView view, String objectName, Us
addVmRxTxDataToResponse(userVm, userVmResponse);
+ if (TemplateType.VNF.equals(userVm.getTemplateType()) && (details.contains(VMDetails.all) || details.contains(VMDetails.vnfnics))) {
+ List<VnfTemplateNicVO> vnfNics = vnfTemplateNicDao.listByTemplateId(userVm.getTemplateId());
+ for (VnfTemplateNicVO nic : vnfNics) {
+ userVmResponse.addVnfNic(new VnfNicResponse(nic.getDeviceId(), nic.getDeviceName(), nic.getRequired(), nic.getDescription()));
+ }
+ List<VnfTemplateDetailVO> vnfDetails = vnfTemplateDetailsDao.listDetails(userVm.getTemplateId());
+ Collections.sort(vnfDetails, (v1, v2) -> v1.getName().compareToIgnoreCase(v2.getName()));
+ for (VnfTemplateDetailVO detail : vnfDetails) {
+ userVmResponse.addVnfDetail(detail.getName(), detail.getValue());
+ }
+ }
Review Comment:
can we extract this?
##########
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:
should this be unregistered after the test?
--
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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org