Merge pull request #47879 from dwoz/ami_role_fix

Fix ami role usage warts #47269
This commit is contained in:
Daniel Wallace 2018-06-01 09:11:55 -05:00 committed by GitHub
commit b88ec5258d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,9 +89,7 @@ def creds(provider):
proxies={'http': ''}, timeout=AWS_METADATA_TIMEOUT, proxies={'http': ''}, timeout=AWS_METADATA_TIMEOUT,
) )
result.raise_for_status() result.raise_for_status()
role = result.text.encode( role = result.text
result.encoding if result.encoding else 'utf-8'
)
except (requests.exceptions.HTTPError, requests.exceptions.ConnectionError): except (requests.exceptions.HTTPError, requests.exceptions.ConnectionError):
return provider['id'], provider['key'], '' return provider['id'], provider['key'], ''
@ -451,7 +449,7 @@ def query(params=None, setname=None, requesturl=None, location=None,
log.debug('AWS Response Status Code: %s', result.status_code) log.debug('AWS Response Status Code: %s', result.status_code)
log.trace( log.trace(
'AWS Response Text: %s', 'AWS Response Text: %s',
result.text.encode(result.encoding if result.encoding else 'utf-8') result.text
) )
result.raise_for_status() result.raise_for_status()
break break
@ -488,11 +486,7 @@ def query(params=None, setname=None, requesturl=None, location=None,
return {'error': data}, requesturl return {'error': data}, requesturl
return {'error': data} return {'error': data}
response = result.text.encode( root = ET.fromstring(result.text)
result.encoding if result.encoding else 'utf-8'
)
root = ET.fromstring(response)
items = root[1] items = root[1]
if return_root is True: if return_root is True:
items = root items = root