Merge "Traffic control fixes and refresh"
This commit is contained in:
commit
4e3d593330
@ -32,7 +32,6 @@ INSTALLATION_FAILED_FILE = '/etc/platform/installation_failed'
|
||||
BACKUPS_PATH = '/opt/backups'
|
||||
|
||||
INTERFACES_LOG_FILE = "/tmp/configure_interfaces.log"
|
||||
TC_SETUP_SCRIPT = '/usr/local/bin/cgcs_tc_setup.sh'
|
||||
|
||||
LINK_MTU_DEFAULT = "1500"
|
||||
|
||||
|
@ -1531,3 +1531,6 @@ DRIVER_MLX_CX4 = 'mlx5_core'
|
||||
|
||||
MELLANOX_DRIVERS = [DRIVER_MLX_CX3,
|
||||
DRIVER_MLX_CX4]
|
||||
|
||||
# Traffic control
|
||||
TRAFFIC_CONTROL_SCRIPT = '/usr/local/bin/tc_setup.sh'
|
||||
|
@ -668,19 +668,19 @@ def get_interface_address_method(context, iface, network_id=None):
|
||||
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)
|
||||
"""
|
||||
networktype = find_networktype_by_network_id(context, network_id)
|
||||
if (networktype and
|
||||
networktype == constants.NETWORK_TYPE_MGMT):
|
||||
networkspeed = constants.LINK_SPEED_10G
|
||||
ifname = get_interface_os_ifname(context, iface)
|
||||
return '/usr/local/bin/cgcs_tc_setup.sh %s %s %s > /dev/null' \
|
||||
% (ifname,
|
||||
networktype,
|
||||
networkspeed)
|
||||
for networktype in iface.networktypelist:
|
||||
if (networktype == constants.NETWORK_TYPE_MGMT):
|
||||
networkspeed = constants.LINK_SPEED_10G
|
||||
ifname = get_interface_os_ifname(context, iface)
|
||||
return '%s %s %s %s > /dev/null' \
|
||||
% (constants.TRAFFIC_CONTROL_SCRIPT,
|
||||
ifname,
|
||||
networktype,
|
||||
networkspeed)
|
||||
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" %
|
||||
(iface.ifname, iface.networktypelist, network_id))
|
||||
traffic_classifier = get_interface_traffic_classifier(context, iface,
|
||||
network_id)
|
||||
if traffic_classifier:
|
||||
config['options']['post_up'] = traffic_classifier
|
||||
|
||||
os_ifname = get_interface_os_ifname(context, iface)
|
||||
if os_ifname == config['ifname']:
|
||||
# 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)
|
||||
if method == STATIC_METHOD:
|
||||
|
@ -675,40 +675,35 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
|
||||
|
||||
def test_get_interface_traffic_classifier_for_mgmt(self):
|
||||
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(
|
||||
constants.NETWORK_TYPE_MGMT)
|
||||
network = self.dbapi.network_get_by_type(
|
||||
constants.NETWORK_TYPE_MGMT)
|
||||
classifier = interface.get_interface_traffic_classifier(
|
||||
self.context, self.iface, network.id)
|
||||
self.context, self.iface)
|
||||
print(self.context)
|
||||
expected = ('/usr/local/bin/cgcs_tc_setup.sh %s %s %s > /dev/null' %
|
||||
(self.port['name'], constants.NETWORK_TYPE_MGMT,
|
||||
expected = ('%s %s %s %s > /dev/null' %
|
||||
(constants.TRAFFIC_CONTROL_SCRIPT,
|
||||
self.port['name'], constants.NETWORK_TYPE_MGMT,
|
||||
constants.LINK_SPEED_10G))
|
||||
self.assertEqual(classifier, expected)
|
||||
|
||||
def test_get_interface_traffic_classifier_for_cluster_host(self):
|
||||
self.iface['ifname'] = 'cluster_host0'
|
||||
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(
|
||||
constants.NETWORK_TYPE_CLUSTER_HOST)
|
||||
network = self.dbapi.network_get_by_type(
|
||||
constants.NETWORK_TYPE_CLUSTER_HOST)
|
||||
classifier = interface.get_interface_traffic_classifier(
|
||||
self.context, self.iface, network.id)
|
||||
self.context, self.iface)
|
||||
self.assertIsNone(classifier)
|
||||
|
||||
def test_get_interface_traffic_classifier_for_oam(self):
|
||||
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(
|
||||
constants.NETWORK_TYPE_OAM)
|
||||
network = self.dbapi.network_get_by_type(
|
||||
constants.NETWORK_TYPE_OAM)
|
||||
classifier = interface.get_interface_traffic_classifier(
|
||||
self.context, self.iface, network.id)
|
||||
self.context, self.iface)
|
||||
self.assertIsNone(classifier)
|
||||
|
||||
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):
|
||||
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(
|
||||
constants.NETWORK_TYPE_MGMT)
|
||||
self._update_context()
|
||||
@ -1010,8 +1005,9 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
|
||||
options = {'IPV6_AUTOCONF': 'no',
|
||||
'LINKDELAY': '20',
|
||||
'post_up':
|
||||
'/usr/local/bin/cgcs_tc_setup.sh %s %s %s > /dev/null' %
|
||||
(self.port['name'], constants.NETWORK_TYPE_MGMT,
|
||||
'%s %s %s %s > /dev/null' %
|
||||
(constants.TRAFFIC_CONTROL_SCRIPT,
|
||||
self.port['name'], constants.NETWORK_TYPE_MGMT,
|
||||
constants.LINK_SPEED_10G)}
|
||||
expected = self._get_static_network_config(
|
||||
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):
|
||||
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(
|
||||
constants.NETWORK_TYPE_MGMT)
|
||||
self.host['personality'] = constants.WORKER
|
||||
@ -1143,8 +1139,9 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
|
||||
options = {'IPV6_AUTOCONF': 'no',
|
||||
'LINKDELAY': '20',
|
||||
'post_up':
|
||||
'/usr/local/bin/cgcs_tc_setup.sh %s %s %s > /dev/null' %
|
||||
(self.port['name'], constants.NETWORK_TYPE_MGMT,
|
||||
'%s %s %s %s > /dev/null' %
|
||||
(constants.TRAFFIC_CONTROL_SCRIPT,
|
||||
self.port['name'], constants.NETWORK_TYPE_MGMT,
|
||||
constants.LINK_SPEED_10G)}
|
||||
expected = self._get_network_config(
|
||||
ifname=self.port['name'], mtu=1500, options=options)
|
||||
|
Loading…
Reference in New Issue
Block a user