Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[routeros] KeyErrors when generating sdict #713

Open
fkusei opened this issue Jun 20, 2022 · 1 comment
Open

[routeros] KeyErrors when generating sdict #713

fkusei opened this issue Jun 20, 2022 · 1 comment

Comments

@fkusei
Copy link
Contributor

fkusei commented Jun 20, 2022

If there's a port which is currently disabled, but cdict is as follows:

{
  "disabled": "false",
  "hw": "true"
}

Bundlewrap will generate a KeyError('hw') (see blelow), because that key isn't present in the sdict for the disabled port.

I'm not sure wether we should just use .get() in keys_to_fix() or handle those edge cases differently.

Full error message:

✘ wi-5.hw.sw-mn  routeros  routeros:/interface/bridge/port?interface=ether23  failed 
│
├─ ('/interface/bridge/port/print', '?=interface=ether23', '?#&') (return code: None)
│ 
│ ({'.id': '*16', '.nextid': '*17', 'interface': 'ether23', 'bridge': 'bridge', 'priority': '0x80', 'path-cost': 10, 'internal-path-cost': 10, 'edge': 'auto', 'point-to-point': 'auto', 'learn': 'auto', 'horizon': 'none', 'auto-isolate': False, 'restricted-role': False, 'restricted-tcn': False, 'pvid': 1, 'frame-types': 'admit-all', 'ingress-filtering': False, 'unknown-unicast-flood': True, 'unknown-multicast-flood': True, 'broadcast-flood': True, 'tag-stacking': False, 'bpdu-guard': False, 'trusted': False, 'multicast-router': 'temporary-query', 'fast-leave': False, 'status': 'inactive', 'inactive': True, 'dynamic': False, 'disabled': True},)
╵
│   File "/home/fkunsmann/.venv/isac/lib/python3.10/site-packages/bundlewrap/concurrency.py", line 133, in run
│     result = self._get_result()
│   File "/home/fkunsmann/.venv/isac/lib/python3.10/site-packages/bundlewrap/concurrency.py", line 73, in _get_result
│     raise exception
│   File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
│     result = self.fn(*self.args, **self.kwargs)
│   File "/home/fkunsmann/.venv/isac/lib/python3.10/site-packages/bundlewrap/items/__init__.py", line 554, in apply
│     status_before = self.cached_status
│   File "/home/fkunsmann/.venv/isac/lib/python3.10/site-packages/bundlewrap/utils/__init__.py", line 36, in cache_wrapper
│     return_value = prop(self)
│   File "/home/fkunsmann/.venv/isac/lib/python3.10/site-packages/bundlewrap/items/__init__.py", line 321, in cached_status
│     return self.get_status()
│   File "/home/fkunsmann/.venv/isac/lib/python3.10/site-packages/bundlewrap/items/__init__.py", line 794, in get_status
│     return ItemStatus(self.cached_cdict, self.cached_sdict)
│   File "/home/fkunsmann/.venv/isac/lib/python3.10/site-packages/bundlewrap/items/__init__.py", line 91, in __init__
│     self.keys_to_fix = keys_to_fix(cdict, sdict)
│   File "/home/fkunsmann/.venv/isac/lib/python3.10/site-packages/bundlewrap/items/__init__.py", line 73, in keys_to_fix
│     if value != sdict[key]:
│ KeyError('hw')

cdict/sdict:

➤ bw items wi-5.hw.sw-mn routeros:/interface/bridge/port?interface=ether23
{
    "bridge": "bridge",
    "comment": "",
    "disabled": "false",
    "hw": "true",
    "pvid": "96"
}
➤ bw items wi-5.hw.sw-mn routeros:/interface/bridge/port?interface=ether23 --state
{
    ".id": "*16",
    ".nextid": "*17",
    "auto-isolate": "false",
    "bpdu-guard": "false",
    "bridge": "bridge",
    "broadcast-flood": "true",
    "comment": "",
    "disabled": "true",
    "dynamic": "false",
    "edge": "auto",
    "fast-leave": "false",
    "frame-types": "admit-all",
    "horizon": "none",
    "inactive": "true",
    "ingress-filtering": "false",
    "interface": "ether23",
    "internal-path-cost": "10",
    "learn": "auto",
    "multicast-router": "temporary-query",
    "path-cost": "10",
    "point-to-point": "auto",
    "priority": "0x80",
    "pvid": "1",
    "restricted-role": "false",
    "restricted-tcn": "false",
    "status": "inactive",
    "tag-stacking": "false",
    "trusted": "false",
    "unknown-multicast-flood": "true",
    "unknown-unicast-flood": "true"
}
@trehn
Copy link
Member

trehn commented Jun 23, 2022

I think you just need to remove hw from the cdict then. There is no other way to resolve this without going down the rabbit hole of making bw aware of routeros specifics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants