Skip to content

Commit

Permalink
Merge "handles empty dhcp_domain with hostname in metadata" into stab…
Browse files Browse the repository at this point in the history
…le/folsom
  • Loading branch information
Jenkins authored and openstack-gerrit committed Nov 4, 2012
2 parents e76848a + 8b4896b commit 3d418dc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions nova/api/metadata/base.py
Expand Up @@ -163,7 +163,8 @@ def get_ec2_metadata(self, version):
if version not in VERSIONS:
raise InvalidMetadataVersion(version)

hostname = "%s.%s" % (self.instance['hostname'], FLAGS.dhcp_domain)
hostname = self._get_hostname()

floating_ips = self.ip_info['floating_ips']
floating_ip = floating_ips and floating_ips[0] or ''

Expand Down Expand Up @@ -290,8 +291,7 @@ def get_openstack_item(self, path_tokens):
self.instance['key_name']: self.instance['key_data']
}

metadata['hostname'] = "%s.%s" % (self.instance['hostname'],
FLAGS.dhcp_domain)
metadata['hostname'] = self._get_hostname()

metadata['name'] = self.instance['display_name']
metadata['launch_index'] = self.instance['launch_index']
Expand All @@ -306,6 +306,11 @@ def get_openstack_item(self, path_tokens):
def _check_version(self, required, requested):
return VERSIONS.index(requested) >= VERSIONS.index(required)

def _get_hostname(self):
return "%s%s%s" % (self.instance['hostname'],
'.' if FLAGS.dhcp_domain else '',
FLAGS.dhcp_domain)

def lookup(self, path):
if path == "" or path[0] != "/":
path = os.path.normpath("/" + path)
Expand Down

0 comments on commit 3d418dc

Please sign in to comment.