fix ec2 cloud provider for endpoint URLs with paths

This commit is contained in:
Grischa Meyer 2014-12-18 17:31:30 +11:00
parent e7d95eed5a
commit e471e37e43

View File

@ -314,8 +314,11 @@ def query(params=None, setname=None, requesturl=None, location=None,
) )
requesturl = 'https://{0}/'.format(endpoint) requesturl = 'https://{0}/'.format(endpoint)
endpoint = urlparse.urlparse(requesturl).netloc
endpoint_path = urlparse.urlparse(requesturl).path
else: else:
endpoint = _urlparse(requesturl).netloc endpoint = _urlparse(requesturl).netloc
endpoint_path = urlparse.urlparse(requesturl).path
if endpoint == '': if endpoint == '':
endpoint_err = ( endpoint_err = (
'Could not find a valid endpoint in the ' 'Could not find a valid endpoint in the '
@ -347,8 +350,9 @@ def query(params=None, setname=None, requesturl=None, location=None,
# %20, however urlencode uses '+'. So replace pluses with %20. # %20, however urlencode uses '+'. So replace pluses with %20.
querystring = querystring.replace('+', '%20') querystring = querystring.replace('+', '%20')
uri = '{0}\n{1}\n/\n{2}'.format(method.encode('utf-8'), uri = '{0}\n{1}\n{2}\n{3}'.format(method.encode('utf-8'),
endpoint.encode('utf-8'), endpoint.encode('utf-8'),
endpoint_path.encode('utf-8'),
querystring.encode('utf-8')) querystring.encode('utf-8'))
hashed = hmac.new(provider['key'], uri, hashlib.sha256) hashed = hmac.new(provider['key'], uri, hashlib.sha256)