summaryrefslogtreecommitdiff
path: root/cloudinit/sources
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-10-14 20:27:07 -0400
committerScott Moser <smoser@ubuntu.com>2015-10-14 20:27:07 -0400
commit4968547752a9f06d49d18f0797ed01c968675252 (patch)
treeea0a1812eeb954540df32d061aceff821388d934 /cloudinit/sources
parent7dab50a3ec98ddb93931cb5d7041c54c78581ede (diff)
parent92ceca45c5d2983742ce18d2e8b2e671629ef4b0 (diff)
downloadvyos-cloud-init-4968547752a9f06d49d18f0797ed01c968675252.tar.gz
vyos-cloud-init-4968547752a9f06d49d18f0797ed01c968675252.zip
azure: support extracting SSH key values from ovf-env.xml
Azure has or will be offering shortly the ability to directly define the SSH key value instead of a fingerprint in the ovf-env.xml file. This patch favors defined SSH keys over the fingerprint method (LP: #1506244).
Diffstat (limited to 'cloudinit/sources')
-rw-r--r--cloudinit/sources/DataSourceAzure.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index ff950deb..c6228e6c 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -148,9 +148,15 @@ class DataSourceAzureNet(sources.DataSource):
wait_for = [shcfgxml]
fp_files = []
+ key_value = None
for pk in self.cfg.get('_pubkeys', []):
- bname = str(pk['fingerprint'] + ".crt")
- fp_files += [os.path.join(ddir, bname)]
+ if pk.get('value', None):
+ key_value = pk['value']
+ LOG.debug("ssh authentication: using value from fabric")
+ else:
+ bname = str(pk['fingerprint'] + ".crt")
+ fp_files += [os.path.join(ddir, bname)]
+ LOG.debug("ssh authentication: using fingerprint from fabirc")
missing = util.log_time(logfunc=LOG.debug, msg="waiting for files",
func=wait_for_files,
@@ -166,7 +172,8 @@ class DataSourceAzureNet(sources.DataSource):
metadata['instance-id'] = iid_from_shared_config(shcfgxml)
except ValueError as e:
LOG.warn("failed to get instance id in %s: %s", shcfgxml, e)
- metadata['public-keys'] = pubkeys_from_crt_files(fp_files)
+
+ metadata['public-keys'] = key_value or pubkeys_from_crt_files(fp_files)
return metadata
def get_data(self):
@@ -497,7 +504,8 @@ def load_azure_ovf_pubkeys(sshnode):
for pk_node in pubkeys:
if not pk_node.hasChildNodes():
continue
- cur = {'fingerprint': "", 'path': ""}
+
+ cur = {'fingerprint': "", 'path': "", 'value': ""}
for child in pk_node.childNodes:
if child.nodeType == text_node or not child.localName:
continue