summaryrefslogtreecommitdiff
path: root/tests/unittests/helpers.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2013-02-07 22:14:42 -0500
committerScott Moser <smoser@ubuntu.com>2013-02-07 22:14:42 -0500
commit174bc39e6b2c1cac3f73f67f25fad87cab16fa42 (patch)
treeb4782eae15b11eff4c6746a2e09135cd7f57c8b2 /tests/unittests/helpers.py
parentb7689728ead61366f3980272ae8212ba0b0225af (diff)
parenta0f882fdd306ef7b3b90c53d5622eb5a6878cb81 (diff)
downloadvyos-cloud-init-174bc39e6b2c1cac3f73f67f25fad87cab16fa42.tar.gz
vyos-cloud-init-174bc39e6b2c1cac3f73f67f25fad87cab16fa42.zip
DataSourceNoCloud: allow setting user-data and meta-data in config
This allows a single file to declare and activate this data source. This could come from: * cloud-config-url on kernel cmdline * /etc/cloud/cloud.cfg.d * debian preseed of 'cloud-init/local-cloud-config' Also here is * some tests * a small fix to parse_cmdline_data found when writing those tests. LP: #1115833
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r--tests/unittests/helpers.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py
index 4258a29d..91a50e18 100644
--- a/tests/unittests/helpers.py
+++ b/tests/unittests/helpers.py
@@ -182,3 +182,10 @@ class FilesystemMockingTestCase(ResourceUsingTestCase):
trap_func = retarget_many_wrapper(new_root, 1, func)
setattr(mod, f, trap_func)
self.patched_funcs.append((mod, f, func))
+
+def populate_dir(path, files):
+ os.makedirs(path)
+ for (name, content) in files.iteritems():
+ with open(os.path.join(path, name), "w") as fp:
+ fp.write(content)
+ fp.close()