diff options
author | 2024-02-06 21:46:29 +0100 | |
---|---|---|
committer | 2024-02-07 12:56:53 +0100 | |
commit | 6dc28a85e25b81bada36a1c21ba501e81a1e02c8 (patch) | |
tree | cfb4754f6c340fd924df3a18267df79653caa78e /src/onaptests/steps/onboard/vf.py | |
parent | 1404b9e8f3da4181da66f957b2a99a5c4430544e (diff) |
Make archive optional on cleanup
If sdc element was not onboarded properly
it cannot be archived but still can be deleted
Issue-ID: TEST-404
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Change-Id: I80836c7bd7735de86c09ebc0ef0b6ea4a21c78fb
Diffstat (limited to 'src/onaptests/steps/onboard/vf.py')
-rw-r--r-- | src/onaptests/steps/onboard/vf.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/onaptests/steps/onboard/vf.py b/src/onaptests/steps/onboard/vf.py index 3e286d9..08fe1f3 100644 --- a/src/onaptests/steps/onboard/vf.py +++ b/src/onaptests/steps/onboard/vf.py @@ -3,8 +3,8 @@ from pathlib import Path from onapsdk.configuration import settings from onapsdk.exceptions import ResourceNotFound -from onapsdk.sdc2.vf import Vf from onapsdk.sdc2.sdc_resource import LifecycleOperation, LifecycleState +from onapsdk.sdc2.vf import Vf from onapsdk.sdc.vsp import Vsp from onaptests.utils.resources import get_resource_location @@ -65,7 +65,8 @@ class VfOnboardStep(BaseStep): def cleanup(self): try: vf = Vf.get_by_name(settings.VF_NAME) - vf.archive() + if vf.lifecycle_state == LifecycleState.CERTIFIED: + vf.archive() vf.delete() except ResourceNotFound: self._logger.warning("VF not created") @@ -163,7 +164,8 @@ class YamlTemplateVfOnboardStep(YamlTemplateBaseStep): for vnf in self.yaml_template["vnfs"]: try: vf_obj: Vf = Vf.get_by_name(name=vnf["vnf_name"]) - vf_obj.archive() + if vf_obj.lifecycle_state == LifecycleState.CERTIFIED: + vf_obj.archive() vf_obj.delete() except ResourceNotFound: self._logger.warning(f"VF {vnf['vnf_name']} does not exist") |