summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-05-30 14:33:02 -0400
committerScott Moser <smoser@ubuntu.com>2014-05-30 14:33:02 -0400
commite0650257e1ef728304a0c7230c0a2d2710a8ac5f (patch)
tree0123a44aedc7007abb9d222e1d6f2006c88c89f5
parent910128e61aa3244e254d9c9c803436a5b9aef93c (diff)
parentf7fa9d2aa9abd81b8f8b79b95bdb1fc0c10b5fe9 (diff)
downloadvyos-cloud-init-e0650257e1ef728304a0c7230c0a2d2710a8ac5f.tar.gz
vyos-cloud-init-e0650257e1ef728304a0c7230c0a2d2710a8ac5f.zip
add vendordata support to cloudsigma datasource
LP: #1303986
-rw-r--r--ChangeLog1
-rw-r--r--cloudinit/sources/DataSourceCloudSigma.py2
-rw-r--r--tests/unittests/test_datasource/test_cloudsigma.py28
3 files changed, 30 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 74145ae1..2ff20c26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
0.7.6:
- open 0.7.6
+ - Enable vendordata on CloudSigma datasource (LP: #1303986)
0.7.5:
- open 0.7.5
- Add a debug log message around import failures
diff --git a/cloudinit/sources/DataSourceCloudSigma.py b/cloudinit/sources/DataSourceCloudSigma.py
index e1c7e566..ad2a044a 100644
--- a/cloudinit/sources/DataSourceCloudSigma.py
+++ b/cloudinit/sources/DataSourceCloudSigma.py
@@ -66,6 +66,8 @@ class DataSourceCloudSigma(sources.DataSource):
self.userdata_raw = server_meta.get('cloudinit-user-data', "")
if 'cloudinit-user-data' in base64_fields:
self.userdata_raw = b64decode(self.userdata_raw)
+ if 'cloudinit' in server_context.get('vendor_data', {}):
+ self.vendordata_raw = server_context["vendor_data"]["cloudinit"]
self.metadata = server_context
self.ssh_public_key = server_meta['ssh_public_key']
diff --git a/tests/unittests/test_datasource/test_cloudsigma.py b/tests/unittests/test_datasource/test_cloudsigma.py
index adbb4afb..a1342a86 100644
--- a/tests/unittests/test_datasource/test_cloudsigma.py
+++ b/tests/unittests/test_datasource/test_cloudsigma.py
@@ -20,7 +20,11 @@ SERVER_CONTEXT = {
"smp": 1,
"tags": ["much server", "very performance"],
"uuid": "65b2fb23-8c03-4187-a3ba-8b7c919e8890",
- "vnc_password": "9e84d6cb49e46379"
+ "vnc_password": "9e84d6cb49e46379",
+ "vendor_data": {
+ "location": "zrh",
+ "cloudinit": "#cloud-config\n\n...",
+ }
}
@@ -68,3 +72,25 @@ class DataSourceCloudSigmaTest(TestCase):
self.datasource.get_data()
self.assertEqual(self.datasource.userdata_raw, b'hi world\n')
+
+ def test_vendor_data(self):
+ self.assertEqual(self.datasource.vendordata_raw,
+ SERVER_CONTEXT['vendor_data']['cloudinit'])
+
+ def test_lack_of_vendor_data(self):
+ stripped_context = copy.deepcopy(SERVER_CONTEXT)
+ del stripped_context["vendor_data"]
+ self.datasource = DataSourceCloudSigma.DataSourceCloudSigma("", "", "")
+ self.datasource.cepko = CepkoMock(stripped_context)
+ self.datasource.get_data()
+
+ self.assertIsNone(self.datasource.vendordata_raw)
+
+ def test_lack_of_cloudinit_key_in_vendor_data(self):
+ stripped_context = copy.deepcopy(SERVER_CONTEXT)
+ del stripped_context["vendor_data"]["cloudinit"]
+ self.datasource = DataSourceCloudSigma.DataSourceCloudSigma("", "", "")
+ self.datasource.cepko = CepkoMock(stripped_context)
+ self.datasource.get_data()
+
+ self.assertIsNone(self.datasource.vendordata_raw)