本文整理匯總了Python中quantumclient.client.HTTPClient.get_auth_info方法的典型用法代碼示例。如果您正苦於以下問題:Python HTTPClient.get_auth_info方法的具體用法?Python HTTPClient.get_auth_info怎麽用?Python HTTPClient.get_auth_info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類quantumclient.client.HTTPClient
的用法示例。
在下文中一共展示了HTTPClient.get_auth_info方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Client
# 需要導入模塊: from quantumclient.client import HTTPClient [as 別名]
# 或者: from quantumclient.client.HTTPClient import get_auth_info [as 別名]
#.........這裏部分代碼省略.........
except Exception:
# If unable to deserialized body it is probably not a
# Quantum error
des_error_body = {'message': response_body}
# Raise the appropriate exception
exception_handler_v20(status_code, des_error_body)
def do_request(self, method, action, body=None, headers=None, params=None):
# Add format and tenant_id
action += ".%s" % self.format
action = self.action_prefix + action
if type(params) is dict and params:
params = utils.safe_encode_dict(params)
action += '?' + urllib.urlencode(params, doseq=1)
# Ensure client always has correct uri - do not guesstimate anything
self.httpclient.authenticate_and_fetch_endpoint_url()
uri_len = len(self.httpclient.endpoint_url) + len(action)
if uri_len > self.MAX_URI_LEN:
raise exceptions.RequestURITooLong(
excess=uri_len - self.MAX_URI_LEN)
if body:
body = self.serialize(body)
self.httpclient.content_type = self.content_type()
resp, replybody = self.httpclient.do_request(action, method, body=body)
status_code = self.get_status_code(resp)
if status_code in (httplib.OK,
httplib.CREATED,
httplib.ACCEPTED,
httplib.NO_CONTENT):
return self.deserialize(replybody, status_code)
else:
self._handle_fault_response(status_code, replybody)
def get_auth_info(self):
return self.httpclient.get_auth_info()
def get_status_code(self, response):
"""
Returns the integer status code from the response, which
can be either a Webob.Response (used in testing) or httplib.Response
"""
if hasattr(response, 'status_int'):
return response.status_int
else:
return response.status
def serialize(self, data):
"""
Serializes a dictionary with a single key (which can contain any
structure) into either xml or json
"""
if data is None:
return None
elif type(data) is dict:
return serializer.Serializer(
self.get_attr_metadata()).serialize(data, self.content_type())
else:
raise Exception("unable to serialize object of type = '%s'" %
type(data))
def deserialize(self, data, status_code):
"""
Deserializes an xml or json string into a dictionary
"""
if status_code == 204:
return data