nm, ovs: Remove translate bridge options step
The OVS bridge options translation step is translating a dict to a dict with the same key & value to the same key & value. Originally, the intention was to use a translation step between the nmstate public state and the nm provider one, assuming that the two do not have to be the same. However, the translation did not evolve to anything useful and an 1:1 relation was always kept. This has no added value at the moment and therefore it is dropped. Signed-off-by: Edward Haas <edwardh@redhat.com>
This commit is contained in:
parent
9adfaa7c78
commit
649a133628
@ -407,7 +407,8 @@ def _build_connection_profile(iface_desired_state, base_con_profile=None):
|
||||
)
|
||||
settings.append(linux_bridge_setting)
|
||||
elif iface_type == ovs.BRIDGE_TYPE:
|
||||
ovs_bridge_options = ovs.translate_bridge_options(iface_desired_state)
|
||||
ovs_bridge_state = iface_desired_state.get(OvsB.CONFIG_SUBTREE, {})
|
||||
ovs_bridge_options = ovs_bridge_state.get(OvsB.OPTIONS_SUBTREE)
|
||||
if ovs_bridge_options:
|
||||
settings.append(ovs.create_bridge_setting(ovs_bridge_options))
|
||||
elif iface_type == ovs.PORT_TYPE:
|
||||
|
@ -17,7 +17,6 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from libnmstate.error import NmstateValueError
|
||||
from libnmstate.schema import OVSBridge as OB
|
||||
|
||||
from . import connection
|
||||
@ -32,9 +31,6 @@ PORT_PROFILE_PREFIX = "ovs-port-"
|
||||
CAPABILITY = "openvswitch"
|
||||
|
||||
|
||||
_BRIDGE_OPTION_NAMES = ["fail-mode", "mcast-snooping-enable", "rstp", "stp"]
|
||||
|
||||
|
||||
def has_ovs_capability():
|
||||
try:
|
||||
nmclient.NM.DeviceType.OVS_BRIDGE
|
||||
@ -43,9 +39,9 @@ def has_ovs_capability():
|
||||
return False
|
||||
|
||||
|
||||
def create_bridge_setting(options):
|
||||
def create_bridge_setting(options_state):
|
||||
bridge_setting = nmclient.NM.SettingOvsBridge.new()
|
||||
for option_name, option_value in options.items():
|
||||
for option_name, option_value in options_state.items():
|
||||
if option_name == "fail-mode":
|
||||
if option_value:
|
||||
bridge_setting.props.fail_mode = option_value
|
||||
@ -55,12 +51,6 @@ def create_bridge_setting(options):
|
||||
bridge_setting.props.rstp_enable = option_value
|
||||
elif option_name == "stp":
|
||||
bridge_setting.props.stp_enable = option_value
|
||||
else:
|
||||
raise NmstateValueError(
|
||||
"Invalid OVS bridge option: '{}'='{}'".format(
|
||||
option_name, option_value
|
||||
)
|
||||
)
|
||||
|
||||
return bridge_setting
|
||||
|
||||
@ -90,15 +80,6 @@ def create_interface_setting():
|
||||
return interface_setting
|
||||
|
||||
|
||||
def translate_bridge_options(iface_state):
|
||||
br_opts = {}
|
||||
bridge_state = iface_state.get("bridge", {}).get("options", {})
|
||||
for key in bridge_state.keys() & set(_BRIDGE_OPTION_NAMES):
|
||||
br_opts[key] = bridge_state[key]
|
||||
|
||||
return br_opts
|
||||
|
||||
|
||||
def is_ovs_bridge_type_id(type_id):
|
||||
return type_id == nmclient.NM.DeviceType.OVS_BRIDGE
|
||||
|
||||
|
@ -128,7 +128,8 @@ def _get_bridge_current_state():
|
||||
|
||||
@nmclient_context
|
||||
def _create_bridge(bridge_desired_state):
|
||||
br_options = nm.ovs.translate_bridge_options(bridge_desired_state)
|
||||
bridge_state = bridge_desired_state.get(OB.CONFIG_SUBTREE, {})
|
||||
br_options = bridge_state.get(OB.OPTIONS_SUBTREE, {})
|
||||
iface_bridge_settings = _get_iface_bridge_settings(br_options)
|
||||
|
||||
with mainloop():
|
||||
|
@ -77,8 +77,6 @@ def test_create_new_ifaces(con_profile_mock):
|
||||
def test_prepare_new_ifaces_configuration(
|
||||
nm_bond_mock, nm_connection_mock, nm_ipv4_mock, nm_ipv6_mock, nm_ovs_mock
|
||||
):
|
||||
nm_ovs_mock.translate_bridge_options.return_value = {}
|
||||
|
||||
ifaces_desired_state = [
|
||||
{
|
||||
"name": "eth0",
|
||||
@ -158,8 +156,6 @@ def test_edit_existing_ifaces_without_profile(
|
||||
def test_prepare_edited_ifaces_configuration(
|
||||
nm_device_mock, nm_connection_mock, nm_ipv4_mock, nm_ipv6_mock, nm_ovs_mock
|
||||
):
|
||||
nm_ovs_mock.translate_bridge_options.return_value = {}
|
||||
|
||||
ifaces_desired_state = [
|
||||
{"name": "eth0", "type": "ethernet", "state": "up"}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user