From 6a20a7f0b2a65626c997d0f9264aa293cf4d21f0 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 27 Jun 2016 16:18:25 -0400 Subject: fix restoring from a datasource that did not have dsmode On upgrade and reboot, if datasource restored from obj.pkl did not have a dsmode attribute, then 'init --local' would fail due to stack trace. LP: #1596690 --- cloudinit/sources/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cloudinit/sources') diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index 2a6b8d90..87b8e524 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -55,6 +55,8 @@ class DataSourceNotFoundException(Exception): @six.add_metaclass(abc.ABCMeta) class DataSource(object): + dsmode = DSMODE_NETWORK + def __init__(self, sys_cfg, distro, paths, ud_proc=None): self.sys_cfg = sys_cfg self.distro = distro @@ -64,7 +66,6 @@ class DataSource(object): self.userdata_raw = None self.vendordata = None self.vendordata_raw = None - self.dsmode = DSMODE_NETWORK # find the datasource config name. # remove 'DataSource' from classname on front, and remove 'Net' on end. -- cgit v1.2.3 From 78a85240aac5b252bae4108514681bed7340c034 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 13 Jul 2016 14:54:56 -0700 Subject: Remove another stray dict comprehension --- cloudinit/sources/helpers/openstack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cloudinit/sources') diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py index d52cb56a..2d001061 100644 --- a/cloudinit/sources/helpers/openstack.py +++ b/cloudinit/sources/helpers/openstack.py @@ -542,8 +542,8 @@ def convert_net_json(network_json=None, known_macs=None): config = [] for link in links: subnets = [] - cfg = {k: v for k, v in link.items() - if k in valid_keys['physical']} + cfg = dict((k, v) for k, v in link.items() + if k in valid_keys['physical']) # 'name' is not in openstack spec yet, but we will support it if it is # present. The 'id' in the spec is currently implemented as the host # nic's name, meaning something like 'tap-adfasdffd'. We do not want -- cgit v1.2.3 From f5ea273e36615cfbbe8f35b3963935e75e22c4a1 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 13 Jul 2016 15:04:07 -0700 Subject: Another stray occurence of a dict comprehension being removed --- cloudinit/sources/helpers/openstack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cloudinit/sources') diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py index 2d001061..2e7a1d47 100644 --- a/cloudinit/sources/helpers/openstack.py +++ b/cloudinit/sources/helpers/openstack.py @@ -553,8 +553,8 @@ def convert_net_json(network_json=None, known_macs=None): for network in [n for n in networks if n['link'] == link['id']]: - subnet = {k: v for k, v in network.items() - if k in valid_keys['subnet']} + subnet = dict((k, v) for k, v in network.items() + if k in valid_keys['subnet']) if 'dhcp' in network['type']: t = 'dhcp6' if network['type'].startswith('ipv6') else 'dhcp4' subnet.update({ -- cgit v1.2.3 From 333eea5105956c978043579a49d935af6d3ceff2 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 13 Jul 2016 15:18:46 -0700 Subject: Fix SmartOS datasource usage of dict comprehensions --- cloudinit/sources/DataSourceSmartOS.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cloudinit/sources') diff --git a/cloudinit/sources/DataSourceSmartOS.py b/cloudinit/sources/DataSourceSmartOS.py index 08bc132b..ccc86883 100644 --- a/cloudinit/sources/DataSourceSmartOS.py +++ b/cloudinit/sources/DataSourceSmartOS.py @@ -718,8 +718,8 @@ def convert_smartos_network_data(network_data=None): config = [] for nic in network_data: - cfg = {k: v for k, v in nic.items() - if k in valid_keys['physical']} + cfg = dict((k, v) for k, v in nic.items() + if k in valid_keys['physical']) cfg.update({ 'type': 'physical', 'name': nic['interface']}) @@ -728,8 +728,8 @@ def convert_smartos_network_data(network_data=None): subnets = [] for ip, gw in zip(nic['ips'], nic['gateways']): - subnet = {k: v for k, v in nic.items() - if k in valid_keys['subnet']} + subnet = dict((k, v) for k, v in nic.items() + if k in valid_keys['subnet']) subnet.update({ 'type': 'static', 'address': ip, -- cgit v1.2.3