diff options
author | Mike Gerdts <mike.gerdts@joyent.com> | 2018-04-20 20:56:36 -0400 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2018-04-20 20:56:36 -0400 |
commit | 23479881f51bae7a3f5743ce677ed82317ea8b9f (patch) | |
tree | da5c9a7e945ab0b1da57eeee31c9df5e25db04a3 /cloudinit | |
parent | 8e111502a0f9d437ff6045f1269c95e5756fc43b (diff) | |
download | vyos-cloud-init-23479881f51bae7a3f5743ce677ed82317ea8b9f.tar.gz vyos-cloud-init-23479881f51bae7a3f5743ce677ed82317ea8b9f.zip |
DataSourceSmartOS: sdc:hostname is ignored
There are three potential sources of the hostname, one of which is
documented SmartOS's vmadm(1M) via the hostname property. That
property's value is retrieved via the sdc:hostname key. The other
two sources for the hostname are a hostname key in customer_metadata
and the VM's uuid (sdc:uuid). Of these three, the sdc:hostname value
is not used in a meaningful way by DataSourceSmartOS.
This fix changes the fallback mechanism when hostname is not
specified in customer_metadata. The order of precedence for setting
the hostname is now 1) hostname in customer_metadata,
2) sdc:hostname, then 3) sdc:uuid.
LP: #1765085
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/sources/DataSourceSmartOS.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cloudinit/sources/DataSourceSmartOS.py b/cloudinit/sources/DataSourceSmartOS.py index d4386fec..0ef10035 100644 --- a/cloudinit/sources/DataSourceSmartOS.py +++ b/cloudinit/sources/DataSourceSmartOS.py @@ -11,7 +11,7 @@ # SmartOS hosts use a serial console (/dev/ttyS1) on KVM Linux Guests # The meta-data is transmitted via key/value pairs made by # requests on the console. For example, to get the hostname, you -# would send "GET hostname" on /dev/ttyS1. +# would send "GET sdc:hostname" on /dev/ttyS1. # For Linux Guests running in LX-Brand Zones on SmartOS hosts # a socket (/native/.zonecontrol/metadata.sock) is used instead # of a serial console. @@ -273,8 +273,14 @@ class DataSourceSmartOS(sources.DataSource): write_boot_content(u_data, u_data_f) # Handle the cloud-init regular meta + + # The hostname may or may not be qualified with the local domain name. + # This follows section 3.14 of RFC 2132. if not md['local-hostname']: - md['local-hostname'] = md['instance-id'] + if md['hostname']: + md['local-hostname'] = md['hostname'] + else: + md['local-hostname'] = md['instance-id'] ud = None if md['user-data']: |