diff options
author | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2023-01-16 15:17:01 +0000 |
---|---|---|
committer | Michal Jagiello <michal.jagiello@t-mobile.pl> | 2023-03-15 10:18:22 +0000 |
commit | d6d052a5f1ce0ae0f0debcbb11220fce1c1dfdc5 (patch) | |
tree | 13c6f43901458af1e66c1e149e43c324f2e19043 /src/onaptests/steps | |
parent | ef50809c847aca4a198c89fb846eb44046036032 (diff) |
Add cleanup to sdc resources ondboarding step
Delete SDC resources on cleanup
Bump onapsdk requirements to 10.4.2
Issue-ID: INT-2193
Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl>
Change-Id: Id9e51f07a9c91a02b67a87eb897a2a4d19fa6738
Diffstat (limited to 'src/onaptests/steps')
-rw-r--r-- | src/onaptests/steps/onboard/pnf.py | 14 | ||||
-rw-r--r-- | src/onaptests/steps/onboard/service.py | 14 | ||||
-rw-r--r-- | src/onaptests/steps/onboard/vendor.py | 7 | ||||
-rw-r--r-- | src/onaptests/steps/onboard/vf.py | 14 | ||||
-rw-r--r-- | src/onaptests/steps/onboard/vsp.py | 21 |
5 files changed, 70 insertions, 0 deletions
diff --git a/src/onaptests/steps/onboard/pnf.py b/src/onaptests/steps/onboard/pnf.py index 4e3303e..75fdbcf 100644 --- a/src/onaptests/steps/onboard/pnf.py +++ b/src/onaptests/steps/onboard/pnf.py @@ -60,6 +60,12 @@ class PnfOnboardStep(BaseStep): ) pnf.onboard() + @BaseStep.store_state(cleanup=True) + def cleanup(self): + pnf: Pnf = Pnf(name=settings.PNF_NAME) + pnf.delete() + super().cleanup() + class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep): """PNF onboard using YAML template step.""" @@ -124,3 +130,11 @@ class YamlTemplatePnfOnboardStep(YamlTemplateBaseStep): artifact=pnf["pnf_artifact_file_path"] ) pnf_obj.onboard() + + @YamlTemplateBaseStep.store_state(cleanup=True) + def cleanup(self): + if "pnfs" in self.yaml_template: + for pnf in self.yaml_template["pnfs"]: + pnf_obj: Pnf = Pnf(name=pnf["pnf_name"]) + pnf_obj.delete() + super().cleanup() diff --git a/src/onaptests/steps/onboard/service.py b/src/onaptests/steps/onboard/service.py index fa21d2c..60ac279 100644 --- a/src/onaptests/steps/onboard/service.py +++ b/src/onaptests/steps/onboard/service.py @@ -82,6 +82,13 @@ class ServiceOnboardStep(BaseStep): service.checkin() service.onboard() + @BaseStep.store_state + def cleanup(self) -> None: + """Cleanup service onboard step.""" + service: Service = Service(name=settings.SERVICE_NAME) + service.delete() + super().cleanup() + class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep): """Service onboard using YAML template step.""" @@ -253,3 +260,10 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep): for property_name, property_value in component_properties.items(): prop: ComponentProperty = component.get_property(property_name) prop.value = property_value + + @YamlTemplateBaseStep.store_state(cleanup=True) + def cleanup(self) -> None: + """Cleanup service onboard step.""" + service: Service = Service(name=self.service_name) + service.delete() + super().cleanup() diff --git a/src/onaptests/steps/onboard/vendor.py b/src/onaptests/steps/onboard/vendor.py index 71b28b9..980a245 100644 --- a/src/onaptests/steps/onboard/vendor.py +++ b/src/onaptests/steps/onboard/vendor.py @@ -28,3 +28,10 @@ class VendorOnboardStep(BaseStep): super().execute() vendor: Vendor = Vendor(name=settings.VENDOR_NAME) vendor.onboard() + + @BaseStep.store_state(cleanup=True) + def cleanup(self) -> None: + vendor: Vendor = Vendor(name=settings.VENDOR_NAME) + vendor.archive() + vendor.delete() + super().cleanup() diff --git a/src/onaptests/steps/onboard/vf.py b/src/onaptests/steps/onboard/vf.py index 852cb82..f77f9af 100644 --- a/src/onaptests/steps/onboard/vf.py +++ b/src/onaptests/steps/onboard/vf.py @@ -47,6 +47,12 @@ class VfOnboardStep(BaseStep): if not vf.created(): vf.onboard() + @BaseStep.store_state(cleanup=True) + def cleanup(self): + vf: Vf = Vf(name=settings.VF_NAME) + vf.delete() + super().cleanup() + class YamlTemplateVfOnboardStep(YamlTemplateBaseStep): """Vf onboard using YAML template step.""" @@ -122,3 +128,11 @@ class YamlTemplateVfOnboardStep(YamlTemplateBaseStep): ) time.sleep(10) vf.onboard() + + @YamlTemplateBaseStep.store_state(cleanup=True) + def cleanup(self): + if "vnfs" in self.yaml_template: + for vnf in self.yaml_template["vnfs"]: + vf_obj: Vf = Vf(name=vnf["vnf_name"]) + vf_obj.delete() + super().cleanup() diff --git a/src/onaptests/steps/onboard/vsp.py b/src/onaptests/steps/onboard/vsp.py index f898268..a7fcf9f 100644 --- a/src/onaptests/steps/onboard/vsp.py +++ b/src/onaptests/steps/onboard/vsp.py @@ -44,6 +44,13 @@ class VspOnboardStep(BaseStep): vsp: Vsp = Vsp(name=settings.VSP_NAME, vendor=vendor, package=open(settings.VSP_FILE_PATH, "rb")) vsp.onboard() + @BaseStep.store_state(cleanup=True) + def cleanup(self): + vsp: Vsp = Vsp(name=settings.VSP_NAME) + vsp.archive() + vsp.delete() + super().cleanup() + class YamlTemplateVspOnboardStep(YamlTemplateBaseStep): """Vsp onboard using YAML template step.""" @@ -118,3 +125,17 @@ class YamlTemplateVspOnboardStep(YamlTemplateBaseStep): vendor=vendor, package=package) vsp.onboard() + + @YamlTemplateBaseStep.store_state(cleanup=True) + def cleanup(self) -> None: + if "vnfs" in self.yaml_template: + for vnf in self.yaml_template["vnfs"]: + vsp: Vsp = Vsp(name=f"{vnf['vnf_name']}_VSP") + vsp.archive() + vsp.delete() + elif "pnfs" in self.yaml_template: + for pnf in self.yaml_template["pnfs"]: + vsp: Vsp = Vsp(name=f"{pnf['pnf_name']}_VSP") + vsp.archive() + vsp.delete() + super().cleanup() |