aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/onboard/service.py
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2024-02-06 21:46:29 +0100
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2024-02-07 12:56:53 +0100
commit6dc28a85e25b81bada36a1c21ba501e81a1e02c8 (patch)
treecfb4754f6c340fd924df3a18267df79653caa78e /src/onaptests/steps/onboard/service.py
parent1404b9e8f3da4181da66f957b2a99a5c4430544e (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/service.py')
-rw-r--r--src/onaptests/steps/onboard/service.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/onaptests/steps/onboard/service.py b/src/onaptests/steps/onboard/service.py
index a9a3b14..cb2e59d 100644
--- a/src/onaptests/steps/onboard/service.py
+++ b/src/onaptests/steps/onboard/service.py
@@ -1,14 +1,15 @@
from typing import Any, Dict
-from yaml import SafeLoader, load
from onapsdk.configuration import settings
from onapsdk.exceptions import ResourceNotFound
+from onapsdk.sdc2.component_instance import (ComponentInstance,
+ ComponentInstanceInput)
from onapsdk.sdc2.pnf import Pnf
-from onapsdk.sdc2.component_instance import ComponentInstance, ComponentInstanceInput
from onapsdk.sdc2.sdc_resource import LifecycleOperation, LifecycleState
from onapsdk.sdc2.service import Service, ServiceInstantiationType
from onapsdk.sdc2.vf import Vf
from onapsdk.sdc2.vl import Vl
+from yaml import SafeLoader, load
from ..base import BaseStep, YamlTemplateBaseStep
from .pnf import PnfOnboardStep, YamlTemplatePnfOnboardStep
@@ -85,7 +86,8 @@ class ServiceOnboardStep(BaseStep):
"""Cleanup service onboard step."""
try:
service: Service = Service.get_by_name(name=settings.SERVICE_NAME)
- service.archive()
+ if service.lifecycle_state == LifecycleState.CERTIFIED:
+ service.archive()
service.delete()
except ResourceNotFound:
self._logger.info(f"Service {settings.SERVICE_NAME} not found")
@@ -252,7 +254,8 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
"""Cleanup service onboard step."""
try:
service: Service = Service.get_by_name(name=self.service_name)
- service.archive()
+ if service.lifecycle_state == LifecycleState.CERTIFIED:
+ service.archive()
service.delete()
except ResourceNotFound:
self._logger.info(f"Service {self.service_name} not found")