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