From 6dc28a85e25b81bada36a1c21ba501e81a1e02c8 Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Tue, 6 Feb 2024 21:46:29 +0100 Subject: 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 Change-Id: I80836c7bd7735de86c09ebc0ef0b6ea4a21c78fb --- src/onaptests/steps/onboard/service.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/onaptests/steps/onboard/service.py') 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") -- cgit 1.2.3-korg