diff options
Diffstat (limited to 'cloudinit/sources/__init__.py')
-rw-r--r-- | cloudinit/sources/__init__.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index 96baff90..f98493de 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -139,7 +139,7 @@ class DataSource(object): return "iid-datasource" return str(self.metadata['instance-id']) - def get_hostname(self, fqdn=False): + def get_hostname(self, fqdn=False, resolve_ip=False): defdomain = "localdomain" defhost = "localhost" domain = defdomain @@ -163,7 +163,18 @@ class DataSource(object): # make up a hostname (LP: #475354) in format ip-xx.xx.xx.xx lhost = self.metadata['local-hostname'] if util.is_ipv4(lhost): +<<<<<<< TREE + toks = [] + if resolve_ip: + toks = util.gethostbyaddr(lhost) + + if toks: + toks = toks.split('.') + else: + toks = ["ip-%s" % lhost.replace(".", "-")] +======= toks = ["ip-%s" % lhost.replace(".", "-")] +>>>>>>> MERGE-SOURCE else: toks = lhost.split(".") |