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,
)
result.raise_for_status()
role = result.text.encode(
result.encoding if result.encoding else 'utf-8'
)
role = result.text
except (requests.exceptions.HTTPError, requests.exceptions.ConnectionError):
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.trace(
'AWS Response Text: %s',
result.text.encode(result.encoding if result.encoding else 'utf-8')
result.text
)
result.raise_for_status()
break
@ -488,11 +486,7 @@ def query(params=None, setname=None, requesturl=None, location=None,
return {'error': data}, requesturl
return {'error': data}
response = result.text.encode(
result.encoding if result.encoding else 'utf-8'
)
root = ET.fromstring(response)
root = ET.fromstring(result.text)
items = root[1]
if return_root is True:
items = root