aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrichomme <morgan.richomme@orange.com>2020-09-04 17:03:23 +0200
committermrichomme <morgan.richomme@orange.com>2020-09-08 11:03:28 +0200
commit076a0030b70a875535f7fcabb7acafe7cf478746 (patch)
tree0f5a62fad16fa4fb930ae0436bf158c20d9ff6b1
parent6022ac2e68ece3720bcfa57b290d73ac0eb238c1 (diff)
Support non multicloud configuration
Add tenant and availability zone manually It is done by multicloud in multicloud mode Use settings.py as the main settings and specific settings per use case Issue-ID: TEST-256 Signed-off-by: mrichomme <morgan.richomme@orange.com> Change-Id: I3a66a8416cddb546780f784568e7a88f2bd1781b Signed-off-by: mrichomme <morgan.richomme@orange.com>
-rw-r--r--README.md7
-rw-r--r--run_basicvm_multicloud_yaml.py (renamed from run.py)0
-rw-r--r--run_basicvm_nomulticloud.py24
-rw-r--r--src/onaptests/configuration/settings.py31
-rw-r--r--src/onaptests/configuration/ubuntu16_multicloud_yaml_settings.py38
-rw-r--r--src/onaptests/configuration/ubuntu16_nomulticloud_noyaml_settings.py56
-rw-r--r--src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py31
-rw-r--r--src/onaptests/steps/instantiate/service_ala_carte.py7
8 files changed, 158 insertions, 36 deletions
diff --git a/README.md b/README.md
index f275115..9987a40 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ instantiate services on ONAP
A basic example is implemented in the python file
-- run.py
+- run_basicvm_multicloud_yaml.py
The global datas defined in these files (see input_datas) shall be
adapted to your environment.
@@ -41,9 +41,12 @@ See ubuntu16test as example
- Export the setting file in a environment variable
```shell
- export ONAP_PYTHON_SDK_SETTINGS="onaptests.configuration.settings"
+ export ONAP_PYTHON_SDK_SETTINGS="onaptests.configuration.ubuntu16_multicloud_yaml_settings"
```
+Note each "use case" may have its own settings corresponding to the test
+environment and configuration.
+
- (optional) Open ssh tunnel towards your openlab setting a dynamic
port forward (by default 1080):
```shell
diff --git a/run.py b/run_basicvm_multicloud_yaml.py
index 22bdb25..22bdb25 100644
--- a/run.py
+++ b/run_basicvm_multicloud_yaml.py
diff --git a/run_basicvm_nomulticloud.py b/run_basicvm_nomulticloud.py
new file mode 100644
index 0000000..e7f63c0
--- /dev/null
+++ b/run_basicvm_nomulticloud.py
@@ -0,0 +1,24 @@
+# import logging
+
+from onaptests.steps.instantiate.module import ModuleInstantiateStep
+
+# from onapsdk.sdc.vendor import Vendor
+
+
+# Configure logging
+# logger = logging.getLogger("")
+# logger.setLevel(logging.INFO)
+# fh = logging.StreamHandler()
+# fh_formatter = logging.Formatter(
+# "%(asctime)s %(levelname)s %(name)s %(lineno)d:%(filename)s(%(process)d) - %(message)s"
+# )
+# fh.setFormatter(fh_formatter)
+# logger.addHandler(fh)
+# Vendor.set_proxy({ 'http': 'socks5h://127.0.0.1:8083', 'https': 'socks5h://127.0.0.1:8083'})
+
+
+if __name__ == "__main__":
+ basic_vm_instantiate = ModuleInstantiateStep()
+ basic_vm_instantiate.execute()
+ # service_onboard = YamlTemplateServiceOnboardStep()
+ # service_onboard.execute()
diff --git a/src/onaptests/configuration/settings.py b/src/onaptests/configuration/settings.py
index 2765415..7385fa0 100644
--- a/src/onaptests/configuration/settings.py
+++ b/src/onaptests/configuration/settings.py
@@ -38,35 +38,4 @@ LOG_CONFIG = {
}
}
-VENDOR_NAME = "sdktests_vendor"
-VSP_NAME = "sdktests_vsp"
-VSP_FILE_PATH = "vfw.zip"
-SERVICE_NAME = "sdktests-service"
-VF_NAME = "sdktests_vf"
-
-CLOUD_REGION_CLOUD_OWNER = "sdktests_cloud_region_owner"
-CLOUD_REGION_ID = "sdktests_cloud_region_id"
-CLOUD_REGION_TYPE = "openstack"
-CLOUD_REGION_VERSION = "titanium_cloud"
-CLOUD_DOMAIN = "Default"
-
-COMPLEX_PHYSICAL_LOCATION_ID = "sdktests_complex_physical_location_id"
-COMPLEX_DATA_CENTER_CODE = "sdktests_complex_data_center_code"
-
-GLOBAL_CUSTOMER_ID = "sdktests_global_customer_id"
-TENANT_ID = "" # Fill me in your custom settings
-
-VIM_USERNAME = "" # Fill me in your custom settings
-VIM_PASSWORD = "" # Fill me in your custom settings
-VIM_SERVICE_URL = "" # Fill me in your custom settings
-
-OWNING_ENTITY = "sdktests_owning_entity"
-PROJECT = "sdktests_project"
-LINE_OF_BUSINESS = "sdktests_line_of_business"
-PLATFORM = "sdktests_platform"
-
-SERVICE_INSTANCE_NAME = "sdktests_service_instance_name"
-
-SERVICE_YAML_TEMPLATE = "templates/vnf-services/ubuntu16test-service.yaml"
-
# SOCK_HTTP = "socks5h://127.0.0.1:8080"
diff --git a/src/onaptests/configuration/ubuntu16_multicloud_yaml_settings.py b/src/onaptests/configuration/ubuntu16_multicloud_yaml_settings.py
new file mode 100644
index 0000000..4b97866
--- /dev/null
+++ b/src/onaptests/configuration/ubuntu16_multicloud_yaml_settings.py
@@ -0,0 +1,38 @@
+# pylint: disable=unused-import
+from .settings import *
+
+""" Specific ubuntu16 with multicloud and yaml config scenario."""
+# pylint: disable=bad-whitespace
+
+USE_MULTICLOUD = True
+
+VENDOR_NAME = "sdktests_vendor"
+VSP_NAME = "sdktests_vsp"
+VSP_FILE_PATH = "vfw.zip"
+SERVICE_NAME = "sdktests-service"
+VF_NAME = "sdktests_vf"
+
+CLOUD_REGION_CLOUD_OWNER = "sdktests_cloud_region_owner"
+CLOUD_REGION_ID = "sdktests_cloud_region_id"
+CLOUD_REGION_TYPE = "openstack"
+CLOUD_REGION_VERSION = "titanium_cloud"
+CLOUD_DOMAIN = "Default"
+
+COMPLEX_PHYSICAL_LOCATION_ID = "sdktests_complex_physical_location_id"
+COMPLEX_DATA_CENTER_CODE = "sdktests_complex_data_center_code"
+
+GLOBAL_CUSTOMER_ID = "sdktests_global_customer_id"
+TENANT_ID = "" # Fill me in your custom settings
+
+VIM_USERNAME = "" # Fill me in your custom settings
+VIM_PASSWORD = "" # Fill me in your custom settings
+VIM_SERVICE_URL = "" # Fill me in your custom settings
+
+OWNING_ENTITY = "sdktests_owning_entity"
+PROJECT = "sdktests_project"
+LINE_OF_BUSINESS = "sdktests_line_of_business"
+PLATFORM = "sdktests_platform"
+
+SERVICE_INSTANCE_NAME = "sdktests_service_instance_name"
+
+SERVICE_YAML_TEMPLATE = "templates/vnf-services/ubuntu16test-service.yaml"
diff --git a/src/onaptests/configuration/ubuntu16_nomulticloud_noyaml_settings.py b/src/onaptests/configuration/ubuntu16_nomulticloud_noyaml_settings.py
new file mode 100644
index 0000000..52d5922
--- /dev/null
+++ b/src/onaptests/configuration/ubuntu16_nomulticloud_noyaml_settings.py
@@ -0,0 +1,56 @@
+import os
+import openstack
+
+# pylint: disable=unused-import
+from .settings import *
+
+# The ONAP part
+USE_MULTICLOUD = False
+
+VENDOR_NAME = "basicvm_vendor"
+VSP_NAME = "basicvm_ubuntu_vsp"
+SERVICE_NAME = "basicvm-ubuntu-service"
+VF_NAME = "basicvm_ubuntu_vf"
+
+CLOUD_REGION_CLOUD_OWNER = "basicvm-cloud-owner"
+CLOUD_REGION_ID = "RegionOne"
+CLOUD_REGION_TYPE = "openstack"
+CLOUD_REGION_VERSION = "openstack"
+CLOUD_DOMAIN = "Default"
+
+AVAILABILITY_ZONE_NAME = "basicvm-availability-zone"
+AVAILABILITY_ZONE_TYPE = "nova"
+COMPLEX_PHYSICAL_LOCATION_ID = "lannion"
+COMPLEX_DATA_CENTER_CODE = "1234-5"
+
+GLOBAL_CUSTOMER_ID = "basicvm-customer"
+
+OWNING_ENTITY = "basicvm-oe"
+PROJECT = "basicvm-project"
+LINE_OF_BUSINESS = "basicvm-lob"
+PLATFORM = "basicvm-platform"
+
+SERVICE_INSTANCE_NAME = "basicvm_ubuntu16_service_instance"
+
+VSP_FILE_PATH = "templates/heat_files/ubuntu16/ubuntu16.zip"
+
+# The cloud Part
+# TODO use the openstack client and assume a cloud.yaml is Provided
+# to avoid data duplication
+CLOUD_REGION_ID = "RegionOne"
+
+TEST_CLOUD = os.getenv('OS_TEST_CLOUD', 'onap-cloud-config')
+try:
+ cloud = openstack.connect(cloud=TEST_CLOUD)
+ VIM_USERNAME = cloud.config.auth['username']
+ VIM_PASSWORD = cloud.config.auth['password']
+ VIM_SERVICE_URL = cloud.config.auth['auth_url']
+ # need a keystone authent to retrieve project info
+ TENANT_ID = "" # Fill me
+ TENANT_NAME = "" # Fill me
+except ValueError:
+ TENANT_ID = "" # Fill me
+ TENANT_NAME = "" # Fill me
+ VIM_USERNAME = "" # Fill me
+ VIM_PASSWORD = "" # Fill me
+ VIM_SERVICE_URL = "" # Fill me
diff --git a/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py
index 23ba994..8b11bc1 100644
--- a/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py
+++ b/src/onaptests/steps/cloud/connect_service_subscription_to_cloud_region.py
@@ -36,11 +36,38 @@ class ConnectServiceSubToCloudRegionStep(BaseStep):
"""
super().execute()
- customer: Customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
- service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(settings.SERVICE_NAME)
+ customer: Customer = Customer.get_by_global_customer_id(
+ settings.GLOBAL_CUSTOMER_ID)
+ service_subscription: ServiceSubscription = customer.get_service_subscription_by_service_type(
+ settings.SERVICE_NAME)
cloud_region: CloudRegion = CloudRegion.get_by_id(
cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
cloud_region_id=settings.CLOUD_REGION_ID,
)
+
+ # Retrieve the tenant
+ # if it does not exist, create it
+ try:
+ tenant: Tenant = cloud_region.get_tenant(settings.TENANT_ID)
+ except ValueError:
+ self._logger.warning("Impossible to retrieve the Specificed Tenant")
+ self._logger.debug("If no multicloud selected, add the tenant")
+ cloud_region.add_tenant(
+ tenant_id=settings.TENANT_ID,
+ tenant_name=settings.TENANT_NAME)
+
+ # be sure that an availability zone has been created
+ # if not, create it
+ try:
+ cloud_region.get_availability_zone_by_name(
+ settings.AVAILABILITY_ZONE_NAME)
+ except ValueError:
+ cloud_region.add_availability_zone(
+ settings.AVAILABILITY_ZONE_NAME,
+ settings.AVAILABILITY_ZONE_TYPE)
+
+ # retrieve tenant
+ # for which we are sure that an availability zone has been created
tenant: Tenant = cloud_region.get_tenant(settings.TENANT_ID)
+
service_subscription.link_to_cloud_region_and_tenant(cloud_region=cloud_region, tenant=tenant)
diff --git a/src/onaptests/steps/instantiate/service_ala_carte.py b/src/onaptests/steps/instantiate/service_ala_carte.py
index dad6563..011528d 100644
--- a/src/onaptests/steps/instantiate/service_ala_carte.py
+++ b/src/onaptests/steps/instantiate/service_ala_carte.py
@@ -50,7 +50,12 @@ class ServiceAlaCarteInstantiateStep(BaseStep):
cloud_region_id=settings.CLOUD_REGION_ID,
)
tenant: Tenant = cloud_region.get_tenant(settings.TENANT_ID)
- owning_entity = AaiOwningEntity.get_by_owning_entity_name(settings.OWNING_ENTITY)
+ try:
+ owning_entity = AaiOwningEntity.get_by_owning_entity_name(
+ settings.OWNING_ENTITY)
+ except ValueError:
+ self._logger.info("Owning entity not found, create it")
+ owning_entity = AaiOwningEntity.create(settings.OWNING_ENTITY)
vid_project = Project.create(settings.PROJECT)
service_instantiation = ServiceInstantiation.instantiate_so_ala_carte(