diff options
author | Daniel Watkins <daniel.watkins@canonical.com> | 2015-05-08 12:58:20 +0100 |
---|---|---|
committer | Daniel Watkins <daniel.watkins@canonical.com> | 2015-05-08 12:58:20 +0100 |
commit | 4a2b6ef37578b13d7240dc1447bbb715b8a0a077 (patch) | |
tree | d15efaf1d750bca15df2c4c6ab50487479f66bab /cloudinit/sources | |
parent | 28e9e693942d758fb5bdc952c32542c77e16f23a (diff) | |
download | vyos-cloud-init-4a2b6ef37578b13d7240dc1447bbb715b8a0a077.tar.gz vyos-cloud-init-4a2b6ef37578b13d7240dc1447bbb715b8a0a077.zip |
Cache certificate response to save on communication with fabric.
Diffstat (limited to 'cloudinit/sources')
-rw-r--r-- | cloudinit/sources/DataSourceAzure.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py index deffd9b2..c783732d 100644 --- a/cloudinit/sources/DataSourceAzure.py +++ b/cloudinit/sources/DataSourceAzure.py @@ -154,6 +154,7 @@ class GoalState(object): def __init__(self, xml, http_client): self.http_client = http_client self.root = ElementTree.fromstring(xml) + self._certificates_xml = None def _text_from_xpath(self, xpath): element = self.root.find(xpath) @@ -182,11 +183,14 @@ class GoalState(object): @property def certificates_xml(self): - url = self._text_from_xpath('./Container/RoleInstanceList/RoleInstance' - '/Configuration/Certificates') - if url is not None: - return self.http_client.get(url, secure=True).contents - return None + if self._certificates_xml is None: + url = self._text_from_xpath( + './Container/RoleInstanceList/RoleInstance' + '/Configuration/Certificates') + if url is not None: + self._certificates_xml = self.http_client.get( + url, secure=True).contents + return self._certificates_xml class OpenSSLManager(object): |