Add MTU value checking and log messages
Ensures that if a specified MTU is more than the maximum it is set to the maximum instead, and adds warning messages for both situations.
This commit is contained in:
parent
87cda72ca9
commit
6ce28c43af
|
@ -83,9 +83,28 @@ class VXNetworkInstance(object):
|
||||||
except Exception:
|
except Exception:
|
||||||
self.vx_mtu = None
|
self.vx_mtu = None
|
||||||
|
|
||||||
|
update_mtu = False
|
||||||
|
|
||||||
# Explicitly set the MTU to max_mtu if unset (in Zookeeper too assuming the key exists)
|
# Explicitly set the MTU to max_mtu if unset (in Zookeeper too assuming the key exists)
|
||||||
if self.vx_mtu == '' or self.vx_mtu is None:
|
if self.vx_mtu == '' or self.vx_mtu is None:
|
||||||
|
self.logger.out(
|
||||||
|
'MTU not specified; setting to maximum MTU {} instead'.format(self.max_mtu),
|
||||||
|
prefix='VNI {}'.format(self.vni),
|
||||||
|
state='w'
|
||||||
|
)
|
||||||
self.vx_mtu = self.max_mtu
|
self.vx_mtu = self.max_mtu
|
||||||
|
update_mtu = True
|
||||||
|
# Ensure the MTU is valid
|
||||||
|
if self.vx_mtu > self.max_mtu:
|
||||||
|
self.logger.out(
|
||||||
|
'MTU {} is larger than maximum MTU {}; setting to maximum MTU instead'.format(self.vx_mtu, self.max_mtu),
|
||||||
|
prefix='VNI {}'.format(self.vni),
|
||||||
|
state='w'
|
||||||
|
)
|
||||||
|
self.vx_mtu = self.max_mtu
|
||||||
|
update_mtu = True
|
||||||
|
|
||||||
|
if update_mtu:
|
||||||
# Try block for migration purposes
|
# Try block for migration purposes
|
||||||
try:
|
try:
|
||||||
self.zkhandler.write([
|
self.zkhandler.write([
|
||||||
|
@ -145,11 +164,30 @@ class VXNetworkInstance(object):
|
||||||
except Exception:
|
except Exception:
|
||||||
self.vx_mtu = None
|
self.vx_mtu = None
|
||||||
|
|
||||||
|
update_mtu = False
|
||||||
|
|
||||||
# Explicitly set the MTU to max_mtu if unset (in Zookeeper too assuming the key exists)
|
# Explicitly set the MTU to max_mtu if unset (in Zookeeper too assuming the key exists)
|
||||||
if self.vx_mtu == '' or self.vx_mtu is None:
|
if self.vx_mtu == '' or self.vx_mtu is None:
|
||||||
|
self.logger.out(
|
||||||
|
'MTU not specified; setting to maximum MTU {} instead'.format(self.max_mtu),
|
||||||
|
prefix='VNI {}'.format(self.vni),
|
||||||
|
state='w'
|
||||||
|
)
|
||||||
self.vx_mtu = self.max_mtu
|
self.vx_mtu = self.max_mtu
|
||||||
try:
|
update_mtu = True
|
||||||
|
# Ensure the MTU is valid
|
||||||
|
if self.vx_mtu > self.max_mtu:
|
||||||
|
self.logger.out(
|
||||||
|
'MTU {} is larger than maximum MTU {}; setting to maximum MTU instead'.format(self.vx_mtu, self.max_mtu),
|
||||||
|
prefix='VNI {}'.format(self.vni),
|
||||||
|
state='w'
|
||||||
|
)
|
||||||
|
self.vx_mtu = self.max_mtu
|
||||||
|
update_mtu = True
|
||||||
|
|
||||||
|
if update_mtu:
|
||||||
# Try block for migration purposes
|
# Try block for migration purposes
|
||||||
|
try:
|
||||||
self.zkhandler.write([
|
self.zkhandler.write([
|
||||||
(('network.mtu', self.vni), self.vx_mtu)
|
(('network.mtu', self.vni), self.vx_mtu)
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue