Skip to content

Commit

Permalink
fix: fixed configuration insertion for members
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile committed Sep 22, 2023
1 parent 8abc640 commit 6b956bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/nethsec/mwan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __store_member(e_uci: EUci, interface_name: str, metric: int, weight: int) -
e_uci.set('mwan3', member_config_name, 'interface', interface_name)
e_uci.set('mwan3', member_config_name, 'metric', metric)
e_uci.set('mwan3', member_config_name, 'weight', weight)
return f'mwan3.{member_config_name}', changed
return member_config_name, changed


def store_policy(e_uci: EUci, name: str, interfaces: list[dict]) -> list[str]:
Expand Down Expand Up @@ -149,7 +149,7 @@ def store_policy(e_uci: EUci, name: str, interfaces: list[dict]) -> list[str]:
interface['weight'])
member_names.append(member_config_name)
if member_created:
changed_config.append(member_config_name)
changed_config.append(f'mwan3.{member_config_name}')

e_uci.set('mwan3', policy_config_name, 'use_member', member_names)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_mwan.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ def test_interface_avoid_edit_of_metric(e_uci):


def test_create_member(e_uci):
assert mwan.__store_member(e_uci, 'RED_1', 10, 100) == ('mwan3.ns_RED_1_M10_W100', True)
assert mwan.__store_member(e_uci, 'RED_1', 10, 100) == ('mwan3.ns_RED_1_M10_W100', False)
assert mwan.__store_member(e_uci, 'RED_1', 1, 100) == ('mwan3.ns_RED_1_M1_W100', True)
assert mwan.__store_member(e_uci, 'RED_1', 10, 100) == ('ns_RED_1_M10_W100', True)
assert mwan.__store_member(e_uci, 'RED_1', 10, 100) == ('ns_RED_1_M10_W100', False)
assert mwan.__store_member(e_uci, 'RED_1', 1, 100) == ('ns_RED_1_M1_W100', True)


def test_create_default_mwan(e_uci):
Expand All @@ -157,7 +157,7 @@ def test_create_default_mwan(e_uci):
assert e_uci.get('mwan3', 'ns_default') == 'policy'
assert e_uci.get('mwan3', 'ns_default', 'name') == 'default'
assert e_uci.get('mwan3', 'ns_default', 'use_member', list=True) == (
'mwan3.ns_RED_1_M10_W200', 'mwan3.ns_RED_2_M20_W100')
'ns_RED_1_M10_W200', 'ns_RED_2_M20_W100')


def test_create_unique_mwan(e_uci):
Expand Down

0 comments on commit 6b956bf

Please sign in to comment.