diff options
author | Chad Smith <chad.smith@canonical.com> | 2018-03-14 23:38:07 -0600 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2018-03-14 23:38:07 -0600 |
commit | 133ad2cb327ad17b7b81319fac8f9f14577c04df (patch) | |
tree | ca14c7c958537e00f1c7ce93405eb77cee85b81e /cloudinit/cloud.py | |
parent | 76460b63f9c310c7de4e5f0c11d1525bedd277e1 (diff) | |
download | vyos-cloud-init-133ad2cb327ad17b7b81319fac8f9f14577c04df.tar.gz vyos-cloud-init-133ad2cb327ad17b7b81319fac8f9f14577c04df.zip |
set_hostname: When present in metadata, set it before network bringup.
When instance meta-data provides hostname information, run
cc_set_hostname in the init-local or init-net stage before network
comes up.
Prevent an initial DHCP request which leaks the stock cloud-image default
hostname before the meta-data provided hostname was processed.
A leaked cloud-image hostname adversely affects Dynamic DNS which
would reallocate 'ubuntu' hostname in DNS to every instance brought up by
cloud-init. These instances would only update DNS to the cloud-init
configured hostname upon DHCP lease renewal.
This branch extends the get_hostname methods in datasource, cloud and
util to limit results to metadata_only to avoid extra cost of querying
the distro for hostname information if metadata does not provide that
information.
LP: #1746455
Diffstat (limited to 'cloudinit/cloud.py')
-rw-r--r-- | cloudinit/cloud.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cloudinit/cloud.py b/cloudinit/cloud.py index ba616781..6d12c437 100644 --- a/cloudinit/cloud.py +++ b/cloudinit/cloud.py @@ -78,8 +78,9 @@ class Cloud(object): def get_locale(self): return self.datasource.get_locale() - def get_hostname(self, fqdn=False): - return self.datasource.get_hostname(fqdn=fqdn) + def get_hostname(self, fqdn=False, metadata_only=False): + return self.datasource.get_hostname( + fqdn=fqdn, metadata_only=metadata_only) def device_name_to_device(self, name): return self.datasource.device_name_to_device(name) |