diff options
author | Scott Moser <smoser@ubuntu.com> | 2013-07-09 20:20:55 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2013-07-09 20:20:55 -0400 |
commit | 950762bb008d25f529c71aae4c0b04f6b0134abb (patch) | |
tree | 17c4e6996df55786db7ac8b3b8c0aaf37f261a3b /cloudinit/sources | |
parent | 4368b264be42472c53bc3333587c7029373ad56a (diff) | |
download | vyos-cloud-init-950762bb008d25f529c71aae4c0b04f6b0134abb.tar.gz vyos-cloud-init-950762bb008d25f529c71aae4c0b04f6b0134abb.zip |
fill out load_azure_ovf_pubkeys
now if there are pubkeys, the cfg['_pubkeys'] entry
will have a list of dicts where each dict has 'fingerprint' and 'path'
entries.
The next thing to do is to block waiting for the <fingerprint>.crt
files to appear in /var/lib/waagent.
Diffstat (limited to 'cloudinit/sources')
-rw-r--r-- | cloudinit/sources/DataSourceAzure.py | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py index d8e39392..43a963ad 100644 --- a/cloudinit/sources/DataSourceAzure.py +++ b/cloudinit/sources/DataSourceAzure.py @@ -146,7 +146,7 @@ def find_child(node, filter_func): return ret -def load_azure_ovf_pubkeys(_sshnode): +def load_azure_ovf_pubkeys(sshnode): # in the future this would return a list of dicts like: # [{'fp': '6BE7A7C3C8A8F4B123CCA5D0C2F1BE4CA7B63ED7', # 'path': 'where/to/go'}] @@ -155,7 +155,43 @@ def load_azure_ovf_pubkeys(_sshnode): # <PublicKey><Fingerprint>ABC</FingerPrint><Path>/ABC</Path> # ... # </PublicKeys></SSH> - return [] + results = find_child(sshnode, lambda n: n.localName == "PublicKeys") + if len(results) == 0: + return [] + if len(results) > 1: + raise BrokenAzureDataSource("Multiple 'PublicKeys'(%s) in SSH node" % + len(results)) + + pubkeys_node = results[0] + pubkeys = find_child(pubkeys_node, lambda n: n.localName == "PublicKey") + + if len(pubkeys) == 0: + return [] + + found = [] + text_node = minidom.Document.TEXT_NODE + + for pk_node in pubkeys: + if not pk_node.hasChildNodes(): + continue + cur = {'fingerprint': "", 'path': ""} + for child in pk_node.childNodes: + if (child.nodeType == text_node or not child.localName): + continue + + name = child.localName.lower() + + if name not in cur.keys(): + continue + + if (len(child.childNodes) != 1 or + child.childNodes[0].nodeType != text_node): + continue + + cur[name] = child.childNodes[0].wholeText.strip() + found.append(cur) + + return found def read_azure_ovf(contents): |