Merge "Support alternate 'public-keys' format for NoCloud service."
This commit is contained in:
commit
1adf31b1c9
@ -307,6 +307,9 @@ class NoCloudConfigDriveService(baseconfigdrive.BaseConfigDriveService):
|
||||
if not raw_ssh_keys:
|
||||
return []
|
||||
|
||||
if isinstance(raw_ssh_keys, list):
|
||||
return raw_ssh_keys
|
||||
|
||||
return [raw_ssh_keys[key].get('openssh-key') for key in raw_ssh_keys]
|
||||
|
||||
def get_network_details(self):
|
||||
|
@ -247,6 +247,16 @@ class TestNoCloudConfigDriveService(unittest.TestCase):
|
||||
result = self._config_drive.get_public_keys()
|
||||
self.assertEqual(result, expected_result)
|
||||
|
||||
@mock.patch(MODULE_PATH + '.NoCloudConfigDriveService._get_meta_data')
|
||||
def test_get_public_keys_alt_fmt(self, mock_get_metadata):
|
||||
fake_key = 'fake key'
|
||||
expected_result = [fake_key]
|
||||
mock_get_metadata.return_value = {
|
||||
'public-keys': [fake_key]
|
||||
}
|
||||
result = self._config_drive.get_public_keys()
|
||||
self.assertEqual(result, expected_result)
|
||||
|
||||
@ddt.data(('', ('V2 network metadata is empty', None)),
|
||||
('1', ('V2 network metadata is not a dictionary', None)),
|
||||
('{}', ('V2 network metadata is empty', None)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user