diff options
17 files changed, 24 insertions, 6 deletions
diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/infra.csar b/catalog/pub/utils/toscaparser/testdata/vnf/infra.csar Binary files differdeleted file mode 100644 index 315b0bfc..00000000 --- a/catalog/pub/utils/toscaparser/testdata/vnf/infra.csar +++ /dev/null diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vbng.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vbng.csar Binary files differdeleted file mode 100644 index 7180dc19..00000000 --- a/catalog/pub/utils/toscaparser/testdata/vnf/vbng.csar +++ /dev/null diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vbrgemu.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vbrgemu.csar Binary files differdeleted file mode 100644 index 69fdbde6..00000000 --- a/catalog/pub/utils/toscaparser/testdata/vnf/vbrgemu.csar +++ /dev/null diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/infra.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/infra.csar Binary files differnew file mode 100644 index 00000000..5c9fbcf0 --- /dev/null +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/infra.csar diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbng.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbng.csar Binary files differnew file mode 100644 index 00000000..b11a6ef9 --- /dev/null +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbng.csar diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbrgemu.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbrgemu.csar Binary files differnew file mode 100644 index 00000000..730ea8d7 --- /dev/null +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbrgemu.csar diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgmux.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgmux.csar Binary files differnew file mode 100644 index 00000000..b0f37a78 --- /dev/null +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgmux.csar diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgw.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgw.csar Binary files differnew file mode 100644 index 00000000..ca652bf6 --- /dev/null +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgw.csar diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/infra.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/infra.csar Binary files differnew file mode 100644 index 00000000..4547db46 --- /dev/null +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/infra.csar diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbng.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbng.csar Binary files differnew file mode 100644 index 00000000..5011563a --- /dev/null +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbng.csar diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbrgemu.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbrgemu.csar Binary files differnew file mode 100644 index 00000000..0f991992 --- /dev/null +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbrgemu.csar diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgmux.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgmux.csar Binary files differnew file mode 100644 index 00000000..3d2dbf73 --- /dev/null +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgmux.csar diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar Binary files differnew file mode 100644 index 00000000..5e47b771 --- /dev/null +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vgmux.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vgmux.csar Binary files differdeleted file mode 100644 index 4108b696..00000000 --- a/catalog/pub/utils/toscaparser/testdata/vnf/vgmux.csar +++ /dev/null diff --git a/catalog/pub/utils/toscaparser/testdata/vnf/vgw.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vgw.csar Binary files differdeleted file mode 100644 index e23dd27f..00000000 --- a/catalog/pub/utils/toscaparser/testdata/vnf/vgw.csar +++ /dev/null diff --git a/catalog/pub/utils/toscaparser/tests.py b/catalog/pub/utils/toscaparser/tests.py index fe559023..004911d9 100644 --- a/catalog/pub/utils/toscaparser/tests.py +++ b/catalog/pub/utils/toscaparser/tests.py @@ -34,15 +34,24 @@ class TestToscaparser(TestCase): def test_vnfd_parse(self): self.remove_temp_dir() - csar_path = os.path.dirname(os.path.abspath(__file__)) + "/testdata/vnf" input_parameters = [{"value": "222222", "key": "sdncontroller"}] - vcpe = ["vgw"] + vcpe = ["vgw", "infra", "vbng", "vbrgemu", "vgmux"] + sriov_path = os.path.dirname(os.path.abspath(__file__)) + "/testdata/vnf/vcpesriov" for vcpe_part in vcpe: - csar_file = ("%s/%s.csar" % (csar_path, vcpe_part)) + 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("metadata:%s", metadata) + logger.debug("sriov metadata:%s", metadata) + self.assertEqual(("vCPE_%s" % vcpe_part), metadata.get("template_name", "")) + + 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", "")) def test_pnfd_parse(self): diff --git a/catalog/pub/utils/toscaparser/vnfdmodel.py b/catalog/pub/utils/toscaparser/vnfdmodel.py index 0b6609b8..74b28f54 100644 --- a/catalog/pub/utils/toscaparser/vnfdmodel.py +++ b/catalog/pub/utils/toscaparser/vnfdmodel.py @@ -62,7 +62,7 @@ class EtsiVnfdInfoModel(BaseInfoModel): rets = [] inject_files = [] for node in nodeTemplates: - logger.error("nodeTemplates :%s", node) + logger.debug("nodeTemplates :%s", node) if self.isNodeTypeX(node, node_types, VDU_COMPUTE_TYPE): ret = {} ret['vdu_id'] = node['name'] @@ -72,13 +72,22 @@ class EtsiVnfdInfoModel(BaseInfoModel): ret['properties'] = node['properties'] if 'inject_files' in node['properties']: inject_files = node['properties']['inject_files'] - if inject_files is not None: + if isinstance(inject_files, list): for inject_file in inject_files: source_path = os.path.join(self.basepath, inject_file['source_path']) with open(source_path, "rb") as f: source_data = f.read() source_data_base64 = source_data.encode("base64") inject_file["source_data_base64"] = source_data_base64 + elif isinstance(inject_files, dict): + source_path = os.path.join(self.basepath, inject_files['source_path']) + with open(source_path, "rb") as f: + source_data = f.read() + source_data_base64 = source_data.encode("base64") + inject_files["source_data_base64"] = source_data_base64 + else: + logger.warn("inject_files %s format is not right.", inject_files) + virtual_storages = self.getRequirementByName(node, 'virtual_storage') ret['virtual_storages'] = map(functools.partial(self._trans_virtual_storage), virtual_storages) ret['dependencies'] = map(lambda x: self.get_requirement_node_name(x), self.getNodeDependencys(node)) |