aboutsummaryrefslogtreecommitdiffstats
path: root/onap-client/onap_client/so
diff options
context:
space:
mode:
authorstark, steven <steven.stark@att.com>2020-08-03 13:03:24 -0700
committerstark, steven <steven.stark@att.com>2020-08-03 13:03:24 -0700
commit32409110b65b013bc65930f3cfdef09671cd3a5a (patch)
tree4bb6c95c057cdde0f08af78e7abc53e2be02fad4 /onap-client/onap_client/so
parent9df81b14e7203d6c3911f5f36881cb5170afdccc (diff)
[VVP] ONAP Client enhancements
Output hooks for resources. Outputs for each resource are returned as part of the complete onap-client spec when a resource is created. Hooks have been added for the SDC resources, to return the TOSCA model for each created resource. Dynamic config change. Ability to specify and reconfigure the onap-client configuration file at runtime without restarting the current session. Logging. Logging has been upgraded to create its own logging instance rather than the root logging instance, to avoid collisions. Issue-ID: VVP-455 Signed-off-by: stark, steven <steven.stark@att.com> Change-Id: I7b03411d221801fc51b80ee6a73d9491e823da56
Diffstat (limited to 'onap-client/onap_client/so')
-rw-r--r--onap-client/onap_client/so/__init__.py4
-rw-r--r--onap-client/onap_client/so/catalog/service_instantiation.py523
-rw-r--r--onap-client/onap_client/so/client.py31
-rw-r--r--onap-client/onap_client/so/module_instance.py2
-rw-r--r--onap-client/onap_client/so/service_instance.py5
-rw-r--r--onap-client/onap_client/so/vnf_instance.py23
6 files changed, 286 insertions, 302 deletions
diff --git a/onap-client/onap_client/so/__init__.py b/onap-client/onap_client/so/__init__.py
index 44cf6d7..5519a84 100644
--- a/onap-client/onap_client/so/__init__.py
+++ b/onap-client/onap_client/so/__init__.py
@@ -34,7 +34,3 @@
# limitations under the License.
#
# ============LICENSE_END============================================
-
-from onap_client.config import APP_CONFIG
-
-SO_PROPERTIES = APP_CONFIG.so
diff --git a/onap-client/onap_client/so/catalog/service_instantiation.py b/onap-client/onap_client/so/catalog/service_instantiation.py
index 665402f..d561317 100644
--- a/onap-client/onap_client/so/catalog/service_instantiation.py
+++ b/onap-client/onap_client/so/catalog/service_instantiation.py
@@ -38,279 +38,274 @@
import uuid
from functools import partial
-from onap_client import so
from onap_client import config
from onap_client.so.client import SOClient
PAYLOADS_DIR = config.PAYLOADS_DIR
-so_properties = so.SO_PROPERTIES
application_id = config.APPLICATION_ID
class ServiceInstantiationClient(SOClient):
@property
- def catalog_resources(self):
- return CATALOG_RESOURCES
-
- @property
def namespace(self):
return "service_instantiation"
-
-CATALOG_RESOURCES = {
- "CREATE_SERVICE_INSTANCE": {
- "verb": "POST",
- "description": "Creates a Service Instance from the service catalog",
- "uri": partial(
- "{endpoint}{service_path}".format,
- endpoint=so_properties.SO_ENDPOINT,
- service_path=so_properties.SO_SERVICE_INSTANCE_PATH,
- ),
- "payload": "{}/so_service_instance.jinja".format(PAYLOADS_DIR),
- "payload-parameters": [
- "service_instance_name",
- "requestor_id",
- "model_invariant_id",
- "model_version_id",
- "model_name",
- "model_version",
- "tenant_id",
- "cloud_owner",
- "cloud_region",
- "api_type",
- "service_type",
- "customer_id",
- "project_name",
- "owning_entity_id",
- ],
- "header-parameters": ["X-TransactionId"],
- "success_code": 202,
- "headers": {
- "Accept": "application/json",
- "Content-Type": "application/json",
- # "X-TransactionId": str(uuid.uuid4()),
- "X-FromAppId": application_id,
- },
- "auth": (so_properties.SO_USERNAME, so_properties.SO_PASSWORD),
- },
- "DELETE_SERVICE_INSTANCE": {
- "verb": "DELETE",
- "description": "Deletes a VNF Instance.",
- "uri": partial(
- "{endpoint}{service_path}/{service_instance_id}".format,
- endpoint=so_properties.SO_ENDPOINT,
- service_path=so_properties.SO_SERVICE_INSTANCE_PATH,
- ),
- "uri-parameters": ["service_instance_id"],
- "payload": "{}/so_delete_service.jinja".format(PAYLOADS_DIR),
- "payload-parameters": [
- "service_invariant_id",
- "service_name",
- "service_version",
- "api_type",
- ],
- "header-parameters": ["X-TransactionId"],
- "success_code": 202,
- "headers": {
- "Accept": "application/json",
- "Content-Type": "application/json",
- # "X-TransactionId": str(uuid.uuid4()),
- "X-FromAppId": application_id,
- },
- "auth": (so_properties.SO_USERNAME, so_properties.SO_PASSWORD),
- },
- "CREATE_VNF_INSTANCE": {
- "verb": "POST",
- "description": "Creates a VNF Instance.",
- "uri": partial(
- "{endpoint}{service_path}/{service_instance_id}/vnfs".format,
- endpoint=so_properties.SO_ENDPOINT,
- service_path=so_properties.SO_SERVICE_INSTANCE_PATH,
- ),
- "uri-parameters": ["service_instance_id"],
- "payload": "{}/so_vnf_instance.jinja".format(PAYLOADS_DIR),
- "payload-parameters": [
- "vnf_instance_name",
- "requestor_id",
- "model_invariant_id",
- "model_version_id",
- "model_name",
- "model_version",
- "model_customization_id",
- "tenant_id",
- "cloud_owner",
- "cloud_region",
- "api_type",
- "platform",
- "line_of_business",
- "service_model_name",
- "service_model_invariant_id",
- "service_model_version",
- "service_model_version_id",
- "service_instance_id",
- ],
- "header-parameters": ["X-TransactionId"],
- "success_code": 202,
- "headers": {
- "Accept": "application/json",
- "Content-Type": "application/json",
- # "X-TransactionId": str(uuid.uuid4()),
- "X-FromAppId": application_id,
- },
- "auth": (so_properties.SO_USERNAME, so_properties.SO_PASSWORD),
- },
- "DELETE_VNF_INSTANCE": {
- "verb": "DELETE",
- "description": "Deletes a VNF Instance.",
- "uri": partial(
- "{endpoint}{service_path}/{service_instance_id}/vnfs/{vnf_instance_id}".format,
- endpoint=so_properties.SO_ENDPOINT,
- service_path=so_properties.SO_SERVICE_INSTANCE_PATH,
- ),
- "uri-parameters": ["service_instance_id", "vnf_instance_id"],
- "payload": "{}/so_delete_vnf.jinja".format(PAYLOADS_DIR),
- "payload-parameters": [
- "vnf_invariant_id",
- "vnf_name",
- "vnf_version",
- "cloud_region",
- "cloud_owner",
- "tenant_id",
- "api_type",
- ],
- "header-parameters": ["X-TransactionId"],
- "success_code": 202,
- "headers": {
- "Accept": "application/json",
- "Content-Type": "application/json",
- # "X-TransactionId": str(uuid.uuid4()),
- "X-FromAppId": application_id,
- },
- "auth": (so_properties.SO_USERNAME, so_properties.SO_PASSWORD),
- },
- "CREATE_MODULE_INSTANCE": {
- "verb": "POST",
- "description": "Creates a VNF Module Instance.",
- "uri": partial(
- "{endpoint}{service_path}/{service_instance_id}/vnfs/{vnf_instance_id}/vfModules".format,
- endpoint=so_properties.SO_ENDPOINT,
- service_path=so_properties.SO_SERVICE_INSTANCE_PATH,
- ),
- "uri-parameters": ["service_instance_id", "vnf_instance_id"],
- "payload": "{}/so_create_module.jinja".format(PAYLOADS_DIR),
- "payload-parameters": [
- "module_instance_name",
- "model_invariant_id",
- "model_version_id",
- "model_name",
- "model_version",
- "model_customization_id",
- "model_name",
- "api_type",
- "tenant_id",
- "cloud_owner",
- "cloud_region",
- "service_instance_id",
- "service_model_name",
- "service_model_invariant_id",
- "service_model_version",
- "service_model_version_id",
- "vnf_instance_id",
- "vnf_model_name",
- "vnf_model_invariant_id",
- "vnf_model_version",
- "vnf_model_version_id",
- "vnf_model_customization_id",
- ],
- "header-parameters": ["X-TransactionId"],
- "success_code": 202,
- "headers": {
- "Accept": "application/json",
- "Content-Type": "application/json",
- # "X-TransactionId": str(uuid.uuid4()),
- "X-FromAppId": application_id,
- },
- "auth": (so_properties.SO_USERNAME, so_properties.SO_PASSWORD),
- },
- "DELETE_MODULE_INSTANCE": {
- "verb": "DELETE",
- "description": "Deletes a VNF Module Instance.",
- "uri": partial(
- "{endpoint}{service_path}/{service_instance_id}/vnfs/{vnf_instance_id}/vfModules/{vf_module_id}".format,
- endpoint=so_properties.SO_ENDPOINT,
- service_path=so_properties.SO_SERVICE_INSTANCE_PATH,
- ),
- "uri-parameters": ["service_instance_id", "vnf_instance_id", "vf_module_id"],
- "payload": "{}/so_delete_module.jinja".format(PAYLOADS_DIR),
- "payload-parameters": [
- "module_invariant_id",
- "module_name",
- "module_version",
- "cloud_region",
- "cloud_owner",
- "tenant_id",
- "api_type",
- ],
- "header-parameters": ["X-TransactionId"],
- "success_code": 202,
- "headers": {
- "Accept": "application/json",
- "Content-Type": "application/json",
- # "X-TransactionId": str(uuid.uuid4()),
- "X-FromAppId": application_id,
- },
- "auth": (so_properties.SO_USERNAME, so_properties.SO_PASSWORD),
- },
- "GET_REQUEST_STATUS": {
- "verb": "GET",
- "description": "Queries the status for a given request ID",
- "uri": partial(
- "{endpoint}{service_path}/{request_id}".format,
- endpoint=so_properties.SO_ENDPOINT,
- service_path=so_properties.SO_ORCHESTRATION_PATH,
- ),
- "uri-parameters": ["request_id"],
- "success_code": 200,
- "headers": {
- "Accept": "application/json",
- "Content-Type": "application/json",
- "X-TransactionId": str(uuid.uuid4()),
- "X-FromAppId": application_id,
- },
- "auth": (so_properties.SO_USERNAME, so_properties.SO_PASSWORD),
- },
- "GET_SERVICE_MODEL": {
- "verb": "GET",
- "description": "Searches the SO catalog for a service model",
- "uri": partial(
- "{endpoint}/service/search/findOneByModelName?modelName={model_name}".format,
- endpoint=so_properties.SO_ENDPOINT,
- ),
- "uri-parameters": ["model_name"],
- "success_code": 200,
- "headers": {
- "Accept": "application/json",
- "Content-Type": "application/json",
- "X-TransactionId": str(uuid.uuid4()),
- "X-FromAppId": application_id,
- },
- "auth": (so_properties.SO_USERNAME, so_properties.SO_PASSWORD),
- },
- "GET_SERVICE_MODEL_DETAILS": {
- "verb": "GET",
- "description": "Searches the SO catalog for a service model",
- "uri": partial(
- "{endpoint}/service/search/findOneByModelName?modelName={model_name}".format,
- endpoint=so_properties.SO_ENDPOINT,
- ),
- "uri-parameters": ["model_name"],
- "success_code": 200,
- "headers": {
- "Accept": "application/json",
- "Content-Type": "application/json",
- "X-TransactionId": str(uuid.uuid4()),
- "X-FromAppId": application_id,
- },
- "auth": (so_properties.SO_USERNAME, so_properties.SO_PASSWORD),
- },
-}
+ @property
+ def catalog_resources(self):
+ return {
+ "CREATE_SERVICE_INSTANCE": {
+ "verb": "POST",
+ "description": "Creates a Service Instance from the service catalog",
+ "uri": partial(
+ "{endpoint}{service_path}".format,
+ endpoint=self.config.so.SO_ENDPOINT,
+ service_path=self.config.so.SO_SERVICE_INSTANCE_PATH,
+ ),
+ "payload": "{}/so_service_instance.jinja".format(PAYLOADS_DIR),
+ "payload-parameters": [
+ "service_instance_name",
+ "requestor_id",
+ "model_invariant_id",
+ "model_version_id",
+ "model_name",
+ "model_version",
+ "tenant_id",
+ "cloud_owner",
+ "cloud_region",
+ "api_type",
+ "service_type",
+ "customer_id",
+ "project_name",
+ "owning_entity_id",
+ ],
+ "header-parameters": ["X-TransactionId"],
+ "success_code": 202,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ # "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD),
+ },
+ "DELETE_SERVICE_INSTANCE": {
+ "verb": "DELETE",
+ "description": "Deletes a VNF Instance.",
+ "uri": partial(
+ "{endpoint}{service_path}/{service_instance_id}".format,
+ endpoint=self.config.so.SO_ENDPOINT,
+ service_path=self.config.so.SO_SERVICE_INSTANCE_PATH,
+ ),
+ "uri-parameters": ["service_instance_id"],
+ "payload": "{}/so_delete_service.jinja".format(PAYLOADS_DIR),
+ "payload-parameters": [
+ "service_invariant_id",
+ "service_name",
+ "service_version",
+ "api_type",
+ ],
+ "header-parameters": ["X-TransactionId"],
+ "success_code": 202,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ # "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD),
+ },
+ "CREATE_VNF_INSTANCE": {
+ "verb": "POST",
+ "description": "Creates a VNF Instance.",
+ "uri": partial(
+ "{endpoint}{service_path}/{service_instance_id}/vnfs".format,
+ endpoint=self.config.so.SO_ENDPOINT,
+ service_path=self.config.so.SO_SERVICE_INSTANCE_PATH,
+ ),
+ "uri-parameters": ["service_instance_id"],
+ "payload": "{}/so_vnf_instance.jinja".format(PAYLOADS_DIR),
+ "payload-parameters": [
+ "vnf_instance_name",
+ "requestor_id",
+ "model_invariant_id",
+ "model_version_id",
+ "model_name",
+ "model_version",
+ "model_customization_id",
+ "tenant_id",
+ "cloud_owner",
+ "cloud_region",
+ "api_type",
+ "platform",
+ "line_of_business",
+ "service_model_name",
+ "service_model_invariant_id",
+ "service_model_version",
+ "service_model_version_id",
+ "service_instance_id",
+ ],
+ "header-parameters": ["X-TransactionId"],
+ "success_code": 202,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ # "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD),
+ },
+ "DELETE_VNF_INSTANCE": {
+ "verb": "DELETE",
+ "description": "Deletes a VNF Instance.",
+ "uri": partial(
+ "{endpoint}{service_path}/{service_instance_id}/vnfs/{vnf_instance_id}".format,
+ endpoint=self.config.so.SO_ENDPOINT,
+ service_path=self.config.so.SO_SERVICE_INSTANCE_PATH,
+ ),
+ "uri-parameters": ["service_instance_id", "vnf_instance_id"],
+ "payload": "{}/so_delete_vnf.jinja".format(PAYLOADS_DIR),
+ "payload-parameters": [
+ "vnf_invariant_id",
+ "vnf_name",
+ "vnf_version",
+ "cloud_region",
+ "cloud_owner",
+ "tenant_id",
+ "api_type",
+ ],
+ "header-parameters": ["X-TransactionId"],
+ "success_code": 202,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ # "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD),
+ },
+ "CREATE_MODULE_INSTANCE": {
+ "verb": "POST",
+ "description": "Creates a VNF Module Instance.",
+ "uri": partial(
+ "{endpoint}{service_path}/{service_instance_id}/vnfs/{vnf_instance_id}/vfModules".format,
+ endpoint=self.config.so.SO_ENDPOINT,
+ service_path=self.config.so.SO_SERVICE_INSTANCE_PATH,
+ ),
+ "uri-parameters": ["service_instance_id", "vnf_instance_id"],
+ "payload": "{}/so_create_module.jinja".format(PAYLOADS_DIR),
+ "payload-parameters": [
+ "module_instance_name",
+ "model_invariant_id",
+ "model_version_id",
+ "model_name",
+ "model_version",
+ "model_customization_id",
+ "model_name",
+ "api_type",
+ "tenant_id",
+ "cloud_owner",
+ "cloud_region",
+ "service_instance_id",
+ "service_model_name",
+ "service_model_invariant_id",
+ "service_model_version",
+ "service_model_version_id",
+ "vnf_instance_id",
+ "vnf_model_name",
+ "vnf_model_invariant_id",
+ "vnf_model_version",
+ "vnf_model_version_id",
+ "vnf_model_customization_id",
+ ],
+ "header-parameters": ["X-TransactionId"],
+ "success_code": 202,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ # "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD),
+ },
+ "DELETE_MODULE_INSTANCE": {
+ "verb": "DELETE",
+ "description": "Deletes a VNF Module Instance.",
+ "uri": partial(
+ "{endpoint}{service_path}/{service_instance_id}/vnfs/{vnf_instance_id}/vfModules/{vf_module_id}".format,
+ endpoint=self.config.so.SO_ENDPOINT,
+ service_path=self.config.so.SO_SERVICE_INSTANCE_PATH,
+ ),
+ "uri-parameters": ["service_instance_id", "vnf_instance_id", "vf_module_id"],
+ "payload": "{}/so_delete_module.jinja".format(PAYLOADS_DIR),
+ "payload-parameters": [
+ "module_invariant_id",
+ "module_name",
+ "module_version",
+ "cloud_region",
+ "cloud_owner",
+ "tenant_id",
+ "api_type",
+ ],
+ "header-parameters": ["X-TransactionId"],
+ "success_code": 202,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ # "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD),
+ },
+ "GET_REQUEST_STATUS": {
+ "verb": "GET",
+ "description": "Queries the status for a given request ID",
+ "uri": partial(
+ "{endpoint}{service_path}/{request_id}".format,
+ endpoint=self.config.so.SO_ENDPOINT,
+ service_path=self.config.so.SO_ORCHESTRATION_PATH,
+ ),
+ "uri-parameters": ["request_id"],
+ "success_code": 200,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD),
+ },
+ "GET_SERVICE_MODEL": {
+ "verb": "GET",
+ "description": "Searches the SO catalog for a service model",
+ "uri": partial(
+ "{endpoint}/service/search/findOneByModelName?modelName={model_name}".format,
+ endpoint=self.config.so.SO_ENDPOINT,
+ ),
+ "uri-parameters": ["model_name"],
+ "success_code": 200,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD),
+ },
+ "GET_SERVICE_MODEL_DETAILS": {
+ "verb": "GET",
+ "description": "Searches the SO catalog for a service model",
+ "uri": partial(
+ "{endpoint}/service/search/findOneByModelName?modelName={model_name}".format,
+ endpoint=self.config.so.SO_ENDPOINT,
+ ),
+ "uri-parameters": ["model_name"],
+ "success_code": 200,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD),
+ },
+ }
diff --git a/onap-client/onap_client/so/client.py b/onap-client/onap_client/so/client.py
index c38cf0c..7e79fe1 100644
--- a/onap-client/onap_client/so/client.py
+++ b/onap-client/onap_client/so/client.py
@@ -36,11 +36,9 @@
# ============LICENSE_END============================================
from functools import partial
-from onap_client import so
from onap_client.client.clients import Client
from onap_client import config
-so_properties = so.SO_PROPERTIES
application_id = config.APPLICATION_ID
@@ -51,19 +49,16 @@ class SOClient(Client):
@property
def catalog_resources(self):
- return CATALOG_RESOURCES
-
-
-CATALOG_RESOURCES = {
- "HEALTH_CHECK": {
- "verb": "GET",
- "description": "Queries so health check endpoint",
- "uri": partial(
- "{endpoint}{service_path}".format,
- endpoint=so_properties.SO_ENDPOINT,
- service_path=so_properties.SO_HEALTH_CHECK_PATH,
- ),
- "success_code": 200,
- "auth": (so_properties.SO_USERNAME, so_properties.SO_PASSWORD),
- },
-}
+ return {
+ "HEALTH_CHECK": {
+ "verb": "GET",
+ "description": "Queries so health check endpoint",
+ "uri": partial(
+ "{endpoint}{service_path}".format,
+ endpoint=self.config.so.SO_ENDPOINT,
+ service_path=self.config.so.SO_HEALTH_CHECK_PATH,
+ ),
+ "success_code": 200,
+ "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD),
+ },
+ }
diff --git a/onap-client/onap_client/so/module_instance.py b/onap-client/onap_client/so/module_instance.py
index 51c9bc2..67da272 100644
--- a/onap-client/onap_client/so/module_instance.py
+++ b/onap-client/onap_client/so/module_instance.py
@@ -37,7 +37,7 @@
import uuid
from onap_client.resource import Resource
-from onap_client.client.clients import Client
+from onap_client.client.clients import get_client as Client
from onap_client.exceptions import ServiceInstanceNotFound, VNFInstanceNotFound, ModuleInstanceNotFound
from onap_client import so
from onap_client import sdnc
diff --git a/onap-client/onap_client/so/service_instance.py b/onap-client/onap_client/so/service_instance.py
index 10271fa..3675a4e 100644
--- a/onap-client/onap_client/so/service_instance.py
+++ b/onap-client/onap_client/so/service_instance.py
@@ -39,8 +39,7 @@ import uuid
from onap_client.lib import generate_dummy_string
from onap_client.resource import Resource
-from onap_client.client.clients import Client
-from onap_client.so import SO_PROPERTIES
+from onap_client.client.clients import get_client as Client
from onap_client.exceptions import (
SORequestStatusUnavailable,
SORequestFailed,
@@ -152,7 +151,7 @@ def poll_request(request_id):
"""Poll an SO request until completion"""
oc = Client()
- poll_interval = SO_PROPERTIES.POLL_INTERVAL or 30
+ poll_interval = oc.config.so.POLL_INTERVAL or 30
request = None
x = 0
while x < 30:
diff --git a/onap-client/onap_client/so/vnf_instance.py b/onap-client/onap_client/so/vnf_instance.py
index abb26c3..0dbd87f 100644
--- a/onap-client/onap_client/so/vnf_instance.py
+++ b/onap-client/onap_client/so/vnf_instance.py
@@ -39,7 +39,7 @@ import uuid
from onap_client.lib import generate_dummy_string
from onap_client.resource import Resource
-from onap_client.client.clients import Client as SOClient
+from onap_client.client.clients import get_client as Client
from onap_client.exceptions import (
ServiceInstanceNotFound,
VNFComponentNotFound,
@@ -52,12 +52,6 @@ from onap_client import so
from onap_client.util import utility
-oc = SOClient()
-so_client = oc.so
-sdc_client = oc.sdc
-sdnc_client = oc.sdnc
-
-
class VNFInstance(Resource):
resource_name = "VNF_INSTANCE"
spec = {
@@ -116,7 +110,7 @@ class VNFInstance(Resource):
vnf_model_version_id = vnf_component["actualComponentUid"]
vnf_model_version = vnf_component["componentVersion"]
- vnf_model = sdc_client.vnf.get_catalog_resource(
+ vnf_model = self.oc.sdc.vnf.get_catalog_resource(
catalog_resource_id=vnf_model_version_id,
).response_data
vnf_model_invariant_id = vnf_model["invariantUUID"]
@@ -135,7 +129,8 @@ class VNFInstance(Resource):
def get_vnf_model_component(service_model_name, vnf_model_name):
- service_model = sdc_client.service.get_sdc_service(
+ oc = Client()
+ service_model = oc.sdc.service.get_sdc_service(
catalog_service_id=sdc.service.get_service_id(service_model_name)
).response_data
@@ -146,7 +141,8 @@ def get_vnf_model_component(service_model_name, vnf_model_name):
def get_service_instance(service_instance_name):
- service_instances = sdnc_client.config.get_service_instances().response_data
+ oc = Client()
+ service_instances = oc.sdnc.config.get_service_instances().response_data
for si in service_instances.get("services", {}).get("service", []):
si_name = (
si.get("service-data", {})
@@ -196,8 +192,10 @@ def get_vnf_instance(service_instance, vnf_instance_name):
def create_vnf_instance(instance_input):
+ oc = Client()
+
headers = {"X-TransactionId": str(uuid.uuid4())}
- vnf_instance = so_client.service_instantiation.create_vnf_instance(
+ vnf_instance = oc.so.service_instantiation.create_vnf_instance(
**instance_input, **headers
)
@@ -213,6 +211,7 @@ def create_vnf_instance(instance_input):
@utility
def delete_vnf_instance(service_instance_name, vnf_instance_name, api_type="GR_API"):
"""Delete a VNF Instance from SO"""
+ oc = Client()
si = so.service_instance.get_service_instance(service_instance_name)
si_id = si.get("service-instance-id")
for vnfi in si.get("service-data", {}).get("vnfs", {}).get("vnf", []):
@@ -223,7 +222,7 @@ def delete_vnf_instance(service_instance_name, vnf_instance_name, api_type="GR_A
tenant_id = vnfi.get("vnf-data").get("vnf-request-input").get("tenant")
cloud_owner = vnfi.get("vnf-data").get("vnf-request-input").get("cloud-owner")
cloud_region = vnfi.get("vnf-data").get("vnf-request-input").get("aic-cloud-region")
- return so_client.service_instantiation.delete_vnf_instance(
+ return oc.so.service_instantiation.delete_vnf_instance(
vnf_invariant_id=invariant_id,
vnf_version=vnf_version,
vnf_name=vnf_instance_name,