← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~kiril-vladimiroff/cloud-init/cloudsigma-vendordata into lp:cloud-init

 

Kiril Vladimiroff has proposed merging lp:~kiril-vladimiroff/cloud-init/cloudsigma-vendordata into lp:cloud-init.

Commit message:
Handle vendor data properly in the CloudSigma Datasource

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~kiril-vladimiroff/cloud-init/cloudsigma-vendordata/+merge/214763

Fixes Bug #1303986
-- 
https://code.launchpad.net/~kiril-vladimiroff/cloud-init/cloudsigma-vendordata/+merge/214763
Your team cloud init development team is requested to review the proposed merge of lp:~kiril-vladimiroff/cloud-init/cloudsigma-vendordata into lp:cloud-init.
=== modified file 'cloudinit/sources/DataSourceCloudSigma.py'
--- cloudinit/sources/DataSourceCloudSigma.py	2014-03-04 17:11:10 +0000
+++ cloudinit/sources/DataSourceCloudSigma.py	2014-04-08 13:49:14 +0000
@@ -66,6 +66,8 @@
         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']

=== modified file 'tests/unittests/test_datasource/test_cloudsigma.py'
--- tests/unittests/test_datasource/test_cloudsigma.py	2014-02-19 08:45:53 +0000
+++ tests/unittests/test_datasource/test_cloudsigma.py	2014-04-08 13:49:14 +0000
@@ -20,7 +20,11 @@
     "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 @@
         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)


Follow ups