Merge "Traffic control fixes and refresh"

This commit is contained in:
Zuul 2019-10-30 18:04:37 +00:00 committed by Gerrit Code Review
commit 4e3d593330
4 changed files with 37 additions and 35 deletions

View File

@ -32,7 +32,6 @@ INSTALLATION_FAILED_FILE = '/etc/platform/installation_failed'
BACKUPS_PATH = '/opt/backups' BACKUPS_PATH = '/opt/backups'
INTERFACES_LOG_FILE = "/tmp/configure_interfaces.log" INTERFACES_LOG_FILE = "/tmp/configure_interfaces.log"
TC_SETUP_SCRIPT = '/usr/local/bin/cgcs_tc_setup.sh'
LINK_MTU_DEFAULT = "1500" LINK_MTU_DEFAULT = "1500"

View File

@ -1531,3 +1531,6 @@ DRIVER_MLX_CX4 = 'mlx5_core'
MELLANOX_DRIVERS = [DRIVER_MLX_CX3, MELLANOX_DRIVERS = [DRIVER_MLX_CX3,
DRIVER_MLX_CX4] DRIVER_MLX_CX4]
# Traffic control
TRAFFIC_CONTROL_SCRIPT = '/usr/local/bin/tc_setup.sh'

View File

@ -668,19 +668,19 @@ def get_interface_address_method(context, iface, network_id=None):
return DHCP_METHOD return DHCP_METHOD
def get_interface_traffic_classifier(context, iface, network_id=None): def get_interface_traffic_classifier(context, iface):
""" """
Get the interface traffic classifier command line (if any) Get the interface traffic classifier command line (if any)
""" """
networktype = find_networktype_by_network_id(context, network_id) for networktype in iface.networktypelist:
if (networktype and if (networktype == constants.NETWORK_TYPE_MGMT):
networktype == constants.NETWORK_TYPE_MGMT): networkspeed = constants.LINK_SPEED_10G
networkspeed = constants.LINK_SPEED_10G ifname = get_interface_os_ifname(context, iface)
ifname = get_interface_os_ifname(context, iface) return '%s %s %s %s > /dev/null' \
return '/usr/local/bin/cgcs_tc_setup.sh %s %s %s > /dev/null' \ % (constants.TRAFFIC_CONTROL_SCRIPT,
% (ifname, ifname,
networktype, networktype,
networkspeed) networkspeed)
return None return None
@ -1013,10 +1013,13 @@ def get_common_network_config(context, iface, config, network_id=None):
""" """
LOG.debug("get_common_network_config %s %s network_id=%s" % LOG.debug("get_common_network_config %s %s network_id=%s" %
(iface.ifname, iface.networktypelist, network_id)) (iface.ifname, iface.networktypelist, network_id))
traffic_classifier = get_interface_traffic_classifier(context, iface,
network_id) os_ifname = get_interface_os_ifname(context, iface)
if traffic_classifier: if os_ifname == config['ifname']:
config['options']['post_up'] = traffic_classifier # post-up scripts do not work for aliases.
traffic_classifier = get_interface_traffic_classifier(context, iface)
if traffic_classifier:
config['options']['post_up'] = traffic_classifier
method = get_interface_address_method(context, iface, network_id) method = get_interface_address_method(context, iface, network_id)
if method == STATIC_METHOD: if method == STATIC_METHOD:

View File

@ -675,40 +675,35 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
def test_get_interface_traffic_classifier_for_mgmt(self): def test_get_interface_traffic_classifier_for_mgmt(self):
self.iface['ifclass'] = constants.INTERFACE_CLASS_PLATFORM self.iface['ifclass'] = constants.INTERFACE_CLASS_PLATFORM
self.iface['networktype'] = constants.NETWORK_TYPE_MGMT self.iface['networktypelist'] = [constants.NETWORK_TYPE_MGMT]
self.iface['networks'] = self._get_network_ids_by_type( self.iface['networks'] = self._get_network_ids_by_type(
constants.NETWORK_TYPE_MGMT) constants.NETWORK_TYPE_MGMT)
network = self.dbapi.network_get_by_type(
constants.NETWORK_TYPE_MGMT)
classifier = interface.get_interface_traffic_classifier( classifier = interface.get_interface_traffic_classifier(
self.context, self.iface, network.id) self.context, self.iface)
print(self.context) print(self.context)
expected = ('/usr/local/bin/cgcs_tc_setup.sh %s %s %s > /dev/null' % expected = ('%s %s %s %s > /dev/null' %
(self.port['name'], constants.NETWORK_TYPE_MGMT, (constants.TRAFFIC_CONTROL_SCRIPT,
self.port['name'], constants.NETWORK_TYPE_MGMT,
constants.LINK_SPEED_10G)) constants.LINK_SPEED_10G))
self.assertEqual(classifier, expected) self.assertEqual(classifier, expected)
def test_get_interface_traffic_classifier_for_cluster_host(self): def test_get_interface_traffic_classifier_for_cluster_host(self):
self.iface['ifname'] = 'cluster_host0' self.iface['ifname'] = 'cluster_host0'
self.iface['ifclass'] = constants.INTERFACE_CLASS_PLATFORM self.iface['ifclass'] = constants.INTERFACE_CLASS_PLATFORM
self.iface['networktype'] = constants.NETWORK_TYPE_CLUSTER_HOST self.iface['networktypelist'] = [constants.NETWORK_TYPE_CLUSTER_HOST]
self.iface['networks'] = self._get_network_ids_by_type( self.iface['networks'] = self._get_network_ids_by_type(
constants.NETWORK_TYPE_CLUSTER_HOST) constants.NETWORK_TYPE_CLUSTER_HOST)
network = self.dbapi.network_get_by_type(
constants.NETWORK_TYPE_CLUSTER_HOST)
classifier = interface.get_interface_traffic_classifier( classifier = interface.get_interface_traffic_classifier(
self.context, self.iface, network.id) self.context, self.iface)
self.assertIsNone(classifier) self.assertIsNone(classifier)
def test_get_interface_traffic_classifier_for_oam(self): def test_get_interface_traffic_classifier_for_oam(self):
self.iface['ifclass'] = constants.INTERFACE_CLASS_PLATFORM self.iface['ifclass'] = constants.INTERFACE_CLASS_PLATFORM
self.iface['networktype'] = constants.NETWORK_TYPE_OAM self.iface['networktypelist'] = [constants.NETWORK_TYPE_OAM]
self.iface['networks'] = self._get_network_ids_by_type( self.iface['networks'] = self._get_network_ids_by_type(
constants.NETWORK_TYPE_OAM) constants.NETWORK_TYPE_OAM)
network = self.dbapi.network_get_by_type(
constants.NETWORK_TYPE_OAM)
classifier = interface.get_interface_traffic_classifier( classifier = interface.get_interface_traffic_classifier(
self.context, self.iface, network.id) self.context, self.iface)
self.assertIsNone(classifier) self.assertIsNone(classifier)
def test_get_interface_traffic_classifier_for_none(self): def test_get_interface_traffic_classifier_for_none(self):
@ -998,7 +993,7 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
def test_get_controller_ethernet_config_mgmt(self): def test_get_controller_ethernet_config_mgmt(self):
self.iface['ifclass'] = constants.INTERFACE_CLASS_PLATFORM self.iface['ifclass'] = constants.INTERFACE_CLASS_PLATFORM
self.iface['networktype'] = constants.NETWORK_TYPE_MGMT self.iface['networktypelist'] = [constants.NETWORK_TYPE_MGMT]
self.iface['networks'] = self._get_network_ids_by_type( self.iface['networks'] = self._get_network_ids_by_type(
constants.NETWORK_TYPE_MGMT) constants.NETWORK_TYPE_MGMT)
self._update_context() self._update_context()
@ -1010,8 +1005,9 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
options = {'IPV6_AUTOCONF': 'no', options = {'IPV6_AUTOCONF': 'no',
'LINKDELAY': '20', 'LINKDELAY': '20',
'post_up': 'post_up':
'/usr/local/bin/cgcs_tc_setup.sh %s %s %s > /dev/null' % '%s %s %s %s > /dev/null' %
(self.port['name'], constants.NETWORK_TYPE_MGMT, (constants.TRAFFIC_CONTROL_SCRIPT,
self.port['name'], constants.NETWORK_TYPE_MGMT,
constants.LINK_SPEED_10G)} constants.LINK_SPEED_10G)}
expected = self._get_static_network_config( expected = self._get_static_network_config(
ifname=self.port['name'], mtu=1500, gateway='192.168.204.1', ifname=self.port['name'], mtu=1500, gateway='192.168.204.1',
@ -1130,7 +1126,7 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
def test_get_worker_ethernet_config_mgmt(self): def test_get_worker_ethernet_config_mgmt(self):
self.iface['ifclass'] = constants.INTERFACE_CLASS_PLATFORM self.iface['ifclass'] = constants.INTERFACE_CLASS_PLATFORM
self.iface['networktype'] = constants.NETWORK_TYPE_MGMT self.iface['networktypelist'] = [constants.NETWORK_TYPE_MGMT]
self.iface['networks'] = self._get_network_ids_by_type( self.iface['networks'] = self._get_network_ids_by_type(
constants.NETWORK_TYPE_MGMT) constants.NETWORK_TYPE_MGMT)
self.host['personality'] = constants.WORKER self.host['personality'] = constants.WORKER
@ -1143,8 +1139,9 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
options = {'IPV6_AUTOCONF': 'no', options = {'IPV6_AUTOCONF': 'no',
'LINKDELAY': '20', 'LINKDELAY': '20',
'post_up': 'post_up':
'/usr/local/bin/cgcs_tc_setup.sh %s %s %s > /dev/null' % '%s %s %s %s > /dev/null' %
(self.port['name'], constants.NETWORK_TYPE_MGMT, (constants.TRAFFIC_CONTROL_SCRIPT,
self.port['name'], constants.NETWORK_TYPE_MGMT,
constants.LINK_SPEED_10G)} constants.LINK_SPEED_10G)}
expected = self._get_network_config( expected = self._get_network_config(
ifname=self.port['name'], mtu=1500, options=options) ifname=self.port['name'], mtu=1500, options=options)