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
This commit is contained in:
Noam Angel 2019-07-10 09:23:03 +00:00
parent 5d44b582b5
commit 9aaaeb21ee
1 changed files with 4 additions and 0 deletions

View File

@ -311,6 +311,10 @@ class NetConfig(object):
def ifdown(self, interface, iftype='interface'):
msg = 'running ifdown on %s: %s' % (iftype, interface)
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'):
"""Run 'ifup' on the specified interface