from onapsdk.sdc.vsp import Vsp
from onaptests.utils.resources import get_resource_location
+
from ..base import BaseStep, YamlTemplateBaseStep
from .vsp import VspOnboardStep, YamlTemplateVspOnboardStep
def cleanup(self):
try:
pnf = Pnf.get_by_name(settings.PNF_NAME)
- pnf.archive()
+ if pnf.lifecycle_state == LifecycleState.CERTIFIED:
+ pnf.archive()
pnf.delete()
except ResourceNotFound:
self._logger.warning("VF not created")
for pnf in self.yaml_template["pnfs"]:
try:
pnf_obj: Pnf = Pnf.get_by_name(name=pnf["pnf_name"])
- pnf_obj.archive()
+ if pnf_obj.lifecycle_state == LifecycleState.CERTIFIED:
+ pnf_obj.archive()
pnf_obj.delete()
except ResourceNotFound:
self._logger.warning(f"PNF {pnf['pnf_name']} does not exist")
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
"""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")
"""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")
+import onapsdk.constants as const
from onapsdk.configuration import settings
from onapsdk.sdc.vendor import Vendor
def cleanup(self) -> None:
vendor: Vendor = Vendor(name=settings.VENDOR_NAME)
if vendor.exists():
- vendor.archive()
+ if vendor.status == const.CERTIFIED:
+ vendor.archive()
vendor.delete()
super().cleanup()
vendor: Vendor = Vendor(name=f"{pnf['pnf_name']}")
vendor.onboard()
+ def _cleanup_vendor(self, name):
+ vendor: Vendor = Vendor(name=name)
+ if vendor.exists():
+ if vendor.status == const.CERTIFIED:
+ vendor.archive()
+ vendor.delete()
+
@YamlTemplateBaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
if "vnfs" in self.yaml_template:
for vnf in self.yaml_template["vnfs"]:
- vendor: Vendor = Vendor(name=f"{vnf['vnf_name']}")
- if vendor.exists():
- vendor.archive()
- vendor.delete()
+ self._cleanup_vendor(f"{vnf['vnf_name']}")
elif "pnfs" in self.yaml_template:
for pnf in self.yaml_template["pnfs"]:
- vendor: Vendor = Vendor(name=f"{pnf['pnf_name']}")
- if vendor.exists():
- vendor.archive()
- vendor.delete()
+ self._cleanup_vendor(f"{pnf['pnf_name']}")
super().cleanup()
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
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")
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")
+import onapsdk.constants as const
from onapsdk.configuration import settings
from onapsdk.sdc.vendor import Vendor
from onapsdk.sdc.vsp import Vsp
def cleanup(self):
vsp: Vsp = Vsp(name=settings.VSP_NAME)
if vsp.exists():
- vsp.archive()
+ if vsp.status == const.CERTIFIED:
+ vsp.archive()
vsp.delete()
super().cleanup()
package=package)
vsp.onboard()
+ def _cleanup_vsp(self, name):
+ vsp: Vsp = Vsp(name=name)
+ if vsp.exists():
+ if vsp.status == const.CERTIFIED:
+ vsp.archive()
+ vsp.delete()
+
@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")
- if vsp.exists():
- vsp.archive()
- vsp.delete()
+ self._cleanup_vsp(f"{vnf['vnf_name']}_VSP")
elif "pnfs" in self.yaml_template:
for pnf in self.yaml_template["pnfs"]:
- vsp: Vsp = Vsp(name=f"{pnf['pnf_name']}_VSP")
- if vsp.exists():
- vsp.archive()
- vsp.delete()
+ self._cleanup_vsp(f"{pnf['pnf_name']}_VSP")
super().cleanup()