aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstark, steven <steven.stark@att.com>2020-05-27 13:14:22 -0700
committerstark, steven <steven.stark@att.com>2020-05-27 13:14:22 -0700
commit67bd9e52c527b7a0ed40eba0896bcae23e8eb4f6 (patch)
tree3d916f7b0b2bb09242fe90722206f1c19e44a470
parentae7a1f690808666d0b6b8b79b739e3a865dd93b1 (diff)
[VVP] Fix VNF description
VNF description field is colliding w/ vnf property description field. Also updating VSP contributor/owner logic so a user doesn't get added if already present, and the owner doesn't get added if already the owner. Issue-ID: VVP-419 Signed-off-by: stark, steven <steven.stark@att.com> Change-Id: Ib8d8daa56c70f6ce548e8eebd9cdc43ff567f1dd
-rw-r--r--onap-client/etc/payloads/catalog_resource.jinja2
-rw-r--r--onap-client/onap_client/sdc/catalog/vnf_catalog.py2
-rw-r--r--onap-client/onap_client/sdc/catalog/vsp_catalog.py22
-rw-r--r--onap-client/onap_client/sdc/service.py2
-rw-r--r--onap-client/onap_client/sdc/vnf.py2
-rw-r--r--onap-client/onap_client/sdc/vsp.py33
-rw-r--r--onap-client/setup.py2
7 files changed, 54 insertions, 11 deletions
diff --git a/onap-client/etc/payloads/catalog_resource.jinja b/onap-client/etc/payloads/catalog_resource.jinja
index b58676b..7489912 100644
--- a/onap-client/etc/payloads/catalog_resource.jinja
+++ b/onap-client/etc/payloads/catalog_resource.jinja
@@ -3,7 +3,7 @@
"toscaArtifacts": {},
"contactId": "{{contact_id}}",
"categories": {{categories|tojson(indent=4)}},
- "description": "{{description}}",
+ "description": "{{vnf_description}}",
"icon": "defaulticon",
"componentInstancesProperties": {},
"componentInstancesAttributes": {},
diff --git a/onap-client/onap_client/sdc/catalog/vnf_catalog.py b/onap-client/onap_client/sdc/catalog/vnf_catalog.py
index 2f07fbe..852d008 100644
--- a/onap-client/onap_client/sdc/catalog/vnf_catalog.py
+++ b/onap-client/onap_client/sdc/catalog/vnf_catalog.py
@@ -74,7 +74,7 @@ CATALOG_RESOURCES = {
"resource_type",
"categories",
"contact_id",
- "description",
+ "vnf_description",
],
"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 a0da6e5..702a1a2 100644
--- a/onap-client/onap_client/sdc/catalog/vsp_catalog.py
+++ b/onap-client/onap_client/sdc/catalog/vsp_catalog.py
@@ -308,6 +308,28 @@ CATALOG_RESOURCES = {
sdc_properties.GLOBAL_SDC_PASSWORD,
),
},
+ "GET_VSP_PERMISSIONS": {
+ "verb": "GET",
+ "description": "Returns the permissions for a VSP.",
+ "uri": partial(
+ "{endpoint}{service_path}/{software_product_id}/permissions".format,
+ endpoint=sdc_properties.SDC_BE_ONBOARD_ENDPOINT,
+ service_path=sdc_properties.SDC_VENDOR_ITEMS_PATH,
+ ),
+ "uri-parameters": ["software_product_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,
+ },
+ "auth": (
+ sdc_properties.GLOBAL_SDC_USERNAME,
+ sdc_properties.GLOBAL_SDC_PASSWORD,
+ ),
+ },
"ADD_VSP_CONTRIBUTER": {
"verb": "PUT",
"description": "Adds a user to a VSP as a contributer",
diff --git a/onap-client/onap_client/sdc/service.py b/onap-client/onap_client/sdc/service.py
index 5da6bb5..1b91c61 100644
--- a/onap-client/onap_client/sdc/service.py
+++ b/onap-client/onap_client/sdc/service.py
@@ -84,7 +84,7 @@ class Service(Resource):
"contact_id": {"type": str, "required": False, "default": "cs0008"},
"category_name": {"type": str, "required": False, "default": "Network L1-3"},
"tag": {"type": str, "required": False, "default": "robot-ete"},
- "project_code": {"type": str, "required": False, "default": "123456"},
+ "project_code": {"type": str, "required": False, "default": ""},
"environment_context": {
"type": str,
"required": False,
diff --git a/onap-client/onap_client/sdc/vnf.py b/onap-client/onap_client/sdc/vnf.py
index 538f3bc..80852a1 100644
--- a/onap-client/onap_client/sdc/vnf.py
+++ b/onap-client/onap_client/sdc/vnf.py
@@ -157,7 +157,7 @@ class VNF(Resource):
vnf_input["network_roles"] = network_roles
vnf_input["policies"] = policies
vnf_input["allow_update"] = allow_update
- vnf_input["description"] = description
+ vnf_input["vnf_description"] = description
super().__init__(vnf_input)
diff --git a/onap-client/onap_client/sdc/vsp.py b/onap-client/onap_client/sdc/vsp.py
index c64af36..c958978 100644
--- a/onap-client/onap_client/sdc/vsp.py
+++ b/onap-client/onap_client/sdc/vsp.py
@@ -136,15 +136,29 @@ class VSP(Resource):
return vsp
def _post_create(self):
+ vsp_permissions = self.oc.sdc.vsp.get_vsp_permissions(
+ software_product_id=self.software_product_id
+ ).response_data.get("results", [])
+ requestor_id = self.oc.sdc.vsp.catalog_resources["MODIFY_VSP_OWNER"].get("headers").get("USER_ID")
+
for contributer in self.contributers:
- self.oc.sdc.vsp.add_vsp_contributer(
- user_id=contributer, software_product_id=self.software_product_id
- )
+ if (
+ not user_exists(contributer, vsp_permissions, permission="Contributor")
+ and contributer != requestor_id
+ ):
+ self.oc.sdc.vsp.add_vsp_contributer(
+ user_id=contributer, software_product_id=self.software_product_id
+ )
if self.owner:
- self.oc.sdc.vsp.modify_vsp_owner(
- user_id=self.owner, software_product_id=self.software_product_id
- )
+ requestor_id = self.oc.sdc.vsp.catalog_resources["MODIFY_VSP_OWNER"].get("headers").get("USER_ID")
+ if (
+ user_exists(requestor_id, vsp_permissions, permission="Owner")
+ and self.owner != requestor_id
+ ):
+ self.oc.sdc.vsp.modify_vsp_owner(
+ user_id=self.owner, software_product_id=self.software_product_id
+ )
def _submit(self):
"""Submits the vsp in SDC"""
@@ -267,3 +281,10 @@ def get_vsp(vsp_name):
return None
vsp_version_id = get_vsp_version_id(vsp_id)
return get_vsp_model(vsp_id, vsp_version_id)
+
+
+def user_exists(contributer, vsp_permissions, permission="Contributor"):
+ for user in vsp_permissions:
+ if contributer == user.get("userId") and permission == user.get("permission"):
+ return True
+ return False
diff --git a/onap-client/setup.py b/onap-client/setup.py
index 398fff2..a813913 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.6.1",
+ version="0.6.2",
author="Steven Stark",
author_email="steven.stark@att.com",
description="Python API wrapper for ONAP applications",