summaryrefslogtreecommitdiff
path: root/cloudinit/sources/helpers
diff options
context:
space:
mode:
authorDouglas Jordan <dojordan@microsoft.com>2018-01-24 16:10:08 -0700
committerChad Smith <chad.smith@canonical.com>2018-01-24 16:10:08 -0700
commitc03bdd3d8ed762cada813c5e95a40b14d2047b57 (patch)
tree708422bb64a8804f649ad7558d5088f9e11011a4 /cloudinit/sources/helpers
parent30597f28512fafbe25486df5865b628d859486c6 (diff)
downloadvyos-cloud-init-c03bdd3d8ed762cada813c5e95a40b14d2047b57.tar.gz
vyos-cloud-init-c03bdd3d8ed762cada813c5e95a40b14d2047b57.zip
Azure VM Preprovisioning support.
This change will enable azure vms to report provisioning has completed twice, first to tell the fabric it has completed then a second time to enable customer settings. The datasource for the second provisioning is the Instance Metadata Service (IMDS),and the VM will poll indefinitely for the new ovf-env.xml from IMDS. This branch introduces EphemeralDHCPv4 which encapsulates common logic used by both DataSourceEc2 an DataSourceAzure for temporary DHCP interactions without side-effects. LP: #1734991
Diffstat (limited to 'cloudinit/sources/helpers')
-rw-r--r--cloudinit/sources/helpers/azure.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py
index 6cda5721..90c12df1 100644
--- a/cloudinit/sources/helpers/azure.py
+++ b/cloudinit/sources/helpers/azure.py
@@ -199,10 +199,10 @@ class WALinuxAgentShim(object):
' </Container>',
'</Health>'])
- def __init__(self, fallback_lease_file=None):
+ def __init__(self, fallback_lease_file=None, dhcp_options=None):
LOG.debug('WALinuxAgentShim instantiated, fallback_lease_file=%s',
fallback_lease_file)
- self.dhcpoptions = None
+ self.dhcpoptions = dhcp_options
self._endpoint = None
self.openssl_manager = None
self.values = {}
@@ -220,7 +220,8 @@ class WALinuxAgentShim(object):
@property
def endpoint(self):
if self._endpoint is None:
- self._endpoint = self.find_endpoint(self.lease_file)
+ self._endpoint = self.find_endpoint(self.lease_file,
+ self.dhcpoptions)
return self._endpoint
@staticmethod
@@ -292,10 +293,14 @@ class WALinuxAgentShim(object):
return _value
@staticmethod
- def find_endpoint(fallback_lease_file=None):
+ def find_endpoint(fallback_lease_file=None, dhcp245=None):
value = None
- LOG.debug('Finding Azure endpoint from networkd...')
- value = WALinuxAgentShim._networkd_get_value_from_leases()
+ if dhcp245 is not None:
+ value = dhcp245
+ LOG.debug("Using Azure Endpoint from dhcp options")
+ if value is None:
+ LOG.debug('Finding Azure endpoint from networkd...')
+ value = WALinuxAgentShim._networkd_get_value_from_leases()
if value is None:
# Option-245 stored in /run/cloud-init/dhclient.hooks/<ifc>.json
# a dhclient exit hook that calls cloud-init-dhclient-hook
@@ -367,8 +372,9 @@ class WALinuxAgentShim(object):
LOG.info('Reported ready to Azure fabric.')
-def get_metadata_from_fabric(fallback_lease_file=None):
- shim = WALinuxAgentShim(fallback_lease_file=fallback_lease_file)
+def get_metadata_from_fabric(fallback_lease_file=None, dhcp_opts=None):
+ shim = WALinuxAgentShim(fallback_lease_file=fallback_lease_file,
+ dhcp_options=dhcp_opts)
try:
return shim.register_with_azure_and_fetch_data()
finally: