Skip to content

Commit 3b69f41

Browse files
committed
DataSource: set ds_cfg to be a dictionary
if the Datasource does not have an entry in config, then set it to be a empty dictionary rather than None. Also remove places that did this elsewhere.
1 parent 0982415 commit 3b69f41

File tree

4 files changed

+3
-12
lines changed

4 files changed

+3
-12
lines changed

cloudinit/sources/DataSourceCloudStack.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ def __init__(self, sys_cfg, distro, paths):
8989

9090
def _get_url_settings(self):
9191
mcfg = self.ds_cfg
92-
if not mcfg:
93-
mcfg = {}
9492
max_wait = 120
9593
try:
9694
max_wait = int(mcfg.get("max_wait", max_wait))
@@ -109,10 +107,6 @@ def _get_url_settings(self):
109107
return (max_wait, timeout)
110108

111109
def wait_for_metadata_service(self):
112-
mcfg = self.ds_cfg
113-
if not mcfg:
114-
mcfg = {}
115-
116110
(max_wait, timeout) = self._get_url_settings()
117111

118112
urls = [uhelp.combine_url(self.metadata_address,

cloudinit/sources/DataSourceEc2.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ def get_instance_id(self):
8484

8585
def _get_url_settings(self):
8686
mcfg = self.ds_cfg
87-
if not mcfg:
88-
mcfg = {}
8987
max_wait = 120
9088
try:
9189
max_wait = int(mcfg.get("max_wait", max_wait))
@@ -102,8 +100,6 @@ def _get_url_settings(self):
102100

103101
def wait_for_metadata_service(self):
104102
mcfg = self.ds_cfg
105-
if not mcfg:
106-
mcfg = {}
107103

108104
(max_wait, timeout) = self._get_url_settings()
109105
if max_wait <= 0:

cloudinit/sources/DataSourceOpenStack.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ def __init__(self, sys_cfg, distro, paths):
4545
self.version = None
4646
self.files = {}
4747
self.ec2_metadata = None
48-
if not self.ds_cfg:
49-
self.ds_cfg = {}
5048

5149
def __str__(self):
5250
root = sources.DataSource.__str__(self)

cloudinit/sources/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ def __init__(self, sys_cfg, distro, paths, ud_proc=None):
7070

7171
self.ds_cfg = util.get_cfg_by_path(self.sys_cfg,
7272
("datasource", name), {})
73+
if not self.ds_cfg:
74+
self.ds_cfg = {}
75+
7376
if not ud_proc:
7477
self.ud_proc = ud.UserDataProcessor(self.paths)
7578
else:

0 commit comments

Comments
 (0)