From a0984e365a7c610e9cb91cf73e5d09db2be6df6a Mon Sep 17 00:00:00 2001 From: "stark, steven" Date: Thu, 15 Oct 2020 12:34:35 -0700 Subject: [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 Change-Id: Iba743176167c2b1df185666b08cbd79c6a559c9e --- .../onap_client/vid/catalog/maintenance_catalog.py | 10 +++++----- onap-client/onap_client/vid/client.py | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'onap-client/onap_client/vid') diff --git a/onap-client/onap_client/vid/catalog/maintenance_catalog.py b/onap-client/onap_client/vid/catalog/maintenance_catalog.py index 32f12ea..3a16387 100644 --- a/onap-client/onap_client/vid/catalog/maintenance_catalog.py +++ b/onap-client/onap_client/vid/catalog/maintenance_catalog.py @@ -65,7 +65,7 @@ class MaintenanceClient(VIDClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.vid.VID_USERNAME, self.config.vid.VID_PASSWORD,), + "auth": self.auth, }, "CREATE_LINE_OF_BUSINESS": { "verb": "POST", @@ -84,7 +84,7 @@ class MaintenanceClient(VIDClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.vid.VID_USERNAME, self.config.vid.VID_PASSWORD,), + "auth": self.auth, }, "CREATE_PLATFORM": { "verb": "POST", @@ -103,7 +103,7 @@ class MaintenanceClient(VIDClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.vid.VID_USERNAME, self.config.vid.VID_PASSWORD,), + "auth": self.auth, }, "CREATE_PROJECT": { "verb": "POST", @@ -122,7 +122,7 @@ class MaintenanceClient(VIDClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.vid.VID_USERNAME, self.config.vid.VID_PASSWORD,), + "auth": self.auth, }, "GET_CATEGORY_PARAMETERS": { "verb": "GET", @@ -139,6 +139,6 @@ class MaintenanceClient(VIDClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.vid.VID_USERNAME, self.config.vid.VID_PASSWORD,), + "auth": self.auth, }, } diff --git a/onap-client/onap_client/vid/client.py b/onap-client/onap_client/vid/client.py index 109f5b3..97fafe6 100644 --- a/onap-client/onap_client/vid/client.py +++ b/onap-client/onap_client/vid/client.py @@ -35,7 +35,9 @@ # # ============LICENSE_END============================================ from functools import partial +from frozendict import frozendict from onap_client.client.clients import Client +from onap_client.auth import auth_handler class VIDClient(Client): @@ -55,6 +57,24 @@ class VIDClient(Client): service_path=self.config.vid.VID_HEALTH_CHECK_PATH, ), "success_code": 200, - "auth": (self.config.vid.VID_USERNAME, self.config.vid.VID_PASSWORD,), + "auth": self.auth, }, } + + @property + def vid_username(self): + """Username to authenticate to VID""" + return self.config.vid.VID_USERNAME + + @property + def vid_password(self): + """Password to authenticate to VID""" + return self.config.vid.VID_PASSWORD + + @property + def auth(self): + return auth_handler( + frozendict(self.config.vid.AUTH_PLUGIN) if self.config.vid.AUTH_PLUGIN else None, + self.vid_username, + self.vid_password, + ) -- cgit 1.2.3-korg