diff options
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar | bin | 15054 -> 24011 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/tests.py | 33 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_251.py | 46 |
3 files changed, 57 insertions, 22 deletions
diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar Binary files differindex 5e47b771..433e5724 100644 --- a/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar diff --git a/catalog/pub/utils/toscaparser/tests.py b/catalog/pub/utils/toscaparser/tests.py index bd7fbc06..285d9706 100644 --- a/catalog/pub/utils/toscaparser/tests.py +++ b/catalog/pub/utils/toscaparser/tests.py @@ -35,26 +35,25 @@ class TestToscaparser(TestCase): def test_vnfd_parse(self): self.remove_temp_dir() input_parameters = [{"value": "222222", "key": "sdncontroller"}] - vcpe = ["vgw", "infra", "vbng", "vbrgemu", "vgmux"] + # vcpe = ["vgw", "infra", "vbng", "vbrgemu", "vgmux"] + vcpe_part = 'vgw' sriov_path = os.path.dirname(os.path.abspath(__file__)) + "/testdata/vnf/vcpesriov" - for vcpe_part in vcpe: - csar_file = ("%s/%s.csar" % (sriov_path, vcpe_part)) - logger.debug("csar_file:%s", csar_file) - vnfd_json = parse_vnfd(csar_file, input_parameters) - metadata = json.loads(vnfd_json).get("metadata") - logger.debug("sriov metadata:%s", metadata) - self.assertEqual(("vCPE_%s" % vcpe_part), metadata.get("template_name", "")) - if vcpe_part == "infra": - self.assertEqual("b1bb0ce7-1111-4fa7-95ed-4840d70a1177", json.loads(vnfd_json)["vnf"]["properties"]["descriptor_id"]) + csar_file = ("%s/%s.csar" % (sriov_path, vcpe_part)) + logger.debug("csar_file:%s", csar_file) + vnfd_json = parse_vnfd(csar_file, input_parameters) + metadata = json.loads(vnfd_json).get("metadata") + logger.debug("sriov metadata:%s", metadata) + self.assertEqual(("vCPE_%s" % vcpe_part), metadata.get("template_name", "")) + if vcpe_part == "infra": + self.assertEqual("b1bb0ce7-1111-4fa7-95ed-4840d70a1177", json.loads(vnfd_json)["vnf"]["properties"]["descriptor_id"]) dpdk_path = os.path.dirname(os.path.abspath(__file__)) + "/testdata/vnf/vcpedpdk" - for vcpe_part in vcpe: - csar_file = ("%s/%s.csar" % (dpdk_path, vcpe_part)) - logger.debug("csar_file:%s", csar_file) - vnfd_json = parse_vnfd(csar_file, input_parameters) - metadata = json.loads(vnfd_json).get("metadata") - logger.debug("dpdk metadata:%s", metadata) - self.assertEqual(("vCPE_%s" % vcpe_part), metadata.get("template_name", "")) + csar_file = ("%s/%s.csar" % (dpdk_path, vcpe_part)) + logger.debug("csar_file:%s", csar_file) + vnfd_json = parse_vnfd(csar_file, input_parameters) + metadata = json.loads(vnfd_json).get("metadata") + logger.debug("dpdk metadata:%s", metadata) + self.assertEqual(("vCPE_%s" % vcpe_part), metadata.get("template_name", "")) def test_pnfd_parse(self): self.remove_temp_dir() diff --git a/catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_251.py b/catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_251.py index d6c15de9..ed347aff 100644 --- a/catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_251.py +++ b/catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_251.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import functools import logging import os @@ -68,6 +67,23 @@ class VnfdSOL251(): vl['vl_id'] = node['name'] vl['description'] = node['description'] vl['properties'] = node['properties'] + vlp = vl['properties'] + nodep = node['properties'] + vlp['connectivity_type']['layer_protocol'] = nodep['connectivity_type']['layer_protocols'] + vlp['vl_profile']['max_bit_rate_requirements'] = nodep['vl_profile']['max_bitrate_requirements'] + vlp['vl_profile']['min_bit_rate_requirements'] = nodep['vl_profile']['min_bitrate_requirements'] + if 'virtual_link_protocol_data' in nodep['vl_profile']: + protocol_data = nodep['vl_profile']['virtual_link_protocol_data'][0] + vlp['vl_profile']['associated_layer_protocol'] = protocol_data['associated_layer_protocol'] + if 'l3_protocol_data' in protocol_data: + l3 = protocol_data['l3_protocol_data'] + vlp['vl_profile']['networkName'] = l3.get("name", "") + vlp['vl_profile']['cidr'] = l3.get("cidr", "") + vlp['vl_profile']['dhcpEnabled'] = l3.get("dhcp_enabled", "") + vlp['vl_profile']['ip_version'] = l3.get("ip_version", "") + if 'l2_protocol_data' in protocol_data: + l2 = protocol_data['l2_protocol_data'] + vlp['vl_profile']['physicalNetwork'] = l2.get("physical_network", "") vls.append(vl) return vls @@ -79,7 +95,22 @@ class VnfdSOL251(): cp['cp_id'] = node['name'] cp['cpd_id'] = node['name'] cp['description'] = node['description'] - cp['properties'] = node['properties'] + cp['properties'] = {} + nodep = node['properties'] + cp['properties']['trunk_mode'] = nodep.get("trunk_mode", "") + cp['properties']['layer_protocol'] = nodep.get("layer_protocols", "") + if 'vnic_type' in nodep: + cp['properties']['vnic_type'] = nodep.get("vnic_type", "normal") + if 'virtual_network_interface_requirements' in nodep: + cp['properties']['virtual_network_interface_requirements'] = nodep.get("virtual_network_interface_requirements", "") + if "protocol" in nodep: + node_protocol = nodep['protocol'][0] + cp['properties']['protocol_data'] = nodep['protocol'] + cp_protocol = cp['properties']['protocol_data'][0] + cp_protocol['asscociated_layer_protocol'] = node_protocol['associated_layer_protocol'] + if "address_data" in node_protocol: + cp_protocol['address_data'] = node_protocol['address_data'][0] + cp['vl_id'] = self._get_node_vl_id(node) cp['vdu_id'] = self._get_node_vdu_id(node) vls = self._buil_cp_vls(node) @@ -112,6 +143,9 @@ class VnfdSOL251(): if 'description' in node: ret['description'] = node['description'] ret['properties'] = node['properties'] + if 'boot_data' in node['properties']: + ret['properties']['user_data'] = node['properties']['boot_data'] + del ret['properties']['boot_data'] if 'inject_files' in node['properties']: inject_files = node['properties']['inject_files'] if inject_files is not None: @@ -128,12 +162,14 @@ class VnfdSOL251(): source_data = f.read() source_data_base64 = source_data.encode("base64") inject_files["source_data_base64"] = source_data_base64 - virtual_storages = self.model.getRequirementByName(node, 'virtual_storage') - ret['virtual_storages'] = map(functools.partial(self._trans_virtual_storage), virtual_storages) ret['dependencies'] = map(lambda x: self.model.get_requirement_node_name(x), self.model.getNodeDependencys(node)) virtual_compute = self.model.getCapabilityByName(node, 'virtual_compute') if virtual_compute is not None and 'properties' in virtual_compute: - ret['virtual_compute'] = virtual_compute['properties'] + vc = {} + vc['virtual_cpu'] = virtual_compute['properties']['virtual_cpu'] + vc['virtual_memory'] = virtual_compute['properties']['virtual_memory'] + vc['virtual_storages'] = virtual_compute['properties'].get("virtual_local_storage", {}) + ret['virtual_compute'] = vc ret['vls'] = self._get_linked_vl_ids(node, nodeTemplates) ret['cps'] = self._get_virtal_binding_cp_ids(node, nodeTemplates) ret['artifacts'] = self.model.build_artifacts(node) |