X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=plugins%2FOpenStack%2Fcommon.py;h=c892a302e73575ba82d27b81dd9bf1c7e191f304;hb=1e3d6ce4b8e9e6b0962f8c9ea939ef23e6a45b49;hp=eed122d4b353cddd4ebde9c525141ed3a0909909;hpb=d00ff82f2b06b5ae2a353e0f6a9b30d813ffa21f;p=osm%2FMON.git diff --git a/plugins/OpenStack/common.py b/plugins/OpenStack/common.py index eed122d..c892a30 100644 --- a/plugins/OpenStack/common.py +++ b/plugins/OpenStack/common.py @@ -21,7 +21,8 @@ ## """Common methods for the OpenStack plugins.""" -import logging as log +import logging +log = logging.getLogger(__name__) from keystoneclient.v3 import client @@ -81,16 +82,11 @@ class Common(object): headers = {'X-Auth-Token': auth_token, 'Content-type': 'application/json'} # perform request and return its result - response = None try: if req_type == "put": response = requests.put( url, data=payload, headers=headers, timeout=1) - elif req_type == "post": - response = requests.post( - url, data=payload, headers=headers, - timeout=1) elif req_type == "get": response = requests.get( url, params=params, headers=headers, timeout=1) @@ -98,9 +94,14 @@ class Common(object): response = requests.delete( url, headers=headers, timeout=1) else: - log.warn("Invalid request type") + response = requests.post( + url, data=payload, headers=headers, + timeout=1) except Exception as e: log.warn("Exception thrown on request", e) + if response is not None: + log.warn("Request resulted in %s code and %s response", + response.status_code, response.text) return response