summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-10-04 17:32:26 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-10-04 17:32:26 -0700
commitab1b27294ce852a5d67b230971a1c28c99940e50 (patch)
treea7b3ccf258011a8a7f197207c2ed7310c49f6307
parentf8b23b39bdf8753986df9ecf5948ffd8e8fdee74 (diff)
downloadvyos-cloud-init-ab1b27294ce852a5d67b230971a1c28c99940e50.tar.gz
vyos-cloud-init-ab1b27294ce852a5d67b230971a1c28c99940e50.zip
Ensure that for config drive that
we map 'hostname' to 'local-hostname' so that the modules work correctly with the cfgdrive style of data.
-rw-r--r--cloudinit/sources/DataSourceConfigDrive.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceConfigDrive.py b/cloudinit/sources/DataSourceConfigDrive.py
index b8154367..b1cf942e 100644
--- a/cloudinit/sources/DataSourceConfigDrive.py
+++ b/cloudinit/sources/DataSourceConfigDrive.py
@@ -85,6 +85,16 @@ class DataSourceConfigDrive(sources.DataSource):
md = results['metadata']
md = util.mergedict(md, DEFAULT_METADATA)
+ # Perform some metadata 'fixups'
+ #
+ # OpenStack uses the 'hostname' key
+ # while most of cloud-init uses the metadata
+ # 'local-hostname' key instead so if it doesn't
+ # exist we need to make sure its copied over.
+ for (tgt, src) in [('local-hostname', 'hostname')]:
+ if tgt not in md and src in md:
+ md[tgt] = md[src]
+
user_dsmode = results.get('dsmode', None)
if user_dsmode not in VALID_DSMODES + (None,):
LOG.warn("user specified invalid mode: %s" % user_dsmode)