aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/instantiate
diff options
context:
space:
mode:
Diffstat (limited to 'src/onaptests/steps/instantiate')
-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
5 files changed, 65 insertions, 156 deletions
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()