ovs: Fix incorrect ovs bond mode
The `balance-tcp` mode also have `lacp: active` in database, we should only set `lacp` mode when not `balance-tcp` mode. Integration test case created to cover all four ovs bond mode. Signed-off-by: Gris Ge <fge@redhat.com>
This commit is contained in:
parent
d2f669ed3d
commit
78dc99fcd5
@ -161,9 +161,11 @@ fn parse_ovs_bond_conf(
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(Value::String(lacp)) = ovsdb_port.options.get("lacp") {
|
||||
if lacp.as_str() == "active" {
|
||||
bond_conf.mode = Some(OvsBridgeBondMode::Lacp);
|
||||
if bond_conf.mode.is_none() {
|
||||
if let Some(Value::String(lacp)) = ovsdb_port.options.get("lacp") {
|
||||
if lacp.as_str() == "active" {
|
||||
bond_conf.mode = Some(OvsBridgeBondMode::Lacp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1501,3 +1501,53 @@ def test_ovs_vlan_access_mode_with_tag_0():
|
||||
|
||||
assertlib.assert_absent(BRIDGE1)
|
||||
assertlib.assert_absent(PORT1)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cleanup_ovs_bridge():
|
||||
yield
|
||||
libnmstate.apply(
|
||||
{
|
||||
Interface.KEY: [
|
||||
{
|
||||
Interface.NAME: BRIDGE0,
|
||||
Interface.STATE: InterfaceState.ABSENT,
|
||||
},
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"bond_mode",
|
||||
[
|
||||
OVSBridge.Port.LinkAggregation.Mode.ACTIVE_BACKUP,
|
||||
OVSBridge.Port.LinkAggregation.Mode.BALANCE_SLB,
|
||||
OVSBridge.Port.LinkAggregation.Mode.BALANCE_TCP,
|
||||
OVSBridge.Port.LinkAggregation.Mode.LACP,
|
||||
],
|
||||
ids=["active-backup", "balance-slb", "balance-tcp", "lacp"],
|
||||
)
|
||||
def test_crate_ovs_bond(cleanup_ovs_bridge, eth1_up, eth2_up, bond_mode):
|
||||
desired_state = yaml.load(
|
||||
"""---
|
||||
interfaces:
|
||||
- name: br0
|
||||
type: ovs-bridge
|
||||
state: up
|
||||
bridge:
|
||||
port:
|
||||
- name: ovs0
|
||||
- name: bond0
|
||||
link-aggregation:
|
||||
mode: {bond_mode}
|
||||
port:
|
||||
- name: eth1
|
||||
- name: eth2
|
||||
""".format(
|
||||
bond_mode=bond_mode
|
||||
),
|
||||
Loader=yaml.SafeLoader,
|
||||
)
|
||||
libnmstate.apply(desired_state)
|
||||
assertlib.assert_state_match(desired_state)
|
||||
|
Loading…
x
Reference in New Issue
Block a user