add vendordata support to cloudsigma datasource
This commit is contained in:
commit
f4d8832ae4
@ -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
|
||||
|
@ -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']
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user