X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=plugins%2FOpenStack%2Fcommon.py;h=c892a302e73575ba82d27b81dd9bf1c7e191f304;hb=95b92b3dacfd93fa1649a5f87dafd2fa6553a086;hp=25cca45edbe0ff5585aac0ba6c389e3ab79ff20d;hpb=cda5f2f5df14f015829cd733d794223c0c370c41;p=osm%2FMON.git diff --git a/plugins/OpenStack/common.py b/plugins/OpenStack/common.py index 25cca45..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 @@ -41,7 +42,7 @@ class Common(object): self._endpoint = None self._ks = None - def _authenticate(self, tenant_id=None): + def _authenticate(self): """Authenticate and/or renew the authentication token.""" if self._auth_token is not None: return self._auth_token @@ -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