summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceAzure.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/sources/DataSourceAzure.py')
-rwxr-xr-xcloudinit/sources/DataSourceAzure.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index 9577355c..81ab88a9 100755
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -299,6 +299,8 @@ class DataSourceAzure(sources.DataSource):
def _unpickle(self, ci_pkl_version: int) -> None:
super()._unpickle(ci_pkl_version)
+
+ self._ephemeral_dhcp_ctx = None
if not hasattr(self, "iso_dev"):
self.iso_dev = None
@@ -514,9 +516,11 @@ class DataSourceAzure(sources.DataSource):
if perform_reprovision or perform_reprovision_after_nic_attach:
LOG.info("Reporting ready to Azure after getting ReprovisionData")
- use_cached_ephemeral = self.distro.networking.is_up(
- self.fallback_interface
- ) and getattr(self, "_ephemeral_dhcp_ctx", None)
+ use_cached_ephemeral = (
+ self.distro.networking.is_up(self.fallback_interface)
+ and self._ephemeral_dhcp_ctx
+ and self._ephemeral_dhcp_ctx.lease
+ )
if use_cached_ephemeral:
self._report_ready(lease=self._ephemeral_dhcp_ctx.lease)
self._ephemeral_dhcp_ctx.clean_network() # Teardown ephemeral
@@ -1322,8 +1326,8 @@ class DataSourceAzure(sources.DataSource):
try:
if (
self.distro.networking.is_up(self.fallback_interface)
- and getattr(self, "_ephemeral_dhcp_ctx", None)
- and getattr(self._ephemeral_dhcp_ctx, "lease", None)
+ and self._ephemeral_dhcp_ctx
+ and self._ephemeral_dhcp_ctx.lease
and unknown_245_key in self._ephemeral_dhcp_ctx.lease
):
report_diagnostic_event(