diff options
author | 2020-10-15 12:34:35 -0700 | |
---|---|---|
committer | 2020-10-15 12:39:49 -0700 | |
commit | a0984e365a7c610e9cb91cf73e5d09db2be6df6a (patch) | |
tree | 67b8aaaffb37b56105569f2233672db9e5720cbd /onap-client/onap_client/sdc | |
parent | 82f201fb65094aad55b3e46634bad39713387c6e (diff) |
[VVP] VVP onap-client enhancements
Adding capability for custom auth plugin (defaults to basic auth).
During updates to VNF models, resource and policy objects are deletd and recreated.
Issue-ID: VVP-477
Signed-off-by: stark, steven <steven.stark@att.com>
Change-Id: Iba743176167c2b1df185666b08cbd79c6a559c9e
Diffstat (limited to 'onap-client/onap_client/sdc')
-rw-r--r-- | onap-client/onap_client/sdc/catalog/license_model_catalog.py | 50 | ||||
-rw-r--r-- | onap-client/onap_client/sdc/catalog/service_catalog.py | 95 | ||||
-rw-r--r-- | onap-client/onap_client/sdc/catalog/vnf_catalog.py | 124 | ||||
-rw-r--r-- | onap-client/onap_client/sdc/catalog/vsp_catalog.py | 65 | ||||
-rw-r--r-- | onap-client/onap_client/sdc/client.py | 37 | ||||
-rw-r--r-- | onap-client/onap_client/sdc/vnf.py | 24 |
6 files changed, 146 insertions, 249 deletions
diff --git a/onap-client/onap_client/sdc/catalog/license_model_catalog.py b/onap-client/onap_client/sdc/catalog/license_model_catalog.py index 0a90ebf..87a9346 100644 --- a/onap-client/onap_client/sdc/catalog/license_model_catalog.py +++ b/onap-client/onap_client/sdc/catalog/license_model_catalog.py @@ -70,10 +70,7 @@ class LicenseModelClient(SDCClient): "license_model_id": ("itemId",), "license_model_version_id": ("version", "id"), }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_KEY_GROUP": { "verb": "POST", @@ -99,10 +96,7 @@ class LicenseModelClient(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"key_group_id": ("value",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_ENTITLEMENT_POOL": { "verb": "POST", @@ -128,10 +122,7 @@ class LicenseModelClient(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"entitlement_pool_id": ("value",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_FEATURE_GROUP": { "verb": "POST", @@ -158,10 +149,7 @@ class LicenseModelClient(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"feature_group_id": ("value",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_LICENSE_AGREEMENT": { "verb": "POST", @@ -183,10 +171,7 @@ class LicenseModelClient(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"license_agreement_id": ("value",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "SUBMIT_LICENSE_MODEL": { "verb": "PUT", @@ -207,10 +192,7 @@ class LicenseModelClient(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_LICENSE_MODEL": { "verb": "GET", @@ -234,10 +216,7 @@ class LicenseModelClient(SDCClient): "license_model_id": ("id",), "description": ("description",), }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_LICENSE_MODEL_VERSION_ATTRIBUTE": { "verb": "GET", @@ -256,10 +235,7 @@ class LicenseModelClient(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_LICENSE_MODEL_VERSIONS": { "verb": "GET", @@ -278,10 +254,7 @@ class LicenseModelClient(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_LICENSE_MODELS": { "verb": "GET", @@ -300,9 +273,6 @@ class LicenseModelClient(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"results": ("results",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, } diff --git a/onap-client/onap_client/sdc/catalog/service_catalog.py b/onap-client/onap_client/sdc/catalog/service_catalog.py index dad8456..33fb8be 100644 --- a/onap-client/onap_client/sdc/catalog/service_catalog.py +++ b/onap-client/onap_client/sdc/catalog/service_catalog.py @@ -83,10 +83,7 @@ class ServiceCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"catalog_service_id": ("uniqueId",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "CHECKOUT_CATALOG_SERVICE": { "verb": "POST", @@ -106,10 +103,7 @@ class ServiceCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"catalog_service_id": ("uniqueId",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_RESOURCE_INSTANCE": { "verb": "POST", @@ -138,10 +132,7 @@ class ServiceCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"catalog_resource_instance_id": ("uniqueId",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "DELETE_RESOURCE_FROM_SERVICE": { "verb": "DELETE", @@ -160,10 +151,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "UPDATE_RESOURCE_VERSION": { "verb": "POST", @@ -186,10 +174,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "CHECKIN_SERVICE": { "verb": "POST", @@ -210,10 +195,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "REQUEST_SERVICE_CERTIFICATION": { "verb": "POST", @@ -234,10 +216,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "START_SERVICE_CERTIFICATION": { "verb": "POST", @@ -258,10 +237,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "FINISH_SERVICE_CERTIFICATION": { "verb": "POST", @@ -283,10 +259,7 @@ class ServiceCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"catalog_service_id": ("uniqueId",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "APPROVE_SERVICE_CERTIFICATION": { "verb": "POST", @@ -307,10 +280,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "DISTRIBUTE_SDC_SERVICE": { "verb": "POST", @@ -330,10 +300,7 @@ class ServiceCatalog(SDCClient): # "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_CATALOG_SERVICE_PROPERTY": { "verb": "POST", @@ -362,10 +329,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_CATALOG_SERVICE_INPUT": { "verb": "POST", @@ -392,10 +356,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "UPDATE_MODULE_DEPLOYMENT_PROPERTIES": { "verb": "POST", @@ -418,10 +379,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_SDC_SERVICE": { "verb": "GET", @@ -440,10 +398,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_SERVICES": { "verb": "GET", @@ -462,10 +417,7 @@ class ServiceCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"services": ("services",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_SERVICE_DISTRIBUTION": { "verb": "GET", @@ -484,10 +436,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_SERVICE_DISTRIBUTION_DETAILS": { "verb": "GET", @@ -506,10 +455,7 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_SDC_CSAR": { "verb": "GET", @@ -528,9 +474,6 @@ class ServiceCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, } diff --git a/onap-client/onap_client/sdc/catalog/vnf_catalog.py b/onap-client/onap_client/sdc/catalog/vnf_catalog.py index 71b20ca..b04b0f5 100644 --- a/onap-client/onap_client/sdc/catalog/vnf_catalog.py +++ b/onap-client/onap_client/sdc/catalog/vnf_catalog.py @@ -75,10 +75,7 @@ class VNFCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"catalog_resource_id": ("uniqueId",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "CERTIFY_CATALOG_RESOURCE": { "verb": "POST", @@ -100,10 +97,7 @@ class VNFCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"catalog_resource_id": ("uniqueId",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_CATALOG_RESOURCE_INPUT": { "verb": "POST", @@ -130,10 +124,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "UPDATE_CATALOG_RESOURCE": { "verb": "PUT", @@ -154,10 +145,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "CHECKOUT_CATALOG_RESOURCE": { "verb": "POST", @@ -176,10 +164,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_CATALOG_RESOURCE_PROPERTY": { "verb": "POST", @@ -208,10 +193,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_CATALOG_RESOURCE_PROPERTY_NON_VF": { "verb": "POST", @@ -240,10 +222,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_CATALOG_RESOURCE_POLICY": { "verb": "POST", @@ -263,10 +242,26 @@ class VNFCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"catalog_resource_id": ("uniqueId",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, + "auth": self.auth, + }, + "DELETE_CATALOG_RESOURCE_POLICY": { + "verb": "DELETE", + "description": "Deletes policy resource to a VNF.", + "uri": partial( + "{endpoint}{service_path}/{catalog_resource_id}/policies/{policy_id}".format, + endpoint=self.config.sdc.SDC_BE_ENDPOINT, + service_path=self.config.sdc.SDC_CATALOG_RESOURCES_PATH, ), + "uri-parameters": ["catalog_resource_id", "policy_id"], + "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": self.config.application_id, + }, + "auth": self.auth, }, "ADD_CATALOG_POLICY_PROPERTY": { "verb": "PUT", @@ -293,10 +288,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_CATALOG_RESOURCE_GROUP": { "verb": "POST", @@ -316,10 +308,7 @@ class VNFCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"catalog_resource_id": ("uniqueId",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_CATALOG_GROUP_PROPERTY": { "verb": "PUT", @@ -348,10 +337,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_GROUP_TO_INSTANCE": { "verb": "POST", @@ -372,10 +358,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_POLICY_TO_INSTANCE": { "verb": "POST", @@ -396,10 +379,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_RESOURCE_INSTANCE": { "verb": "POST", @@ -428,10 +408,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_RESOURCE_RELATIONSHIP": { "verb": "POST", @@ -461,10 +438,26 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, + "auth": self.auth, + }, + "DELETE_RESOURCE_FROM_VNF": { + "verb": "DELETE", + "description": "Delete a resource from a VNF.", + "uri": partial( + "{endpoint}{service_path}/{catalog_resource_id}/resourceInstance/{resource_id}".format, + endpoint=self.config.sdc.SDC_BE_ENDPOINT, + service_path=self.config.sdc.SDC_CATALOG_RESOURCES_PATH, ), + "uri-parameters": ["catalog_resource_id", "resource_id"], + "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": self.config.application_id, + }, + "auth": self.auth, }, "GET_CATALOG_RESOURCE": { "verb": "GET", @@ -484,10 +477,7 @@ class VNFCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"catalog_resource_name": ("name",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_CATALOG_RESOURCE_METADATA": { "verb": "GET", @@ -506,10 +496,7 @@ class VNFCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_RESOURCES": { "verb": "GET", @@ -528,9 +515,6 @@ class VNFCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"resources": ("resources",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, } diff --git a/onap-client/onap_client/sdc/catalog/vsp_catalog.py b/onap-client/onap_client/sdc/catalog/vsp_catalog.py index f8ddb9b..19ca631 100644 --- a/onap-client/onap_client/sdc/catalog/vsp_catalog.py +++ b/onap-client/onap_client/sdc/catalog/vsp_catalog.py @@ -80,10 +80,7 @@ class VSPCatalog(SDCClient): "software_product_id": ("itemId",), "software_product_version_id": ("version", "id"), }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "UPDATE_SOFTWARE_PRODUCT": { "verb": "POST", @@ -106,10 +103,7 @@ class VSPCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "UPLOAD_HEAT_PACKAGE": { "verb": "POST", @@ -129,10 +123,7 @@ class VSPCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "VALIDATE_SOFTWARE_PRODUCT": { "verb": "PUT", @@ -151,10 +142,7 @@ class VSPCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "SUBMIT_SOFTWARE_PRODUCT": { "verb": "PUT", @@ -175,10 +163,7 @@ class VSPCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "PACKAGE_SOFTWARE_PRODUCT": { "verb": "PUT", @@ -199,10 +184,7 @@ class VSPCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_SOFTWARE_PRODUCT": { "verb": "GET", @@ -222,10 +204,7 @@ class VSPCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"name": ("name",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_SOFTWARE_PRODUCT_INFORMATION": { "verb": "GET", @@ -245,10 +224,7 @@ class VSPCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"name": ("name",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_SOFTWARE_PRODUCT_VERSIONS": { "verb": "GET", @@ -271,10 +247,7 @@ class VSPCatalog(SDCClient): "software_product_version_id": ("id",), "description": ("description",), }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_SOFTWARE_PRODUCTS": { "verb": "GET", @@ -293,10 +266,7 @@ class VSPCatalog(SDCClient): "X-FromAppId": self.config.application_id, }, "return_data": {"results": ("results",)}, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "GET_VSP_PERMISSIONS": { "verb": "GET", @@ -315,10 +285,7 @@ class VSPCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "ADD_VSP_CONTRIBUTER": { "verb": "PUT", @@ -339,10 +306,7 @@ class VSPCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, "MODIFY_VSP_OWNER": { "verb": "PUT", @@ -363,9 +327,6 @@ class VSPCatalog(SDCClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, - ), + "auth": self.auth, }, } diff --git a/onap-client/onap_client/sdc/client.py b/onap-client/onap_client/sdc/client.py index 725cbeb..59c9b1b 100644 --- a/onap-client/onap_client/sdc/client.py +++ b/onap-client/onap_client/sdc/client.py @@ -35,9 +35,12 @@ # # ============LICENSE_END============================================ import uuid +from frozendict import frozendict from functools import partial + from onap_client.client.clients import Client +from onap_client.auth import auth_handler class SDCClient(Client): @@ -64,10 +67,7 @@ class SDCClient(Client): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - # "auth": ( - # self.sdc_designer_user_id, - # self.config.sdc.SDC_DESIGNER_PASSWORD, - # ), + "auth": self.auth, }, "GET_RESOURCE_CATEGORIES": { "verb": "GET", @@ -83,10 +83,25 @@ class SDCClient(Client): "Content-Type": "application/json", "USER_ID": self.sdc_designer_user_id, }, - "auth": ( - self.global_sdc_username, - self.global_sdc_password, + "auth": self.auth, + }, + "ADD_USER": { + "verb": "POST", + "description": "Add a user to SDC.", + "uri": partial( + "{endpoint}{service_path}".format, + endpoint=self.config.sdc.SDC_BE_ENDPOINT, + service_path=self.config.sdc.SDC_USER_PATH, ), + "payload": "{}/sdc_add_user.jinja".format(self.config.payload_directory), + "payload-parameters": ["first_name", "last_name", "user_id", "email", "role"], + "success_code": 201, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "USER_ID": self.sdc_ops_user_id, + }, + "auth": self.auth, }, } @@ -125,3 +140,11 @@ class SDCClient(Client): def sdc_governor_user_id(self): """Ops role User ID""" return self.config.sdc.SDC_GOVERNOR_USER_ID + + @property + def auth(self): + return auth_handler( + frozendict(self.config.sdc.AUTH_PLUGIN) if self.config.sdc.AUTH_PLUGIN else None, + self.global_sdc_username, + self.global_sdc_password, + ) diff --git a/onap-client/onap_client/sdc/vnf.py b/onap-client/onap_client/sdc/vnf.py index 4c42dbe..af5f71f 100644 --- a/onap-client/onap_client/sdc/vnf.py +++ b/onap-client/onap_client/sdc/vnf.py @@ -165,9 +165,14 @@ class VNF(Resource): for policy in policies: policy_name = policy.get("policy_name") policy_id = self.policy_exists(policy_name) - if not policy_id: - policy_id = self.add_policy_resource(policy_name) - self.associate_policy(policy_id, vm_type_instances) + if policy_id: + self.oc.sdc.vnf.delete_catalog_resource_policy( + policy_id=policy_id, + catalog_resource_id=self.catalog_resource_id + ) + + policy_id = self.add_policy_resource(policy_name) + self.associate_policy(policy_id, vm_type_instances) for k, v in policy.get("properties", {}).items(): self.add_policy_property(policy_id, k, v) @@ -198,7 +203,7 @@ class VNF(Resource): resource_name = "{}-{}".format(resource_name, resource_name_index) if self.resource_exists(resource_name): - continue + self.delete_resource(resource_name) catalog_resource_name = resource.get("catalog_resource_name") resource_id = resource.get("resource_id") @@ -285,6 +290,17 @@ class VNF(Resource): return False + def delete_resource(self, resource_name): + component_instances = self.tosca.get("componentInstances", []) + + for component in component_instances: + if component.get("name") == resource_name: + self.oc.sdc.vnf.delete_resource_from_vnf( + catalog_resource_id=self.catalog_resource_id, + resource_id=component.get("uniqueId") + ) + return + def policy_exists(self, policy_name): """Checking the tosca model for a VF to see if a resource has already been added |