aboutsummaryrefslogtreecommitdiffstats
path: root/osdf/adapters/dcae/des.py
diff options
context:
space:
mode:
authorkrishnaa96 <krishna.moorthy6@wipro.com>2021-01-05 11:05:17 +0530
committerkrishnaa96 <krishna.moorthy6@wipro.com>2021-01-05 12:20:23 +0530
commit869b18e4db3be57075cf0deb24d62b33f6c6879a (patch)
tree715f60c354ed1b978f5cd035f1bc3e0f24b8aa34 /osdf/adapters/dcae/des.py
parent8323a205518f013598d9177c14ce26bcee9e09a3 (diff)
Remove ca-cert from docker image
CA cert can be directly used by the request library. So it is not needed to install in the base image Issue-ID: OPTFRA-891 Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com> Change-Id: Ia7642cded9057148abcaf0f2f8c9e85d63a08012
Diffstat (limited to 'osdf/adapters/dcae/des.py')
-rw-r--r--osdf/adapters/dcae/des.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/osdf/adapters/dcae/des.py b/osdf/adapters/dcae/des.py
index 57d0371..17517d7 100644
--- a/osdf/adapters/dcae/des.py
+++ b/osdf/adapters/dcae/des.py
@@ -17,9 +17,10 @@
#
import requests
-from requests.auth import HTTPBasicAuth
+from requests.exceptions import HTTPError
from osdf.config.base import osdf_config
+from osdf.utils.interfaces import RestClient
class DESException(Exception):
@@ -36,16 +37,14 @@ def extract_data(service_id, request_data):
config = osdf_config.deployment
user, password = config['desUsername'], config['desPassword']
- auth = HTTPBasicAuth(user, password)
headers = config["desHeaders"]
req_url = config["desUrl"] + config["desApiPath"] + service_id
+ rc = RestClient(userid=user, passwd=password, url=req_url, headers=headers, method="POST")
try:
- response = requests.post(req_url, data=request_data, headers=headers, auth=auth, verify=False)
+ response_json = rc.request(data=request_data)
+ return response_json.get("result")
except requests.RequestException as e:
raise DESException("Request exception was encountered {}".format(e))
-
- if response.status_code == 200:
- return response.json().get("result")
- else:
- raise DESException("Response code other than 200. Response code: {}".format(response.status_code))
+ except HTTPError as ex:
+ raise DESException("Response code other than 200. Response code: {}".format(ex.response.status_code))