better error handling for bonding
This commit is contained in:
parent
fb53796e2f
commit
e3e840ec5d
1 changed files with 9 additions and 10 deletions
|
|
@ -91,11 +91,7 @@ class Network():
|
||||||
self.nics.append(nic)
|
self.nics.append(nic)
|
||||||
|
|
||||||
def _set_bonding_interfaces(self):
|
def _set_bonding_interfaces(self):
|
||||||
bonding_nics = [x for x in self.nics if x['bonding']]
|
bonding_nics = (x for x in self.nics if x['bonding'])
|
||||||
if not len(bonding_nics):
|
|
||||||
return False
|
|
||||||
|
|
||||||
logging.debug('Setting bonding interfaces..')
|
|
||||||
for nic in bonding_nics:
|
for nic in bonding_nics:
|
||||||
bond_int = self.get_netbox_network_card(nic)
|
bond_int = self.get_netbox_network_card(nic)
|
||||||
logging.debug('Setting slave interface for {name}'.format(
|
logging.debug('Setting slave interface for {name}'.format(
|
||||||
|
|
@ -105,11 +101,14 @@ class Network():
|
||||||
self.get_netbox_network_card(slave_nic)
|
self.get_netbox_network_card(slave_nic)
|
||||||
for slave_nic in self.nics
|
for slave_nic in self.nics
|
||||||
if slave_nic['name'] in nic['bonding_slaves']):
|
if slave_nic['name'] in nic['bonding_slaves']):
|
||||||
|
if slave_int.lag is None or slave_int.lag.id != bond_int.id:
|
||||||
logging.debug('Settting interface {name} as slave of {master}'.format(
|
logging.debug('Settting interface {name} as slave of {master}'.format(
|
||||||
name=slave_int.name, master=bond_int.name
|
name=slave_int.name, master=bond_int.name
|
||||||
))
|
))
|
||||||
slave_int.lag = bond_int
|
slave_int.lag = bond_int
|
||||||
slave_int.save()
|
slave_int.save()
|
||||||
|
else:
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_network_cards(self):
|
def get_network_cards(self):
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue