From ae7a1f690808666d0b6b8b79b739e3a865dd93b1 Mon Sep 17 00:00:00 2001 From: "stark, steven" Date: Thu, 21 May 2020 14:36:33 -0700 Subject: [VVP] adding VSP owner and VF description Adding optional mechanism to override the VSP owner Addition optional field for the VF descriptino Issue-ID: VVP-418 Signed-off-by: stark, steven Change-Id: Ib297a22a75a138881647fc2b8e91149c9e7a686c --- onap-client/etc/payloads/catalog_resource.jinja | 2 +- onap-client/onap_client/sdc/catalog/vnf_catalog.py | 1 + onap-client/onap_client/sdc/catalog/vsp_catalog.py | 24 ++++++++++++++++++++++ onap-client/onap_client/sdc/vnf.py | 5 ++++- onap-client/onap_client/sdc/vsp.py | 8 ++++++++ onap-client/setup.py | 2 +- 6 files changed, 39 insertions(+), 3 deletions(-) diff --git a/onap-client/etc/payloads/catalog_resource.jinja b/onap-client/etc/payloads/catalog_resource.jinja index b9647b8..b58676b 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": "vendor software product", + "description": "{{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 6cf2207..2f07fbe 100644 --- a/onap-client/onap_client/sdc/catalog/vnf_catalog.py +++ b/onap-client/onap_client/sdc/catalog/vnf_catalog.py @@ -74,6 +74,7 @@ CATALOG_RESOURCES = { "resource_type", "categories", "contact_id", + "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 7070032..a0da6e5 100644 --- a/onap-client/onap_client/sdc/catalog/vsp_catalog.py +++ b/onap-client/onap_client/sdc/catalog/vsp_catalog.py @@ -332,4 +332,28 @@ CATALOG_RESOURCES = { sdc_properties.GLOBAL_SDC_PASSWORD, ), }, + "MODIFY_VSP_OWNER": { + "verb": "PUT", + "description": "Changes the owner of a VSP", + "uri": partial( + "{endpoint}{service_path}/{software_product_id}/permissions/Owner".format, + endpoint=sdc_properties.SDC_BE_ONBOARD_ENDPOINT, + service_path=sdc_properties.SDC_VENDOR_ITEMS_PATH, + ), + "uri-parameters": ["software_product_id"], + "payload": "{}/add_vsp_contributer.jinja".format(PAYLOADS_DIR), + "payload-parameters": ["user_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, + ), + }, } diff --git a/onap-client/onap_client/sdc/vnf.py b/onap-client/onap_client/sdc/vnf.py index d772675..538f3bc 100644 --- a/onap-client/onap_client/sdc/vnf.py +++ b/onap-client/onap_client/sdc/vnf.py @@ -51,6 +51,7 @@ class VNF(Resource): resource_name = "VNF" spec = { "software_product_name": {"type": str, "required": True}, + "description": {"type": str, "required": False, "default": "VNF"}, "vnf_name": { "type": str, "required": False, @@ -131,6 +132,7 @@ class VNF(Resource): network_roles=[], policies=[], allow_update=False, + description="VNF", ): self.oc = Client() @@ -139,7 +141,7 @@ class VNF(Resource): 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") @@ -155,6 +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 super().__init__(vnf_input) diff --git a/onap-client/onap_client/sdc/vsp.py b/onap-client/onap_client/sdc/vsp.py index 25b3170..c64af36 100644 --- a/onap-client/onap_client/sdc/vsp.py +++ b/onap-client/onap_client/sdc/vsp.py @@ -46,6 +46,7 @@ from onap_client.exceptions import ResourceAlreadyExistsException class VSP(Resource): resource_name = "VSP" spec = { + "owner": {"type": str, "required": False, "default": ""}, "vendor_name": {"type": str, "required": True}, "license_model_name": {"type": str, "required": True}, "file_path": {"type": str, "required": True}, @@ -83,6 +84,7 @@ class VSP(Resource): sub_category, contributers=[], allow_update=False, + owner="", ): self.oc = Client() vsp_input = {} @@ -111,6 +113,7 @@ class VSP(Resource): vsp_input["sub_category"] = sub_category.lower() vsp_input["contributers"] = contributers vsp_input["allow_update"] = allow_update + vsp_input["owner"] = owner super().__init__(vsp_input) @@ -138,6 +141,11 @@ class VSP(Resource): 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 + ) + def _submit(self): """Submits the vsp in SDC""" self.oc.sdc.vsp.submit_software_product(**self.attributes, action="Submit") diff --git a/onap-client/setup.py b/onap-client/setup.py index e685152..398fff2 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.0", + version="0.6.1", author="Steven Stark", author_email="steven.stark@att.com", description="Python API wrapper for ONAP applications", -- cgit 1.2.3-korg