aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/cloud
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2021-02-05 20:37:02 +0000
committermorganrol <morgan.richomme@orange.com>2021-02-08 18:12:38 +0100
commitdf5a03610d6f00ed8e8ee3e153de055fbc5dae94 (patch)
tree252a682d3932edd33301861c604abefb2191d8cd /src/onaptests/steps/cloud
parent5021508f4b6f8bf2bb6ef890b4bb960dc144484b (diff)
Python SDK 7.4.0 compatibility
Use Python SDK exceptions. Issue-ID: TEST-302 Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl> Change-Id: I76996817c0d7b91c0214ad521c3768682ff07e83
Diffstat (limited to 'src/onaptests/steps/cloud')
-rw-r--r--src/onaptests/steps/cloud/cloud_region_create.py3
-rw-r--r--src/onaptests/steps/cloud/complex_create.py13
-rw-r--r--src/onaptests/steps/cloud/customer_create.py6
-rw-r--r--src/onaptests/steps/cloud/k8s_connectivity_info_create.py3
-rw-r--r--src/onaptests/steps/cloud/register_cloud.py15
5 files changed, 25 insertions, 15 deletions
diff --git a/src/onaptests/steps/cloud/cloud_region_create.py b/src/onaptests/steps/cloud/cloud_region_create.py
index ba46466..21c846f 100644
--- a/src/onaptests/steps/cloud/cloud_region_create.py
+++ b/src/onaptests/steps/cloud/cloud_region_create.py
@@ -1,6 +1,7 @@
"""A&AI cloud region creation module."""
from onapsdk.aai.cloud_infrastructure import CloudRegion
from onapsdk.configuration import settings
+from onapsdk.exceptions import ResourceNotFound
from ..base import BaseStep
@@ -38,7 +39,7 @@ class CloudRegionCreateStep(BaseStep):
cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
cloud_region_id=settings.CLOUD_REGION_ID,
)
- except ValueError:
+ except ResourceNotFound:
CloudRegion.create(
cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
cloud_region_id=settings.CLOUD_REGION_ID,
diff --git a/src/onaptests/steps/cloud/complex_create.py b/src/onaptests/steps/cloud/complex_create.py
index 1bb7e51..60565f4 100644
--- a/src/onaptests/steps/cloud/complex_create.py
+++ b/src/onaptests/steps/cloud/complex_create.py
@@ -1,5 +1,6 @@
from onapsdk.aai.cloud_infrastructure import Complex
from onapsdk.configuration import settings
+from onapsdk.exceptions import APIError
from ..base import BaseStep
@@ -27,8 +28,10 @@ class ComplexCreateStep(BaseStep):
"""
super().execute()
- Complex.create(
- physical_location_id=settings.COMPLEX_PHYSICAL_LOCATION_ID,
- data_center_code=settings.COMPLEX_DATA_CENTER_CODE,
- name=settings.COMPLEX_PHYSICAL_LOCATION_ID
- )
+ try:
+ Complex.create(
+ physical_location_id=settings.COMPLEX_PHYSICAL_LOCATION_ID,
+ data_center_code=settings.COMPLEX_DATA_CENTER_CODE,
+ name=settings.COMPLEX_PHYSICAL_LOCATION_ID)
+ except APIError:
+ self._logger.warn("Try to update the complex failed.")
diff --git a/src/onaptests/steps/cloud/customer_create.py b/src/onaptests/steps/cloud/customer_create.py
index 6c78d55..1cc0879 100644
--- a/src/onaptests/steps/cloud/customer_create.py
+++ b/src/onaptests/steps/cloud/customer_create.py
@@ -1,5 +1,6 @@
from onapsdk.aai.business import Customer
from onapsdk.configuration import settings
+from onapsdk.exceptions import APIError
from ..base import BaseStep
@@ -25,4 +26,7 @@ class CustomerCreateStep(BaseStep):
- GLOBAL_CUSTOMER_ID.
"""
super().execute()
- Customer.create(settings.GLOBAL_CUSTOMER_ID, settings.GLOBAL_CUSTOMER_ID, "INFRA")
+ try:
+ Customer.create(settings.GLOBAL_CUSTOMER_ID, settings.GLOBAL_CUSTOMER_ID, "INFRA")
+ except APIError:
+ self._logger.warn("Try to update the Customer failed.")
diff --git a/src/onaptests/steps/cloud/k8s_connectivity_info_create.py b/src/onaptests/steps/cloud/k8s_connectivity_info_create.py
index de0e683..2855be7 100644
--- a/src/onaptests/steps/cloud/k8s_connectivity_info_create.py
+++ b/src/onaptests/steps/cloud/k8s_connectivity_info_create.py
@@ -1,5 +1,6 @@
"""Connectivity info creation module."""
from onapsdk.configuration import settings
+from onapsdk.exceptions import APIError
from onapsdk.msb.k8s import ConnectivityInfo
from ..base import BaseStep
@@ -31,7 +32,7 @@ class K8SConnectivityInfoStep(BaseStep):
try:
self._logger.info("Check if k8s connectivity information exists")
ConnectivityInfo.get_connectivity_info_by_region_id(settings.CLOUD_REGION_ID)
- except ValueError:
+ except APIError:
self._logger.info("Create the k8s connectivity information")
ConnectivityInfo.create(settings.CLOUD_REGION_ID,
settings.CLOUD_REGION_CLOUD_OWNER,
diff --git a/src/onaptests/steps/cloud/register_cloud.py b/src/onaptests/steps/cloud/register_cloud.py
index 72da4f7..58c3e35 100644
--- a/src/onaptests/steps/cloud/register_cloud.py
+++ b/src/onaptests/steps/cloud/register_cloud.py
@@ -4,6 +4,7 @@ from uuid import uuid4
from onapsdk.aai.cloud_infrastructure import CloudRegion
from onapsdk.configuration import settings
+from onapsdk.exceptions import ResourceNotFound
from ..base import BaseStep
from onaptests.steps.cloud.cloud_region_create import CloudRegionCreateStep
@@ -45,11 +46,11 @@ class RegisterCloudRegionStep(BaseStep):
- TENANT_NAME.
"""
super().execute()
- cloud_region: CloudRegion = CloudRegion.get_by_id(
- cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
- cloud_region_id=settings.CLOUD_REGION_ID,
- )
- if not list(cloud_region.esr_system_infos):
+ try:
+ cloud_region: CloudRegion = CloudRegion.get_by_id(
+ cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
+ cloud_region_id=settings.CLOUD_REGION_ID)
+ except ResourceNotFound:
cloud_region.add_esr_system_info(
esr_system_info_id=str(uuid4()),
user_name=settings.VIM_USERNAME,
@@ -78,7 +79,7 @@ class RegisterCloudRegionStep(BaseStep):
# if it does not exist, create it
try:
cloud_region.get_tenant(settings.TENANT_ID)
- except ValueError:
+ except ResourceNotFound:
self._logger.warning("Impossible to retrieve the Specificed Tenant")
self._logger.debug("If no multicloud selected, add the tenant")
cloud_region.add_tenant(
@@ -90,7 +91,7 @@ class RegisterCloudRegionStep(BaseStep):
try:
cloud_region.get_availability_zone_by_name(
settings.AVAILABILITY_ZONE_NAME)
- except ValueError:
+ except ResourceNotFound:
cloud_region.add_availability_zone(
settings.AVAILABILITY_ZONE_NAME,
settings.AVAILABILITY_ZONE_TYPE)