aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/onaptests/scenario/basic_cnf_macro.py12
-rw-r--r--src/onaptests/scenario/basic_vm_macro.py12
-rw-r--r--src/onaptests/scenario/multi_vnf_macro.py12
-rw-r--r--src/onaptests/scenario/pnf_macro.py12
-rw-r--r--src/onaptests/steps/base.py56
-rw-r--r--src/onaptests/steps/instantiate/service_ala_carte.py56
-rw-r--r--src/onaptests/steps/instantiate/service_macro.py33
-rw-r--r--src/onaptests/steps/instantiate/vf_module_ala_carte.py58
-rw-r--r--src/onaptests/steps/instantiate/vl_ala_carte.py30
-rw-r--r--src/onaptests/steps/instantiate/vnf_ala_carte.py44
-rw-r--r--src/onaptests/steps/loop/clamp.py15
-rw-r--r--src/onaptests/steps/onboard/clamp.py15
-rw-r--r--src/onaptests/steps/onboard/service.py14
13 files changed, 118 insertions, 251 deletions
diff --git a/src/onaptests/scenario/basic_cnf_macro.py b/src/onaptests/scenario/basic_cnf_macro.py
index c96ce4f..1fecd95 100644
--- a/src/onaptests/scenario/basic_cnf_macro.py
+++ b/src/onaptests/scenario/basic_cnf_macro.py
@@ -66,18 +66,6 @@ class BasicCnfMacroStep(YamlTemplateBaseScenarioStep):
return {}
@property
- def service_name(self) -> dict:
- """Service name.
-
- Get from YAML template.
-
- Returns:
- str: Service name
-
- """
- return next(iter(self.yaml_template.keys()))
-
- @property
def service_instance_name(self) -> str:
"""Service instance name.
diff --git a/src/onaptests/scenario/basic_vm_macro.py b/src/onaptests/scenario/basic_vm_macro.py
index e526d14..ec60e78 100644
--- a/src/onaptests/scenario/basic_vm_macro.py
+++ b/src/onaptests/scenario/basic_vm_macro.py
@@ -66,18 +66,6 @@ class BasicVmMacroStep(YamlTemplateBaseScenarioStep):
return {}
@property
- def service_name(self) -> dict:
- """Service name.
-
- Get from YAML template.
-
- Returns:
- str: Service name
-
- """
- return next(iter(self.yaml_template.keys()))
-
- @property
def service_instance_name(self) -> str:
"""Service instance name.
diff --git a/src/onaptests/scenario/multi_vnf_macro.py b/src/onaptests/scenario/multi_vnf_macro.py
index 96ade6d..fc00cec 100644
--- a/src/onaptests/scenario/multi_vnf_macro.py
+++ b/src/onaptests/scenario/multi_vnf_macro.py
@@ -70,18 +70,6 @@ class MultiVnfUbuntuMacroStep(YamlTemplateBaseScenarioStep):
return self._model_yaml_template
@property
- def service_name(self) -> dict:
- """Service name.
-
- Get from YAML template.
-
- Returns:
- str: Service name
-
- """
- return next(iter(self.yaml_template.keys()))
-
- @property
def service_instance_name(self) -> str:
"""Service instance name.
diff --git a/src/onaptests/scenario/pnf_macro.py b/src/onaptests/scenario/pnf_macro.py
index 630e439..f8afad5 100644
--- a/src/onaptests/scenario/pnf_macro.py
+++ b/src/onaptests/scenario/pnf_macro.py
@@ -75,18 +75,6 @@ class PnfMacroScenarioStep(YamlTemplateBaseScenarioStep):
return {}
@property
- def service_name(self) -> dict:
- """Service name.
-
- Get from YAML template.
-
- Returns:
- str: Service name
-
- """
- return next(iter(self.yaml_template.keys()))
-
- @property
def service_instance_name(self) -> str:
"""Service instance name.
diff --git a/src/onaptests/steps/base.py b/src/onaptests/steps/base.py
index 06064b4..4fca3e7 100644
--- a/src/onaptests/steps/base.py
+++ b/src/onaptests/steps/base.py
@@ -7,7 +7,7 @@ import time
from abc import ABC, abstractmethod
from typing import Iterator, List, Optional
-from onapsdk.aai.business import Customer
+from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription
from onapsdk.configuration import settings
from onapsdk.exceptions import SDKException, SettingsError
from onaptests.steps.reports_collection import (Report, ReportsCollection,
@@ -20,6 +20,7 @@ from onaptests.utils.exceptions import (OnapTestException,
IF_VALIDATION = "PYTHON_SDK_TESTS_VALIDATION"
+IF_FORCE_CLEANUP = "PYTHON_SDK_TESTS_FORCE_CLEANUP"
class StoreStateHandler(ABC):
@@ -43,11 +44,11 @@ class StoreStateHandler(ABC):
if cleanup:
self._start_cleanup_time = time.time()
try:
- if (self._executed and self._cleanup and
+ if (self._cleanup and self._state_execute and
(self._is_validation_only or
self.check_preconditions(cleanup=True))):
self._log_execution_state("START", cleanup)
- if not self._is_validation_only:
+ if not self._is_validation_only or self._is_force_cleanup:
fun(self, *args, **kwargs)
self._cleaned_up = True
execution_status = ReportStepStatus.PASS
@@ -159,6 +160,7 @@ class BaseStep(StoreStateHandler, ABC):
self._nesting_level: int = 0
self._break_on_error: bool = break_on_error
self._is_validation_only = os.environ.get(IF_VALIDATION) is not None
+ self._is_force_cleanup = os.environ.get(IF_FORCE_CLEANUP) is not None
def add_step(self, step: "BaseStep") -> None:
"""Add substep.
@@ -401,6 +403,54 @@ class BaseStep(StoreStateHandler, ABC):
class YamlTemplateBaseStep(BaseStep, ABC):
"""Base YAML template step."""
+ def __init__(self, cleanup: bool):
+ """Initialize step."""
+
+ super().__init__(cleanup=cleanup)
+ self._service_instance: ServiceInstance = None
+ self._service_subscription: ServiceSubscription = None
+ self._customer: Customer = None
+
+ def _load_customer_and_subscription(self, reload: bool = False):
+ if self._customer is None:
+ self._customer: Customer = \
+ Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
+ if self._service_subscription is None or reload:
+ self._service_subscription: ServiceSubscription = \
+ self._customer.get_service_subscription_by_service_type(self.service_name)
+
+ def _load_service_instance(self):
+ if self._service_instance is None:
+ self._service_instance: ServiceInstance = \
+ self._service_subscription.get_service_instance_by_name(self.service_instance_name)
+
+ @property
+ def service_name(self) -> str:
+ """Service name.
+
+ Get from YAML template if it's a root step, get from parent otherwise.
+
+ Returns:
+ str: Service name
+
+ """
+ if self.is_root:
+ return next(iter(self.yaml_template.keys()))
+ return self.parent.service_name
+
+ @property
+ def service_instance_name(self) -> str:
+ """Service instance name.
+
+ Generate service instance name.
+ If not applicable None is returned
+
+ Returns:
+ str: Service instance name
+
+ """
+ return None
+
@property
@abstractmethod
def yaml_template(self) -> dict:
diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py
index 1773aa4..528215d 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, SafeLoader
from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant
-from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription
+from onapsdk.aai.business import Customer
from onapsdk.aai.business.owning_entity import OwningEntity as AaiOwningEntity
from onapsdk.configuration import settings
from onapsdk.exceptions import ResourceNotFound
@@ -102,7 +102,6 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._service_instance_name: str = None
- self._service_instance: str = None
if not settings.ONLY_INSTANTIATE:
self.add_step(YamlTemplateServiceOnboardStep())
self.add_step(ConnectServiceSubToCloudRegionStep())
@@ -139,20 +138,6 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
return {}
@property
- def service_name(self) -> str:
- """Service name.
-
- Get from YAML template if it's a root step, get from parent otherwise.
-
- Returns:
- str: Service name
-
- """
- if self.is_root:
- return next(iter(self.yaml_template.keys()))
- return self.parent.service_name
-
- @property
def service_instance_name(self) -> str:
"""Service instance name.
@@ -187,9 +172,7 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
"""
super().execute()
service = Service(self.service_name)
- customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
- service_subscription: ServiceSubscription = \
- customer.get_service_subscription_by_service_type(service.name)
+ self._load_customer_and_subscription()
cloud_region: CloudRegion = CloudRegion.get_by_id(
cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
cloud_region_id=settings.CLOUD_REGION_ID,
@@ -229,10 +212,10 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
service,
cloud_region,
tenant,
- customer,
+ self._customer,
owning_entity,
settings.PROJECT,
- service_subscription,
+ self._service_subscription,
service_instance_name=self.service_instance_name
)
try:
@@ -244,10 +227,8 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
self._logger.error("Service instantiation %s failed", self.service_instance_name)
raise onap_test_exceptions.ServiceInstantiateException
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)
+ self._load_customer_and_subscription(reload=True)
+ self._load_service_instance()
@YamlTemplateBaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
@@ -257,15 +238,18 @@ class YamlTemplateServiceAlaCarteInstantiateStep(YamlTemplateBaseStep):
Exception: Service cleaning failed
"""
- service_deletion = self._service_instance.delete(a_la_carte=True)
- try:
- service_deletion.wait_for_finish(settings.ORCHESTRATION_REQUEST_TIMEOUT)
- except TimeoutError:
- self._logger.error("Service deletion %s timed out", self._service_instance_name)
- raise onap_test_exceptions.ServiceCleanupException
- 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 onap_test_exceptions.ServiceCleanupException
+ self._load_customer_and_subscription()
+ self._load_service_instance()
+ if self._service_instance:
+ service_deletion = self._service_instance.delete(a_la_carte=True)
+ try:
+ service_deletion.wait_for_finish(settings.ORCHESTRATION_REQUEST_TIMEOUT)
+ except TimeoutError:
+ self._logger.error("Service deletion %s timed out", self._service_instance_name)
+ raise onap_test_exceptions.ServiceCleanupException
+ 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 onap_test_exceptions.ServiceCleanupException
super().cleanup()
diff --git a/src/onaptests/steps/instantiate/service_macro.py b/src/onaptests/steps/instantiate/service_macro.py
index 88eef4d..4211cbf 100644
--- a/src/onaptests/steps/instantiate/service_macro.py
+++ b/src/onaptests/steps/instantiate/service_macro.py
@@ -2,10 +2,8 @@
import time
from typing import List
from uuid import uuid4
-from onapsdk.aai.business.service import ServiceInstance
from yaml import load, SafeLoader
-from onapsdk.aai.business.customer import Customer, ServiceSubscription
from onapsdk.aai.business.owning_entity import OwningEntity
from onapsdk.aai.cloud_infrastructure.cloud_region import CloudRegion
from onapsdk.aai.cloud_infrastructure.tenant import Tenant
@@ -46,7 +44,6 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
self._yaml_template: dict = None
self._model_yaml_template: dict = None
self._service_instance_name: str = None
- self._service_instance: str = None
if not settings.ONLY_INSTANTIATE:
self.add_step(YamlTemplateServiceOnboardStep())
@@ -103,20 +100,6 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
return self.parent.model_yaml_template
@property
- def service_name(self) -> str:
- """Service name.
-
- Get from YAML template if it's a root step, get from parent otherwise.
-
- Returns:
- str: Service name
-
- """
- if self.is_root:
- return next(iter(self.yaml_template.keys()))
- return self.parent.service_name
-
- @property
def service_instance_name(self) -> str:
"""Service instance name.
@@ -151,9 +134,7 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
"""
super().execute()
service = Service(self.service_name)
- customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
- service_subscription: ServiceSubscription = \
- customer.get_service_subscription_by_service_type(service.name)
+ self._load_customer_and_subscription()
if any(
filter(lambda x: x in self.yaml_template[self.service_name].keys(),
["vnfs", "networks"])):
@@ -219,14 +200,14 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
service_instantiation = ServiceInstantiation.instantiate_macro(
sdc_service=service,
- customer=customer,
+ customer=self._customer,
owning_entity=owning_entity,
project=settings.PROJECT,
line_of_business=settings.LINE_OF_BUSINESS,
platform=settings.PLATFORM,
cloud_region=cloud_region,
tenant=tenant,
- service_subscription=service_subscription,
+ service_subscription=self._service_subscription,
service_instance_name=self.service_instance_name,
vnf_parameters=vnf_params_list,
enable_multicloud=settings.USE_MULTICLOUD,
@@ -241,10 +222,8 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
self._logger.error("Service instantiation %s failed", self.service_instance_name)
raise onap_test_exceptions.ServiceInstantiateException
- 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)
+ self._load_customer_and_subscription(reload=True)
+ self._load_service_instance()
@YamlTemplateBaseStep.store_state(cleanup=True)
def cleanup(self) -> None:
@@ -254,6 +233,8 @@ class YamlTemplateServiceMacroInstantiateStep(YamlTemplateBaseStep):
Exception: Service cleaning failed
"""
+ self._load_customer_and_subscription()
+ self._load_service_instance()
if self._service_instance:
service_deletion = self._service_instance.delete(a_la_carte=False)
try:
diff --git a/src/onaptests/steps/instantiate/vf_module_ala_carte.py b/src/onaptests/steps/instantiate/vf_module_ala_carte.py
index 015e479..1682536 100644
--- a/src/onaptests/steps/instantiate/vf_module_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vf_module_ala_carte.py
@@ -3,7 +3,6 @@ from uuid import uuid4
from yaml import load, SafeLoader
from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant
-from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription
from onapsdk.configuration import settings
from onapsdk.so.instantiation import InstantiationParameter
@@ -26,7 +25,6 @@ class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep):
self._yaml_template: dict = None
self._service_instance_name: str = None
- self._service_instance: ServiceInstance = None
if settings.CLOUD_REGION_TYPE == settings.K8S_REGION_TYPE:
# K8SProfileStep creates the requested profile and then calls
# YamlTemplateVnfAlaCarteInstantiateStep step
@@ -66,20 +64,6 @@ class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep):
return {}
@property
- def service_name(self) -> str:
- """Service name.
-
- Get from YAML template if it's a root step, get from parent otherwise.
-
- Returns:
- str: Service name
-
- """
- if self.is_root:
- return next(iter(self.yaml_template.keys()))
- return self.parent.service_name
-
- @property
def service_instance_name(self) -> str:
"""Service instance name.
@@ -129,11 +113,8 @@ class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep):
"""
super().execute()
- customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
- 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)
+ self._load_customer_and_subscription()
+ self._load_service_instance()
cloud_region: CloudRegion = CloudRegion.get_by_id(
cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
cloud_region_id=settings.CLOUD_REGION_ID,
@@ -166,22 +147,23 @@ class YamlTemplateVfModuleAlaCarteInstantiateStep(YamlTemplateBaseStep):
Exception: Vf module cleaning failed
"""
- for vnf_instance in self._service_instance.vnf_instances:
- self._logger.debug("VNF instance %s found in Service Instance ",
- vnf_instance.name)
- self._logger.info("Get VF Modules")
- for vf_module in vnf_instance.vf_modules:
- self._logger.info("Delete VF Module %s",
- vf_module.name)
- vf_module_deletion = vf_module.delete(a_la_carte=True)
-
- try:
- vf_module_deletion.wait_for_finish(settings.ORCHESTRATION_REQUEST_TIMEOUT)
- if vf_module_deletion.failed:
- self._logger.error("VfModule deletion %s failed", vf_module.name)
+ if self._service_instance:
+ for vnf_instance in self._service_instance.vnf_instances:
+ self._logger.debug("VNF instance %s found in Service Instance ",
+ vnf_instance.name)
+ self._logger.info("Get VF Modules")
+ for vf_module in vnf_instance.vf_modules:
+ self._logger.info("Delete VF Module %s",
+ vf_module.name)
+ vf_module_deletion = vf_module.delete(a_la_carte=True)
+
+ try:
+ vf_module_deletion.wait_for_finish(settings.ORCHESTRATION_REQUEST_TIMEOUT)
+ if vf_module_deletion.failed:
+ self._logger.error("VfModule deletion %s failed", vf_module.name)
+ raise onap_test_exceptions.VfModuleCleanupException
+ self._logger.info("VfModule %s deleted", vf_module.name)
+ except TimeoutError:
+ self._logger.error("VfModule deletion %s timed out", vf_module.name)
raise onap_test_exceptions.VfModuleCleanupException
- self._logger.info("VfModule %s deleted", vf_module.name)
- except TimeoutError:
- self._logger.error("VfModule deletion %s timed out", vf_module.name)
- raise onap_test_exceptions.VfModuleCleanupException
super().cleanup()
diff --git a/src/onaptests/steps/instantiate/vl_ala_carte.py b/src/onaptests/steps/instantiate/vl_ala_carte.py
index 414615a..7c2f4d9 100644
--- a/src/onaptests/steps/instantiate/vl_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vl_ala_carte.py
@@ -3,7 +3,6 @@ from typing import Iterable
from uuid import uuid4
from yaml import load, SafeLoader
-from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription
from onapsdk.configuration import settings
from onapsdk.so.instantiation import Subnet
from onapsdk.sdc.service import Service
@@ -25,7 +24,6 @@ class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep):
super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._service_instance_name: str = None
- self._service_instance: ServiceInstance = None
self.add_step(YamlTemplateServiceAlaCarteInstantiateStep())
@property
@@ -60,20 +58,6 @@ class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep):
return {}
@property
- def service_name(self) -> str:
- """Service name.
-
- Get from YAML template if it's a root step, get from parent otherwise.
-
- Returns:
- str: Service name
-
- """
- if self.is_root:
- return next(iter(self.yaml_template.keys()))
- return self.parent.service_name
-
- @property
def service_instance_name(self) -> str:
"""Service instance name.
@@ -129,15 +113,11 @@ class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep):
"""
super().execute()
service: Service = Service(self.service_name)
- customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
- service_subscription: ServiceSubscription = \
- customer.get_service_subscription_by_service_type(self.service_name)
- service_instance: ServiceInstance = \
- service_subscription.get_service_instance_by_name(self.service_instance_name)
- self._service_instance = service_instance
+ self._load_customer_and_subscription()
+ self._load_service_instance()
for idx, network in enumerate(service.networks):
# for network in self.yaml_template[self.service_name]["networks"]:
- net_instantiation = service_instance.add_network(
+ net_instantiation = self._service_instance.add_network(
network,
settings.LINE_OF_BUSINESS,
settings.PLATFORM,
@@ -159,7 +139,7 @@ class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep):
Raises:
Exception: VL cleaning failed
"""
- if self._cleanup:
+ if self._service_instance:
for net_instance in self._service_instance.network_instances:
self._logger.info("Start network deletion %s", net_instance.name)
net_deletion = net_instance.delete(a_la_carte=True)
@@ -171,4 +151,4 @@ class YamlTemplateVlAlaCarteInstantiateStep(YamlTemplateBaseStep):
except TimeoutError:
self._logger.error("VL deletion %s timed out", net_instance.name)
raise onap_test_exceptions.NetworkCleanupException
- super().cleanup()
+ super().cleanup()
diff --git a/src/onaptests/steps/instantiate/vnf_ala_carte.py b/src/onaptests/steps/instantiate/vnf_ala_carte.py
index a7ac5c3..2aa5e5e 100644
--- a/src/onaptests/steps/instantiate/vnf_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vnf_ala_carte.py
@@ -2,7 +2,6 @@ from uuid import uuid4
from yaml import load, SafeLoader
from onapsdk.aai.cloud_infrastructure import CloudRegion, Tenant
-from onapsdk.aai.business import Customer, ServiceInstance, ServiceSubscription
from onapsdk.configuration import settings
from onapsdk.sdc.service import Service
@@ -23,7 +22,6 @@ class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep):
super().__init__(cleanup=settings.CLEANUP_FLAG)
self._yaml_template: dict = None
self._service_instance_name: str = None
- self._service_instance: ServiceInstance = None
self.add_step(YamlTemplateServiceAlaCarteInstantiateStep())
@property
@@ -58,20 +56,6 @@ class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep):
return {}
@property
- def service_name(self) -> str:
- """Service name.
-
- Get from YAML template if it's a root step, get from parent otherwise.
-
- Returns:
- str: Service name
-
- """
- if self.is_root:
- return next(iter(self.yaml_template.keys()))
- return self.parent.service_name
-
- @property
def service_instance_name(self) -> str:
"""Service instance name.
@@ -102,11 +86,8 @@ class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep):
"""
super().execute()
service: Service = Service(self.service_name)
- customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
- 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)
+ self._load_customer_and_subscription()
+ self._load_service_instance()
cloud_region: CloudRegion = CloudRegion.get_by_id(
cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
cloud_region_id=settings.CLOUD_REGION_ID,
@@ -137,15 +118,16 @@ class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep):
Exception: VNF cleaning failed
"""
- for vnf_instance in self._service_instance.vnf_instances:
- vnf_deletion = vnf_instance.delete(a_la_carte=True)
-
- try:
- vnf_deletion.wait_for_finish(settings.ORCHESTRATION_REQUEST_TIMEOUT)
- if vnf_deletion.failed:
- self._logger.error("VNF deletion %s failed", vnf_instance.name)
+ if self._service_instance:
+ for vnf_instance in self._service_instance.vnf_instances:
+ vnf_deletion = vnf_instance.delete(a_la_carte=True)
+
+ try:
+ vnf_deletion.wait_for_finish(settings.ORCHESTRATION_REQUEST_TIMEOUT)
+ if vnf_deletion.failed:
+ self._logger.error("VNF deletion %s failed", vnf_instance.name)
+ raise onap_test_exceptions.VnfCleanupException
+ except TimeoutError:
+ self._logger.error("VNF deletion %s timed out", vnf_instance.name)
raise onap_test_exceptions.VnfCleanupException
- except TimeoutError:
- self._logger.error("VNF deletion %s timed out", vnf_instance.name)
- raise onap_test_exceptions.VnfCleanupException
super().cleanup()
diff --git a/src/onaptests/steps/loop/clamp.py b/src/onaptests/steps/loop/clamp.py
index 245abc6..dc00eb1 100644
--- a/src/onaptests/steps/loop/clamp.py
+++ b/src/onaptests/steps/loop/clamp.py
@@ -65,21 +65,6 @@ class ClampStep(YamlTemplateBaseStep):
def model_yaml_template(self) -> dict:
return {}
- @property
- def service_name(self) -> str:
- """Service name.
-
- Get from YAML template if it's a root step, get from parent otherwise.
-
- Returns:
- str: Service name
-
- """
- if self.is_root:
- return next(iter(self.yaml_template.keys()))
- else:
- return self.parent.service_name
-
def check(self, operational_policies: list, is_template: bool = False) -> str:
"""Check CLAMP requirements to create a loop."""
self._logger.info("Check operational policy")
diff --git a/src/onaptests/steps/onboard/clamp.py b/src/onaptests/steps/onboard/clamp.py
index 7cb20ff..22783c6 100644
--- a/src/onaptests/steps/onboard/clamp.py
+++ b/src/onaptests/steps/onboard/clamp.py
@@ -58,21 +58,6 @@ class OnboardClampStep(YamlTemplateBaseStep):
def model_yaml_template(self) -> dict:
return {}
- @property
- def service_name(self) -> str:
- """Service name.
-
- Get from YAML template if it's a root step, get from parent otherwise.
-
- Returns:
- str: Service name
-
- """
- if self.is_root:
- return next(iter(self.yaml_template.keys()))
- else:
- return self.parent.service_name
-
@YamlTemplateBaseStep.store_state
def execute(self):
"""Onboard service."""
diff --git a/src/onaptests/steps/onboard/service.py b/src/onaptests/steps/onboard/service.py
index be0f6fd..bcf153f 100644
--- a/src/onaptests/steps/onboard/service.py
+++ b/src/onaptests/steps/onboard/service.py
@@ -171,20 +171,6 @@ class YamlTemplateServiceOnboardStep(YamlTemplateBaseStep):
return self._model_yaml_template
return self.parent.model_yaml_template
- @property
- def service_name(self) -> str:
- """Service name.
-
- Get from YAML template if it's a root step, get from parent otherwise.
-
- Returns:
- str: Service name
-
- """
- if self.is_root:
- return next(iter(self.yaml_template.keys()))
- return self.parent.service_name
-
@YamlTemplateBaseStep.store_state
def execute(self):
"""Onboard service."""