diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
index 6ff4e1c..a0db27d 100644
--- a/cloudinit/cmd/main.py
+++ b/cloudinit/cmd/main.py
@@ -330,6 +330,14 @@ def main_init(name, args):
# Stage 5
try:
init.fetch(existing=existing)
+ ## Here it seems like we should centrally control updating of
+ ## the hostname. We'd set it if this is a new instance.
+ ## Unfortunately, 'init.is_new_instance' is not usable
+ ## until after 'instancify' has been called below.... hm...
+ ## somehow we'd want to update /etc/hostname and set the system
+ ## host name only if this is a new instance.
+ init.set_hostname()
+
# if in network mode, and the datasource is local
# then work was done at that stage.
if mode == sources.DSMODE_NETWORK and init.datasource.dsmode != mode:
@@ -357,6 +365,15 @@ def main_init(name, args):
LOG.debug("[%s] barreling on in force mode without datasource",
mode)
+ ## It seems something here should call on the datasource to say:
+ ## "network is up now, you can collect the rest of your data"
+ ## This is because azure will have had 'get_data' called at a point
+ ## in which there is no network. 'activate' is called too late.
+ ##
+ ## init.get_remaining_data would call the datasources's
+ ## get_remaining_data (if it has that attribute)
+ init.get_remaining_data()
+
# Stage 6
iid = init.instancify()
LOG.debug("[%s] %s will now be targeting instance id: %s. new=%s",
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index c5af8b8..a563740 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -162,6 +162,23 @@ class DataSourceAzureNet(sources.DataSource):
metadata['public-keys'] = key_value or pubkeys_from_crt_files(fp_files)
return metadata
+ def get_remaining_data(self):
+ if self.ds_cfg['agent_command'] == AGENT_START_BUILTIN:
+ metadata_func = partial(get_metadata_from_fabric,
+ fallback_lease_file=self.
+ dhclient_lease_file)
+ else:
+ metadata_func = self.get_metadata_from_agent
+
+ try:
+ fabric_data = metadata_func()
+ except Exception as exc:
+ LOG.info("Error communicating with Azure fabric; assume we aren't"
+ " on Azure.", exc_info=True)
+ return False
+ self.metadata.update(fabric_data)
+
+
def get_data(self):
# azure removes/ejects the cdrom containing the ovf-env.xml
# file on reboot. So, in order to successfully reboot we
@@ -219,22 +236,7 @@ class DataSourceAzureNet(sources.DataSource):
# the directory to be protected.
write_files(ddir, files, dirmode=0o700)
- if self.ds_cfg['agent_command'] == AGENT_START_BUILTIN:
- metadata_func = partial(get_metadata_from_fabric,
- fallback_lease_file=self.
- dhclient_lease_file)
- else:
- metadata_func = self.get_metadata_from_agent
-
- try:
- fabric_data = metadata_func()
- except Exception as exc:
- LOG.info("Error communicating with Azure fabric; assume we aren't"
- " on Azure.", exc_info=True)
- return False
self.metadata['instance-id'] = util.read_dmi_data('system-uuid')
- self.metadata.update(fabric_data)
-
return True
def device_name_to_device(self, name):
@@ -648,8 +650,10 @@ class NonAzureDataSource(Exception):
# Used to match classes to dependencies
+# Azure does require network for configuration, but needs to run
+# before networking comes up to apply the hostname.
datasources = [
- (DataSourceAzureNet, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),
+ (DataSourceAzureNet, (sources.DEP_FILESYSTEM)),
]