aboutsummaryrefslogtreecommitdiffstats
path: root/onap-client
diff options
context:
space:
mode:
authorstark, steven <steven.stark@att.com>2020-09-08 14:30:48 -0700
committerstark, steven <steven.stark@att.com>2020-09-08 14:31:24 -0700
commit591c548e569423dad8d106d4d2cd26bc5ce24b19 (patch)
treea87f7b6c094319e315d998ca858d04f976a24d0c /onap-client
parenta8f5a0db87076f43b2596b5aba2a5b76d6eaaa63 (diff)
[VVP] Adding deployment level properties to service.py
Issue-ID: VVP-468 Signed-off-by: stark, steven <steven.stark@att.com> Change-Id: I9bc1a46122b402b4fab833d052e9e49c17d78619
Diffstat (limited to 'onap-client')
-rw-r--r--onap-client/onap_client/sdc/catalog/service_catalog.py26
-rw-r--r--onap-client/onap_client/sdc/service.py28
-rw-r--r--onap-client/setup.py2
3 files changed, 55 insertions, 1 deletions
diff --git a/onap-client/onap_client/sdc/catalog/service_catalog.py b/onap-client/onap_client/sdc/catalog/service_catalog.py
index c845422..aad645f 100644
--- a/onap-client/onap_client/sdc/catalog/service_catalog.py
+++ b/onap-client/onap_client/sdc/catalog/service_catalog.py
@@ -402,6 +402,32 @@ class ServiceCatalog(SDCClient):
self.global_sdc_password,
),
},
+ "UPDATE_MODULE_DEPLOYMENT_PROPERTIES": {
+ "verb": "POST",
+ "description": "Updates the deployment properties for a module.",
+ "uri": partial(
+ "{endpoint}{service_path}/{catalog_service_id}/resourceInstance/{catalog_resource_instance_id}/artifacts/{module_id}".format,
+ endpoint=self.config.sdc.SDC_BE_ENDPOINT,
+ service_path=self.config.sdc.SDC_CATALOG_RESOURCES_PATH,
+ ),
+ "uri-parameters": ["catalog_service_id", "catalog_resource_instance_id", "module_id"],
+ "payload": "{}/generic_payload.jinja".format(PAYLOADS_DIR),
+ "payload-parameters": [
+ "payload_data",
+ ],
+ "success_code": 200,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ "USER_ID": self.sdc_designer_user_id,
+ "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (
+ self.global_sdc_username,
+ self.global_sdc_password,
+ ),
+ },
"GET_SDC_SERVICE": {
"verb": "GET",
"description": "Gets a service from the SDC Catalog",
diff --git a/onap-client/onap_client/sdc/service.py b/onap-client/onap_client/sdc/service.py
index 5f2f918..6aace73 100644
--- a/onap-client/onap_client/sdc/service.py
+++ b/onap-client/onap_client/sdc/service.py
@@ -110,6 +110,7 @@ class Service(Resource):
"catalog_resource_name": {"type": str, "required": False},
"origin_type": {"type": str, "required": False, "default": "VF"},
"properties": {"type": dict, "required": False, "default": {}},
+ "deployment_properties": {"type": dict, "required": False, "default": {}}
},
},
"allow_update": {"type": bool, "required": False, "default": False},
@@ -157,6 +158,9 @@ class Service(Resource):
v = json.dumps(v).replace('"', '\\"')
self.add_property_value(resource_name, k, v)
+ if resource.get("deployment_properties"):
+ self.update_resource_deployment_properties(resource_name, resource.get("deployment_properties"))
+
def _submit(self):
"""Submits the service in SDC and distributes the model"""
oc = Client()
@@ -244,6 +248,30 @@ class Service(Resource):
self._refresh()
+ def update_resource_deployment_properties(self, resource_name, deployment_properties):
+ vnf_instance = {}
+ for component_instance in self.tosca.get("componentInstances", []):
+ if component_instance.get("componentName") == resource_name:
+ vnf_instance = component_instance
+ break
+
+ if not vnf_instance:
+ raise exceptions.ResourceNotFoundException(
+ "Resource {} was not found on Service {}".format(
+ resource_name, self.service_name
+ )
+ )
+
+ for deployment_artifact_name, deployment_artifact in vnf_instance.get("deploymentArtifacts").items():
+ if deployment_artifact.get("artifactType") == "HEAT_ENV":
+ deployment_artifact.update(deployment_properties)
+ self.oc.sdc.service.update_module_deployment_properties(
+ catalog_service_id=self.catalog_service_id,
+ catalog_resource_instance_id=vnf_instance.get("uniqueId"),
+ module_id=deployment_artifact.get("uniqueId"),
+ payload_data=deployment_artifact,
+ )
+
def add_property_value(self, resource_name, property_name, input_value):
"""Updates an property value on a resource attached to a Service
diff --git a/onap-client/setup.py b/onap-client/setup.py
index 58e36e8..e9907f0 100644
--- a/onap-client/setup.py
+++ b/onap-client/setup.py
@@ -47,7 +47,7 @@ for file in os.listdir("etc/payloads"):
setuptools.setup(
name="onap-client",
- version="0.10.1",
+ version="0.10.2",
author="Steven Stark",
author_email="steven.stark@att.com",
description="Python API wrapper for ONAP applications",