ifdown does not work if no ifcfg file exist

ifdown happen before writing_config and if interface is up by
dhcp/dhclient it will not be down, ifdown relaying on ifcfg exist.

causing issue when pxe boot interface is also used as part of bond
interface.
interface is required to be down before adding to bond,
this patch validate that any physical interface will be in down state.

Change-Id: Ie096bf1296062744193bdcb9713ee42405e206d8
Closes-Bug: #1836024
(cherry picked from commit 9aaaeb21ee)
This commit is contained in:
Noam Angel 2019-07-10 09:23:03 +00:00 committed by Dan Sneddon
parent a61f37aeed
commit 08dd63ec00
1 changed files with 4 additions and 0 deletions

View File

@ -311,6 +311,10 @@ class NetConfig(object):
def ifdown(self, interface, iftype='interface'): def ifdown(self, interface, iftype='interface'):
msg = 'running ifdown on %s: %s' % (iftype, interface) msg = 'running ifdown on %s: %s' % (iftype, interface)
self.execute(msg, '/sbin/ifdown', interface, check_exit_code=False) self.execute(msg, '/sbin/ifdown', interface, check_exit_code=False)
if utils.is_active_nic(interface):
msg = '%s %s is up, trying with ip command' % (iftype, interface)
self.execute(msg, '/sbin/ip',
'link', 'set', 'dev', interface, 'down')
def ifup(self, interface, iftype='interface'): def ifup(self, interface, iftype='interface'):
"""Run 'ifup' on the specified interface """Run 'ifup' on the specified interface