Merge "ovn-migration-mtu: Support migrating MTU of GRE networks"

This commit is contained in:
Zuul 2020-07-31 02:03:35 +00:00 committed by Gerrit Code Review
commit d419d7d1cc
1 changed files with 15 additions and 5 deletions

View File

@ -16,10 +16,18 @@
import os
import sys
from neutron_lib import constants
from openstack import connection
# TODO(dalvarez): support also GRE
GENEVE_TO_VXLAN_OVERHEAD = 8
# Overhead size of Geneve is configurable, use the recommended value
GENEVE_ENCAP_OVERHEAD = 38
# map of network types to migrate and the difference in overhead size when
# converted to Geneve.
NETWORK_TYPE_OVERHEAD_DIFF = {
'vxlan': GENEVE_ENCAP_OVERHEAD - constants.VXLAN_ENCAP_OVERHEAD,
'gre': GENEVE_ENCAP_OVERHEAD - constants.GRE_ENCAP_OVERHEAD,
}
def get_connection():
@ -75,7 +83,7 @@ def verify_network_mtu():
success = True
for network in conn.network.networks():
if network.provider_physical_network is None and (
network.provider_network_type == 'vxlan') and (
network.provider_network_type in NETWORK_TYPE_OVERHEAD_DIFF) and (
'adapted_mtu' not in network.tags):
print("adapted_mtu tag is not set for the Network "
"[" + str(network.name) + "]")
@ -95,7 +103,8 @@ def update_network_mtu():
for network in conn.network.networks():
try:
if network.provider_physical_network is None and (
network.provider_network_type == 'vxlan') and (
network.provider_network_type in
NETWORK_TYPE_OVERHEAD_DIFF) and (
'adapted_mtu' not in network.tags):
print("Updating the mtu and the tag 'adapted_mtu"
" of the network - " + str(network.name))
@ -103,7 +112,8 @@ def update_network_mtu():
new_tags.append('adapted_mtu')
conn.network.update_network(
network,
mtu=int(network.mtu) - GENEVE_TO_VXLAN_OVERHEAD)
mtu=int(network.mtu) - NETWORK_TYPE_OVERHEAD_DIFF[
network.provider_network_type])
conn.network.set_tags(network, new_tags)
except Exception as e:
print("Exception occured while updating the MTU:" + str(e))