diff options
-rwxr-xr-x | bin/cloud-init | 1 | ||||
-rw-r--r-- | cloudinit/distros/debian.py | 3 | ||||
-rw-r--r-- | cloudinit/sources/DataSourceOVF.py | 30 | ||||
-rw-r--r-- | cloudinit/stages.py | 8 | ||||
-rwxr-xr-x | udev/cloud-init-wait | 18 |
5 files changed, 38 insertions, 22 deletions
diff --git a/bin/cloud-init b/bin/cloud-init index 341359e3..715be4b5 100755 --- a/bin/cloud-init +++ b/bin/cloud-init @@ -259,6 +259,7 @@ def main_init(name, args): util.logexc(LOG, ("No instance datasource found!" " Likely bad things to come!")) if not args.force: + init.apply_network_config() if args.local: return (None, []) else: diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py index b14fa3e2..5d7e6cfc 100644 --- a/cloudinit/distros/debian.py +++ b/cloudinit/distros/debian.py @@ -82,7 +82,8 @@ class Distro(distros.Distro): ns = net.parse_net_config_data(netconfig) net.render_network_state(target="/", network_state=ns, eni=self.network_conf_fn, - links_prefix=self.links_prefix) + links_prefix=self.links_prefix, + netrules=None) util.del_file("/etc/network/interfaces.d/eth0.cfg") return [] diff --git a/cloudinit/sources/DataSourceOVF.py b/cloudinit/sources/DataSourceOVF.py index 5734d233..2a6cd050 100644 --- a/cloudinit/sources/DataSourceOVF.py +++ b/cloudinit/sources/DataSourceOVF.py @@ -24,7 +24,6 @@ from xml.dom import minidom import base64 import os -import shutil import re import time @@ -75,7 +74,14 @@ class DataSourceOVF(sources.DataSource): system_type = util.read_dmi_data("system-product-name") if system_type is None: LOG.debug("No system-product-name found") - elif 'vmware' in system_type.lower(): + + if seedfile: + # Found a seed dir + seed = os.path.join(self.paths.seed_dir, seedfile) + (md, ud, cfg) = read_ovf_environment(contents) + self.environment = contents + found.append(seed) + elif system_type and 'vmware' in system_type.lower(): LOG.debug("VMware Virtualization Platform found") if not util.get_cfg_option_bool( self.sys_cfg, "disable_vmware_customization", True): @@ -85,10 +91,15 @@ class DataSourceOVF(sources.DataSource): deployPkgPluginPath = search_file("/usr/lib/open-vm-tools", "libdeployPkgPlugin.so") if deployPkgPluginPath: + # When the VM is powered on, the "VMware Tools" daemon + # copies the customization specification file to + # /var/run/vmware-imc directory. cloud-init code needs + # to search for the file in that directory. vmwareImcConfigFilePath = util.log_time( logfunc=LOG.debug, msg="waiting for configuration file", - func=wait_for_imc_cfg_file, args=("/tmp", "cust.cfg")) + func=wait_for_imc_cfg_file, + args=("/var/run/vmware-imc", "cust.cfg")) if vmwareImcConfigFilePath: LOG.debug("Found VMware DeployPkg Config File at %s" % @@ -112,10 +123,10 @@ class DataSourceOVF(sources.DataSource): set_customization_status( GuestCustStateEnum.GUESTCUST_STATE_RUNNING, GuestCustEventEnum.GUESTCUST_EVENT_CUSTOMIZE_FAILED) + enable_nics(nics) return False finally: - dirPath = os.path.dirname(vmwareImcConfigFilePath) - shutil.rmtree(dirPath) + util.del_dir(os.path.dirname(vmwareImcConfigFilePath)) try: LOG.debug("Applying the Network customization") @@ -127,19 +138,14 @@ class DataSourceOVF(sources.DataSource): set_customization_status( GuestCustStateEnum.GUESTCUST_STATE_RUNNING, GuestCustEventEnum.GUESTCUST_EVENT_NETWORK_SETUP_FAILED) + enable_nics(nics) return False vmwarePlatformFound = True - enable_nics(nics) set_customization_status( GuestCustStateEnum.GUESTCUST_STATE_DONE, GuestCustErrorEnum.GUESTCUST_ERROR_SUCCESS) - elif seedfile: - # Found a seed dir - seed = os.path.join(self.paths.seed_dir, seedfile) - (md, ud, cfg) = read_ovf_environment(contents) - self.environment = contents - found.append(seed) + enable_nics(nics) else: np = {'iso': transport_iso9660, 'vmware-guestd': transport_vmware_guestd, } diff --git a/cloudinit/stages.py b/cloudinit/stages.py index 143a4fc9..3fbb4443 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -596,7 +596,13 @@ class Init(object): return LOG.info("Applying network configuration from %s: %s", src, netcfg) - return self.distro.apply_network_config(netcfg) + try: + return self.distro.apply_network_config(netcfg) + except NotImplementedError: + LOG.warn("distro '%s' does not implement apply_network_config. " + "networking may not be configured properly." % + self.distro) + return class Modules(object): diff --git a/udev/cloud-init-wait b/udev/cloud-init-wait index 7d53dee4..b434005d 100755 --- a/udev/cloud-init-wait +++ b/udev/cloud-init-wait @@ -3,16 +3,18 @@ CI_NET_READY="/run/cloud-init/network-config-ready" LOG="/run/cloud-init/${0##*/}.log" LOG_INIT=0 +MAX_WAIT=60 DEBUG=0 block_until_ready() { - local fname="$1" - local naplen="$2" max="$3" n=0 - while ! [ -f "$fname" ]; do - n=$(($n+1)) - [ "$n" -ge "$max" ] && return 1 - sleep $naplen - done + local fname="$1" max="$2" + [ -f "$fname" ] && return 0 + # udevadm settle below will exit at the first of 3 conditions + # 1.) timeout 2.) file exists 3.) all in-flight udev events are processed + # since this is being run from a udev event, the 3 wont happen. + # thus, this is essentially a inotify wait or timeout on a file in /run + # that is created by cloud-init-local. + udevadm settle "--timeout=$max" "--exit-if-exists=$fname" } log() { @@ -56,7 +58,7 @@ main() { return 0 fi - block_until_ready "$readyfile" .1 600 || + block_until_ready "$readyfile" "$MAX_WAIT" || { log "failed waiting for ready on $INTERFACE"; return 1; } log "net config ready" |