aboutsummaryrefslogtreecommitdiffstats
path: root/onap-client/onap_client
diff options
context:
space:
mode:
authorstark, steven <steven.stark@att.com>2020-05-19 09:52:46 -0700
committerstark, steven <steven.stark@att.com>2020-05-19 09:59:16 -0700
commitd481ad9918d383c82335e52db4a360964194ef5d (patch)
treef3174fa5bc95e340b908e3c854edf1af2e8119c9 /onap-client/onap_client
parente4fca937cc6104ff56c52f720d26552febe44bee (diff)
[VVP] Updates to VVP test-engine
Removing module level variables. These can cause import errors if certain modules are not imported "properly". Removing these lets developers import modules as-needed. Add support for VNF category. The VNF category is looked up based on the category chosen by the VSP. Increase test coverage. Update ovp testsuite based on these changes. Issue-ID: VVP-418 Signed-off-by: stark, steven <steven.stark@att.com> Change-Id: I074375b8afae1adff60e0730d6f8a69d01cdd475
Diffstat (limited to 'onap-client/onap_client')
-rw-r--r--onap-client/onap_client/sdc/catalog/vnf_catalog.py2
-rw-r--r--onap-client/onap_client/sdc/catalog/vsp_catalog.py23
-rw-r--r--onap-client/onap_client/sdc/client.py19
-rw-r--r--onap-client/onap_client/sdc/license_model.py35
-rw-r--r--onap-client/onap_client/sdc/service.py58
-rw-r--r--onap-client/onap_client/sdc/tests/test_license_model.py20
-rw-r--r--onap-client/onap_client/sdc/tests/test_service.py132
-rw-r--r--onap-client/onap_client/sdc/tests/test_vnf.py58
-rw-r--r--onap-client/onap_client/sdc/tests/test_vsp.py22
-rw-r--r--onap-client/onap_client/sdc/vnf.py78
-rw-r--r--onap-client/onap_client/sdc/vsp.py55
-rw-r--r--onap-client/onap_client/sdnc/preload.py11
-rw-r--r--onap-client/onap_client/so/module_instance.py15
-rw-r--r--onap-client/onap_client/so/service_instance.py36
-rw-r--r--onap-client/onap_client/so/tests/base_preload.json37
-rw-r--r--onap-client/onap_client/so/tests/test_module_instance.py227
-rw-r--r--onap-client/onap_client/so/tests/test_service_instance.py136
-rw-r--r--onap-client/onap_client/so/tests/test_vnf_instance.py174
-rw-r--r--onap-client/onap_client/tests/test-spec.json21
-rw-r--r--onap-client/onap_client/tests/test_engine.py49
-rw-r--r--onap-client/onap_client/tests/testdata.py38
21 files changed, 1098 insertions, 148 deletions
diff --git a/onap-client/onap_client/sdc/catalog/vnf_catalog.py b/onap-client/onap_client/sdc/catalog/vnf_catalog.py
index cd08dad..6cf2207 100644
--- a/onap-client/onap_client/sdc/catalog/vnf_catalog.py
+++ b/onap-client/onap_client/sdc/catalog/vnf_catalog.py
@@ -72,6 +72,8 @@ CATALOG_RESOURCES = {
"vnf_name",
"vendor_name",
"resource_type",
+ "categories",
+ "contact_id",
],
"success_code": 201,
"headers": {
diff --git a/onap-client/onap_client/sdc/catalog/vsp_catalog.py b/onap-client/onap_client/sdc/catalog/vsp_catalog.py
index 574149e..7070032 100644
--- a/onap-client/onap_client/sdc/catalog/vsp_catalog.py
+++ b/onap-client/onap_client/sdc/catalog/vsp_catalog.py
@@ -237,6 +237,29 @@ CATALOG_RESOURCES = {
sdc_properties.GLOBAL_SDC_PASSWORD,
),
},
+ "GET_SOFTWARE_PRODUCT_INFORMATION": {
+ "verb": "GET",
+ "description": "Gets Information for a VSP from Catalog",
+ "uri": partial(
+ "{endpoint}{service_path}/{software_product_id}/versions/{software_product_version_id}/questionnaire".format,
+ endpoint=sdc_properties.SDC_BE_ONBOARD_ENDPOINT,
+ service_path=sdc_properties.SDC_VENDOR_SOFTWARE_PRODUCT_PATH,
+ ),
+ "uri-parameters": ["software_product_id", "software_product_version_id"],
+ "success_code": 200,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ "USER_ID": sdc_properties.SDC_DESIGNER_USER_ID,
+ "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "return_data": {"name": ("name",)},
+ "auth": (
+ sdc_properties.GLOBAL_SDC_USERNAME,
+ sdc_properties.GLOBAL_SDC_PASSWORD,
+ ),
+ },
"GET_SOFTWARE_PRODUCT_VERSIONS": {
"verb": "GET",
"description": "Returns a list of vsp versions",
diff --git a/onap-client/onap_client/sdc/client.py b/onap-client/onap_client/sdc/client.py
index 8863e07..c1923da 100644
--- a/onap-client/onap_client/sdc/client.py
+++ b/onap-client/onap_client/sdc/client.py
@@ -78,4 +78,23 @@ CATALOG_RESOURCES = {
sdc_properties.SDC_DESIGNER_PASSWORD,
),
},
+ "GET_RESOURCE_CATEGORIES": {
+ "verb": "GET",
+ "description": "Queries SDC for resource categories",
+ "uri": partial(
+ "{endpoint}{service_path}".format,
+ endpoint=sdc_properties.SDC_BE_ENDPOINT,
+ service_path=sdc_properties.SDC_RESOURCE_CATEGORIES_PATH,
+ ),
+ "success_code": 200,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ "USER_ID": sdc_properties.SDC_DESIGNER_USER_ID,
+ },
+ "auth": (
+ sdc_properties.GLOBAL_SDC_USERNAME,
+ sdc_properties.GLOBAL_SDC_PASSWORD,
+ ),
+ },
}
diff --git a/onap-client/onap_client/sdc/license_model.py b/onap-client/onap_client/sdc/license_model.py
index e5ae740..591509e 100644
--- a/onap-client/onap_client/sdc/license_model.py
+++ b/onap-client/onap_client/sdc/license_model.py
@@ -37,9 +37,7 @@
from onap_client.lib import generate_dummy_string, generate_dummy_date
from onap_client.resource import Resource
-from onap_client.client.clients import Client as SDCClient
-
-license_model_client = SDCClient().sdc.license_model
+from onap_client.client.clients import Client
class LicenseModel(Resource):
@@ -98,6 +96,7 @@ class LicenseModel(Resource):
license_start_date,
license_end_date,
):
+ self.oc = Client()
license_input = {}
license_input["vendor_name"] = vendor_name
@@ -121,9 +120,9 @@ class LicenseModel(Resource):
def _submit(self):
"""Submits the license model in SDC"""
- license_model_client.submit_license_model(**self.attributes, action="Submit")
+ self.oc.sdc.license_model.submit_license_model(**self.attributes, action="Submit")
- license_model = license_model_client.get_license_model(**self.attributes)
+ license_model = self.oc.sdc.license_model.get_license_model(**self.attributes)
self.attributes["tosca"] = license_model.response_data
@@ -136,30 +135,32 @@ def create_license_model(license_input):
:return: dictionary of updated values for created lm
"""
+ oc = Client()
+
kwargs = license_input
- license_model = license_model_client.add_license_model(**kwargs)
+ license_model = oc.sdc.license_model.add_license_model(**kwargs)
kwargs["license_model_id"] = license_model.license_model_id
kwargs["license_model_version_id"] = license_model.license_model_version_id
- key_group = license_model_client.add_key_group(**kwargs)
+ key_group = oc.sdc.license_model.add_key_group(**kwargs)
key_group_id = key_group.key_group_id
- entitlement_pool = license_model_client.add_entitlement_pool(**kwargs)
+ entitlement_pool = oc.sdc.license_model.add_entitlement_pool(**kwargs)
entitlement_pool_id = entitlement_pool.entitlement_pool_id
kwargs["entitlement_pool_id"] = entitlement_pool_id
kwargs["key_group_id"] = key_group_id
- feature_group = license_model_client.add_feature_group(**kwargs)
+ feature_group = oc.sdc.license_model.add_feature_group(**kwargs)
feature_group_id = feature_group.feature_group_id
kwargs["feature_group_id"] = feature_group_id
- license_agreement = license_model_client.add_license_agreement(**kwargs)
+ license_agreement = oc.sdc.license_model.add_license_agreement(**kwargs)
kwargs["license_agreement_id"] = license_agreement.license_agreement_id
- license_model = license_model_client.get_license_model(**kwargs)
+ license_model = oc.sdc.license_model.get_license_model(**kwargs)
kwargs["tosca"] = license_model.response_data
return kwargs
@@ -172,7 +173,9 @@ def get_license_model_id(license_model_name):
:return: uuid of lm or None
"""
- response = license_model_client.get_license_models()
+ oc = Client()
+
+ response = oc.sdc.license_model.get_license_models()
results = response.response_data.get("results")
for license_model in results:
if license_model.get("name") == license_model_name:
@@ -187,9 +190,11 @@ def get_license_model_version_id(license_model_id):
:return: uuid of lm version id or None
"""
+ oc = Client()
+
license_model_version_id = None
creation_time = -1
- response = license_model_client.get_license_model_versions(
+ response = oc.sdc.license_model.get_license_model_versions(
license_model_id=license_model_id
)
results = response.response_data.get("results")
@@ -210,7 +215,9 @@ def get_license_model_attribute(license_model_id, license_model_version_id, attr
:return: uuid of attribute of license-model
"""
- response = license_model_client.get_license_model_version_attribute(
+ oc = Client()
+
+ response = oc.sdc.license_model.get_license_model_version_attribute(
license_model_id=license_model_id,
license_model_version_id=license_model_version_id,
attribute=attribute,
diff --git a/onap-client/onap_client/sdc/service.py b/onap-client/onap_client/sdc/service.py
index 55c8f5c..5da6bb5 100644
--- a/onap-client/onap_client/sdc/service.py
+++ b/onap-client/onap_client/sdc/service.py
@@ -38,9 +38,8 @@
from onap_client.lib import generate_dummy_string
from onap_client.resource import Resource
from onap_client import exceptions
-from onap_client.client.clients import Client as SDCClient
+from onap_client.client.clients import Client
from onap_client.sdc.vnf import get_vnf_id
-from onap_client import sdc
from onap_client.sdc import SDC_PROPERTIES
from onap_client.util import utility
@@ -49,9 +48,6 @@ import json
import random
import uuid
-service_client = SDCClient().sdc.service
-sdc_properties = sdc.SDC_PROPERTIES
-
def normalize_category_icon(category_name):
if category_name == "Network L1-3":
@@ -138,6 +134,8 @@ class Service(Resource):
wait_for_distribution=False,
allow_update=False,
):
+ self.oc = Client()
+
service_input = {}
category_name_lower = category_name.lower()
@@ -208,15 +206,15 @@ class Service(Resource):
def _submit(self):
"""Submits the service in SDC and distributes the model"""
- DISTRIBUTION_STEPS = sdc_properties.SERVICE_DISTRIBUTION or []
+ DISTRIBUTION_STEPS = SDC_PROPERTIES.SERVICE_DISTRIBUTION or []
- service_client.checkin_service(**self.attributes, user_remarks="checking in")
+ self.oc.sdc.service.checkin_service(**self.attributes, user_remarks="checking in")
if (
not DISTRIBUTION_STEPS
or "request_service_certification" in DISTRIBUTION_STEPS
):
- service_client.request_service_certification(
+ self.oc.sdc.service.request_service_certification(
**self.attributes, user_remarks="requesting certification"
)
@@ -224,7 +222,7 @@ class Service(Resource):
not DISTRIBUTION_STEPS
or "start_service_certification" in DISTRIBUTION_STEPS
):
- service_client.start_service_certification(
+ self.oc.sdc.service.start_service_certification(
**self.attributes, user_remarks="certifying"
)
@@ -232,7 +230,7 @@ class Service(Resource):
not DISTRIBUTION_STEPS
or "finish_service_certification" in DISTRIBUTION_STEPS
):
- catalog_service = service_client.finish_service_certification(
+ catalog_service = self.oc.sdc.service.finish_service_certification(
**self.attributes, user_remarks="certified"
)
self.attributes["catalog_service_id"] = catalog_service.catalog_service_id
@@ -241,11 +239,11 @@ class Service(Resource):
not DISTRIBUTION_STEPS
or "approve_service_certification" in DISTRIBUTION_STEPS
):
- service_client.approve_service_certification(
+ self.oc.sdc.service.approve_service_certification(
**self.attributes, user_remarks="approved"
)
headers = {"X-TransactionId": str(uuid.uuid4())}
- service_client.distribute_sdc_service(**self.attributes, **headers)
+ self.oc.sdc.service.distribute_sdc_service(**self.attributes, **headers)
if self.wait_for_distribution:
poll_distribution(self.service_name)
@@ -267,13 +265,13 @@ class Service(Resource):
if component_instances:
for component in component_instances:
if component.get("componentName") == catalog_resource_name:
- service_client.delete_resource_from_service(
+ self.oc.sdc.service.delete_resource_from_service(
catalog_service_id=self.catalog_service_id,
resource_instance_id=component.get("uniqueId")
)
break
- resource_instance = service_client.add_resource_instance(
+ resource_instance = self.oc.sdc.service.add_resource_instance(
**self.attributes,
posX=random.randrange(150, 550), # nosec
posY=random.randrange(150, 450), # nosec
@@ -318,7 +316,7 @@ class Service(Resource):
owner_id = prop.get("ownerId")
schemaType = prop.get("schemaType", "")
property_type = prop.get("type")
- return service_client.add_catalog_service_property(
+ return self.oc.sdc.service.add_catalog_service_property(
**self.attributes,
unique_id=unique_id,
parent_unique_id=parent_unique_id,
@@ -337,27 +335,29 @@ class Service(Resource):
)
def _refresh(self):
- self.tosca = service_client.get_sdc_service(
+ self.tosca = self.oc.sdc.service.get_sdc_service(
catalog_service_id=self.catalog_service_id
).response_data
def update_service(existing_service_id, service_input):
+ oc = Client()
+
kwargs = service_input
- existing_service = service_client.get_sdc_service(
+ existing_service = oc.sdc.service.get_sdc_service(
catalog_service_id=existing_service_id
).response_data
if existing_service.get("lifecycleState") != "NOT_CERTIFIED_CHECKOUT":
- service = service_client.checkout_catalog_service(catalog_service_id=existing_service_id).response_data
+ service = oc.sdc.service.checkout_catalog_service(catalog_service_id=existing_service_id).response_data
else:
service = existing_service
new_service_id = service.get("uniqueId")
kwargs["catalog_service_id"] = new_service_id
- kwargs["tosca"] = service_client.get_sdc_service(catalog_service_id=new_service_id).response_data
+ kwargs["tosca"] = oc.sdc.service.get_sdc_service(catalog_service_id=new_service_id).response_data
return kwargs
@@ -369,9 +369,11 @@ def create_service(service_input):
:return: dictionary of updated values for created service
"""
+ oc = Client()
+
kwargs = service_input
- service = service_client.add_catalog_service(**kwargs)
+ service = oc.sdc.service.add_catalog_service(**kwargs)
kwargs["catalog_service_id"] = service.catalog_service_id
kwargs["tosca"] = service.response_data
@@ -382,7 +384,9 @@ def create_service(service_input):
@utility
def get_service(service_name):
"""Queries SDC for the TOSCA model for a service"""
- return service_client.get_sdc_service(
+ oc = Client()
+
+ return oc.sdc.service.get_sdc_service(
catalog_service_id=get_service_id(service_name)
).response_data
@@ -390,7 +394,9 @@ def get_service(service_name):
@utility
def get_service_id(service_name):
"""Queries SDC for the uniqueId of a service model"""
- response = service_client.get_services()
+ oc = Client()
+
+ response = oc.sdc.service.get_services()
results = response.response_data.get("services", [])
update_time = -1
catalog_service = {}
@@ -407,10 +413,12 @@ def get_service_uuid(service_name):
def get_service_distribution(service_name):
+ oc = Client()
+
distribution_id = get_distribution_id(service_name)
if distribution_id:
- return service_client.get_service_distribution_details(
+ return oc.sdc.service.get_service_distribution_details(
distribution_id=distribution_id
).response_data
@@ -418,7 +426,9 @@ def get_service_distribution(service_name):
def get_distribution_id(service_name):
- distribution = service_client.get_service_distribution(
+ oc = Client()
+
+ distribution = oc.sdc.service.get_service_distribution(
distribution_service_id=get_service_uuid(service_name)
).response_data
if distribution:
diff --git a/onap-client/onap_client/sdc/tests/test_license_model.py b/onap-client/onap_client/sdc/tests/test_license_model.py
index 459c2e0..8da7d07 100644
--- a/onap-client/onap_client/sdc/tests/test_license_model.py
+++ b/onap-client/onap_client/sdc/tests/test_license_model.py
@@ -38,13 +38,13 @@
import responses
from onap_client.client.clients import Client
from onap_client.sdc.license_model import LicenseModel
-from onap_client.tests.utils import mockup_client, mockup_catalog_item
-
-license_model_client = Client().sdc.license_model
+from onap_client.tests.utils import mockup_catalog_item
@responses.activate
def test_license_model_create():
+ oc = Client()
+
LICENSE_MODEL_ID = "license_model_id"
LICENSE_MODEL_VERSION_ID = "license_model_version_id"
FEATURE_GROUP_ID = "feature_group_id"
@@ -56,7 +56,7 @@ def test_license_model_create():
DESCRIPTION = "description"
mockup_catalog_item(
- license_model_client.catalog_items["ADD_LICENSE_MODEL"],
+ oc.sdc.license_model.catalog_items["ADD_LICENSE_MODEL"],
override_return_data={
"itemId": LICENSE_MODEL_ID,
"version": {"id": LICENSE_MODEL_VERSION_ID},
@@ -64,7 +64,7 @@ def test_license_model_create():
)
mockup_catalog_item(
- license_model_client.catalog_items["ADD_KEY_GROUP"],
+ oc.sdc.license_model.catalog_items["ADD_KEY_GROUP"],
override_return_data={"value": KEYGROUP_ID},
override_uri_params={
"license_model_id": LICENSE_MODEL_ID,
@@ -73,7 +73,7 @@ def test_license_model_create():
)
mockup_catalog_item(
- license_model_client.catalog_items["ADD_ENTITLEMENT_POOL"],
+ oc.sdc.license_model.catalog_items["ADD_ENTITLEMENT_POOL"],
override_return_data={"value": ENTITLEMENT_POOL_ID},
override_uri_params={
"license_model_id": LICENSE_MODEL_ID,
@@ -82,7 +82,7 @@ def test_license_model_create():
)
mockup_catalog_item(
- license_model_client.catalog_items["ADD_FEATURE_GROUP"],
+ oc.sdc.license_model.catalog_items["ADD_FEATURE_GROUP"],
override_return_data={"value": FEATURE_GROUP_ID},
override_uri_params={
"license_model_id": LICENSE_MODEL_ID,
@@ -91,7 +91,7 @@ def test_license_model_create():
)
mockup_catalog_item(
- license_model_client.catalog_items["ADD_LICENSE_AGREEMENT"],
+ oc.sdc.license_model.catalog_items["ADD_LICENSE_AGREEMENT"],
override_return_data={"value": LICENSE_AGREEMENT_ID},
override_uri_params={
"license_model_id": LICENSE_MODEL_ID,
@@ -101,7 +101,7 @@ def test_license_model_create():
return_data = {"vendorName": VENDOR_NAME, "id": ID, "description": DESCRIPTION}
mockup_catalog_item(
- license_model_client.catalog_items["GET_LICENSE_MODEL"],
+ oc.sdc.license_model.catalog_items["GET_LICENSE_MODEL"],
override_return_data=return_data,
override_uri_params={
"license_model_id": LICENSE_MODEL_ID,
@@ -109,8 +109,6 @@ def test_license_model_create():
},
)
- mockup_client(license_model_client)
-
lm = LicenseModel(
VENDOR_NAME,
"abc123",
diff --git a/onap-client/onap_client/sdc/tests/test_service.py b/onap-client/onap_client/sdc/tests/test_service.py
new file mode 100644
index 0000000..e4789a5
--- /dev/null
+++ b/onap-client/onap_client/sdc/tests/test_service.py
@@ -0,0 +1,132 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2020 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+
+import responses
+
+from onap_client.tests.utils import mockup_catalog_item
+from onap_client.client.clients import Client
+from onap_client.sdc.service import Service
+
+
+@responses.activate
+def test_vnf_create():
+ oc = Client()
+
+ VNF_NAME = "vnf_name"
+ SERVICE_MODEL_ID = "service_model_id"
+ VNF_RESOURCE_ID = "vnf_resource_id"
+ SERVICE_NAME = "service_name"
+
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["GET_SERVICES"],
+ override_return_data={
+ "services": []
+ },
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["ADD_CATALOG_SERVICE"],
+ override_return_data={
+ "uniqueId": SERVICE_MODEL_ID
+ },
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["ADD_RESOURCE_INSTANCE"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ override_return_data={
+ "uniqueId": VNF_RESOURCE_ID
+ },
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["CHECKIN_SERVICE"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["REQUEST_SERVICE_CERTIFICATION"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["START_SERVICE_CERTIFICATION"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["FINISH_SERVICE_CERTIFICATION"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ override_return_data={"uniqueId": SERVICE_MODEL_ID}
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["APPROVE_SERVICE_CERTIFICATION"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["DISTRIBUTE_SDC_SERVICE"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["GET_SDC_SERVICE"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ override_return_data={
+ "uniqueId": SERVICE_MODEL_ID,
+ }
+ )
+
+ service = Service(
+ "A-la-carte",
+ SERVICE_NAME,
+ "cs0008",
+ "Network L1-3",
+ "robot",
+ "123456",
+ "General_Revenue-Bearing",
+ "true",
+ "This is a test",
+ "",
+ "",
+ "",
+ resources=[{
+ "resource_name": VNF_NAME,
+ "resource_id": VNF_RESOURCE_ID,
+ "catalog_resource_name": VNF_NAME,
+ "origin_type": "VF",
+ "properties": {}
+ }],
+ allow_update=False,
+ wait_for_distribution=False
+ )
+
+ service._submit()
+
+ assert service.service_name == SERVICE_NAME
diff --git a/onap-client/onap_client/sdc/tests/test_vnf.py b/onap-client/onap_client/sdc/tests/test_vnf.py
index 025a2d8..f72043e 100644
--- a/onap-client/onap_client/sdc/tests/test_vnf.py
+++ b/onap-client/onap_client/sdc/tests/test_vnf.py
@@ -36,7 +36,8 @@
# ============LICENSE_END============================================
import responses
-from onap_client.tests.utils import mockup_client, mockup_catalog_item
+
+from onap_client.tests.utils import mockup_catalog_item
from onap_client.client.clients import Client
from onap_client.sdc.vnf import VNF
from onap_client.sdc.vnf import (
@@ -44,12 +45,11 @@ from onap_client.sdc.vnf import (
network_role_property_for_instance,
)
-vnf_client = Client().sdc.vnf
-vsp_client = Client().sdc.vsp
-
@responses.activate
def test_vnf_create():
+ oc = Client()
+
SOFTWARE_PRODUCT_NAME = "software_product_name"
SOFTWARE_PRODUCT_ID = "software_product_id"
SOFTWARE_PRODUCT_VERSION_ID = "software_product_version_id"
@@ -68,13 +68,13 @@ def test_vnf_create():
"name": VNF_NAME,
}
mockup_catalog_item(
- vsp_client.catalog_items["GET_SOFTWARE_PRODUCTS"],
+ oc.sdc.vsp.catalog_items["GET_SOFTWARE_PRODUCTS"],
override_return_data={
"results": [{"name": SOFTWARE_PRODUCT_NAME, "id": SOFTWARE_PRODUCT_ID}]
},
)
mockup_catalog_item(
- vsp_client.catalog_items["GET_SOFTWARE_PRODUCT_VERSIONS"],
+ oc.sdc.vsp.catalog_items["GET_SOFTWARE_PRODUCT_VERSIONS"],
override_return_data={
"results": [
{"name": SOFTWARE_PRODUCT_NAME, "id": SOFTWARE_PRODUCT_VERSION_ID}
@@ -83,40 +83,66 @@ def test_vnf_create():
override_uri_params={"software_product_id": SOFTWARE_PRODUCT_ID},
)
mockup_catalog_item(
- vsp_client.catalog_items["GET_SOFTWARE_PRODUCT"],
- override_return_data={"vendorName": "vendor_name"},
+ oc.sdc.vsp.catalog_items["GET_SOFTWARE_PRODUCT"],
+ override_return_data={
+ "vendorName": "vendor_name",
+ "category": "resourceNewCategory.application l4+",
+ "subCategory": "resourceNewCategory.application l4+.web server",
+ },
override_uri_params={
"software_product_id": SOFTWARE_PRODUCT_ID,
"software_product_version_id": SOFTWARE_PRODUCT_VERSION_ID,
},
)
mockup_catalog_item(
- vnf_client.catalog_items["GET_RESOURCES"],
+ oc.sdc.vnf.catalog_items["GET_RESOURCES"],
override_return_data={"resources": []},
)
mockup_catalog_item(
- vnf_client.catalog_items["ADD_CATALOG_RESOURCE"],
+ oc.sdc.vnf.catalog_items["ADD_CATALOG_RESOURCE"],
override_return_data=return_data,
)
mockup_catalog_item(
- vnf_client.catalog_items["GET_CATALOG_RESOURCE"],
+ oc.sdc.vnf.catalog_items["GET_CATALOG_RESOURCE"],
override_return_data=return_data,
override_uri_params={"catalog_resource_id": CATALOG_RESOURCE_ID},
)
mockup_catalog_item(
- vnf_client.catalog_items["CERTIFY_CATALOG_RESOURCE"],
+ oc.sdc.vnf.catalog_items["CERTIFY_CATALOG_RESOURCE"],
override_return_data=return_data,
override_uri_params={"catalog_resource_id": CATALOG_RESOURCE_ID},
)
mockup_catalog_item(
- vnf_client.catalog_items["ADD_CATALOG_RESOURCE_PROPERTY"],
+ oc.sdc.vnf.catalog_items["ADD_CATALOG_RESOURCE_PROPERTY"],
override_uri_params={
"catalog_resource_id": CATALOG_RESOURCE_ID,
"catalog_resource_instance_id": "instance_id1",
},
)
-
- mockup_client(vnf_client)
+ mockup_catalog_item(
+ oc.sdc.catalog_items["GET_RESOURCE_CATEGORIES"],
+ override_return_data=[
+ {
+ "name": "Application L4+",
+ "normalizedName": "application l4+",
+ "uniqueId": "resourceNewCategory.application l4+",
+ "icons": False,
+ "subcategories": [
+ {
+ "name": "Call Control",
+ "normalizedName": "call control",
+ "uniqueId": "resourceNewCategory.application l4+.call control",
+ "icons": ["call_controll"],
+ "groupings": False,
+ "version": False,
+ "ownerId": False,
+ "empty": False,
+ "type": False
+ }
+ ]
+ }
+ ],
+ )
vnf = VNF(
SOFTWARE_PRODUCT_NAME,
@@ -127,7 +153,7 @@ def test_vnf_create():
vnf._submit()
- assert "catalog_resource_name" in vnf.tosca
+ assert "componentInstancesInputs" in vnf.tosca
def test_instance_ids_for_property():
diff --git a/onap-client/onap_client/sdc/tests/test_vsp.py b/onap-client/onap_client/sdc/tests/test_vsp.py
index 4d71a81..f14e16e 100644
--- a/onap-client/onap_client/sdc/tests/test_vsp.py
+++ b/onap-client/onap_client/sdc/tests/test_vsp.py
@@ -43,12 +43,11 @@ from os.path import dirname, abspath
THIS_DIR = dirname(abspath(__file__))
-license_model_client = Client().sdc.license_model
-vsp_client = Client().sdc.vsp
-
@responses.activate
def test_vsp_create():
+ oc = Client()
+
LICENSE_MODEL_ID = "license_model_id"
LICENSE_MODEL_VERSION_ID = "license_model_version_id"
FEATURE_GROUP_ID = "feature_group_id"
@@ -59,49 +58,48 @@ def test_vsp_create():
VSP_NAME = "software_product_name"
mockup_catalog_item(
- license_model_client.catalog_items["GET_LICENSE_MODELS"],
+ oc.sdc.license_model.catalog_items["GET_LICENSE_MODELS"],
override_return_data={
"results": [{"name": LICENSE_MODEL_NAME, "id": LICENSE_MODEL_ID}]
},
)
mockup_catalog_item(
- license_model_client.catalog_items["GET_LICENSE_MODEL_VERSIONS"],
+ oc.sdc.license_model.catalog_items["GET_LICENSE_MODEL_VERSIONS"],
override_return_data={
"results": [{"name": LICENSE_MODEL_NAME, "id": LICENSE_MODEL_VERSION_ID}]
},
)
mockup_catalog_item(
- license_model_client.catalog_items["GET_LICENSE_MODEL_VERSION_ATTRIBUTE"],
+ oc.sdc.license_model.catalog_items["GET_LICENSE_MODEL_VERSION_ATTRIBUTE"],
override_return_data={
"results": [{"name": LICENSE_MODEL_NAME, "id": FEATURE_GROUP_ID}]
},
override_uri_params={"attribute": "feature-groups"},
)
mockup_catalog_item(
- license_model_client.catalog_items["GET_LICENSE_MODEL_VERSION_ATTRIBUTE"],
+ oc.sdc.license_model.catalog_items["GET_LICENSE_MODEL_VERSION_ATTRIBUTE"],
override_return_data={
"results": [{"name": LICENSE_MODEL_NAME, "id": LICENSE_AGREEMENT_ID}]
},
override_uri_params={"attribute": "license-agreements"},
)
- mockup_client(license_model_client)
mockup_catalog_item(
- vsp_client.catalog_items["GET_SOFTWARE_PRODUCTS"],
+ oc.sdc.vsp.catalog_items["GET_SOFTWARE_PRODUCTS"],
override_return_data={"results": []},
)
mockup_catalog_item(
- vsp_client.catalog_items["ADD_SOFTWARE_PRODUCT"],
+ oc.sdc.vsp.catalog_items["ADD_SOFTWARE_PRODUCT"],
override_return_data={
"itemId": VSP_MODEL_ID,
"version": {"id": VSP_MODEL_VERSION_ID},
},
)
mockup_catalog_item(
- vsp_client.catalog_items["GET_SOFTWARE_PRODUCT"],
+ oc.sdc.vsp.catalog_items["GET_SOFTWARE_PRODUCT"],
override_return_data={"name": VSP_NAME},
)
- mockup_client(vsp_client)
+ mockup_client(oc.sdc.vsp)
vsp = sdc.vsp.VSP(
"vendor_name",
diff --git a/onap-client/onap_client/sdc/vnf.py b/onap-client/onap_client/sdc/vnf.py
index 1d2989a..d772675 100644
--- a/onap-client/onap_client/sdc/vnf.py
+++ b/onap-client/onap_client/sdc/vnf.py
@@ -38,7 +38,7 @@
from onap_client.lib import generate_dummy_string
from onap_client.resource import Resource
from onap_client import exceptions, sdc
-from onap_client.client.clients import Client as SDCClient
+from onap_client.client.clients import Client
from onap_client.sdc import vsp
from onap_client.util import utility
@@ -46,8 +46,6 @@ import time
import random
import json
-vnf_client = SDCClient().sdc.vnf
-
class VNF(Resource):
resource_name = "VNF"
@@ -134,15 +132,21 @@ class VNF(Resource):
policies=[],
allow_update=False,
):
+ self.oc = Client()
vnf_input = {}
software_product_id = vsp.get_vsp_id(software_product_name)
software_product_version_id = vsp.get_vsp_version_id(software_product_id)
vsp_model = vsp.get_vsp_model(software_product_id, software_product_version_id)
+ print(vsp_model)
vsp_vendor = vsp_model.get("vendorName")
+ vsp_category = vsp_model.get("category")
+ vsp_sub_category = vsp_model.get("subCategory")
vnf_input["software_product_id"] = software_product_id
+ vnf_input["vsp_category"] = vsp_category
+ vnf_input["vsp_sub_category"] = vsp_sub_category
vnf_input["vendor_name"] = vsp_vendor
vnf_input["vnf_name"] = vnf_name
vnf_input["resource_type"] = resource_type
@@ -246,7 +250,7 @@ class VNF(Resource):
capability_name = capability.get("name")
capability_uid = capability.get("uniqueId")
- return vnf_client.add_resource_relationship(
+ return self.oc.sdc.vnf.add_resource_relationship(
**self.attributes,
from_node_resource_id=from_node,
to_node_resource_id=to_node,
@@ -317,12 +321,12 @@ class VNF(Resource):
def _submit(self):
"""Submits the vnf in SDC"""
- certification = vnf_client.certify_catalog_resource(
+ certification = self.oc.sdc.vnf.certify_catalog_resource(
**self.attributes, user_remarks="Ready!"
)
self.attributes["catalog_resource_id"] = certification.catalog_resource_id
- vnf = vnf_client.get_catalog_resource(**self.attributes)
+ vnf = self.oc.sdc.vnf.get_catalog_resource(**self.attributes)
self.attributes["catalog_resource_name"] = vnf.catalog_resource_name
self.attributes["tosca"] = vnf.response_data
@@ -342,7 +346,7 @@ class VNF(Resource):
unique_id = item["uniqueId"]
parent_unique_id = item["parentUniqueId"]
owner_id = item["ownerId"]
- return vnf_client.add_catalog_resource_input(
+ return self.oc.sdc.vnf.add_catalog_resource_input(
**self.attributes,
input_default_value=input_default_value,
input_name=input_name,
@@ -380,7 +384,7 @@ class VNF(Resource):
owner_id = prop.get("ownerId")
schemaType = prop.get("schemaType", "")
property_type = prop.get("type")
- return vnf_client.add_catalog_resource_property(
+ return self.oc.sdc.vnf.add_catalog_resource_property(
**self.attributes,
unique_id=unique_id,
parent_unique_id=parent_unique_id,
@@ -419,7 +423,7 @@ class VNF(Resource):
owner_id = prop.get("ownerId")
schemaType = prop.get("schemaType", "")
property_type = prop.get("type")
- return vnf_client.add_catalog_resource_property_non_vf(
+ return self.oc.sdc.vnf.add_catalog_resource_property_non_vf(
**self.attributes,
unique_id=unique_id,
parent_unique_id=parent_unique_id,
@@ -456,7 +460,7 @@ class VNF(Resource):
unique_id = prop.get("uniqueId")
property_type = prop.get("type")
description = prop.get("description")
- return vnf_client.add_catalog_policy_property(
+ return self.oc.sdc.vnf.add_catalog_policy_property(
**self.attributes,
unique_id=unique_id,
catalog_policy_id=policy_id,
@@ -483,7 +487,7 @@ class VNF(Resource):
"Policy {} was not found in configuration file".format(policy_name)
)
- return vnf_client.add_catalog_resource_policy(
+ return self.oc.sdc.vnf.add_catalog_resource_policy(
**self.attributes, catalog_policy_name=policy
)
@@ -495,34 +499,36 @@ class VNF(Resource):
"""
- return vnf_client.add_policy_to_instance(
+ return self.oc.sdc.vnf.add_policy_to_instance(
**self.attributes, catalog_policy_id=policy_id, instance_ids=instance_ids
)
def _refresh(self):
"""GETs the VNF model from SDC and updates the VNF object"""
- vnf = vnf_client.get_catalog_resource(**self.attributes)
+ vnf = self.oc.sdc.vnf.get_catalog_resource(**self.attributes)
self.attributes["tosca"] = vnf.response_data
def update_vnf(catalog_resource_id, vnf_input):
- existing_vnf = vnf_client.get_catalog_resource(
+ oc = Client()
+
+ existing_vnf = oc.sdc.vnf.get_catalog_resource(
catalog_resource_id=catalog_resource_id
).response_data
if existing_vnf.get("lifecycleState") != "NOT_CERTIFIED_CHECKOUT":
- vnf = vnf_client.checkout_catalog_resource(catalog_resource_id=catalog_resource_id).response_data
+ vnf = oc.sdc.vnf.checkout_catalog_resource(catalog_resource_id=catalog_resource_id).response_data
else:
- vnf = vnf_client.get_catalog_resource_metadata(catalog_resource_id=catalog_resource_id).response_data.get("metadata", {})
+ vnf = oc.sdc.vnf.get_catalog_resource_metadata(catalog_resource_id=catalog_resource_id).response_data.get("metadata", {})
- new_vnf_metadata = vnf_client.get_catalog_resource_metadata(catalog_resource_id=vnf.get("uniqueId")).response_data.get("metadata", {})
+ new_vnf_metadata = oc.sdc.vnf.get_catalog_resource_metadata(catalog_resource_id=vnf.get("uniqueId")).response_data.get("metadata", {})
csar_version = vsp.get_vsp_version_id(vnf.get("csarUUID"), search_key="name")
vnf["csarVersion"] = csar_version
vnf["componentMetadata"] = new_vnf_metadata
- updated_vnf = vnf_client.update_catalog_resource(catalog_resource_id=vnf.get("uniqueId"), payload_data=json.dumps(vnf)).response_data
+ updated_vnf = oc.sdc.vnf.update_catalog_resource(catalog_resource_id=vnf.get("uniqueId"), payload_data=json.dumps(vnf)).response_data
vnf_input["catalog_resource_id"] = updated_vnf.get("uniqueId")
vnf_input["tosca"] = updated_vnf
@@ -537,8 +543,21 @@ def create_vnf(vnf_input):
:return: dictionary of updated values for created vnf
"""
+ oc = Client()
+
kwargs = vnf_input
- vnf = vnf_client.add_catalog_resource(**kwargs)
+
+ category = get_resource_category(kwargs.get("vsp_category"))
+ vsp_sub_category = []
+ for subcategory in category.get("subcategories", []):
+ if subcategory.get("uniqueId") == kwargs.get("vsp_sub_category"):
+ vsp_sub_category.append(subcategory)
+ break
+
+ category["subcategories"] = vsp_sub_category
+ kwargs["contact_id"] = vsp.get_vsp_owner(kwargs.get("software_product_id"))
+
+ vnf = oc.sdc.vnf.add_catalog_resource(**kwargs, categories=[category])
kwargs["catalog_resource_id"] = vnf.catalog_resource_id
kwargs["tosca"] = vnf.response_data
@@ -599,9 +618,11 @@ def add_resource(parent_resource_id, catalog_resource_id, catalog_resource_name,
:origin_type: specifies the origin of the attached resource
"""
+ oc = Client()
+
milli_timestamp = int(time.time() * 1000)
- resource_instance = vnf_client.add_resource_instance(
+ resource_instance = oc.sdc.vnf.add_resource_instance(
catalog_resource_id=parent_resource_id,
posX=random.randrange(150, 550), # nosec
posY=random.randrange(150, 450), # nosec
@@ -621,13 +642,26 @@ def add_resource(parent_resource_id, catalog_resource_id, catalog_resource_name,
@utility
def get_vnf(vnf_name):
"""Queries SDC for the TOSCA model for a VNF"""
- return vnf_client.get_catalog_resource(
+ oc = Client()
+
+ return oc.sdc.vnf.get_catalog_resource(
catalog_resource_id=get_vnf_id(vnf_name)
).response_data
+def get_resource_category(category_name):
+ oc = Client()
+ resource_categories = oc.sdc.get_resource_categories().response_data
+ for category in resource_categories:
+ if category.get("uniqueId") == category_name:
+ return category
+ return None
+
+
def get_vnf_id(vnf_name):
- response = vnf_client.get_resources()
+ oc = Client()
+
+ response = oc.sdc.vnf.get_resources()
results = response.response_data.get("resources", [])
catalog_resource = {}
update_time = -1
diff --git a/onap-client/onap_client/sdc/vsp.py b/onap-client/onap_client/sdc/vsp.py
index 781f6eb..25b3170 100644
--- a/onap-client/onap_client/sdc/vsp.py
+++ b/onap-client/onap_client/sdc/vsp.py
@@ -37,13 +37,11 @@
from onap_client.lib import generate_dummy_string
from onap_client.resource import Resource
-from onap_client.client.clients import Client as SDCClient
+from onap_client.client.clients import Client
from onap_client import sdc
from onap_client.util import utility
from onap_client.exceptions import ResourceAlreadyExistsException
-vsp_client = SDCClient().sdc.vsp
-
class VSP(Resource):
resource_name = "VSP"
@@ -86,7 +84,7 @@ class VSP(Resource):
contributers=[],
allow_update=False,
):
-
+ self.oc = Client()
vsp_input = {}
license_model_id = sdc.license_model.get_license_model_id(license_model_name)
@@ -136,25 +134,27 @@ class VSP(Resource):
def _post_create(self):
for contributer in self.contributers:
- vsp_client.add_vsp_contributer(
+ self.oc.sdc.vsp.add_vsp_contributer(
user_id=contributer, software_product_id=self.software_product_id
)
def _submit(self):
"""Submits the vsp in SDC"""
- vsp_client.submit_software_product(**self.attributes, action="Submit")
- vsp_client.package_software_product(**self.attributes, action="Create_Package")
+ self.oc.sdc.vsp.submit_software_product(**self.attributes, action="Submit")
+ self.oc.sdc.vsp.package_software_product(**self.attributes, action="Create_Package")
- vsp = vsp_client.get_software_product(**self.attributes)
+ vsp = self.oc.sdc.vsp.get_software_product(**self.attributes)
self.attributes["tosca"] = vsp.response_data
def update_vsp(existing_vsp, vsp_input):
+ oc = Client()
+
existing_vsp_id = existing_vsp.get("id")
existing_vsp_version_id = existing_vsp.get("version")
if get_vsp_version_id(existing_vsp_id, search_key="status") == "Certified":
- vsp_client.update_software_product(
+ oc.sdc.vsp.update_software_product(
software_product_id=existing_vsp_id,
software_product_version_id=existing_vsp_version_id,
description=vsp_input.get("description", "New VSP Version")
@@ -163,10 +163,10 @@ def update_vsp(existing_vsp, vsp_input):
vsp_input["software_product_id"] = existing_vsp_id
vsp_input["software_product_version_id"] = get_vsp_version_id(existing_vsp_id)
- vsp_client.upload_heat_package(**vsp_input)
- vsp_client.validate_software_product(**vsp_input)
+ oc.sdc.vsp.upload_heat_package(**vsp_input)
+ oc.sdc.vsp.validate_software_product(**vsp_input)
- vsp = vsp_client.get_software_product(**vsp_input)
+ vsp = oc.sdc.vsp.get_software_product(**vsp_input)
vsp_input["tosca"] = vsp.response_data
return vsp_input
@@ -179,16 +179,18 @@ def create_vsp(vsp_input):
:return: dictionary of updated values for created vsp
"""
+ oc = Client()
+
kwargs = vsp_input
- vsp = vsp_client.add_software_product(**kwargs)
+ vsp = oc.sdc.vsp.add_software_product(**kwargs)
kwargs["software_product_id"] = vsp.software_product_id
kwargs["software_product_version_id"] = vsp.software_product_version_id
- vsp_client.upload_heat_package(**kwargs)
- vsp_client.validate_software_product(**kwargs)
+ oc.sdc.vsp.upload_heat_package(**kwargs)
+ oc.sdc.vsp.validate_software_product(**kwargs)
- vsp = vsp_client.get_software_product(**kwargs)
+ vsp = oc.sdc.vsp.get_software_product(**kwargs)
kwargs["tosca"] = vsp.response_data
return kwargs
@@ -201,7 +203,9 @@ def get_vsp_id(vsp_name):
:return: id of vsp or None
"""
- response = vsp_client.get_software_products()
+ oc = Client()
+
+ response = oc.sdc.vsp.get_software_products()
results = response.response_data.get("results", {})
for vsp in results:
if vsp.get("name") == vsp_name:
@@ -216,9 +220,11 @@ def get_vsp_version_id(vsp_id, search_key="id"):
:return: uuid of vsp version id or None
"""
+ oc = Client()
+
vsp_version_id = None
creation_time = -1
- response = vsp_client.get_software_product_versions(software_product_id=vsp_id)
+ response = oc.sdc.vsp.get_software_product_versions(software_product_id=vsp_id)
results = response.response_data.get("results")
for version in results:
if version.get("creationTime", 0) > creation_time:
@@ -229,11 +235,22 @@ def get_vsp_version_id(vsp_id, search_key="id"):
def get_vsp_model(vsp_id, vsp_version_id):
- return vsp_client.get_software_product(
+ oc = Client()
+
+ return oc.sdc.vsp.get_software_product(
software_product_id=vsp_id, software_product_version_id=vsp_version_id,
).response_data
+def get_vsp_owner(vsp_id):
+ oc = Client()
+ vsps = oc.sdc.vsp.get_software_products().response_data.get("results", [])
+ for vsp in vsps:
+ if vsp.get("id") == vsp_id:
+ return vsp.get("owner")
+ return None
+
+
@utility
def get_vsp(vsp_name):
"""Queries SDC for the tosca model for a VSP"""
diff --git a/onap-client/onap_client/sdnc/preload.py b/onap-client/onap_client/sdnc/preload.py
index 65c5e0c..a8e4a77 100644
--- a/onap-client/onap_client/sdnc/preload.py
+++ b/onap-client/onap_client/sdnc/preload.py
@@ -39,14 +39,11 @@ import json
import tempfile
from onap_client.resource import Resource
-from onap_client.client.clients import Client as SDNCClient
+from onap_client.client.clients import Client
from onap_client.exceptions import ServiceInstanceNotFound, VNFInstanceNotFound
from onap_client import so
from onap_client.config import LOG as logger
-oc = SDNCClient()
-sdnc_client = oc.sdnc
-
class Preload(Resource):
resource_name = "PRELOAD"
@@ -143,10 +140,12 @@ class Preload(Resource):
def create_preload(preload_path, api_type):
+ oc = Client()
+
if api_type == "GR_API":
- sdnc_client.operations.gr_api_preload(preload_path=preload_path)
+ oc.sdnc.operations.gr_api_preload(preload_path=preload_path)
elif api_type == "VNF_API":
- sdnc_client.operations.vnf_api_preload(preload_path=preload_path)
+ oc.sdnc.operations.vnf_api_preload(preload_path=preload_path)
def update_preload_with_instance(
diff --git a/onap-client/onap_client/so/module_instance.py b/onap-client/onap_client/so/module_instance.py
index 19af17a..75105ed 100644
--- a/onap-client/onap_client/so/module_instance.py
+++ b/onap-client/onap_client/so/module_instance.py
@@ -37,17 +37,14 @@
import uuid
from onap_client.resource import Resource
-from onap_client.client.clients import Client as SOClient
+from onap_client.client.clients import Client
from onap_client.exceptions import ServiceInstanceNotFound, VNFInstanceNotFound, ModuleInstanceNotFound
from onap_client import so
from onap_client import sdnc
from onap_client.util import utility
-oc = SOClient()
-so_client = oc.so
-
-class VNFInstance(Resource):
+class ModuleInstance(Resource):
resource_name = "MODULE_INSTANCE"
spec = {
"module_instance_name": {"type": str, "required": True},
@@ -180,6 +177,8 @@ class VNFInstance(Resource):
def create_module_instance(instance_input):
+ oc = Client()
+
sdnc.preload.Preload(
instance_input.get("preload_path"),
instance_input.get("vnf_instance_name"),
@@ -190,7 +189,7 @@ def create_module_instance(instance_input):
)
headers = {"X-TransactionId": str(uuid.uuid4())}
- module_instance = so_client.service_instantiation.create_module_instance(
+ module_instance = oc.so.service_instantiation.create_module_instance(
**instance_input, **headers
)
@@ -206,6 +205,8 @@ def create_module_instance(instance_input):
@utility
def delete_module_instance(service_instance_name, vnf_instance_name, module_instance_name, api_type="GR_API"):
"""Delete a Module 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", []):
@@ -220,7 +221,7 @@ def delete_module_instance(service_instance_name, vnf_instance_name, module_inst
tenant_id = modulei.get("vf-module-data").get("vf-module-request-input").get("tenant")
cloud_owner = modulei.get("vf-module-data").get("vf-module-request-input").get("cloud-owner")
cloud_region = modulei.get("vf-module-data").get("vf-module-request-input").get("aic-cloud-region")
- return so_client.service_instantiation.delete_module_instance(
+ return oc.so.service_instantiation.delete_module_instance(
module_invariant_id=module_invariant_id,
module_name=module_name,
module_version=module_version,
diff --git a/onap-client/onap_client/so/service_instance.py b/onap-client/onap_client/so/service_instance.py
index a5a2e8f..6398ac8 100644
--- a/onap-client/onap_client/so/service_instance.py
+++ b/onap-client/onap_client/so/service_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 Client
from onap_client.so import SO_PROPERTIES
from onap_client.exceptions import (
SORequestStatusUnavailable,
@@ -50,16 +50,8 @@ from onap_client.exceptions import (
)
from onap_client import sdc
from onap_client.util import utility
-
from time import sleep
-oc = SOClient()
-so_client = oc.so
-sdc_client = oc.sdc
-aai_client = oc.aai
-sdnc_client = oc.sdnc
-vid_client = oc.vid
-
class ServiceInstance(Resource):
resource_name = "SERVICE_INSTANCE"
@@ -97,6 +89,8 @@ class ServiceInstance(Resource):
project_name,
owning_entity_name,
):
+ self.oc = Client()
+
instance_input = {}
tenant_id = get_tenant_id(cloud_region, cloud_owner, tenant_name)
@@ -117,7 +111,7 @@ class ServiceInstance(Resource):
super().__init__(instance_input)
def _create(self, instance_input):
- service_model = sdc_client.service.get_sdc_service(
+ service_model = self.oc.sdc.service.get_sdc_service(
catalog_service_id=sdc.service.get_service_id(
instance_input.get("model_name")
)
@@ -126,7 +120,7 @@ class ServiceInstance(Resource):
instance_input["model_invariant_id"] = service_model["invariantUUID"]
instance_input["model_version_id"] = service_model["uniqueId"]
- category_parameters = vid_client.maintenance.get_category_parameters().response_data
+ category_parameters = self.oc.vid.maintenance.get_category_parameters().response_data
for entity in category_parameters.get("categoryParameters", {}).get("owningEntity", []):
if entity.get("name") == instance_input.get("owning_entity_name"):
instance_input["owning_entity_id"] = entity.get("id")
@@ -145,7 +139,9 @@ class ServiceInstance(Resource):
def get_service_instance(instance_name):
"""Queries SDNC for a list of all service instances and returns
The service instance that matches <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", []):
if si.get("service-data", {}).get("service-request-input", {}).get("service-instance-name") == instance_name:
return si
@@ -154,7 +150,9 @@ def get_service_instance(instance_name):
def get_tenant_id(cloud_region, cloud_owner, tenant_name):
- tenants = aai_client.cloud_infrastructure.get_cloud_region_tenants(
+ oc = Client()
+
+ tenants = oc.aai.cloud_infrastructure.get_cloud_region_tenants(
cloud_owner=cloud_owner,
cloud_region=cloud_region
).response_data
@@ -167,8 +165,10 @@ def get_tenant_id(cloud_region, cloud_owner, tenant_name):
def create_service_instance(instance_input):
+ oc = Client()
+
headers = {"X-TransactionId": str(uuid.uuid4())}
- service_instance = so_client.service_instantiation.create_service_instance(
+ service_instance = oc.so.service_instantiation.create_service_instance(
**instance_input, **headers
)
@@ -184,11 +184,13 @@ def create_service_instance(instance_input):
@utility
def poll_request(request_id):
"""Poll an SO request until completion"""
+ oc = Client()
+
poll_interval = SO_PROPERTIES.POLL_INTERVAL or 30
request = None
x = 0
while x < 30:
- request = so_client.service_instantiation.get_request_status(
+ request = oc.so.service_instantiation.get_request_status(
request_id=request_id
).response_data
status = request.get("request", {}).get("requestStatus", {}).get("requestState")
@@ -216,12 +218,14 @@ def poll_request(request_id):
@utility
def delete_service_instance(service_instance_name, api_type="GR_API"):
"""Delete a Service Instance from SO"""
+ oc = Client()
+
si = get_service_instance(service_instance_name)
si_id = si.get("service-instance-id")
invariant_id = si.get("service-data").get("service-information").get("onap-model-information").get("model-invariant-uuid")
version = si.get("service-data").get("service-information").get("onap-model-information").get("model-version")
- return so_client.service_instantiation.delete_service_instance(
+ return oc.so.service_instantiation.delete_service_instance(
service_invariant_id=invariant_id,
service_name=service_instance_name,
service_version=version,
diff --git a/onap-client/onap_client/so/tests/base_preload.json b/onap-client/onap_client/so/tests/base_preload.json
new file mode 100644
index 0000000..e4876a6
--- /dev/null
+++ b/onap-client/onap_client/so/tests/base_preload.json
@@ -0,0 +1,37 @@
+{
+ "input": {
+ "request-information": {
+ "request-id": "robot12",
+ "order-version": "1",
+ "notification-url": "openecomp.org",
+ "order-number": "1",
+ "request-action": "PreloadVfModuleRequest"
+ },
+ "sdnc-request-header": {
+ "svc-request-id": "robot12",
+ "svc-notification-url": "http://openecomp.org:8080/adapters/rest/SDNCNotify",
+ "svc-action": "reserve"
+ },
+ "preload-vf-module-topology-information": {
+ "vnf-topology-identifier-structure": {
+ "vnf-name": "",
+ "vnf-type": ""
+ },
+ "vnf-resource-assignments": {
+ "availability-zones": {
+ "availability-zone": []
+ },
+ "vnf-networks": {}
+ },
+ "vf-module-topology": {
+ "vf-module-topology-identifier": {
+ "vf-module-type": "",
+ "vf-module-name": ""
+ },
+ "vf-module-parameters": {
+ "param": []
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/onap-client/onap_client/so/tests/test_module_instance.py b/onap-client/onap_client/so/tests/test_module_instance.py
new file mode 100644
index 0000000..297fdea
--- /dev/null
+++ b/onap-client/onap_client/so/tests/test_module_instance.py
@@ -0,0 +1,227 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2020 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+import responses
+from onap_client.client.clients import Client
+from onap_client.tests.utils import mockup_catalog_item
+from onap_client.so.module_instance import ModuleInstance
+from os.path import dirname, abspath
+
+THIS_DIR = dirname(abspath(__file__))
+
+
+@responses.activate
+def test_module_instance():
+ oc = Client()
+
+ SERVICE_MODEL_NAME = "service_model_name"
+ SERVICE_MODEL_ID = "service_model_id"
+ SERVICE_MODEL_INVARIANT_ID = "service_model_invariant_id"
+ SERVICE_INSTANCE_NAME = "service_instance_name"
+ SERVICE_INSTANCE_ID = "service_instance_id"
+ SERVICE_INSTANCE_INVARIANT_ID = "service_instance_invariant_id"
+ SERVICE_INSTANCE_VERSION = "service_instance_version"
+ SERVICE_INSTANCE_UUID = "service_instance_uuid"
+
+ VNF_MODEL_NAME = "vnf_model_name"
+ VNF_INSTANCE_NAME = "vnf_instance_name"
+ VNF_INSTANCE_ID = "vnf_instance_id"
+ VNF_CUSTOMIZATION_UUID = "vnf_customization_uuid"
+ VNF_INVARIANT_ID = "vnf_invariant_id"
+ VNF_ACTUAL_UUID = "vnf_actual_uuid"
+ VNF_VERSION = "vnf_version"
+
+ HEAT_TEMPLATE_NAME = "base.yaml"
+ HEAT_TEMPLATE_ARTIFACT_UUID = "heat_template_artifact_uuid"
+
+ MODULE_MODEL_INVARIANT_UUID = "module_model_invariant_uuid"
+ MODULE_MODEL_VERSION_ID = "module_model_version_id"
+ MODULE_MODEL_CUSTOMIZATION_ID = "module_model_customization_id"
+ MODULE_MODEL_NAME = "module_model_name"
+ MODULE_MODEL_VERSION = "module_model_version"
+
+ MODULE_INSTANCE_NAME = "module_instance_name"
+
+ CLOUD_OWNER = "cloud_owner"
+ CLOUD_REGION = "cloud_region"
+ TENANT_NAME = "tenant_name"
+ TENANT_ID = "tenant_id"
+ REQUEST_ID = "request_id"
+
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["GET_SERVICES"],
+ override_return_data={
+ "services": [
+ {
+ "name": SERVICE_MODEL_NAME,
+ "uniqueId": SERVICE_MODEL_ID,
+ "lastUpdateDate": 123456,
+ }
+ ]
+ },
+ )
+ mockup_catalog_item(
+ oc.aai.cloud_infrastructure.catalog_items["GET_CLOUD_REGION_TENANTS"],
+ override_uri_params={"cloud_owner": CLOUD_OWNER, "cloud_region": CLOUD_REGION},
+ override_return_data={
+ "tenant": [
+ {
+ "tenant-name": TENANT_NAME,
+ "tenant-id": TENANT_ID
+ }
+ ],
+ }
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["GET_SDC_SERVICE"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ override_return_data={
+ "invariantUUID": SERVICE_MODEL_INVARIANT_ID,
+ "uniqueId": SERVICE_MODEL_ID,
+ "componentInstances": [
+ {
+ "componentName": VNF_MODEL_NAME,
+ "customizationUUID": VNF_CUSTOMIZATION_UUID,
+ "actualComponentUid": VNF_ACTUAL_UUID,
+ "componentVersion": VNF_VERSION,
+ "deploymentArtifacts": {
+ "heat1": {
+ "artifactName": HEAT_TEMPLATE_NAME,
+ "artifactUUID": HEAT_TEMPLATE_ARTIFACT_UUID
+ }
+ },
+ "groupInstances": [
+ {
+ "artifactsUuid": [HEAT_TEMPLATE_ARTIFACT_UUID],
+ "invariantUUID": MODULE_MODEL_INVARIANT_UUID,
+ "groupUUID": MODULE_MODEL_VERSION_ID,
+ "customizationUUID": MODULE_MODEL_CUSTOMIZATION_ID,
+ "groupName": MODULE_MODEL_NAME,
+ "version": MODULE_MODEL_VERSION
+ }
+ ]
+ }
+ ]
+ }
+ )
+ mockup_catalog_item(
+ oc.sdc.vnf.catalog_items["GET_CATALOG_RESOURCE"],
+ override_return_data={
+ "invariantUUID": VNF_INVARIANT_ID
+ },
+ override_uri_params={"catalog_resource_id": VNF_ACTUAL_UUID},
+ )
+ mockup_catalog_item(
+ oc.sdnc.operations.catalog_items["GR_API_PRELOAD"],
+ )
+ mockup_catalog_item(
+ oc.sdnc.config.catalog_items["GET_SERVICE_INSTANCES"],
+ override_return_data={
+ "services": {
+ "service": [
+ {
+ "service-data": {
+ "service-request-input": {
+ "service-instance-name": SERVICE_INSTANCE_NAME
+ },
+ "service-information": {
+ "onap-model-information": {
+ "model-invariant-uuid": SERVICE_INSTANCE_INVARIANT_ID,
+ "model-uuid": SERVICE_INSTANCE_UUID,
+ "model-version": SERVICE_INSTANCE_VERSION,
+ "model-name": SERVICE_MODEL_NAME,
+ }
+ },
+ "vnfs": {
+ "vnf": [
+ {
+ "vnf-data": {
+ "vnf-information": {
+ "vnf-name": VNF_INSTANCE_NAME,
+ "vnf-id": VNF_INSTANCE_ID,
+ "onap-model-information": {
+ "model-name": VNF_MODEL_NAME,
+ "model-invariant-uuid": VNF_INVARIANT_ID,
+ "model-uuid": VNF_ACTUAL_UUID,
+ "model-customization-uuid": VNF_CUSTOMIZATION_UUID,
+ "model-version": "1.0"
+ }
+ }
+ }
+ }
+ ]
+ }
+ },
+ "service-instance-id": SERVICE_INSTANCE_ID
+ }
+ ]
+ }
+ },
+ )
+ mockup_catalog_item(
+ oc.so.service_instantiation.catalog_items["CREATE_MODULE_INSTANCE"],
+ override_return_data={
+ "requestReferences": {
+ "requestId": REQUEST_ID
+ }
+ }
+ )
+ mockup_catalog_item(
+ oc.so.service_instantiation.catalog_items["GET_REQUEST_STATUS"],
+ override_uri_params={"request_id": REQUEST_ID},
+ override_return_data={
+ "request": {
+ "requestStatus": {
+ "requestState": "COMPLETE"
+ }
+ }
+ }
+ )
+
+ mi = ModuleInstance(
+ MODULE_INSTANCE_NAME,
+ VNF_INSTANCE_NAME,
+ SERVICE_INSTANCE_NAME,
+ "cs0008",
+ HEAT_TEMPLATE_NAME,
+ "{}/base_preload.json".format(THIS_DIR),
+ TENANT_NAME,
+ CLOUD_OWNER,
+ CLOUD_REGION,
+ "GR_API"
+ )
+
+ assert mi.module_instance_name == MODULE_INSTANCE_NAME
diff --git a/onap-client/onap_client/so/tests/test_service_instance.py b/onap-client/onap_client/so/tests/test_service_instance.py
new file mode 100644
index 0000000..e0afccc
--- /dev/null
+++ b/onap-client/onap_client/so/tests/test_service_instance.py
@@ -0,0 +1,136 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2020 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+import responses
+from onap_client.client.clients import Client
+from onap_client.tests.utils import mockup_catalog_item
+from onap_client.so.service_instance import ServiceInstance
+
+
+@responses.activate
+def test_service_instance():
+ oc = Client()
+
+ SERVICE_MODEL_NAME = "service_model"
+ SERVICE_MODEL_ID = "service_model_id"
+ SERVICE_MODEL_INVARIANT_ID = "service_model_invariant_id"
+ SERVICE_INSTANCE_NAME = "SERVICE_INSTANCE_NAME"
+ OWNING_ENTITY_NAME = "owning_entity"
+ OWNING_ENTITY_ID = "owning_entity_id"
+ CLOUD_OWNER = "cloud_owner"
+ CLOUD_REGION = "cloud_region"
+ TENANT_NAME = "tenant_name"
+ TENANT_ID = "tenant_id"
+ REQUEST_ID = "request_id"
+
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["GET_SERVICES"],
+ override_return_data={
+ "services": [
+ {
+ "name": SERVICE_MODEL_NAME,
+ "uniqueId": SERVICE_MODEL_ID,
+ "lastUpdateDate": 123456
+ }
+ ]
+ },
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["GET_SDC_SERVICE"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ override_return_data={"invariantUUID": SERVICE_MODEL_INVARIANT_ID, "uniqueId": SERVICE_MODEL_ID}
+ )
+ mockup_catalog_item(
+ oc.aai.cloud_infrastructure.catalog_items["GET_CLOUD_REGION_TENANTS"],
+ override_uri_params={"cloud_owner": CLOUD_OWNER, "cloud_region": CLOUD_REGION},
+ override_return_data={
+ "tenant": [
+ {
+ "tenant-name": TENANT_NAME,
+ "tenant-id": TENANT_ID
+ }
+ ],
+ }
+ )
+ mockup_catalog_item(
+ oc.vid.maintenance.catalog_items["GET_CATEGORY_PARAMETERS"],
+ override_return_data={
+ "categoryParameters": {
+ "owningEntity": [
+ {
+ "name": OWNING_ENTITY_NAME,
+ "id": OWNING_ENTITY_ID
+ }
+ ]
+ },
+ }
+ )
+ mockup_catalog_item(
+ oc.so.service_instantiation.catalog_items["CREATE_SERVICE_INSTANCE"],
+ override_return_data={
+ "requestReferences": {
+ "requestId": REQUEST_ID
+ }
+ }
+ )
+ mockup_catalog_item(
+ oc.so.service_instantiation.catalog_items["GET_REQUEST_STATUS"],
+ override_uri_params={"request_id": REQUEST_ID},
+ override_return_data={
+ "request": {
+ "requestStatus": {
+ "requestState": "COMPLETE"
+ }
+ }
+ }
+ )
+
+ si = ServiceInstance(
+ SERVICE_INSTANCE_NAME,
+ "cs0008",
+ SERVICE_MODEL_NAME,
+ "1.0",
+ TENANT_NAME,
+ CLOUD_OWNER,
+ CLOUD_REGION,
+ "GR_API",
+ "ONAPSERVICE",
+ "ONAPCUSTOMER",
+ "ONAPPROJECT",
+ OWNING_ENTITY_NAME
+ )
+
+ assert si.service_instance_name == SERVICE_INSTANCE_NAME
diff --git a/onap-client/onap_client/so/tests/test_vnf_instance.py b/onap-client/onap_client/so/tests/test_vnf_instance.py
new file mode 100644
index 0000000..3805da8
--- /dev/null
+++ b/onap-client/onap_client/so/tests/test_vnf_instance.py
@@ -0,0 +1,174 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2020 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+import responses
+from onap_client.client.clients import Client
+from onap_client.tests.utils import mockup_catalog_item
+from onap_client.so.vnf_instance import VNFInstance
+
+
+@responses.activate
+def test_vnf_instance():
+ oc = Client()
+
+ SERVICE_MODEL_NAME = "service_model_name"
+ SERVICE_MODEL_ID = "service_model_id"
+ SERVICE_MODEL_INVARIANT_ID = "service_model_invariant_id"
+ SERVICE_INSTANCE_NAME = "service_instance_name"
+ SERVICE_INSTANCE_ID = "service_instance_id"
+ SERVICE_INSTANCE_INVARIANT_ID = "service_instance_invariant_id"
+ SERVICE_INSTANCE_VERSION = "service_instance_version"
+ SERVICE_INSTANCE_UUID = "service_instance_uuid"
+
+ VNF_MODEL_NAME = "vnf_model_name"
+ VNF_INSTANCE_NAME = "vnf_instance_name"
+ VNF_CUSTOMIZATION_UUID = "vnf_customization_uuid"
+ VNF_INVARIANT_ID = "vnf_invariant_id"
+ VNF_ACTUAL_UUID = "vnf_actual_uuid"
+ VNF_VERSION = "vnf_version"
+
+ CLOUD_OWNER = "cloud_owner"
+ CLOUD_REGION = "cloud_region"
+ TENANT_NAME = "tenant_name"
+ TENANT_ID = "tenant_id"
+ REQUEST_ID = "request_id"
+
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["GET_SERVICES"],
+ override_return_data={
+ "services": [
+ {
+ "name": SERVICE_MODEL_NAME,
+ "uniqueId": SERVICE_MODEL_ID,
+ "lastUpdateDate": 123456,
+ }
+ ]
+ },
+ )
+ mockup_catalog_item(
+ oc.aai.cloud_infrastructure.catalog_items["GET_CLOUD_REGION_TENANTS"],
+ override_uri_params={"cloud_owner": CLOUD_OWNER, "cloud_region": CLOUD_REGION},
+ override_return_data={
+ "tenant": [
+ {
+ "tenant-name": TENANT_NAME,
+ "tenant-id": TENANT_ID
+ }
+ ],
+ }
+ )
+ mockup_catalog_item(
+ oc.sdc.service.catalog_items["GET_SDC_SERVICE"],
+ override_uri_params={"catalog_service_id": SERVICE_MODEL_ID},
+ override_return_data={
+ "invariantUUID": SERVICE_MODEL_INVARIANT_ID,
+ "uniqueId": SERVICE_MODEL_ID,
+ "componentInstances": [
+ {
+ "componentName": VNF_MODEL_NAME,
+ "customizationUUID": VNF_CUSTOMIZATION_UUID,
+ "actualComponentUid": VNF_ACTUAL_UUID,
+ "componentVersion": VNF_VERSION
+ }
+ ]
+ }
+ )
+ mockup_catalog_item(
+ oc.sdc.vnf.catalog_items["GET_CATALOG_RESOURCE"],
+ override_return_data={
+ "invariantUUID": VNF_INVARIANT_ID
+ },
+ override_uri_params={"catalog_resource_id": VNF_ACTUAL_UUID},
+ )
+ mockup_catalog_item(
+ oc.sdnc.config.catalog_items["GET_SERVICE_INSTANCES"],
+ override_return_data={
+ "services": {
+ "service": [
+ {
+ "service-data": {
+ "service-request-input": {
+ "service-instance-name": SERVICE_INSTANCE_NAME
+ },
+ "service-information": {
+ "onap-model-information": {
+ "model-invariant-uuid": SERVICE_INSTANCE_INVARIANT_ID,
+ "model-uuid": SERVICE_INSTANCE_UUID,
+ "model-version": SERVICE_INSTANCE_VERSION,
+ "model-name": SERVICE_MODEL_NAME,
+ }
+ }
+ },
+ "service-instance-id": SERVICE_INSTANCE_ID
+ }
+ ]
+ }
+ },
+ )
+ mockup_catalog_item(
+ oc.so.service_instantiation.catalog_items["CREATE_VNF_INSTANCE"],
+ override_return_data={
+ "requestReferences": {
+ "requestId": REQUEST_ID
+ }
+ }
+ )
+ mockup_catalog_item(
+ oc.so.service_instantiation.catalog_items["GET_REQUEST_STATUS"],
+ override_uri_params={"request_id": REQUEST_ID},
+ override_return_data={
+ "request": {
+ "requestStatus": {
+ "requestState": "COMPLETE"
+ }
+ }
+ }
+ )
+
+ vnfi = VNFInstance(
+ VNF_INSTANCE_NAME,
+ SERVICE_INSTANCE_NAME,
+ "cs0008",
+ VNF_MODEL_NAME,
+ TENANT_NAME,
+ CLOUD_OWNER,
+ CLOUD_REGION,
+ "GR_API",
+ "platform",
+ "lob"
+ )
+
+ assert vnfi.vnf_instance_name == VNF_INSTANCE_NAME
diff --git a/onap-client/onap_client/tests/test-spec.json b/onap-client/onap_client/tests/test-spec.json
new file mode 100644
index 0000000..b2fa428
--- /dev/null
+++ b/onap-client/onap_client/tests/test-spec.json
@@ -0,0 +1,21 @@
+{
+ "parameters": {
+ "test1": "test1value"
+ },
+ "spec": [
+ {
+ "type": "TEST_RESOURCE",
+ "resource_spec": {
+ "test1": "{{test1}}",
+ "test2": [
+ {
+ "test2_nested": "test2nested",
+ "test2_nesteddict": {
+ "abc": "123"
+ }
+ }
+ ]
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/onap-client/onap_client/tests/test_engine.py b/onap-client/onap_client/tests/test_engine.py
new file mode 100644
index 0000000..808e5b7
--- /dev/null
+++ b/onap-client/onap_client/tests/test_engine.py
@@ -0,0 +1,49 @@
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2020 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+from onap_client.tests.testdata import TestResource # noqa: F401
+from onap_client.engine import load_spec
+from os.path import dirname, abspath
+
+THIS_DIR = dirname(abspath(__file__))
+
+
+def test_engine():
+ spec_file = "{}/test-spec.json".format(THIS_DIR)
+
+ t = load_spec(spec_file)
+
+ assert isinstance(t, dict)
diff --git a/onap-client/onap_client/tests/testdata.py b/onap-client/onap_client/tests/testdata.py
index ade4713..c5cb235 100644
--- a/onap-client/onap_client/tests/testdata.py
+++ b/onap-client/onap_client/tests/testdata.py
@@ -37,7 +37,7 @@
from functools import partial
from os.path import dirname, abspath
-
+from onap_client.resource import Resource
from onap_client.client.clients import Client
TEST_URI = "http://this.is.a.test.com"
@@ -54,6 +54,42 @@ class TestClient(Client):
return CATALOG_RESOURCES
+class TestResource(Resource):
+ resource_name = "TEST_RESOURCE"
+ spec = {
+ "test1": {"type": str, "required": True},
+ "test2": {
+ "type": list,
+ "list_item": dict,
+ "required": False,
+ "default": [],
+ "nested": {
+ "test2_nested": {"type": str, "required": True},
+ "test2_nesteddict": {"type": dict, "required": True, "default": {}},
+ },
+ },
+ }
+
+ def __init__(self, test1, test2):
+ instance_input = {}
+
+ instance_input["test1"] = test1
+ instance_input["test2"] = test2
+
+ super().__init__(instance_input)
+
+ def _create(self, instance_input):
+ print("creating test instance {}".format(instance_input))
+
+ return instance_input
+
+ def _post_create(self):
+ print("post create for test instance")
+
+ def _submit(self):
+ print("submit for test instance")
+
+
CATALOG_RESOURCES = {
"MAKE_TEST_REQUEST": {
"verb": "POST",