summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2019-05-10 15:34:21 -0600
committergit-ubuntu importer <ubuntu-devel-discuss@lists.ubuntu.com>2019-05-10 21:45:10 +0000
commit284d197db18fd6f344475c72dec72c80d3edcf9c (patch)
treedea4d02ae48632f6ef9ceb51d894ed49b0a7bc9f
parent6c1ef72880d196a2732193e6ca316d1ae4b58a34 (diff)
downloadcloud-init-git-284d197db18fd6f344475c72dec72c80d3edcf9c.tar.gz
19.1-1-gbaa47854-0ubuntu1 (patches unapplied)
Imported using git-ubuntu import.
-rwxr-xr-xcloudinit/sources/helpers/azure.py14
-rw-r--r--debian/changelog8
-rw-r--r--tests/unittests/test_datasource/test_azure_helper.py9
3 files changed, 26 insertions, 5 deletions
diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py
index d3af05ee..82c4c8c4 100755
--- a/cloudinit/sources/helpers/azure.py
+++ b/cloudinit/sources/helpers/azure.py
@@ -20,6 +20,9 @@ from cloudinit.reporting import events
LOG = logging.getLogger(__name__)
+# This endpoint matches the format as found in dhcp lease files, since this
+# value is applied if the endpoint can't be found within a lease file
+DEFAULT_WIRESERVER_ENDPOINT = "a8:3f:81:10"
azure_ds_reporter = events.ReportEventStack(
name="azure-ds",
@@ -297,7 +300,12 @@ class WALinuxAgentShim(object):
@azure_ds_telemetry_reporter
def _get_value_from_leases_file(fallback_lease_file):
leases = []
- content = util.load_file(fallback_lease_file)
+ try:
+ content = util.load_file(fallback_lease_file)
+ except IOError as ex:
+ LOG.error("Failed to read %s: %s", fallback_lease_file, ex)
+ return None
+
LOG.debug("content is %s", content)
option_name = _get_dhcp_endpoint_option_name()
for line in content.splitlines():
@@ -372,9 +380,9 @@ class WALinuxAgentShim(object):
fallback_lease_file)
value = WALinuxAgentShim._get_value_from_leases_file(
fallback_lease_file)
-
if value is None:
- raise ValueError('No endpoint found.')
+ LOG.warning("No lease found; using default endpoint")
+ value = DEFAULT_WIRESERVER_ENDPOINT
endpoint_ip_address = WALinuxAgentShim.get_ip_from_lease_value(value)
LOG.debug('Azure endpoint found at %s', endpoint_ip_address)
diff --git a/debian/changelog b/debian/changelog
index 6e62259c..5646a6ae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+cloud-init (19.1-1-gbaa47854-0ubuntu1) eoan; urgency=medium
+
+ * New upstream snapshot.
+ - Azure: Return static fallback address as if failed to find endpoint
+ [Jason Zions (MSFT)]
+
+ -- Chad Smith <chad.smith@canonical.com> Fri, 10 May 2019 15:34:21 -0600
+
cloud-init (19.1-0ubuntu1) eoan; urgency=medium
* New upstream release.
diff --git a/tests/unittests/test_datasource/test_azure_helper.py b/tests/unittests/test_datasource/test_azure_helper.py
index 02556165..bd006aba 100644
--- a/tests/unittests/test_datasource/test_azure_helper.py
+++ b/tests/unittests/test_datasource/test_azure_helper.py
@@ -67,12 +67,17 @@ class TestFindEndpoint(CiTestCase):
self.networkd_leases.return_value = None
def test_missing_file(self):
- self.assertRaises(ValueError, wa_shim.find_endpoint)
+ """wa_shim find_endpoint uses default endpoint if leasefile not found
+ """
+ self.assertEqual(wa_shim.find_endpoint(), "168.63.129.16")
def test_missing_special_azure_line(self):
+ """wa_shim find_endpoint uses default endpoint if leasefile is found
+ but does not contain DHCP Option 245 (whose value is the endpoint)
+ """
self.load_file.return_value = ''
self.dhcp_options.return_value = {'eth0': {'key': 'value'}}
- self.assertRaises(ValueError, wa_shim.find_endpoint)
+ self.assertEqual(wa_shim.find_endpoint(), "168.63.129.16")
@staticmethod
def _build_lease_content(encoded_address):