feat: Retrieve and manage MTU for the interfaces
This commit is contained in:
parent
9204ae2187
commit
221ac16e87
2 changed files with 13 additions and 0 deletions
|
@ -55,6 +55,7 @@ class IPMI():
|
|||
|
||||
ret = {}
|
||||
ret['name'] = 'IPMI'
|
||||
ret["mtu"] = 1500
|
||||
ret['bonding'] = False
|
||||
ret['mac'] = _ipmi['MAC Address']
|
||||
ret['vlan'] = int(_ipmi['802.1q VLAN ID']) \
|
||||
|
|
|
@ -85,6 +85,7 @@ class Network(object):
|
|||
ip_addr.append(addr)
|
||||
|
||||
mac = open('/sys/class/net/{}/address'.format(interface), 'r').read().strip()
|
||||
mtu = int(open('/sys/class/net/{}/mtu'.format(interface), 'r').read().strip())
|
||||
vlan = None
|
||||
if len(interface.split('.')) > 1:
|
||||
vlan = int(interface.split('.')[1])
|
||||
|
@ -114,6 +115,7 @@ class Network(object):
|
|||
'ethtool': Ethtool(interface).parse(),
|
||||
'virtual': virtual,
|
||||
'vlan': vlan,
|
||||
'mtu': mtu,
|
||||
'bonding': bonding,
|
||||
'bonding_slaves': bonding_slaves,
|
||||
}
|
||||
|
@ -276,6 +278,9 @@ class Network(object):
|
|||
if nic['mac']:
|
||||
params['mac_address'] = nic['mac']
|
||||
|
||||
if nic['mtu']:
|
||||
params['mtu'] = nic['mtu']
|
||||
|
||||
interface = self.nb_net.interfaces.create(**params)
|
||||
|
||||
if nic['vlan']:
|
||||
|
@ -443,6 +448,13 @@ class Network(object):
|
|||
ret, interface = self.reset_vlan_on_interface(nic, interface)
|
||||
nic_update += ret
|
||||
|
||||
if hasattr(interface, 'mtu'):
|
||||
if nic['mtu'] != interface.mtu:
|
||||
logging.info('Interface mtu is wrong, updating to: {mtu}'.format(
|
||||
mtu=nic['mtu']))
|
||||
interface.mtu = nic['mtu']
|
||||
nic_update += 1
|
||||
|
||||
if hasattr(interface, 'type'):
|
||||
_type = self.get_netbox_type_for_nic(nic)
|
||||
if not interface.type or \
|
||||
|
|
Loading…
Reference in a new issue