From 4a2b6ef37578b13d7240dc1447bbb715b8a0a077 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Fri, 8 May 2015 12:58:20 +0100 Subject: Cache certificate response to save on communication with fabric. --- cloudinit/sources/DataSourceAzure.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'cloudinit/sources/DataSourceAzure.py') 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): -- cgit v1.2.3