When down_netdev was called with deconfigure=True (which is the default),
it would invoke, e.g. "/sbin/ifconfig eth0 down 0.0.0.0", with the
intention of taking the interface down and removing any IP address from it
at the same time.
In fact, this removed any IP address from it and brought the device *up*,
because ifconfig executes its commands in the order that they are
specified, and setting or unsetting an IP address brings a device up.
We could specify the commands in the opposite order ("0.0.0.0 down") but
it seems to me more obviously correct to just run ifconfig twice, so that
is what this commit does.
This commit could break things, because it could be that there is a bug
elsewhere that depends on down_netdev not actually bringing a device down,
but it is needed for the upcoming device renaming commit (to fix bug
NIC-20), because a network device has to be down to be renamed.
if not interface_exists(interface):
log("down_netdev: interface %s does not exist, ignoring" % interface)
return
- argv = ["/sbin/ifconfig", interface, 'down']
if deconfigure:
- argv += ['0.0.0.0']
-
# Kill dhclient.
pidfile_name = '/var/run/dhclient-%s.pid' % interface
pidfile = None
os.remove(pidfile_name)
except:
pass
- run_command(argv)
+
+ run_command(["/sbin/ifconfig", interface, '0.0.0.0'])
+
+ run_command(["/sbin/ifconfig", interface, 'down'])
def up_netdev(interface):
run_command(["/sbin/ifconfig", interface, 'up'])