diff options
author | Ben Howard <ben.howard@canonical.com> | 2013-09-11 14:56:36 -0600 |
---|---|---|
committer | Ben Howard <ben.howard@canonical.com> | 2013-09-11 14:56:36 -0600 |
commit | 23f7b8a39bb197db557bdcf851639ea4111b7786 (patch) | |
tree | 9f1a5501fd1f9c0d4b32b597b09ae19ceaab9ef6 /cloudinit/sources/__init__.py | |
parent | 1979ea3e3440335632af8e7e58dd34aae52a2b96 (diff) | |
parent | 6b122985da19c08ea50a25226c726f2982680efb (diff) | |
download | vyos-cloud-init-23f7b8a39bb197db557bdcf851639ea4111b7786.tar.gz vyos-cloud-init-23f7b8a39bb197db557bdcf851639ea4111b7786.zip |
Merged in upstream changes with disk partition support
Diffstat (limited to 'cloudinit/sources/__init__.py')
-rw-r--r-- | cloudinit/sources/__init__.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index 974c0407..7dc1fbde 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -53,9 +53,16 @@ class DataSource(object): self.userdata = None self.metadata = None self.userdata_raw = None + + # find the datasource config name. + # remove 'DataSource' from classname on front, and remove 'Net' on end. + # Both Foo and FooNet sources expect config in cfg['sources']['Foo'] name = type_utils.obj_name(self) if name.startswith(DS_PREFIX): name = name[len(DS_PREFIX):] + if name.endswith('Net'): + name = name[0:-3] + self.ds_cfg = util.get_cfg_by_path(self.sys_cfg, ("datasource", name), {}) if not ud_proc: @@ -144,7 +151,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 @@ -168,7 +175,14 @@ 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): - toks = ["ip-%s" % lhost.replace(".", "-")] + toks = [] + if resolve_ip: + toks = util.gethostbyaddr(lhost) + + if toks: + toks = str(toks).split('.') + else: + toks = ["ip-%s" % lhost.replace(".", "-")] else: toks = lhost.split(".") |