From ab1b27294ce852a5d67b230971a1c28c99940e50 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 4 Oct 2012 17:32:26 -0700 Subject: Ensure that for config drive that we map 'hostname' to 'local-hostname' so that the modules work correctly with the cfgdrive style of data. --- cloudinit/sources/DataSourceConfigDrive.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) -- cgit v1.2.3