diff options
author | Nicolás Fort <95703796+nicolas-fort@users.noreply.github.com> | 2023-07-31 15:22:51 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-31 15:22:51 -0300 |
commit | 657a566df58478c2f5d4bccad952bfcb7991e847 (patch) | |
tree | 1cf6ab7548286f358d05389132cd82bc177c676a /src/op_mode/bridge.py | |
parent | 7ae9d8953ddc9ba38d62400187ce1ec44abb5a6e (diff) | |
parent | df33f450b4e8b7e0286e36540de81edfb5f52e73 (diff) | |
download | vyos-1x-657a566df58478c2f5d4bccad952bfcb7991e847.tar.gz vyos-1x-657a566df58478c2f5d4bccad952bfcb7991e847.zip |
Merge branch 'current' into T5014-dnat
Diffstat (limited to 'src/op_mode/bridge.py')
-rwxr-xr-x | src/op_mode/bridge.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/op_mode/bridge.py b/src/op_mode/bridge.py index 5531c41d0..1834b9cc9 100755 --- a/src/op_mode/bridge.py +++ b/src/op_mode/bridge.py @@ -24,6 +24,7 @@ from tabulate import tabulate from vyos.utils.process import cmd from vyos.utils.process import rc_cmd +from vyos.utils.process import call from vyos.utils.dict import dict_search import vyos.opmode @@ -129,7 +130,8 @@ def _get_formatted_output_vlan(data): if vlan_entry.get('vlanEnd'): vlan_end = vlan_entry.get('vlanEnd') vlan = f'{vlan}-{vlan_end}' - flags = ', '.join(vlan_entry.get('flags')).lower() + flags_raw = vlan_entry.get('flags') + flags = ', '.join(flags_raw if isinstance(flags_raw,list) else "").lower() data_entries.append([interface, vlan, flags]) headers = ["Interface", "Vlan", "Flags"] @@ -164,6 +166,23 @@ def _get_formatted_output_mdb(data): output = tabulate(data_entries, headers) return output +def _get_bridge_detail(iface): + """Get interface detail statistics""" + return call(f'vtysh -c "show interface {iface}"') + +def _get_bridge_detail_nexthop_group(iface): + """Get interface detail nexthop_group statistics""" + return call(f'vtysh -c "show interface {iface} nexthop-group"') + +def _get_bridge_detail_nexthop_group_raw(iface): + out = cmd(f'vtysh -c "show interface {iface} nexthop-group"') + return out + +def _get_bridge_detail_raw(iface): + """Get interface detail json statistics""" + data = cmd(f'vtysh -c "show interface {iface} json"') + data_dict = json.loads(data) + return data_dict def show(raw: bool): bridge_data = _get_raw_data_summary() @@ -196,6 +215,17 @@ def show_mdb(raw: bool, interface: str): else: return _get_formatted_output_mdb(mdb_data) +def show_detail(raw: bool, nexthop_group: typing.Optional[bool], interface: str): + if raw: + if nexthop_group: + return _get_bridge_detail_nexthop_group_raw(interface) + else: + return _get_bridge_detail_raw(interface) + else: + if nexthop_group: + return _get_bridge_detail_nexthop_group(interface) + else: + return _get_bridge_detail(interface) if __name__ == '__main__': try: |