diff options
author | mrichomme <morgan.richomme@orange.com> | 2020-09-14 18:16:26 +0200 |
---|---|---|
committer | mrichomme <morgan.richomme@orange.com> | 2020-09-16 17:54:32 +0200 |
commit | b6f965609e956d9d26f3359b75ef2aaf1d596a5f (patch) | |
tree | 2204eb1557e22b2a46645ffa7566da3efe7d8ea8 /src/onaptests/steps/instantiate/service_ala_carte.py | |
parent | a85a306fb5ee8259b09c392c03ac499c828b5597 (diff) |
Add cleanup function
Issue-ID: TEST-240
Signed-off-by: mrichomme <morgan.richomme@orange.com>
Change-Id: I784e958f869a0cbee702c915509fe80d37d44b65
Signed-off-by: mrichomme <morgan.richomme@orange.com>
Diffstat (limited to 'src/onaptests/steps/instantiate/service_ala_carte.py')
-rw-r--r-- | src/onaptests/steps/instantiate/service_ala_carte.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py index 4742d61..249a171 100644 --- a/src/onaptests/steps/instantiate/service_ala_carte.py +++ b/src/onaptests/steps/instantiate/service_ala_carte.py @@ -3,7 +3,7 @@ from uuid import uuid4 from yaml import load from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant -from onapsdk.aai.business import Customer +from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription from onapsdk.aai.business.owning_entity import OwningEntity as AaiOwningEntity from onapsdk.configuration import settings from onapsdk.sdc.service import Service @@ -84,6 +84,8 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep): super().__init__(cleanup=cleanup) self._yaml_template: dict = None self._service_instance_name: str = None + self._service_instance: str = None + self.add_step(YamlTemplateServiceOnboardStep(cleanup)) self.add_step(ConnectServiceSubToCloudRegionStep(cleanup)) @@ -178,3 +180,28 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep): time.sleep(10) if service_instantiation.failed: raise Exception("Service instantiation failed") + else: + service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(self.service_name) + self._service_instance: ServiceInstance = service_subscription.get_service_instance_by_name(self.service_instance_name) + + + def cleanup(self) -> None: + """Cleanup Service. + + Raises: + Exception: Service cleaning failed + + """ + super().cleanup() + service_deletion = self._service_instance.delete() + nb_try = 0 + nb_try_max = 30 + while not service_deletion.finished and nb_try < nb_try_max: + self._logger.info("Wait for Service deletion") + nb_try += 1 + time.sleep(15) + if service_deletion.finished: + self._logger.info("Service %s deleted", self._service_instance_name) + else: + self._logger.error("Service deletion %s failed", self._service_instance_name) + raise Exception("Service cleanup failed") |