summaryrefslogtreecommitdiff
path: root/src/op_mode/firewall.py
diff options
context:
space:
mode:
authorsarthurdev <965089+sarthurdev@users.noreply.github.com>2022-01-10 23:50:25 +0100
committersarthurdev <965089+sarthurdev@users.noreply.github.com>2022-01-11 11:57:56 +0100
commit5334ca6fc758c3e9c86dfcb3d4ace5d54ab8878a (patch)
treea38e71c05b425e28b4927757594ceb9793acf3a5 /src/op_mode/firewall.py
parent6e23345a693c5ccaaae7694dd60a91315a911631 (diff)
downloadvyos-1x-5334ca6fc758c3e9c86dfcb3d4ace5d54ab8878a.tar.gz
vyos-1x-5334ca6fc758c3e9c86dfcb3d4ace5d54ab8878a.zip
firewall: op-mode: T4131: Display `show firewall group` reference and member items sorted and one per line
Diffstat (limited to 'src/op_mode/firewall.py')
-rwxr-xr-xsrc/op_mode/firewall.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/op_mode/firewall.py b/src/op_mode/firewall.py
index cf70890a6..030a9b19a 100755
--- a/src/op_mode/firewall.py
+++ b/src/op_mode/firewall.py
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import argparse
+import ipaddress
import json
import re
import tabulate
@@ -266,13 +267,15 @@ def show_firewall_group(name=None):
continue
references = find_references(group_type, group_name)
- row = [group_name, group_type, ', '.join(references)]
+ row = [group_name, group_type, '\n'.join(references) or 'N/A']
if 'address' in group_conf:
- row.append(", ".join(group_conf['address']))
+ row.append("\n".join(sorted(group_conf['address'], key=ipaddress.ip_address)))
elif 'network' in group_conf:
- row.append(", ".join(group_conf['network']))
+ row.append("\n".join(sorted(group_conf['network'], key=ipaddress.ip_network)))
elif 'port' in group_conf:
- row.append(", ".join(group_conf['port']))
+ row.append("\n".join(sorted(group_conf['port'])))
+ else:
+ row.append('N/A')
rows.append(row)
if rows:
@@ -302,7 +305,7 @@ def show_summary():
for name, name_conf in firewall['ipv6_name'].items():
description = name_conf.get('description', '')
interfaces = ", ".join(name_conf['interface'])
- v6_out.append([name, description, interfaces])
+ v6_out.append([name, description, interfaces or 'N/A'])
if v6_out:
print('\nIPv6 name:\n')