Merge lp:~kiril-vladimiroff/cloud-init/cloudsigma-vendordata into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Kiril Vladimiroff
Status: Rejected
Rejected by: Scott Moser
Proposed branch: lp:~kiril-vladimiroff/cloud-init/cloudsigma-vendordata
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 55 lines (+29/-1)
2 files modified
cloudinit/sources/DataSourceCloudSigma.py (+2/-0)
tests/unittests/test_datasource/test_cloudsigma.py (+27/-1)
To merge this branch: bzr merge lp:~kiril-vladimiroff/cloud-init/cloudsigma-vendordata
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+214763@code.launchpad.net

Commit message

Handle vendor data properly in the CloudSigma Datasource

Description of the change

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

My only comment is 'vendor_data' versus 'vendor-data'.
The other key here is 'cloudinit-user-data' (using '-' rather than '_').

inconsistency seems non-ideal unless theres something i'm missing.

Revision history for this message
Kiril Vladimiroff (kiril-vladimiroff) wrote :

Well, all of our keys in the server context are using the `snake_case` convention. Basically the `cloudinit-user-data` was the only exception, based on the fact that it's in the meta fields and these fields are managed entirely by our users (so we can't force conventions there). The vendor_data field is not in the meta, users don't have control over it and I prefer to follow our `snake_case` convention there.

Best case scenario for me would be to change `cloudinit-user-data` to `cloudinit_user_data`, though.

Revision history for this message
Joshua Harlow (harlowja) wrote :

Seems all fixed up to me :)

Revision history for this message
Kiril Vladimiroff (kiril-vladimiroff) wrote :

> Seems all fixed up to me :)

Great. Then I guess we can move on to merging this :)

Revision history for this message
Scott Moser (smoser) wrote :

Hi,
A *long* wait on replying to this, sorry.
Is this still useful ? I surely should have pulled it two years ago, and I can pull it now if it is useful.

Revision history for this message
Scott Moser (smoser) wrote :

Oh, and the other thing is that the convention has kind of changed for reading vendor data, you can use
 self.vendordata_raw = sources.convert_vendordata(server_context["vendor_data"])

and it should do the right thing now.

Revision history for this message
Scott Moser (smoser) wrote :

Hello,
Thank you for taking the time to contribute to cloud-init. Cloud-init has moved its revision control system to git. As a result, we are marking all bzr merge proposals as 'rejected'. If you would like to re-submit this proposal for review, please do so by following the current HACKING documentation at http://cloudinit.readthedocs.io/en/latest/topics/hacking.html .

Kiril,
Thanks for this and other contributions to cloud-init. Please do resubmit.

Unmerged revisions

972. By Kiril Vladimiroff

Add support for vendor-data in the CloudSigma Datasource

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/sources/DataSourceCloudSigma.py'
2--- cloudinit/sources/DataSourceCloudSigma.py 2014-03-04 17:11:10 +0000
3+++ cloudinit/sources/DataSourceCloudSigma.py 2014-04-08 13:49:14 +0000
4@@ -66,6 +66,8 @@
5 self.userdata_raw = server_meta.get('cloudinit-user-data', "")
6 if 'cloudinit-user-data' in base64_fields:
7 self.userdata_raw = b64decode(self.userdata_raw)
8+ if 'cloudinit' in server_context.get('vendor_data', {}):
9+ self.vendordata_raw = server_context["vendor_data"]["cloudinit"]
10
11 self.metadata = server_context
12 self.ssh_public_key = server_meta['ssh_public_key']
13
14=== modified file 'tests/unittests/test_datasource/test_cloudsigma.py'
15--- tests/unittests/test_datasource/test_cloudsigma.py 2014-02-19 08:45:53 +0000
16+++ tests/unittests/test_datasource/test_cloudsigma.py 2014-04-08 13:49:14 +0000
17@@ -20,7 +20,11 @@
18 "smp": 1,
19 "tags": ["much server", "very performance"],
20 "uuid": "65b2fb23-8c03-4187-a3ba-8b7c919e8890",
21- "vnc_password": "9e84d6cb49e46379"
22+ "vnc_password": "9e84d6cb49e46379",
23+ "vendor_data": {
24+ "location": "zrh",
25+ "cloudinit": "#cloud-config\n\n...",
26+ }
27 }
28
29
30@@ -68,3 +72,25 @@
31 self.datasource.get_data()
32
33 self.assertEqual(self.datasource.userdata_raw, b'hi world\n')
34+
35+ def test_vendor_data(self):
36+ self.assertEqual(self.datasource.vendordata_raw,
37+ SERVER_CONTEXT['vendor_data']['cloudinit'])
38+
39+ def test_lack_of_vendor_data(self):
40+ stripped_context = copy.deepcopy(SERVER_CONTEXT)
41+ del stripped_context["vendor_data"]
42+ self.datasource = DataSourceCloudSigma.DataSourceCloudSigma("", "", "")
43+ self.datasource.cepko = CepkoMock(stripped_context)
44+ self.datasource.get_data()
45+
46+ self.assertIsNone(self.datasource.vendordata_raw)
47+
48+ def test_lack_of_cloudinit_key_in_vendor_data(self):
49+ stripped_context = copy.deepcopy(SERVER_CONTEXT)
50+ del stripped_context["vendor_data"]["cloudinit"]
51+ self.datasource = DataSourceCloudSigma.DataSourceCloudSigma("", "", "")
52+ self.datasource.cepko = CepkoMock(stripped_context)
53+ self.datasource.get_data()
54+
55+ self.assertIsNone(self.datasource.vendordata_raw)