aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstark, steven <steven.stark@att.com>2020-09-23 15:48:44 -0700
committerstark, steven <steven.stark@att.com>2020-09-23 15:49:39 -0700
commit82f201fb65094aad55b3e46634bad39713387c6e (patch)
treee363382e43be36b50a903980647b677a738654d9
parentb5b81c492ab382fc1014f92e7daad6fdb97377af (diff)
[VVP] Adding toggle for SSL verification to config
Issue-ID: VVP-469 Signed-off-by: stark, steven <steven.stark@att.com> Change-Id: Ifa4b5902dae2a5ac145245b962d5cca8d4d30651
-rw-r--r--onap-client/onap_client/client/catalog.py12
-rw-r--r--onap-client/onap_client/client/request.py4
-rw-r--r--onap-client/onap_client/config.py2
-rw-r--r--onap-client/onap_client/lib.py4
-rw-r--r--onap-client/setup.py2
5 files changed, 13 insertions, 11 deletions
diff --git a/onap-client/onap_client/client/catalog.py b/onap-client/onap_client/client/catalog.py
index 03f10ff..fed3acf 100644
--- a/onap-client/onap_client/client/catalog.py
+++ b/onap-client/onap_client/client/catalog.py
@@ -63,11 +63,12 @@ class Catalog(ABC):
"""Attached as an attribute for each catalog entry in a catalog.
Used to make a request to ONAP."""
- def __init__(self, catalog_resource):
+ def __init__(self, catalog_resource, verify=False):
self.resource = catalog_resource
+ self.verify_request = verify
def __call__(self, **kwargs):
- return make_request(self.resource, **kwargs)
+ return make_request(self.resource, self.verify_request, **kwargs)
def __init__(self, config_file=None, **kwargs):
"""Iterates through all child classes and attaches them as attributes, named
@@ -96,13 +97,13 @@ class Catalog(ABC):
self.set_config(config_file)
- def load(self, item_name, resource_data):
+ def load(self, item_name, resource_data, verify=False):
"""Consume a catalog resource entry as an APICatalogResource,
and set it as an attribute on this.class as a CallHandle object"""
resource = APICatalogResource(item_name, resource_data)
self.catalog_items[item_name] = resource
- setattr(self, item_name.lower(), self.CallHandle(resource))
+ setattr(self, item_name.lower(), self.CallHandle(resource, verify=verify))
@property
@abstractmethod
@@ -127,11 +128,12 @@ class Catalog(ABC):
def set_config(self, config_file):
self.config = config.load_config(config_file, "onap_client")
+ verify = self.config.REQUESTS_VERIFY
for attr_name, attr in self.__dict__.items():
if isinstance(attr, Catalog):
attr.set_config(config_file)
for k, v in attr.catalog_resources.items():
- attr.load(k, v)
+ attr.load(k, v, verify=verify)
def override(override_key):
def decorator(func):
diff --git a/onap-client/onap_client/client/request.py b/onap-client/onap_client/client/request.py
index 268ee98..84c8280 100644
--- a/onap-client/onap_client/client/request.py
+++ b/onap-client/onap_client/client/request.py
@@ -57,13 +57,13 @@ class RequestHandler:
"""
self.request_object = request_object
- def make_request(self):
+ def make_request(self, verify):
r = Request(self.request_object)
logger.info("Submitting request: {}".format(self.request_object.description))
# TODO
# Add verify to config file
- return ResponseHandler(r.request(verify=False), self.request_object)
+ return ResponseHandler(r.request(verify=verify), self.request_object)
class Request:
diff --git a/onap-client/onap_client/config.py b/onap-client/onap_client/config.py
index 3b85bf8..e7d9d6d 100644
--- a/onap-client/onap_client/config.py
+++ b/onap-client/onap_client/config.py
@@ -56,7 +56,7 @@ class Config:
def __getattr__(self, attr):
item = self.config.get(attr, None)
- if isinstance(item, str):
+ if isinstance(item, (str, bool)):
return item
elif isinstance(item, dict):
return self.ConfigClient(item)
diff --git a/onap-client/onap_client/lib.py b/onap-client/onap_client/lib.py
index 78da11b..31cfebb 100644
--- a/onap-client/onap_client/lib.py
+++ b/onap-client/onap_client/lib.py
@@ -42,7 +42,7 @@ from onap_client import exceptions
from onap_client.client.request import RequestHandler, APICatalogRequestObject
-def make_request(catalog_item, **kwargs):
+def make_request(catalog_item, verify_request, **kwargs):
"""Makes a request using by merging an APICatalogResource and
kwargs to fill in the required parameters
@@ -57,7 +57,7 @@ def make_request(catalog_item, **kwargs):
request_handler = RequestHandler(catalog_request)
- response_handler = request_handler.make_request()
+ response_handler = request_handler.make_request(verify_request)
if not response_handler.success:
raise exceptions.RequestFailure(
diff --git a/onap-client/setup.py b/onap-client/setup.py
index 2f0a0fe..a6db762 100644
--- a/onap-client/setup.py
+++ b/onap-client/setup.py
@@ -47,7 +47,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="onap-client",
- version="1.0.1",
+ version="1.1.0",
author="Steven Stark",
author_email="steven.stark@att.com",
description="Python API wrapper for ONAP applications",