Following with the thought process of the proposal by smoser in #3, I have made the following change in cloudinit/distros/__init__.py to work around this in my environment. ( doesn't go through the complexity of taking down only the auto interfaces )
def apply_network(self, settings, bring_up=True):
# Write it out
dev_names = self._write_network(settings)
# Now try to bring them up
if bring_up: self._bring_down_interfaces(dev_names) <---- new method
return self._bring_up_interfaces(dev_names)
return False
Then added these default implementations:
def _bring_down_interface(self, device_name):
cmd = ['ifdown', device_name] LOG.debug("Attempting to run bring down interface %s using command %s", device_name, cmd)
try:
(_out, err) = util.subp(cmd)
if len(err): LOG.warn("Running %s resulted in stderr output: %s", cmd, err)
return True
except util.ProcessExecutionError: util.logexc(LOG, "Running interface command %s failed", cmd)
return False
def _bring_down_interfaces(self, device_names):
am_failed = 0
for d in device_names:
if not self._bring_down_interface(d): am_failed += 1
if am_failed == 0:
return True
return False
Since Ubuntu always returns --all for device_names, so implement in debian.py as:
def _bring_down_interfaces(self, device_names):
use_all = False
for d in device_names:
if d == 'all': use_all = True
if use_all:
return distros.Distro._bring_down_interface(self, '--all')
else:
return distros.Distro._bring_down_interfaces(self, device_names)
Following with the thought process of the proposal by smoser in #3, I have made the following change in cloudinit/ distros/ __init_ _.py to work around this in my environment. ( doesn't go through the complexity of taking down only the auto interfaces )
def apply_network(self, settings, bring_up=True): network( settings)
self. _bring_ down_interfaces (dev_names) <---- new method up_interfaces( dev_names)
# Write it out
dev_names = self._write_
# Now try to bring them up
if bring_up:
return self._bring_
return False
Then added these default implementations:
def _bring_ down_interface( self, device_name):
LOG.debug( "Attempting to run bring down interface %s using command %s",
device_ name, cmd)
LOG.warn( "Running %s resulted in stderr output: %s", cmd, err) cutionError:
util. logexc( LOG, "Running interface command %s failed", cmd)
cmd = ['ifdown', device_name]
try:
(_out, err) = util.subp(cmd)
if len(err):
return True
except util.ProcessExe
return False
def _bring_ down_interfaces (self, device_names): down_interface( d):
am_failed += 1
am_failed = 0
for d in device_names:
if not self._bring_
if am_failed == 0:
return True
return False
Since Ubuntu always returns --all for device_names, so implement in debian.py as:
def _bring_ down_interfaces (self, device_names):
use_all = True Distro. _bring_ down_interface( self, '--all') Distro. _bring_ down_interfaces (self, device_names)
use_all = False
for d in device_names:
if d == 'all':
if use_all:
return distros.
else:
return distros.