diff options
author | Ryan Harper <ryan.harper@canonical.com> | 2016-05-26 21:17:29 -0500 |
---|---|---|
committer | Ryan Harper <ryan.harper@canonical.com> | 2016-05-26 21:17:29 -0500 |
commit | c1c1550d74d067d78cf4ba1cf64f38c2dae8c9e1 (patch) | |
tree | 8725465ffa453e36918db345bc391258a00b68a5 /cloudinit/sources/DataSourceSmartOS.py | |
parent | 22bd075cd77ccc1021e049333f498afd56de2c6a (diff) | |
download | vyos-cloud-init-c1c1550d74d067d78cf4ba1cf64f38c2dae8c9e1.tar.gz vyos-cloud-init-c1c1550d74d067d78cf4ba1cf64f38c2dae8c9e1.zip |
Move sdc:nics to a JSON map. Add unittest for sdc:nics
Diffstat (limited to 'cloudinit/sources/DataSourceSmartOS.py')
-rw-r--r-- | cloudinit/sources/DataSourceSmartOS.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/cloudinit/sources/DataSourceSmartOS.py b/cloudinit/sources/DataSourceSmartOS.py index 6355fc2a..35fa8c33 100644 --- a/cloudinit/sources/DataSourceSmartOS.py +++ b/cloudinit/sources/DataSourceSmartOS.py @@ -64,7 +64,11 @@ SMARTOS_ATTRIB_MAP = { 'availability_zone': ('sdc:datacenter_name', True), 'vendor-data': ('sdc:vendor-data', False), 'operator-script': ('sdc:operator-script', False), - 'network-data': ('sdc:nics', False), +} + +SMARTOS_ATTRIB_JSON = { + # Cloud-init Key : (SmartOS Key known JSON) + 'network-data': 'sdc:nics', } DS_NAME = 'SmartOS' @@ -233,6 +237,9 @@ class DataSourceSmartOS(sources.DataSource): smartos_noun, strip = attribute md[ci_noun] = self.md_client.get(smartos_noun, strip=strip) + for ci_noun, smartos_noun in SMARTOS_ATTRIB_JSON.items(): + md[ci_noun] = self.md_client.get_json(smartos_noun) + # @datadictionary: This key may contain a program that is written # to a file in the filesystem of the guest on each boot and then # executed. It may be of any format that would be considered @@ -281,11 +288,7 @@ class DataSourceSmartOS(sources.DataSource): self.metadata = util.mergemanydict([md, self.metadata]) self.userdata_raw = ud self.vendordata_raw = md['vendor-data'] - if not md['network-data']: - smartos_noun, strip = SMARTOS_ATTRIB_MAP.get('network-data') - self.network_data = self.md_client.get_json(smartos_noun, - strip=strip) - md['network-data'] = self.network_data + self.network_data = md['network-data'] self._set_provisioned() return True @@ -401,8 +404,8 @@ class JoyentMetadataClient(object): result = result.strip() return result - def get_json(self, key, default=None, strip=False): - result = self.get(key, default=default, strip=strip) + def get_json(self, key, default=None): + result = self.get(key, default=default) if result is None: return default return json.loads(result) |