From 21154ffabd99861799b485fcadeb371cd033964c Mon Sep 17 00:00:00 2001 From: sunnycarter <36891339+sunnycarter@users.noreply.github.com> Date: Wed, 5 Jul 2023 16:47:10 +0100 Subject: [PATCH] Fix VNFD build (#42) --- src/aosm/azext_aosm/_configuration.py | 3 ++- .../{input.json => input_with_fp.json} | 0 .../tests/latest/mock_vnf/input_with_sas.json | 18 ++++++++++++++++++ src/aosm/azext_aosm/tests/latest/test_vnf.py | 13 +++++++++++-- 4 files changed, 31 insertions(+), 3 deletions(-) rename src/aosm/azext_aosm/tests/latest/mock_vnf/{input.json => input_with_fp.json} (100%) create mode 100644 src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_sas.json diff --git a/src/aosm/azext_aosm/_configuration.py b/src/aosm/azext_aosm/_configuration.py index 221e972423b..744edb79c8f 100644 --- a/src/aosm/azext_aosm/_configuration.py +++ b/src/aosm/azext_aosm/_configuration.py @@ -340,7 +340,8 @@ def __post_init__(self): self.arm_template = ArtifactConfig(**self.arm_template) if isinstance(self.vhd, dict): - self.vhd["file_path"] = self.path_from_cli_dir(self.vhd["file_path"]) + if self.vhd.get("file_path"): + self.vhd["file_path"] = self.path_from_cli_dir(self.vhd["file_path"]) self.vhd = ArtifactConfig(**self.vhd) self.validate() diff --git a/src/aosm/azext_aosm/tests/latest/mock_vnf/input.json b/src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_fp.json similarity index 100% rename from src/aosm/azext_aosm/tests/latest/mock_vnf/input.json rename to src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_fp.json diff --git a/src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_sas.json b/src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_sas.json new file mode 100644 index 00000000000..2a959add126 --- /dev/null +++ b/src/aosm/azext_aosm/tests/latest/mock_vnf/input_with_sas.json @@ -0,0 +1,18 @@ +{ + "publisher_name": "jamie-mobile-publisher", + "publisher_resource_group_name": "Jamie-publisher", + "nf_name": "ubuntu-vm", + "version": "1.0.0", + "acr_artifact_store_name": "ubuntu-acr", + "location": "eastus", + "blob_artifact_store_name": "ubuntu-blob-store", + "image_name_parameter": "imageName", + "arm_template": { + "file_path": "ubuntu-template.json", + "version": "1.0.0" + }, + "vhd": { + "blob_sas_url": "https://a/dummy/sas-url", + "version": "1-0-0" + } +} diff --git a/src/aosm/azext_aosm/tests/latest/test_vnf.py b/src/aosm/azext_aosm/tests/latest/test_vnf.py index b44574ef6bb..03dd4eb3d66 100644 --- a/src/aosm/azext_aosm/tests/latest/test_vnf.py +++ b/src/aosm/azext_aosm/tests/latest/test_vnf.py @@ -37,7 +37,16 @@ def test_build(self): os.chdir(test_dir) try: - build_definition("vnf", str(mock_vnf_folder / "input.json")) + build_definition("vnf", str(mock_vnf_folder / "input_with_fp.json")) + assert os.path.exists("nfd-bicep-ubuntu-template") + finally: + os.chdir(starting_directory) + + with TemporaryDirectory() as test_dir: + os.chdir(test_dir) + + try: + build_definition("vnf", str(mock_vnf_folder / "input_with_sas.json")) assert os.path.exists("nfd-bicep-ubuntu-template") finally: os.chdir(starting_directory) @@ -53,7 +62,7 @@ def test_build_with_ordered_params(self): try: build_definition( "vnf", - str(mock_vnf_folder / "input.json"), + str(mock_vnf_folder / "input_with_fp.json"), order_params=True, ) assert os.path.exists("nfd-bicep-ubuntu-template")