handle user-data for metadata grains

This commit is contained in:
Daniel Wallace 2018-03-14 08:40:09 -06:00
parent 083846fe0e
commit 19bd1d9db5
No known key found for this signature in database
GPG key ID: 5FA5E5544F010D48

View file

@ -48,9 +48,11 @@ def _search(prefix="latest/"):
Recursively look up all grains in the metadata server
'''
ret = {}
linedata = http.query(os.path.join(HOST, prefix))
linedata = http.query(os.path.join(HOST, prefix), headers=True)
if 'body' not in linedata:
return ret
if linedata['headers'].get('Content-Type', 'text/plain') == 'application/octet-stream':
return linedata['body']
for line in linedata['body'].split('\n'):
if line.endswith('/'):
ret[line[:-1]] = _search(prefix=os.path.join(prefix, line))