summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2016-06-10 14:16:51 -0700
committerJoshua Harlow <harlowja@gmail.com>2016-06-10 14:16:51 -0700
commit6ada153ebfd9483d76f904dafaa1fc80f61c9205 (patch)
tree148f2f126032e0c8df83aabbfbe15246dd0cd973
parent30f1a6be14635aadf7c0c0b7071ddf947563a1b3 (diff)
downloadvyos-cloud-init-6ada153ebfd9483d76f904dafaa1fc80f61c9205.tar.gz
vyos-cloud-init-6ada153ebfd9483d76f904dafaa1fc80f61c9205.zip
Just mock 'on_first_boot' vs special argument
-rw-r--r--cloudinit/sources/DataSourceConfigDrive.py5
-rw-r--r--tests/unittests/test_datasource/test_configdrive.py11
2 files changed, 9 insertions, 7 deletions
diff --git a/cloudinit/sources/DataSourceConfigDrive.py b/cloudinit/sources/DataSourceConfigDrive.py
index cea08de2..3130e618 100644
--- a/cloudinit/sources/DataSourceConfigDrive.py
+++ b/cloudinit/sources/DataSourceConfigDrive.py
@@ -62,7 +62,7 @@ class DataSourceConfigDrive(openstack.SourceMixin, sources.DataSource):
mstr += "[source=%s]" % (self.source)
return mstr
- def get_data(self, skip_first_boot=False):
+ def get_data(self):
found = None
md = {}
results = {}
@@ -111,8 +111,7 @@ class DataSourceConfigDrive(openstack.SourceMixin, sources.DataSource):
# 'injected files' and apply legacy ENI network format.
prev_iid = get_previous_iid(self.paths)
cur_iid = md['instance-id']
- if (prev_iid != cur_iid and self.dsmode == sources.DSMODE_PASS
- and not skip_first_boot):
+ if prev_iid != cur_iid and self.dsmode == sources.DSMODE_PASS:
on_first_boot(results, distro=self.distro)
LOG.debug("%s: not claiming datasource, dsmode=%s", self,
self.dsmode)
diff --git a/tests/unittests/test_datasource/test_configdrive.py b/tests/unittests/test_datasource/test_configdrive.py
index b898e2bd..18551b92 100644
--- a/tests/unittests/test_datasource/test_configdrive.py
+++ b/tests/unittests/test_datasource/test_configdrive.py
@@ -370,7 +370,8 @@ class TestConfigDriveDataSource(TestCase):
util.find_devs_with = orig_find_devs_with
util.is_partition = orig_is_partition
- def test_pubkeys_v2(self):
+ @mock.patch('cloudinit.sources.DataSourceConfigDrive.on_first_boot')
+ def test_pubkeys_v2(self, on_first_boot):
"""Verify that public-keys work in config-drive-v2."""
populate_dir(self.tmp, CFG_DRIVE_FILES_V2)
myds = cfg_ds_from_dir(self.tmp)
@@ -385,13 +386,15 @@ class TestNetJson(TestCase):
self.addCleanup(shutil.rmtree, self.tmp)
self.maxDiff = None
- def test_network_data_is_found(self):
+ @mock.patch('cloudinit.sources.DataSourceConfigDrive.on_first_boot')
+ def test_network_data_is_found(self, on_first_boot):
"""Verify that network_data is present in ds in config-drive-v2."""
populate_dir(self.tmp, CFG_DRIVE_FILES_V2)
myds = cfg_ds_from_dir(self.tmp)
self.assertIsNotNone(myds.network_json)
- def test_network_config_is_converted(self):
+ @mock.patch('cloudinit.sources.DataSourceConfigDrive.on_first_boot')
+ def test_network_config_is_converted(self, on_first_boot):
"""Verify that network_data is converted and present on ds object."""
populate_dir(self.tmp, CFG_DRIVE_FILES_V2)
myds = cfg_ds_from_dir(self.tmp)
@@ -558,7 +561,7 @@ def cfg_ds_from_dir(seed_d):
helpers.Paths({}))
cfg_ds.seed_dir = seed_d
cfg_ds.known_macs = KNOWN_MACS.copy()
- if not cfg_ds.get_data(skip_first_boot=True):
+ if not cfg_ds.get_data():
raise RuntimeError("Data source did not extract itself from"
" seed directory %s" % seed_d)
return cfg_ds