Add bond option primary_reselect
This update is to allow the option primary_reselect configurable for aggregated ethernet interface. The option is to prevent reverting between the primary slave and other slaves. Story: 2008706 Task: 42057 Change-Id: Icacc0bd2d5e42bf2e5db1505fd676c628dbe3ed1 Signed-off-by: Teresa Ho <teresa.ho@windriver.com>
This commit is contained in:
parent
7a2a54c2b7
commit
08c14894f3
|
@ -2417,6 +2417,7 @@ itemNotFound (404)
|
|||
"iftype (Optional)", "plain", "xsd:string", "Indicates the type of L2 interface; ``ethernet`` or ``ae`` (aggregated ethernet or link aggregation (LAG)) or ``vlan`` (virtual lan) or ``vf`` (sriov vf)."
|
||||
"aemode (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae``, this attribute indicates the basic mode of operation for the AE/LAG interface. Supported modes are: balanced round robin, active-backup, balanced xor, broadcast, 802.3ad, balance-tlb, balance-alb. NOTE only balanced xor and active-standby modes are supported by interfaces of ifclass=data."
|
||||
"txhashpolicy (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae`` and ``aemode : balanced``, this attribute indicates what packet headers the AE/LAG is using to distribute packets across the different links/ports of the AE/LAG group; ``layer2``, ``layer2+3`` or ``layer3+4``."
|
||||
"primary_reselect (Optional)", "plain", "xsd:string", "The reselection policy for the primary slave of the AE/LAG interface: ``always`` (default), ``better``or ``failure``. Only applicable if ``iftype : ae`` and ``aemode : active_standby`` and ``ifclass :platform``."
|
||||
"vlan_id (Optional)", "plain", "xsd:integer", "Only applicable if ``iftype : vlan``, this attribute indicates that the vlan interface id. A vlan id between 1 and 4094 (inclusive) must be selected. NOTE The vlan id must be unique for the host interface."
|
||||
"imac (Optional)", "plain", "xsd:string", "The MAC Address being used by the interface. In the case of AE/LAG, the MAC address of one of the physical ports of the AE/LAG group is used."
|
||||
"imtu (Optional)", "plain", "xsd:integer", "The Maximum Transmission Unit (MTU) of the interface, in bytes."
|
||||
|
@ -2451,6 +2452,7 @@ itemNotFound (404)
|
|||
}
|
||||
],
|
||||
"txhashpolicy": null,
|
||||
"primary_reselect": null,
|
||||
"schedpolicy": null,
|
||||
"imac": "08:00:27:80:aa:6e",
|
||||
"sriov_numvfs": 0,
|
||||
|
@ -2476,6 +2478,7 @@ itemNotFound (404)
|
|||
}
|
||||
],
|
||||
"txhashpolicy": "layer2",
|
||||
"primary_reselect": null,
|
||||
"schedpolicy": null,
|
||||
"imac": null,
|
||||
"sriov_numvfs": 0,
|
||||
|
@ -2532,6 +2535,7 @@ itemNotFound (404)
|
|||
"iftype (Optional)", "plain", "xsd:string", "Indicates the type of L2 interface; ``ethernet`` or ``ae`` (aggregated ethernet or link aggregation (LAG)) or ``vlan`` (virtual lan)."
|
||||
"aemode (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae``, this attribute indicates the basic mode of operation for the AE/LAG interface. Supported modes are: balanced round robin, active-backup, balanced xor, broadcast, 802.3ad, balance-tlb, balance-alb. NOTE only balanced xor and active-standby modes are supported by interfaces of ifclass=data."
|
||||
"txhashpolicy (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae`` and ``aemode : balanced``, this attribute indicates what packet headers the AE/LAG is using to distribute packets across the different links/ports of the AE/LAG group; ``layer2``, ``layer2+3`` or ``layer3+4``."
|
||||
"primary_reselect (Optional)", "plain", "xsd:string", "The reselection policy for the primary slave of the AE/LAG interface: ``always`` (default), ``better``or ``failure``. Only applicable if ``iftype : ae`` and ``aemode : active_standby`` and ``ifclass :platform``."
|
||||
"vlan_id (Optional)", "plain", "xsd:integer", "Only applicable if ``iftype : vlan``, this attribute indicates that the vlan interface id. A vlan id between 1 and 4094 (inclusive) must be selected. NOTE The vlan id must be unique for the host interface."
|
||||
"imac (Optional)", "plain", "xsd:string", "The MAC Address being used by the interface. In the case of AE/LAG, the MAC address of one of the physical ports of the AE/LAG group is used."
|
||||
"imtu (Optional)", "plain", "xsd:integer", "The Maximum Transmission Unit (MTU) of the interface, in bytes."
|
||||
|
@ -2563,6 +2567,7 @@ itemNotFound (404)
|
|||
}
|
||||
],
|
||||
"txhashpolicy" : "layer2",
|
||||
"primary_reselect": null,
|
||||
"schedpolicy" : null,
|
||||
"uuid" : "740a5bec-b7a8-4645-93ed-aea0d4cfbf86",
|
||||
"ihost_uuid" : "ff453a51-1d3b-437f-a65e-b2d163f79f85",
|
||||
|
@ -2623,8 +2628,9 @@ badMediaType (415)
|
|||
"ifname (Optional)", "plain", "xsd:string", "The name for the interface."
|
||||
"ifclass (Optional)", "plain", "xsd:string", "The class of the interface: ``platform``, ``data``, ``pci-passthrough`` or ``pci-sriov``."
|
||||
"iftype (Optional)", "plain", "xsd:string", "The type of interface; i.e. ``ae`` or ``vlan`` or ``ethernet``."
|
||||
"aemode (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae``, this attribute specifies whether the AE/LAG should operate as ``balanced`` or ``active_standby`` or ``802.3ad`` across its links. The ``balanced`` and ``active_standby`` are the only modes supported by ``data`` type interface. For ``mgmt`` type interface the ``802.3ad`` option must be selected."
|
||||
"aemode (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae``, this attribute specifies whether the AE/LAG should operate as ``balanced`` or ``active_standby`` or ``802.3ad`` across its links. The ``balanced`` and ``active_standby`` are the only modes supported by ``data`` type interface. For ``mgmt`` type interface the ``802.3ad`` and ``active_standby`` options are supported."
|
||||
"txhashpolicy (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae`` and ``aemode : balanced``, this attribute specifies what packet headers the AE/LAG should use to distribute packets across the different links/ports of the AE/LAG group; ``layer2``, ``layer2+3`` or ``layer3+4``."
|
||||
"primary_reselect (Optional)", "plain", "xsd:string", "The reselection policy for the primary slave of the AE/LAG interface: ``always`` (default), ``better``or ``failure``. Only applicable if ``iftype : ae`` and ``aemode : active_standby`` and ``ifclass :platform``."
|
||||
"vlan_id (Optional)", "plain", "xsd:integer", "Only applicable if ``iftype : vlan``, this attribute specifies a virtual lan id for a vlan interface type."
|
||||
"ports (Optional)", "plain", "xsd:list", "This attribute specifies a comma-separated list of ports that this interface contains. If ``iftype : ethernet`` then only one port is allowed."
|
||||
"uses (Optional)", "plain", "xsd:list", "Only applicable if ``iftype : ae`` or ``iftype: vlan`` or ``iftype: ethernet``, this attribute specifies a comma-separated list of interfaces that this interface uses."
|
||||
|
@ -2645,6 +2651,7 @@ badMediaType (415)
|
|||
"iftype (Optional)", "plain", "xsd:string", "Indicates the type of L2 interface; ``ethernet`` or ``ae`` (aggregated ethernet or link aggregation (LAG)) or ``vlan`` (virtual lan)."
|
||||
"aemode (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae``, this attribute indicates the basic mode of operation for the AE/LAG interface. Supported modes are: balanced round robin, active-backup, balanced xor, broadcast, 802.3ad, balance-tlb, balance-alb. NOTE only balanced xor and active-standby modes are supported by interfaces of ifclass=data."
|
||||
"txhashpolicy (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae`` and ``aemode : balanced``, this attribute indicates what packet headers the AE/LAG is using to distribute packets across the different links/ports of the AE/LAG group; ``layer2``, ``layer2+3`` or ``layer3+4``."
|
||||
"primary_reselect (Optional)", "plain", "xsd:string", "The reselection policy for the primary slave of the AE/LAG interface: ``always`` (default), ``better``or ``failure``. Only applicable if ``iftype : ae`` and ``aemode : active_standby`` and ``ifclass :platform``."
|
||||
"vlan_id (Optional)", "plain", "xsd:integer", "Only applicable if ``iftype : vlan``, this attribute indicates that the vlan interface id. A vlan id between 1 and 4094 (inclusive) must be selected. NOTE The vlan id must be unique for the host interface."
|
||||
"imac (Optional)", "plain", "xsd:string", "The MAC Address being used by the interface. In the case of AE/LAG, the MAC address of one of the physical ports of the AE/LAG group is used."
|
||||
"imtu (Optional)", "plain", "xsd:integer", "The Maximum Transmission Unit (MTU) of the interface, in bytes."
|
||||
|
@ -2667,6 +2674,7 @@ badMediaType (415)
|
|||
{
|
||||
"iftype": "ae",
|
||||
"txhashpolicy": "layer2",
|
||||
"primary_reselect": null,
|
||||
"ihost_uuid": "ff453a51-1d3b-437f-a65e-b2d163f79f85",
|
||||
"imtu": "1500",
|
||||
"ifclass": "data",
|
||||
|
@ -2705,6 +2713,7 @@ badMediaType (415)
|
|||
"ihost_uuid": "ff453a51-1d3b-437f-a65e-b2d163f79f85",
|
||||
"vlan_id": null,
|
||||
"txhashpolicy": "layer2",
|
||||
"primary_reselect": null,
|
||||
"created_at": "2014-09-29T10:55:20.515705+00:00",
|
||||
"schedpolicy": null,
|
||||
"imac": null,
|
||||
|
@ -2754,6 +2763,7 @@ badMediaType (415)
|
|||
"iftype (Optional)", "plain", "xsd:string", "The type of interface; i.e. ``ethernet`` or ``ae`` or ``vlan``."
|
||||
"aemode (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae``, this attribute specifies whether the AE/LAG should operate as ``balanced`` or ``active_standby`` across its links. These are the only modes supported by ``data`` type interface."
|
||||
"txhashpolicy (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae`` and ``aemode : balanced``, this attribute specifies what packet headers the AE/LAG should use to distribute packets across the different links/ports of the AE/LAG group; ``layer2``, ``layer2+3`` or ``layer3+4``."
|
||||
"primary_reselect (Optional)", "plain", "xsd:string", "The reselection policy for the primary slave of the AE/LAG interface: ``always`` (default), ``better``or ``failure``. Only applicable if ``iftype : ae`` and ``aemode : active_standby`` and ``ifclass :platform``."
|
||||
"vlan_id (Optional)", "plain", "xsd:integer", "Only applicable if ``iftype : vlan``, this attribute specifies a virtual lan id for a vlan interface type."
|
||||
"ports (Optional)", "plain", "xsd:list", "This attribute specifies a comma-separated list of ports that this interface contains. If ``iftype : ethernet`` then only one port is allowed."
|
||||
"uses (Optional)", "plain", "xsd:list", "Only applicable if ``iftype : ae`` or ``iftype: vlan`` or ``iftype: ethernet``, this attribute specifies a comma-separated list of interfaces that this interface uses."
|
||||
|
@ -2773,6 +2783,7 @@ badMediaType (415)
|
|||
"iftype (Optional)", "plain", "xsd:string", "Indicates the type of L2 interface; ``ethernet`` or ``ae`` (aggregated ethernet or link aggregation (LAG)) or ``vlan`` (virtual lan)."
|
||||
"aemode (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae``, this attribute indicates the basic mode of operation for the AE/LAG interface. Supported modes are: balanced round robin, active-backup, balanced xor, broadcast, 802.3ad, balance-tlb, balance-alb. NOTE only balanced xor and active-standby modes are supported by interfaces of ifclass=data."
|
||||
"txhashpolicy (Optional)", "plain", "xsd:string", "Only applicable if ``iftype : ae`` and ``aemode : balanced``, this attribute indicates what packet headers the AE/LAG is using to distribute packets across the different links/ports of the AE/LAG group; ``layer2``, ``layer2+3`` or ``layer3+4``."
|
||||
"primary_reselect (Optional)", "plain", "xsd:string", "The reselection policy for the primary slave of the AE/LAG interface: ``always`` (default), ``better``or ``failure``. Only applicable if ``iftype : ae`` and ``aemode : active_standby`` and ``ifclass :platform``."
|
||||
"vlan_id (Optional)", "plain", "xsd:integer", "Only applicable if ``iftype : vlan``, this attribute indicates that the vlan interface id. A vlan id between 1 and 4094 (inclusive) must be selected. NOTE The vlan id must be unique for the host interface."
|
||||
"imac (Optional)", "plain", "xsd:string", "The MAC Address being used by the interface. In the case of AE/LAG, the MAC address of one of the physical ports of the AE/LAG group is used."
|
||||
"imtu (Optional)", "plain", "xsd:integer", "The Maximum Transmission Unit (MTU) of the interface, in bytes."
|
||||
|
@ -2808,6 +2819,11 @@ badMediaType (415)
|
|||
"value": "active_standby",
|
||||
"op": "replace"
|
||||
},
|
||||
{
|
||||
"path": "/primary_reselect",
|
||||
"value": "better",
|
||||
"op": "replace"
|
||||
},
|
||||
{
|
||||
"path": "/uses",
|
||||
"value": ['eth2','eth3'],
|
||||
|
@ -2844,6 +2860,7 @@ badMediaType (415)
|
|||
"ihost_uuid": "ff453a51-1d3b-437f-a65e-b2d163f79f85",
|
||||
"vlan_id": null,
|
||||
"txhashpolicy": "layer2",
|
||||
"primary_reselect": null,
|
||||
"created_at": "2014-09-29T10:55:20.515705+00:00",
|
||||
"schedpolicy": null,
|
||||
"imac": null,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2013-2015 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -15,7 +15,7 @@ from cgtsclient.v1 import port
|
|||
CREATION_ATTRIBUTES = ['ifname', 'iftype', 'ihost_uuid', 'imtu', 'ifclass',
|
||||
'networks', 'network_uuid', 'networktype', 'aemode', 'txhashpolicy',
|
||||
'providernetworks', 'datanetworks', 'ifcapabilities', 'ports', 'imac',
|
||||
'vlan_id', 'uses', 'used_by',
|
||||
'vlan_id', 'uses', 'used_by', 'primary_reselect',
|
||||
'ipv4_mode', 'ipv6_mode', 'ipv4_pool', 'ipv6_pool',
|
||||
'sriov_numvfs', 'sriov_vf_driver', 'ptp_role', 'max_tx_rate']
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2013-2014 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -17,7 +17,7 @@ from cgtsclient.v1 import iinterface as iinterface_utils
|
|||
def _print_iinterface_show(cc, iinterface):
|
||||
fields = ['ifname', 'iftype', 'ports',
|
||||
'imac', 'imtu', 'ifclass', 'ptp_role',
|
||||
'aemode', 'schedpolicy', 'txhashpolicy',
|
||||
'aemode', 'schedpolicy', 'txhashpolicy', 'primary_reselect',
|
||||
'uuid', 'ihost_uuid',
|
||||
'vlan_id', 'uses', 'used_by',
|
||||
'created_at', 'updated_at', 'sriov_numvfs',
|
||||
|
@ -80,6 +80,9 @@ def do_host_if_list(cc, args):
|
|||
if i.aemode in ['balanced', '802.3ad']:
|
||||
attr_str = "%s,AE_XMIT_POLICY=%s" % (
|
||||
attr_str, i.txhashpolicy)
|
||||
if i.aemode == 'active_standby' and i.primary_reselect:
|
||||
attr_str = "%s,primary_reselect=%s" % (
|
||||
attr_str, i.primary_reselect)
|
||||
if i.ifclass and i.ifclass == 'data':
|
||||
if False in i.dpdksupport:
|
||||
attr_str = "%s,accelerated=False" % attr_str
|
||||
|
@ -176,11 +179,16 @@ def do_host_if_delete(cc, args):
|
|||
dest='max_tx_rate',
|
||||
metavar='<max_tx_rate>',
|
||||
help='The max tx rate (Mb/s) of the SR-IOV VF interface')
|
||||
@utils.arg('--primary-reselect',
|
||||
dest='primary_reselect',
|
||||
metavar='<primary reselect>',
|
||||
choices=['always', 'better', 'failure'],
|
||||
help='The reselection policy for active standby bonded interface (always, better, failure)')
|
||||
def do_host_if_add(cc, args):
|
||||
"""Add an interface."""
|
||||
|
||||
field_list = ['ifname', 'iftype', 'imtu', 'ifclass', 'aemode',
|
||||
'txhashpolicy', 'vlan_id', 'ptp_role',
|
||||
'txhashpolicy', 'vlan_id', 'ptp_role', 'primary_reselect',
|
||||
'ipv4_mode', 'ipv6_mode', 'ipv4_pool', 'ipv6_pool',
|
||||
'sriov_numvfs', 'sriov_vf_driver', 'max_tx_rate']
|
||||
|
||||
|
@ -278,11 +286,16 @@ def do_host_if_add(cc, args):
|
|||
dest='max_tx_rate',
|
||||
metavar='<max_tx_rate>',
|
||||
help='The max tx rate (Mb/s) of the VF interface')
|
||||
@utils.arg('--primary-reselect',
|
||||
dest='primary_reselect',
|
||||
metavar='<primary reselect>',
|
||||
choices=['always', 'better', 'failure'],
|
||||
help='The reselection policy for active standby bonded interface (always, better, failure)')
|
||||
def do_host_if_modify(cc, args):
|
||||
"""Modify interface attributes."""
|
||||
|
||||
rwfields = ['iftype', 'ifname', 'imtu', 'aemode', 'txhashpolicy',
|
||||
'ports', 'ifclass', 'ptp_role',
|
||||
'ports', 'ifclass', 'ptp_role', 'primary_reselect',
|
||||
'ipv4_mode', 'ipv6_mode', 'ipv4_pool', 'ipv6_pool',
|
||||
'sriov_numvfs', 'sriov_vf_driver', 'max_tx_rate']
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Copyright (c) 2013-2019 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -144,6 +144,9 @@ class Interface(base.APIBase):
|
|||
txhashpolicy = wtypes.text
|
||||
"Represent the txhashpolicy of the interface"
|
||||
|
||||
primary_reselect = wtypes.text
|
||||
"Represent the primary_reselect mode of the interface"
|
||||
|
||||
ifcapabilities = {wtypes.text: utils.ValidTypes(wtypes.text,
|
||||
six.integer_types)}
|
||||
"This interface's meta data"
|
||||
|
@ -221,7 +224,7 @@ class Interface(base.APIBase):
|
|||
'vlan_id', 'uses', 'usesmodify', 'used_by',
|
||||
'ipv4_mode', 'ipv6_mode', 'ipv4_pool', 'ipv6_pool',
|
||||
'sriov_numvfs', 'sriov_vf_driver', 'ptp_role',
|
||||
'max_tx_rate'])
|
||||
'max_tx_rate', 'primary_reselect'])
|
||||
|
||||
# never expose the ihost_id attribute
|
||||
interface.ihost_id = wtypes.Unset
|
||||
|
@ -673,6 +676,7 @@ def _set_defaults(interface):
|
|||
defaults = {'imtu': DEFAULT_MTU,
|
||||
'aemode': constants.AE_MODE_ACTIVE_STANDBY,
|
||||
'txhashpolicy': None,
|
||||
'primary_reselect': None,
|
||||
'vlan_id': None,
|
||||
'sriov_numvfs': 0,
|
||||
'sriov_vf_driver': None,
|
||||
|
@ -1081,6 +1085,33 @@ def _check_interface_ptp(interface):
|
|||
raise wsme.exc.ClientSideError(msg)
|
||||
|
||||
|
||||
def _check_ae_primary_reselect(interface):
|
||||
ifclass = interface['ifclass']
|
||||
iftype = interface['iftype']
|
||||
primary_reselect = interface['primary_reselect']
|
||||
aemode = interface['aemode']
|
||||
if primary_reselect is not None:
|
||||
if iftype != constants.INTERFACE_TYPE_AE:
|
||||
msg = _("The option primary_reselect is only applicable to bonded interface. ")
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
if aemode != constants.AE_MODE_ACTIVE_STANDBY and primary_reselect is not None:
|
||||
msg = _("Device interface with interface type 'aggregated ethernet' "
|
||||
"in '%s' mode should not specify primary_reselect option." % aemode)
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
if (ifclass != constants.INTERFACE_CLASS_PLATFORM and
|
||||
primary_reselect != constants.PRIMARY_RESELECT_ALWAYS):
|
||||
msg = _("The option primary_reselect must be 'always' for non-platform interfaces. ")
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
if primary_reselect not in constants.VALID_PRIMARY_RESELECT_LIST:
|
||||
msg = _("Invalid bonding primary reselect option: '{}'. "
|
||||
"Valid options must be one of {}".format(primary_reselect,
|
||||
', '.join(constants.VALID_PRIMARY_RESELECT_LIST)))
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
else:
|
||||
if iftype == constants.INTERFACE_TYPE_AE and aemode == constants.AE_MODE_ACTIVE_STANDBY:
|
||||
interface['primary_reselect'] = constants.PRIMARY_RESELECT_ALWAYS
|
||||
|
||||
|
||||
def _check_interface_data(op, interface, ihost, existing_interface,
|
||||
datanetworks=None):
|
||||
# Get data
|
||||
|
@ -1221,6 +1252,8 @@ def _check_interface_data(op, interface, ihost, existing_interface,
|
|||
"in '%s' mode should not specify a Tx Hash Policy." % aemode)
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
|
||||
_check_ae_primary_reselect(interface)
|
||||
|
||||
# Make sure interface type is valid
|
||||
supported_type = [constants.INTERFACE_TYPE_AE,
|
||||
constants.INTERFACE_TYPE_VLAN,
|
||||
|
@ -1865,6 +1898,9 @@ def _check(op, interface, ports=None, ifaces=None, from_profile=False,
|
|||
if 'txhashpolicy' not in iface:
|
||||
iface['txhashpolicy'] = None
|
||||
|
||||
if 'primary_reselect' not in iface:
|
||||
iface['primary_reselect'] = None
|
||||
|
||||
_check_interface_data(
|
||||
"modify", iface, ihost, existing_iface, datanetworks)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Copyright (c) 2013-2018 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2021 Wind River Systems, Inc.
|
||||
#
|
||||
|
||||
import jsonpatch
|
||||
|
@ -79,7 +79,8 @@ INTERFACE_PROFILE_FIELDS = ['ifname', 'iftype', 'imtu', 'networktype',
|
|||
'txhashpolicy', 'forihostid', 'datanetworks',
|
||||
'vlan_id', 'ipv4_mode', 'ipv6_mode',
|
||||
'ipv4_pool', 'ipv6_pool',
|
||||
'sriov_numvfs', 'sriov_vf_driver', 'max_tx_rate']
|
||||
'sriov_numvfs', 'sriov_vf_driver', 'max_tx_rate',
|
||||
'primary_reselect']
|
||||
|
||||
|
||||
class Profile(base.APIBase):
|
||||
|
@ -1389,6 +1390,7 @@ def _create_if_profile(profile_name, profile_node):
|
|||
'networktype': nt,
|
||||
'aemode': aeIf.aeMode,
|
||||
'txhashpolicy': aeIf.txPolicy,
|
||||
'primary_reselect': aeIf.primary_reselect,
|
||||
'forihostid': iprofile_id,
|
||||
'datanetworks': providernets,
|
||||
'ipv4_mode': ipv4_mode,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Copyright (c) 2013-2015 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2021 Wind River Systems, Inc.
|
||||
#
|
||||
|
||||
import netaddr
|
||||
|
@ -307,12 +307,15 @@ class AeInterface(Interface):
|
|||
if node.tag == 'activeStandby':
|
||||
self.aeMode = 'activeStandby'
|
||||
self.txPolicy = None
|
||||
self.primary_reselect = node.get('primary_reselect')
|
||||
elif node.tag == 'balanced':
|
||||
self.aeMode = 'balanced'
|
||||
self.txPolicy = node.get('txPolicy')
|
||||
self.primary_reselect = None
|
||||
elif node.tag == 'ieee802.3ad':
|
||||
self.aeMode = '802.3ad'
|
||||
self.txPolicy = node.get('txPolicy')
|
||||
self.primary_reselect = None
|
||||
|
||||
node = ifNode.find('interfaces')
|
||||
if node:
|
||||
|
|
|
@ -730,6 +730,13 @@ VALID_AEMODE_LIST = [AE_MODE_ACTIVE_STANDBY,
|
|||
AE_MODE_BALANCED,
|
||||
AE_MODE_LACP]
|
||||
|
||||
PRIMARY_RESELECT_ALWAYS = 'always'
|
||||
PRIMARY_RESELECT_BETTER = 'better'
|
||||
PRIMARY_RESELECT_FAILURE = 'failure'
|
||||
VALID_PRIMARY_RESELECT_LIST = [PRIMARY_RESELECT_ALWAYS,
|
||||
PRIMARY_RESELECT_BETTER,
|
||||
PRIMARY_RESELECT_FAILURE]
|
||||
|
||||
SM_MULTICAST_MGMT_IP_NAME = "sm-mgmt-ip"
|
||||
MTCE_MULTICAST_MGMT_IP_NAME = "mtce-mgmt-ip"
|
||||
PATCH_CONTROLLER_MULTICAST_MGMT_IP_NAME = "patch-controller-mgmt-ip"
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright (c) 2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
from sqlalchemy import Column, MetaData, String, Table
|
||||
|
||||
ENGINE = 'InnoDB'
|
||||
CHARSET = 'utf8'
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
ae_interfaces = Table('ae_interfaces', meta, autoload=True)
|
||||
ae_interfaces.create_column(Column('primary_reselect', String(32)))
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
# Downgrade is unsupported in this release.
|
||||
raise NotImplementedError('SysInv database downgrade is unsupported.')
|
|
@ -415,6 +415,7 @@ class AeInterfaces(EthernetCommon, Interfaces):
|
|||
aedict = Column(JSONEncodedDict) # e.g. 802.3ad parameters
|
||||
txhashpolicy = Column(String(255)) # e.g. L2, L2L3, L3L4
|
||||
schedpolicy = Column(String(255))
|
||||
primary_reselect = Column(String(32)) # e.g. always, better, failure
|
||||
|
||||
__mapper_args__ = {
|
||||
'polymorphic_identity': 'ae',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2013-2019 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -129,6 +129,7 @@ class Interface(base.SysinvObject):
|
|||
'aemode': utils.str_or_none,
|
||||
'schedpolicy': utils.str_or_none,
|
||||
'txhashpolicy': utils.str_or_none,
|
||||
'primary_reselect': utils.str_or_none,
|
||||
'networktypelist': utils.list_of_strings_or_none,
|
||||
'datanetworks': utils.list_of_strings_or_none,
|
||||
|
||||
|
@ -161,7 +162,7 @@ class Interface(base.SysinvObject):
|
|||
'datanetworks': get_datanetworks}
|
||||
|
||||
_optional_fields = ['aemode', 'txhashpolicy', 'schedpolicy',
|
||||
'vlan_id', 'vlan_type']
|
||||
'vlan_id', 'vlan_type', 'primary_reselect']
|
||||
|
||||
@base.remotable_classmethod
|
||||
def get_by_uuid(cls, context, uuid):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2013-2016 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -19,6 +19,7 @@ class AEInterface(interface_ethernet.EthernetInterface):
|
|||
'aemode': utils.str_or_none,
|
||||
'schedpolicy': utils.str_or_none,
|
||||
'txhashpolicy': utils.str_or_none,
|
||||
'primary_reselect': utils.str_or_none,
|
||||
'ifcapabilities': utils.dict_or_none,
|
||||
}, **interface_ethernet.EthernetInterface.fields)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2017-2019 Wind River Systems, Inc.
|
||||
# Copyright (c) 2017-2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -878,6 +878,8 @@ def get_bond_interface_options(iface, primary_iface):
|
|||
# Requires the active device in an active_standby LAG
|
||||
# configuration to be determined based on the lowest MAC address
|
||||
options = 'mode=active-backup miimon=100 primary={}'.format(primary_iface['ifname'])
|
||||
if iface['primary_reselect']:
|
||||
options += ' primary_reselect=%s' % iface['primary_reselect']
|
||||
else:
|
||||
options = 'xmit_hash_policy=%s miimon=100' % tx_hash_policy
|
||||
if ae_mode in BALANCED_AE_MODES:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2013-2016 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -1744,6 +1744,57 @@ class TestPostMixin(object):
|
|||
self.assertIn("Invalid aggregated ethernet mode 'bad_aemode'",
|
||||
response.json['error_message'])
|
||||
|
||||
def test_non_aemode_primary_reselect(self):
|
||||
ndict = self._post_get_test_interface(
|
||||
ihost_uuid=self.worker.uuid,
|
||||
ifname='name',
|
||||
ifclass=constants.INTERFACE_CLASS_PLATFORM,
|
||||
iftype=constants.INTERFACE_TYPE_ETHERNET,
|
||||
aemode=constants.AE_MODE_ACTIVE_STANDBY,
|
||||
primary_reselect=constants.PRIMARY_RESELECT_BETTER)
|
||||
response = self._post_and_check_failure(ndict)
|
||||
self.assertIn("The option primary_reselect is only applicable to bonded interface.",
|
||||
response.json['error_message'])
|
||||
|
||||
def test_aemode_balanced_primary_reselect(self):
|
||||
ndict = self._post_get_test_interface(
|
||||
ihost_uuid=self.worker.uuid,
|
||||
ifname='name',
|
||||
ifclass=constants.INTERFACE_CLASS_PLATFORM,
|
||||
iftype=constants.INTERFACE_TYPE_AE,
|
||||
aemode=constants.AE_MODE_BALANCED,
|
||||
txhashpolicy='layer2',
|
||||
primary_reselect=constants.PRIMARY_RESELECT_BETTER)
|
||||
response = self._post_and_check_failure(ndict)
|
||||
self.assertIn("Device interface with interface type "
|
||||
"\'aggregated ethernet\' in \'balanced\' "
|
||||
"mode should not specify primary_reselect option.",
|
||||
response.json['error_message'])
|
||||
|
||||
def test_aemode_invalid_data_primary_reselect(self):
|
||||
ndict = self._post_get_test_interface(
|
||||
ihost_uuid=self.worker.uuid,
|
||||
ifname='name',
|
||||
ifclass=constants.INTERFACE_CLASS_DATA,
|
||||
iftype=constants.INTERFACE_TYPE_AE,
|
||||
aemode=constants.AE_MODE_ACTIVE_STANDBY,
|
||||
primary_reselect=constants.PRIMARY_RESELECT_FAILURE)
|
||||
response = self._post_and_check_failure(ndict)
|
||||
self.assertIn("The option primary_reselect must be 'always' for non-platform interfaces.",
|
||||
response.json['error_message'])
|
||||
|
||||
def test_aemode_invalid_primary_reselect(self):
|
||||
ndict = self._post_get_test_interface(
|
||||
ihost_uuid=self.worker.uuid,
|
||||
ifname='name',
|
||||
ifclass=constants.INTERFACE_CLASS_PLATFORM,
|
||||
iftype=constants.INTERFACE_TYPE_AE,
|
||||
aemode='active_standby',
|
||||
primary_reselect='bad_primary_reselect')
|
||||
response = self._post_and_check_failure(ndict)
|
||||
self.assertIn("Invalid bonding primary reselect option: 'bad_primary_reselect'",
|
||||
response.json['error_message'])
|
||||
|
||||
def test_setting_mgmt_mtu_allowed(self):
|
||||
ndict = self._post_get_test_interface(
|
||||
ihost_uuid=self.worker.uuid,
|
||||
|
|
|
@ -1038,6 +1038,7 @@ def get_test_interface(**kw):
|
|||
'networktypelist': kw.get('networktypelist', []),
|
||||
'aemode': kw.get('aemode'),
|
||||
'txhashpolicy': kw.get('txhashpolicy', None),
|
||||
'primary_reselect': kw.get('primary_reselect', None),
|
||||
'vlan_id': kw.get('vlan_id', None),
|
||||
'uses': kw.get('uses', []),
|
||||
'used_by': kw.get('used_by', []),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2017-2018 Wind River Systems, Inc.
|
||||
# Copyright (c) 2017-2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
@ -1265,12 +1265,29 @@ class InterfaceTestCase(InterfaceTestCaseMixin, dbbase.BaseHostTestCase):
|
|||
def test_get_controller_bond_config_active_standby(self):
|
||||
bond = self._create_bond_test("bond0")
|
||||
bond['aemode'] = 'active_standby'
|
||||
bond['primary_reselect'] = constants.PRIMARY_RESELECT_ALWAYS
|
||||
self._update_context()
|
||||
config = interface.get_interface_network_config(self.context, bond)
|
||||
options = {'IPV6_AUTOCONF': 'no',
|
||||
'up': 'sleep 10',
|
||||
'MACADDR': bond['imac'],
|
||||
'BONDING_OPTS': 'mode=active-backup miimon=100 primary=eth1'}
|
||||
'BONDING_OPTS': 'mode=active-backup miimon=100 primary=eth1 primary_reselect=always'}
|
||||
expected = self._get_network_config(
|
||||
ifname=bond['ifname'], mtu=1500, method='manual', options=options)
|
||||
print(expected)
|
||||
self.assertEqual(expected, config)
|
||||
|
||||
def test_get_controller_bond_config_active_standby_primary_reselect(self):
|
||||
bond = self._create_bond_test("bond0", constants.INTERFACE_CLASS_PLATFORM,
|
||||
constants.NETWORK_TYPE_MGMT)
|
||||
bond['aemode'] = 'active_standby'
|
||||
bond['primary_reselect'] = constants.PRIMARY_RESELECT_BETTER
|
||||
self._update_context()
|
||||
config = interface.get_interface_network_config(self.context, bond)
|
||||
options = {'IPV6_AUTOCONF': 'no',
|
||||
'up': 'sleep 10',
|
||||
'MACADDR': bond['imac'],
|
||||
'BONDING_OPTS': 'mode=active-backup miimon=100 primary=eth1 primary_reselect=better'}
|
||||
expected = self._get_network_config(
|
||||
ifname=bond['ifname'], mtu=1500, method='manual', options=options)
|
||||
print(expected)
|
||||
|
|
Loading…
Reference in New Issue