diff options
Diffstat (limited to 'src/op_mode')
-rwxr-xr-x | src/op_mode/dynamic_dns.py | 4 | ||||
-rwxr-xr-x | src/op_mode/lldp_op.py | 2 | ||||
-rwxr-xr-x | src/op_mode/show_cpu.py | 20 | ||||
-rwxr-xr-x | src/op_mode/show_igmpproxy.py | 8 | ||||
-rwxr-xr-x | src/op_mode/show_nat_statistics.py | 12 | ||||
-rwxr-xr-x | src/op_mode/show_openvpn.py | 4 | ||||
-rwxr-xr-x | src/op_mode/show_usb_serial.py | 4 | ||||
-rwxr-xr-x | src/op_mode/show_vrf.py | 4 | ||||
-rwxr-xr-x | src/op_mode/show_wireless.py | 17 | ||||
-rwxr-xr-x | src/op_mode/snmp_v3.py | 8 |
10 files changed, 38 insertions, 45 deletions
diff --git a/src/op_mode/dynamic_dns.py b/src/op_mode/dynamic_dns.py index 021acfd73..962943896 100755 --- a/src/op_mode/dynamic_dns.py +++ b/src/op_mode/dynamic_dns.py @@ -26,13 +26,13 @@ from vyos.util import call cache_file = r'/run/ddclient/ddclient.cache' OUT_TMPL_SRC = """ -{%- for entry in hosts -%} +{% for entry in hosts %} ip address : {{ entry.ip }} host-name : {{ entry.host }} last update : {{ entry.time }} update-status: {{ entry.status }} -{% endfor -%} +{% endfor %} """ def show_status(): diff --git a/src/op_mode/lldp_op.py b/src/op_mode/lldp_op.py index 172ce71b7..fa19e7d45 100755 --- a/src/op_mode/lldp_op.py +++ b/src/op_mode/lldp_op.py @@ -117,7 +117,7 @@ if __name__ == '__main__': parser.print_help() exit(1) - tmpl = jinja2.Template(lldp_out, trim_blocks=True) + tmpl = jinja2.Template(lldp_out) config_text = tmpl.render(parse_data(neighbors)) print(config_text) diff --git a/src/op_mode/show_cpu.py b/src/op_mode/show_cpu.py index 0a540da1d..0040e950d 100755 --- a/src/op_mode/show_cpu.py +++ b/src/op_mode/show_cpu.py @@ -21,16 +21,16 @@ from sys import exit from vyos.util import popen, DEVNULL OUT_TMPL_SRC = """ -{%- if cpu -%} -{% if 'vendor' in cpu %}CPU Vendor: {{cpu.vendor}}{%- endif %} -{% if 'model' in cpu %}Model: {{cpu.model}}{%- endif %} -{% if 'cpus' in cpu %}Total CPUs: {{cpu.cpus}}{%- endif %} -{% if 'sockets' in cpu %}Sockets: {{cpu.sockets}}{%- endif %} -{% if 'cores' in cpu %}Cores: {{cpu.cores}}{%- endif %} -{% if 'threads' in cpu %}Threads: {{cpu.threads}}{%- endif %} -{% if 'mhz' in cpu %}Current MHz: {{cpu.mhz}}{%- endif %} -{% if 'mhz_min' in cpu %}Minimum MHz: {{cpu.mhz_min}}{%- endif %} -{% if 'mhz_max' in cpu %}Maximum MHz: {{cpu.mhz_max}}{%- endif %} +{% if cpu %} +{% if 'vendor' in cpu %}CPU Vendor: {{cpu.vendor}}{% endif %} +{% if 'model' in cpu %}Model: {{cpu.model}}{% endif %} +{% if 'cpus' in cpu %}Total CPUs: {{cpu.cpus}}{% endif %} +{% if 'sockets' in cpu %}Sockets: {{cpu.sockets}}{% endif %} +{% if 'cores' in cpu %}Cores: {{cpu.cores}}{% endif %} +{% if 'threads' in cpu %}Threads: {{cpu.threads}}{% endif %} +{% if 'mhz' in cpu %}Current MHz: {{cpu.mhz}}{% endif %} +{% if 'mhz_min' in cpu %}Minimum MHz: {{cpu.mhz_min}}{% endif %} +{% if 'mhz_max' in cpu %}Maximum MHz: {{cpu.mhz_max}}{% endif %} {% endif %} """ diff --git a/src/op_mode/show_igmpproxy.py b/src/op_mode/show_igmpproxy.py index 5ccc16287..4714e494b 100755 --- a/src/op_mode/show_igmpproxy.py +++ b/src/op_mode/show_igmpproxy.py @@ -36,9 +36,9 @@ import vyos.config # eth0.3 0.0b 0 0.0b 0 xxx.xxx.x.7 # tun1 0.0b 0 0.0b 0 xxx.xxx.xxx.2 vif_out_tmpl = """ -{%- for r in data %} +{% for r in data %} {{ "%-10s"|format(r.interface) }} {{ "%-12s"|format(r.bytes_in) }} {{ "%-12s"|format(r.pkts_in) }} {{ "%-12s"|format(r.bytes_out) }} {{ "%-12s"|format(r.pkts_out) }} {{ "%-15s"|format(r.loc) }} -{%- endfor %} +{% endfor %} """ # Output Template for "show ip multicast mfc" command @@ -48,9 +48,9 @@ vif_out_tmpl = """ # xxx.xxx.xxx.250 xxx.xx.xxx.75 -- # xxx.xxx.xx.124 xx.xxx.xxx.26 -- mfc_out_tmpl = """ -{%- for r in data %} +{% for r in data %} {{ "%-15s"|format(r.group) }} {{ "%-15s"|format(r.origin) }} {{ "%-12s"|format(r.pkts) }} {{ "%-12s"|format(r.bytes) }} {{ "%-12s"|format(r.wrong) }} {{ "%-10s"|format(r.iif) }} {{ "%-20s"|format(r.oifs|join(', ')) }} -{%- endfor %} +{% endfor %} """ parser = argparse.ArgumentParser() diff --git a/src/op_mode/show_nat_statistics.py b/src/op_mode/show_nat_statistics.py index 0b53112f2..482993d06 100755 --- a/src/op_mode/show_nat_statistics.py +++ b/src/op_mode/show_nat_statistics.py @@ -26,14 +26,14 @@ OUT_TMPL_SRC=""" rule pkts bytes interface ---- ---- ----- --------- {% for r in output %} -{%- if r.comment -%} -{%- set packets = r.counter.packets -%} -{%- set bytes = r.counter.bytes -%} -{%- set interface = r.interface -%} +{% if r.comment %} +{% set packets = r.counter.packets %} +{% set bytes = r.counter.bytes %} +{% set interface = r.interface %} {# remove rule comment prefix #} -{%- set comment = r.comment | replace('SRC-NAT-', '') | replace('DST-NAT-', '') | replace(' tcp_udp', '') -%} +{% set comment = r.comment | replace('SRC-NAT-', '') | replace('DST-NAT-', '') | replace(' tcp_udp', '') %} {{ "%-4s" | format(comment) }} {{ "%9s" | format(packets) }} {{ "%12s" | format(bytes) }} {{ interface }} -{%- endif %} +{% endif %} {% endfor %} """ diff --git a/src/op_mode/show_openvpn.py b/src/op_mode/show_openvpn.py index 1da4c7ecb..f7b99cc0d 100755 --- a/src/op_mode/show_openvpn.py +++ b/src/op_mode/show_openvpn.py @@ -28,9 +28,9 @@ OpenVPN status on {{ intf }} Client CN Remote Host Local Host TX bytes RX bytes Connected Since --------- ----------- ---------- -------- -------- --------------- -{%- for c in clients %} +{% for c in clients %} {{ "%-15s"|format(c.name) }} {{ "%-21s"|format(c.remote) }} {{ "%-21s"|format(local) }} {{ "%-9s"|format(c.tx_bytes) }} {{ "%-9s"|format(c.rx_bytes) }} {{ c.online_since }} -{%- endfor %} +{% endfor %} {% endif %} """ diff --git a/src/op_mode/show_usb_serial.py b/src/op_mode/show_usb_serial.py index 776898c25..973bf19c8 100755 --- a/src/op_mode/show_usb_serial.py +++ b/src/op_mode/show_usb_serial.py @@ -22,9 +22,9 @@ from sys import exit OUT_TMPL_SRC = """Device Model Vendor ------ ------ ------ -{%- for d in devices %} +{% for d in devices %} {{ "%-16s" | format(d.device) }} {{ "%-19s" | format(d.model)}} {{d.vendor}} -{%- endfor %} +{% endfor %} """ diff --git a/src/op_mode/show_vrf.py b/src/op_mode/show_vrf.py index b6bb73d01..94358c6e4 100755 --- a/src/op_mode/show_vrf.py +++ b/src/op_mode/show_vrf.py @@ -23,9 +23,9 @@ from vyos.util import cmd vrf_out_tmpl = """ VRF name state mac address flags interfaces -------- ----- ----------- ----- ---------- -{%- for v in vrf %} +{% for v in vrf %} {{"%-16s"|format(v.ifname)}} {{ "%-8s"|format(v.operstate | lower())}} {{"%-17s"|format(v.address | lower())}} {{ v.flags|join(',')|lower()}} {{v.members|join(',')|lower()}} -{%- endfor %} +{% endfor %} """ diff --git a/src/op_mode/show_wireless.py b/src/op_mode/show_wireless.py index b5ee3aee1..19ab6771c 100755 --- a/src/op_mode/show_wireless.py +++ b/src/op_mode/show_wireless.py @@ -28,7 +28,6 @@ parser.add_argument("-s", "--scan", help="Scan for Wireless APs on given interfa parser.add_argument("-b", "--brief", action="store_true", help="Show wireless configuration") parser.add_argument("-c", "--stations", help="Show wireless clients connected on interface, e.g. 'wlan0'") - def show_brief(): config = Config() if len(config.list_effective_nodes('interfaces wireless')) == 0: @@ -37,17 +36,11 @@ def show_brief(): interfaces = [] for intf in config.list_effective_nodes('interfaces wireless'): - config.set_level('interfaces wireless {}'.format(intf)) - data = { - 'name': intf, - 'type': '', - 'ssid': '', - 'channel': '' - } - data['type'] = config.return_effective_value('type') - data['ssid'] = config.return_effective_value('ssid') - data['channel'] = config.return_effective_value('channel') - + config.set_level(f'interfaces wireless {intf}') + data = { 'name': intf } + data['type'] = config.return_effective_value('type') or '-' + data['ssid'] = config.return_effective_value('ssid') or '-' + data['channel'] = config.return_effective_value('channel') or '-' interfaces.append(data) return interfaces diff --git a/src/op_mode/snmp_v3.py b/src/op_mode/snmp_v3.py index 92601f15e..a1f76f0bc 100755 --- a/src/op_mode/snmp_v3.py +++ b/src/op_mode/snmp_v3.py @@ -37,7 +37,7 @@ SNMPv3 Groups: Group View ----- ---- - {% if group -%}{% for g in group -%} + {% if group %}{% for g in group %} {{ "%-20s" | format(g.name) }}{{ g.view }}({{ g.mode }}) {% endfor %}{% endif %} """ @@ -47,7 +47,7 @@ SNMPv3 Trap-targets: Tpap-target Port Protocol Auth Priv Type EngineID User ----------- ---- -------- ---- ---- ---- -------- ---- - {% if trap -%}{% for t in trap -%} + {% if trap %}{% for t in trap %} {{ "%-20s" | format(t.name) }} {{ t.port }} {{ t.proto }} {{ t.auth }} {{ t.priv }} {{ t.type }} {{ "%-32s" | format(t.engID) }} {{ t.user }} {% endfor %}{% endif %} """ @@ -57,14 +57,14 @@ SNMPv3 Users: User Auth Priv Mode Group ---- ---- ---- ---- ----- - {% if user -%}{% for u in user -%} + {% if user %}{% for u in user %} {{ "%-20s" | format(u.name) }}{{ u.auth }} {{ u.priv }} {{ u.mode }} {{ u.group }} {% endfor %}{% endif %} """ VIEW_OUTP_TMPL_SRC = """ SNMPv3 Views: - {% if view -%}{% for v in view %} + {% if view %}{% for v in view %} View : {{ v.name }} OIDs : .{{ v.oids | join("\n .")}} {% endfor %}{% endif %} |