Sync with heat-jeos commit 13f183e

This commit is contained in:
Steve Baker 2013-02-21 11:11:55 +13:00
parent e65198dde8
commit 33210832b5

View File

@ -816,19 +816,27 @@ class ConfigsetsHandler(object):
return executionlist return executionlist
def metadata_server_port(): def metadata_server_port(datafile='/var/lib/cloud/data/cfn-metadata-server'):
""" """
Return the the metadata server port Return the the metadata server port
reads the :NNNN from the end of the URL in cfn-metadata-server reads the :NNNN from the end of the URL in cfn-metadata-server
""" """
try: try:
f = open("/var/lib/cloud/data/cfn-metadata-server") f = open(datafile)
server_url = f.read().strip() server_url = f.read().strip()
f.close() f.close()
if not server_url[-1] == '/': except IOError:
server_url += '/' return None
if len(server_url) < 1:
return None
if server_url[-1] == '/':
server_url = server_url[:-1]
try:
return int(server_url.split(':')[-1]) return int(server_url.split(':')[-1])
except: except ValueError:
return None return None