aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2024-02-12 10:56:25 +0100
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2024-02-12 17:44:13 +0100
commitfe9e41845e9ab8a36d4a6877b92d5e78c618c2c5 (patch)
tree4886eaf0903fc336ca2de4ede5d2fb13572841be /src
parent858f92861731a4e73668eff3d7a665507965d9a4 (diff)
Cleanup SO instance before instantation
Cleanup SO instance before instantation Issue-ID: TEST-402 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> Change-Id: If38938a4ce949eda3c8c91c3a1e38090dc986508
Diffstat (limited to 'src')
-rw-r--r--src/onaptests/steps/instantiate/service_ala_carte.py30
-rw-r--r--src/onaptests/steps/instantiate/service_macro.py57
2 files changed, 67 insertions, 20 deletions
diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py
index 7933794..e3aac8a 100644
--- a/src/onaptests/steps/instantiate/service_ala_carte.py
+++ b/src/onaptests/steps/instantiate/service_ala_carte.py
@@ -106,6 +106,10 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
super().execute()
service = Service(self.service_name)
self._load_customer_and_subscription()
+ try:
+ self._load_service_instance()
+ except ResourceNotFound:
+ self._logger.info("There is no leftover service instance in SO")
cloud_region: CloudRegion = CloudRegion.get_by_id(
cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
cloud_region_id=settings.CLOUD_REGION_ID,
@@ -118,6 +122,9 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
self._logger.info("Owning entity not found, create it")
owning_entity = AaiOwningEntity.create(settings.OWNING_ENTITY)
+ # remove leftover
+ self._cleanup_logic()
+
service_instantiation = ServiceInstantiation.instantiate_ala_carte(
service,
cloud_region,
@@ -139,16 +146,7 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
self._load_customer_and_subscription(reload=True)
self._load_service_instance()
- @YamlTemplateBaseStep.store_state(cleanup=True)
- def cleanup(self) -> None:
- """Cleanup Service.
-
- Raises:
- Exception: Service cleaning failed
-
- """
- self._load_customer_and_subscription()
- self._load_service_instance()
+ def _cleanup_logic(self) -> None:
if self._service_instance:
service_deletion = self._service_instance.delete(a_la_carte=True)
try:
@@ -161,4 +159,16 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
else:
self._logger.error("Service deletion %s failed", self._service_instance_name)
raise onap_test_exceptions.ServiceCleanupException
+
+ @YamlTemplateBaseStep.store_state(cleanup=True)
+ def cleanup(self) -> None:
+ """Cleanup Service.
+
+ Raises:
+ Exception: Service cleaning failed
+
+ """
+ self._load_customer_and_subscription()
+ self._load_service_instance()
+ self._cleanup_logic()
super().cleanup()
diff --git a/src/onaptests/steps/instantiate/service_macro.py b/src/onaptests/steps/instantiate/service_macro.py
index dd32b65..fb5e9d4 100644
--- a/src/onaptests/steps/instantiate/service_macro.py
+++ b/src/onaptests/steps/instantiate/service_macro.py
@@ -136,6 +136,10 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
super().execute()
service = Service(self.service_name)
self._load_customer_and_subscription()
+ try:
+ self._load_service_instance()
+ except ResourceNotFound:
+ self._logger.info("There is no leftover service instance in SO")
if any(
filter(lambda x: x in self.yaml_template[self.service_name].keys(),
["vnfs", "networks"])):
@@ -176,6 +180,36 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
for vf_module_data in vnf_data.get("vf_module_parameters", [])]
))
+ try:
+ if settings.PNF_WITHOUT_VES:
+ skip_pnf_registration_event = True
+ except SDKException:
+ skip_pnf_registration_event = False
+ return (
+ service, self._customer, self._service_subscription, cloud_region,
+ tenant, owning_entity, so_service, skip_pnf_registration_event, vnf_params_list)
+
+
+class YamlTemplateServiceMacroInstantiateStep(YamlTemplateServiceMacroInstantiateBaseStep):
+ """Instantiate SO service."""
+
+ def __init__(self):
+ """Init YamlTemplateServiceMacroInstantiateStep."""
+ super().__init__(cleanup=settings.CLEANUP_FLAG)
+
+ @property
+ def description(self) -> str:
+ """Step description."""
+ return "Instantiate SO service"
+
+ @YamlTemplateBaseStep.store_state
+ def execute(self):
+ super().execute()
+ (service, _, _, cloud_region, tenant, owning_entity, so_service,
+ skip_pnf_registration_event, vnf_params_list) = self.base_execute()
+ # remove leftover
+ self._cleanup_logic()
+
service_instantiation = ServiceInstantiation.instantiate_macro(
sdc_service=service,
customer=self._customer,
@@ -203,16 +237,7 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
self._load_customer_and_subscription(reload=True)
self._load_service_instance()
- @YamlTemplateBaseStep.store_state(cleanup=True)
- def cleanup(self) -> None:
- """Cleanup Service.
-
- Raises:
- Exception: Service cleaning failed
-
- """
- self._load_customer_and_subscription()
- self._load_service_instance()
+ def _cleanup_logic(self) -> None:
if self._service_instance:
service_deletion = self._service_instance.delete(a_la_carte=False)
try:
@@ -225,4 +250,16 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
else:
self._logger.error("Service deletion %s failed", self._service_instance_name)
raise onap_test_exceptions.ServiceCleanupException
+
+ @YamlTemplateBaseStep.store_state(cleanup=True)
+ def cleanup(self) -> None:
+ """Cleanup Service.
+
+ Raises:
+ Exception: Service cleaning failed
+
+ """
+ self._load_customer_and_subscription()
+ self._load_service_instance()
+ self._cleanup_logic()
super().cleanup()