diff options
116 files changed, 1880 insertions, 245 deletions
@@ -91,18 +91,15 @@ op_mode_definitions: rm -f $(OP_TMPL_DIR)/set/node.def rm -f $(OP_TMPL_DIR)/show/node.def rm -f $(OP_TMPL_DIR)/show/interfaces/node.def - rm -f $(OP_TMPL_DIR)/show/ip/node.def - rm -f $(OP_TMPL_DIR)/show/ip/route/node.def rm -f $(OP_TMPL_DIR)/show/ipv6/node.def rm -f $(OP_TMPL_DIR)/show/ipv6/route/node.def rm -f $(OP_TMPL_DIR)/restart/node.def rm -f $(OP_TMPL_DIR)/monitor/node.def rm -f $(OP_TMPL_DIR)/generate/node.def - rm -f $(OP_TMPL_DIR)/show/vpn/node.def rm -f $(OP_TMPL_DIR)/show/system/node.def + rm -f $(OP_TMPL_DIR)/show/vpn/node.def rm -f $(OP_TMPL_DIR)/delete/node.def rm -f $(OP_TMPL_DIR)/reset/vpn/node.def - rm -f $(OP_TMPL_DIR)/show/system/node.def .PHONY: component_versions .ONESHELL: diff --git a/data/templates/dhcp-client/ipv6.tmpl b/data/templates/dhcp-client/ipv6.tmpl index 6cfe24d3e..490f14726 100644 --- a/data/templates/dhcp-client/ipv6.tmpl +++ b/data/templates/dhcp-client/ipv6.tmpl @@ -10,7 +10,7 @@ interface {{ ifname }} { {% if not dhcpv6_temporary %} send ia-na 1; # non-temporary address {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} send ia-pd 2; # prefix delegation {% endif %} }; @@ -21,9 +21,12 @@ id-assoc na 1 { }; {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} id-assoc pd 2 { -{% for intf in dhcpv6_pd %} +{% if dhcpv6_pd_length %} + prefix ::/{{ dhcpv6_pd_length }} infinity; +{% endif %} +{% for intf in dhcpv6_pd_interfaces %} prefix-interface {{ intf.ifname }} { {% if intf.sla_id %} sla-id {{ intf.sla_id }}; diff --git a/data/templates/frr/bgp.frr.tmpl b/data/templates/frr/bgp.frr.tmpl new file mode 100644 index 000000000..cd6f31c93 --- /dev/null +++ b/data/templates/frr/bgp.frr.tmpl @@ -0,0 +1 @@ +!
diff --git a/data/templates/pppoe/ip-down.script.tmpl b/data/templates/pppoe/ip-down.script.tmpl index fe8fd7584..9e6bd2a8e 100644 --- a/data/templates/pppoe/ip-down.script.tmpl +++ b/data/templates/pppoe/ip-down.script.tmpl @@ -25,9 +25,12 @@ fi # Always delete default route when interface goes down vtysh -c "conf t" ${VRF_NAME} -c "no ip route 0.0.0.0/0 {{ intf }} ${VRF_NAME}" +{% if ipv6_enable %} +vtysh -c "conf t" ${VRF_NAME} -c "no ipv6 route ::/0 {{ intf }} ${VRF_NAME}" +{% endif %} {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} # Start wide dhcpv6 client systemctl stop dhcp6c@{{ intf }}.service {% endif %} diff --git a/data/templates/pppoe/ip-pre-up.script.tmpl b/data/templates/pppoe/ip-pre-up.script.tmpl index 9a7ba7d57..6a2d2af94 100644 --- a/data/templates/pppoe/ip-pre-up.script.tmpl +++ b/data/templates/pppoe/ip-pre-up.script.tmpl @@ -2,7 +2,6 @@ # As PPPoE is an "on demand" interface we need to re-configure it when it # becomes up - if [ "$6" != "{{ intf }}" ]; then exit fi diff --git a/data/templates/pppoe/ip-up.script.tmpl b/data/templates/pppoe/ip-up.script.tmpl index 697ebcc20..a274296b6 100644 --- a/data/templates/pppoe/ip-up.script.tmpl +++ b/data/templates/pppoe/ip-up.script.tmpl @@ -7,13 +7,14 @@ if [ "$6" != "{{ intf }}" ]; then fi {% if not on_demand %} -# See https://phabricator.vyos.net/T2248 & T2220. Determine if we are enslaved -# to a VRF, this is needed to properly insert the default route. - # add some info to syslog DIALER_PID=$(cat /var/run/{{ intf }}.pid) logger -t pppd[$DIALER_PID] "executing $0" +{% if default_route != 'none' -%} +# See https://phabricator.vyos.net/T2248 & T2220. Determine if we are enslaved +# to a VRF, this is needed to properly insert the default route. + SED_OPT="^ip route" VRF_NAME="" if [ -d /sys/class/net/{{ intf }}/upper_* ]; then @@ -27,21 +28,22 @@ if [ -d /sys/class/net/{{ intf }}/upper_* ]; then VRF_NAME="vrf ${VRF}" fi -{% if 'auto' in default_route -%} +{% if default_route == 'auto' -%} # Only insert a new default route if there is no default route configured routes=$(vtysh -c "show running-config" | sed -n "/${SED_OPT}/,/!/p" | grep 0.0.0.0/0 | wc -l) if [ "$routes" -ne 0 ]; then exit 1 fi -{% elif 'force' in default_route -%} +{% elif default_route == 'force' -%} # Retrieve current static default routes and remove it from the routing table vtysh -c "show running-config" | sed -n "/${SED_OPT}/,/!/p" | grep 0.0.0.0/0 | while read route ; do vtysh -c "conf t" ${VTY_OPT} -c "no ${route} ${VRF_NAME}" done -{% endif %} +{% endif %} # Add default route to default or VRF routing table vtysh -c "conf t" ${VTY_OPT} -c "ip route 0.0.0.0/0 {{ intf }} ${VRF_NAME}" logger -t pppd[$DIALER_PID] "added default route via {{ intf }} ${VRF_NAME}" +{% endif %} {% endif %} diff --git a/data/templates/pppoe/ipv6-up.script.tmpl b/data/templates/pppoe/ipv6-up.script.tmpl index 90873229a..097f1d4c3 100644 --- a/data/templates/pppoe/ipv6-up.script.tmpl +++ b/data/templates/pppoe/ipv6-up.script.tmpl @@ -7,6 +7,8 @@ if [ "$6" != "{{ intf }}" ]; then exit fi +set -x + {% if ipv6_autoconf -%} # add some info to syslog DIALER_PID=$(cat /var/run/{{ intf }}.pid) @@ -37,10 +39,49 @@ echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/forwarding echo 2 > /proc/sys/net/ipv6/conf/{{ intf }}/accept_ra # Autoconfigure addresses using Prefix Information in Router Advertisements. -echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/autoconfigure +echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/autoconf {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} # Start wide dhcpv6 client systemctl start dhcp6c@{{ intf }}.service {% endif %} + + +{% if default_route != 'none' -%} +# See https://phabricator.vyos.net/T2248 & T2220. Determine if we are enslaved +# to a VRF, this is needed to properly insert the default route. + +SED_OPT="^ipv6 route" +VRF_NAME="" +if [ -d /sys/class/net/{{ intf }}/upper_* ]; then + # Determine upper (VRF) interface + VRF=$(basename $(ls -d /sys/class/net/{{ intf }}/upper_*)) + # Remove upper_ prefix from result string + VRF=${VRF#"upper_"} + # generate new SED command + SED_OPT="vrf ${VRF}" + # generate vtysh option + VRF_NAME="vrf ${VRF}" +fi + +{% if default_route == 'auto' -%} +# Only insert a new default route if there is no default route configured +routes=$(vtysh -c "show running-config" | sed -n "/${SED_OPT}/,/!/p" | grep ::/0 | wc -l) +if [ "$routes" -ne 0 ]; then + exit 1 +fi + +{% elif default_route == 'force' -%} +# Retrieve current static default routes and remove it from the routing table +vtysh -c "show running-config" | sed -n "/${SED_OPT}/,/!/p" | grep ::/0 | while read route ; do + vtysh -c "conf t" ${VTY_OPT} -c "no ${route} ${VRF_NAME}" +done +{% endif %} + +# Add default route to default or VRF routing table +vtysh -c "conf t" ${VTY_OPT} -c "ipv6 route ::/0 {{ intf }} ${VRF_NAME}" +logger -t pppd[$DIALER_PID] "added default route via {{ intf }} ${VRF_NAME}" +{% endif %} + + diff --git a/data/templates/ssh/sshd_config.tmpl b/data/templates/ssh/sshd_config.tmpl index 5deb5232a..949a8558f 100644 --- a/data/templates/ssh/sshd_config.tmpl +++ b/data/templates/ssh/sshd_config.tmpl @@ -22,7 +22,6 @@ TCPKeepAlive yes Banner /etc/issue.net Subsystem sftp /usr/lib/openssh/sftp-server UsePAM yes -HostKey /etc/ssh/ssh_host_rsa_key # Specifies whether sshd should look up the remote host name, # and to check that the resolved host name for the remote IP diff --git a/debian/control b/debian/control index 1312d9462..bb6116251 100644 --- a/debian/control +++ b/debian/control @@ -36,6 +36,7 @@ Depends: python3, python3-xmltodict, bsdmainutils, cron, + etherwake, systemd, easy-rsa, ipaddrcheck, @@ -76,8 +77,6 @@ Depends: python3, mtr-tiny, telnet, traceroute, - vyos-qat-kernel-modules, - vyos-qat-utilities, ssl-cert, nginx-light, lldpd, diff --git a/interface-definitions/firewall-options.xml.in b/interface-definitions/firewall-options.xml.in index 2936cc703..defd44f06 100644 --- a/interface-definitions/firewall-options.xml.in +++ b/interface-definitions/firewall-options.xml.in @@ -8,7 +8,7 @@ <priority>990</priority> </properties> <children> - <tagNode name="interface" owner="sudo ${vyos_conf_scripts_dir}/firewall_options.py"> + <tagNode name="interface" owner="${vyos_conf_scripts_dir}/firewall_options.py"> <properties> <help>Interface clamping options</help> <completionHelp> diff --git a/interface-definitions/include/bgp-afi-aggregate-address.xml.i b/interface-definitions/include/bgp-afi-aggregate-address.xml.i new file mode 100644 index 000000000..40c030fc1 --- /dev/null +++ b/interface-definitions/include/bgp-afi-aggregate-address.xml.i @@ -0,0 +1,12 @@ +<leafNode name="as-set">
+ <properties>
+ <help>Generate AS-set path information for this aggregate address</help>
+ <valueless/>
+ </properties>
+</leafNode>
+<leafNode name="summary-only">
+ <properties>
+ <help>Announce the aggregate summary network only</help>
+ <valueless/>
+ </properties>
+</leafNode>
diff --git a/interface-definitions/include/dhcpv6-options.xml.i b/interface-definitions/include/dhcpv6-options.xml.i index 2c5058d2c..98a87dba2 100644 --- a/interface-definitions/include/dhcpv6-options.xml.i +++ b/interface-definitions/include/dhcpv6-options.xml.i @@ -3,52 +3,71 @@ <help>DHCPv6 options</help> </properties> <children> - <tagNode name="delegate"> + <node name="prefix-delegation"> <properties> - <help>Delegate IPv6 prefix from provider to this interface</help> - <completionHelp> - <script>${vyos_completion_dir}/list_interfaces.py --broadcast</script> - </completionHelp> + <help>DHCPv6 Prefix Delegation Options</help> </properties> <children> - <leafNode name="interface-id"> + <leafNode name="length"> <properties> - <help>Interface address identifier</help> + <help>Request IPv6 prefix length from peer</help> <valueHelp> - <format>0-</format> - <description>Used to form IPv6 interface address (default: EUI-64)</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--non-negative"/> - </constraint> - </properties> - </leafNode> - <leafNode name="sla-id"> - <properties> - <help>Interface site-Level aggregator (SLA)</help> - <valueHelp> - <format>0-128</format> - <description>Decimal integer which fits in the length of SLA IDs</description> + <format>32-64</format> + <description>Length of delegated prefix</description> </valueHelp> <constraint> - <validator name="numeric" argument="--range 0-128"/> + <validator name="numeric" argument="--range 32-64"/> </constraint> </properties> </leafNode> - <leafNode name="sla-len"> + <tagNode name="interface"> <properties> - <help>Site-Level aggregator (SLA) length</help> - <valueHelp> - <format>0-128</format> - <description>Length of delegated prefix</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--range 0-128"/> - </constraint> + <help>Delegate IPv6 prefix from provider to this interface</help> + <completionHelp> + <script>${vyos_completion_dir}/list_interfaces.py --broadcast</script> + </completionHelp> </properties> - </leafNode> + <children> + <leafNode name="address"> + <properties> + <help>Local interface address assigned to interface</help> + <valueHelp> + <format>>0</format> + <description>Used to form IPv6 interface address (default: EUI-64)</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--non-negative"/> + </constraint> + </properties> + </leafNode> + <leafNode name="sla-id"> + <properties> + <help>Interface site-Level aggregator (SLA)</help> + <valueHelp> + <format>0-128</format> + <description>Decimal integer which fits in the length of SLA IDs</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 0-128"/> + </constraint> + </properties> + </leafNode> + <leafNode name="sla-len"> + <properties> + <help>Site-Level aggregator (SLA) length</help> + <valueHelp> + <format>0-128</format> + <description>Length of delegated prefix</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 0-128"/> + </constraint> + </properties> + </leafNode> + </children> + </tagNode> </children> - </tagNode> + </node> <leafNode name="parameters-only"> <properties> <help>Acquire only config parameters, no address</help> diff --git a/interface-definitions/interfaces-openvpn.xml.in b/interface-definitions/interfaces-openvpn.xml.in index b5da8cf76..bdf5aeddb 100644 --- a/interface-definitions/interfaces-openvpn.xml.in +++ b/interface-definitions/interfaces-openvpn.xml.in @@ -800,6 +800,7 @@ <valueless/> </properties> </leafNode> + #include <include/interface-vrf.xml.i> </children> </tagNode> </children> diff --git a/interface-definitions/interfaces-wirelessmodem.xml.in b/interface-definitions/interfaces-wirelessmodem.xml.in index 6bec34b56..91eee56ab 100644 --- a/interface-definitions/interfaces-wirelessmodem.xml.in +++ b/interface-definitions/interfaces-wirelessmodem.xml.in @@ -47,6 +47,9 @@ <leafNode name="device"> <properties> <help>System device name (default: ttyUSB0)</help> + <completionHelp> + <script>ls -1 /dev | grep ttyUSB</script> + </completionHelp> <valueHelp> <format>ttyXXX</format> <description>System TTY device name</description> diff --git a/interface-definitions/nat.xml.in b/interface-definitions/nat.xml.in index a0b3b815b..7998bd660 100644 --- a/interface-definitions/nat.xml.in +++ b/interface-definitions/nat.xml.in @@ -1,6 +1,6 @@ <?xml version="1.0"?> <interfaceDefinition> - <node name="nat" owner="sudo ${vyos_conf_scripts_dir}/nat.py"> + <node name="nat" owner="${vyos_conf_scripts_dir}/nat.py"> <properties> <help>Network Address Translation (NAT) parameters</help> <priority>220</priority> diff --git a/interface-definitions/protocols-bgp.xml.in b/interface-definitions/protocols-bgp.xml.in index 2932d890e..3a4600753 100644 --- a/interface-definitions/protocols-bgp.xml.in +++ b/interface-definitions/protocols-bgp.xml.in @@ -38,18 +38,7 @@ </constraint> </properties> <children> - <leafNode name="as-set"> - <properties> - <help>Generate AS-set path information for this aggregate address</help> - <valueless/> - </properties> - </leafNode> - <leafNode name="summary-only"> - <properties> - <help>Announce the aggregate summary network only</help> - <valueless/> - </properties> - </leafNode> + #include <include/bgp-afi-aggregate-address.xml.i> </children> </tagNode> <tagNode name="network"> @@ -151,18 +140,7 @@ </constraint> </properties> <children> - <leafNode name="as-set"> - <properties> - <help>Generate AS-set path information for this aggregate address</help> - <valueless/> - </properties> - </leafNode> - <leafNode name="summary-only"> - <properties> - <help>Announce the aggregate summary network only</help> - <valueless/> - </properties> - </leafNode> + #include <include/bgp-afi-aggregate-address.xml.i> </children> </tagNode> <tagNode name="network"> @@ -375,7 +353,7 @@ </leafNode> <leafNode name="disable-connected-check"> <properties> - <help>Disable check to see if EBGP peer's address is a connected route</help> + <help>Disable check to see if eBGP peer address is a connected route</help> <valueless/> </properties> </leafNode> @@ -528,7 +506,7 @@ </leafNode> <leafNode name="port"> <properties> - <help>Neighbor's BGP port</help> + <help>Neighbor BGP port</help> <valueHelp> <format><1-65535></format> <description>Neighbor BGP port number</description> @@ -605,7 +583,7 @@ </valueHelp> <valueHelp> <format>0</format> - <description>Don't hold timer</description> + <description>Hold timer disabled</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-65535"/> @@ -662,7 +640,7 @@ <regex>(en|eth|br|bond|gnv|vxlan|wg|tun)[0-9]+</regex> </constraint> </properties> - </leafNode> + </leafNode> </children> </tagNode> <node name="parameters"> @@ -940,7 +918,7 @@ </node> <leafNode name="enforce-first-as"> <properties> - <help>Require first AS in the path to match peer's AS</help> + <help>Require first AS in the path to match peer AS number</help> <valueless/> </properties> </leafNode> @@ -951,7 +929,7 @@ <children> <leafNode name="stalepath-time"> <properties> - <help>Maximum time to hold onto restarting peer's stale paths</help> + <help>Maximum time to hold onto restarting neighbors stale paths</help> <valueHelp> <format><1-3600></format> <description>Hold time in seconds</description> @@ -983,7 +961,7 @@ </leafNode> <leafNode name="no-fast-external-failover"> <properties> - <help>Disable immediate session reset if peer's connected link goes down</help> + <help>Disable immediate session reset on peer link down event</help> <valueless/> </properties> </leafNode> @@ -1054,7 +1032,7 @@ </leafNode> <leafNode name="disable-connected-check"> <properties> - <help>Disable check to see if EBGP peer's address is a connected route</help> + <help>Disable check to see if eBGP peer address is a connected route</help> <valueless/> </properties> </leafNode> @@ -1199,7 +1177,7 @@ </valueHelp> <valueHelp> <format>0</format> - <description>Don't hold routes</description> + <description>Do not hold routes</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-65535"/> diff --git a/interface-definitions/vrf.xml.in b/interface-definitions/vrf.xml.in index 7c75bf824..9b9828ddd 100644 --- a/interface-definitions/vrf.xml.in +++ b/interface-definitions/vrf.xml.in @@ -19,7 +19,7 @@ <constraint> <validator name="vrf-name"/> </constraint> - <constraintErrorMessage>VRF instance name must be 16 characters or less and can not\nbe named as regular network interfaces</constraintErrorMessage> + <constraintErrorMessage>VRF instance name must be 15 characters or less and can not\nbe named as regular network interfaces.\n</constraintErrorMessage> <valueHelp> <format>name</format> <description>Instance name</description> diff --git a/op-mode-definitions/connect-disconnect.xml b/op-mode-definitions/connect-disconnect.xml index cbce2d9ef..f0fcef5da 100644 --- a/op-mode-definitions/connect-disconnect.xml +++ b/op-mode-definitions/connect-disconnect.xml @@ -10,6 +10,7 @@ <help>Bring up a connection-oriented network interface</help> <completionHelp> <path>interfaces pppoe</path> + <path>interfaces wirelessmodem</path> </completionHelp> </properties> <command>sudo ${vyos_op_scripts_dir}/connect_disconnect.py --connect "$3"</command> @@ -26,6 +27,7 @@ <help>Take down a connection-oriented network interface</help> <completionHelp> <path>interfaces pppoe</path> + <path>interfaces wirelessmodem</path> </completionHelp> </properties> <command>sudo ${vyos_op_scripts_dir}/connect_disconnect.py --disconnect "$3"</command> diff --git a/op-mode-definitions/dhcp.xml b/op-mode-definitions/dhcp.xml index 2013d0014..48752cfd5 100644 --- a/op-mode-definitions/dhcp.xml +++ b/op-mode-definitions/dhcp.xml @@ -161,4 +161,43 @@ </node> </children> </node> + <node name="renew"> + <properties> + <help>Renew specified variable</help> + </properties> + <children> + <node name="dhcp"> + <properties> + <help>Renew DHCP client lease</help> + </properties> + <children> + <tagNode name="interface"> + <properties> + <help>Renew DHCP client lease for specified interface</help> + <completionHelp> + <script>${vyos_completion_dir}/list_interfaces.py</script> + </completionHelp> + </properties> + <command>sudo systemctl restart "dhclient@$4.service"</command> + </tagNode> + </children> + </node> + <node name="dhcpv6"> + <properties> + <help>Renew DHCPv6 client lease</help> + </properties> + <children> + <tagNode name="interface"> + <properties> + <help>Renew DHCPv6 client lease for specified interface</help> + <completionHelp> + <script>${vyos_completion_dir}/list_interfaces.py</script> + </completionHelp> + </properties> + <command>sudo systemctl restart "dhcp6c@$4.service"</command> + </tagNode> + </children> + </node> + </children> + </node> </interfaceDefinition> diff --git a/op-mode-definitions/dynamic-dns.xml b/op-mode-definitions/dns-dynamic.xml index 6ea6482e1..9c37874fb 100644 --- a/op-mode-definitions/dynamic-dns.xml +++ b/op-mode-definitions/dns-dynamic.xml @@ -2,6 +2,20 @@ <interfaceDefinition> <node name="show"> <children> + <node name="log"> + <children> + <node name="dns"> + <children> + <node name="dynamic"> + <properties> + <help>Show log for dynamic DNS</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e "ddclient"</command> + </node> + </children> + </node> + </children> + </node> <node name="dns"> <properties> <help>Show DNS information</help> @@ -24,6 +38,20 @@ </node> </children> </node> + <node name="restart"> + <children> + <node name="dns"> + <children> + <node name="dynamic"> + <properties> + <help>Restart Dynamic DNS service</help> + </properties> + <command>sudo ${vyos_op_scripts_dir}/dynamic_dns.py --update</command> + </node> + </children> + </node> + </children> + </node> <node name="update"> <properties> <help>Update data for a service</help> diff --git a/op-mode-definitions/dns-forwarding.xml b/op-mode-definitions/dns-forwarding.xml index 785a05e9c..23de97704 100644 --- a/op-mode-definitions/dns-forwarding.xml +++ b/op-mode-definitions/dns-forwarding.xml @@ -2,6 +2,23 @@ <interfaceDefinition> <node name="show"> <children> + <node name="log"> + <children> + <node name="dns"> + <properties> + <help>Show log for Domain Name Service (DNS)</help> + </properties> + <children> + <node name="forwarding"> + <properties> + <help>Show log for DNS Forwarding</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e "pdns_recursor"</command> + </node> + </children> + </node> + </children> + </node> <node name="dns"> <properties> <help>Show DNS information</help> diff --git a/op-mode-definitions/ipv4-route.xml b/op-mode-definitions/ipv4-route.xml index d2846a6f2..1bda3ac11 100644 --- a/op-mode-definitions/ipv4-route.xml +++ b/op-mode-definitions/ipv4-route.xml @@ -16,44 +16,6 @@ </properties> <command>netstat -gn4</command> </leafNode> - - <node name="route"> - <properties> - <help>Show IP routes</help> - </properties> - <children> - <node name="cache"> - <properties> - <help>Show kernel route cache</help> - </properties> - <command>ip -s route list cache</command> - </node> - <tagNode name="cache"> - <properties> - <help>Show kernel route cache for a given route</help> - <completionHelp> - <list><x.x.x.x> <x.x.x.x/x></list> - </completionHelp> - </properties> - <command>ip -s route list cache $5</command> - </tagNode> - <node name="forward"> - <properties> - <help>Show kernel route table</help> - </properties> - <command>ip route list</command> - </node> - <tagNode name="forward"> - <properties> - <help>Show kernel route table for a given route</help> - <completionHelp> - <list><x.x.x.x> <x.x.x.x/x></list> - </completionHelp> - </properties> - <command>ip -s route list $5</command> - </tagNode> - </children> - </node> </children> </node> </children> diff --git a/op-mode-definitions/show-interfaces-ethernet.xml b/op-mode-definitions/show-interfaces-ethernet.xml new file mode 100644 index 000000000..63afe8248 --- /dev/null +++ b/op-mode-definitions/show-interfaces-ethernet.xml @@ -0,0 +1,47 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="interfaces"> + <children> + <tagNode name="ethernet"> + <properties> + <help>Show ethernet interface information</help> + <completionHelp> + <path>interfaces ethernet</path> + </completionHelp> + </properties> + <children> + <node name="physical"> + <properties> + <help>Show physical device information for specified ethernet interface</help> + </properties> + <command>/sbin/ethtool "$4"; /sbin/ethtool -i "$4"</command> + <children> + <leafNode name="offload"> + <properties> + <help>Show physical device offloading capabilities</help> + </properties> + <command>/sbin/ethtool -k "$4"</command> + </leafNode> + </children> + </node> + <leafNode name="statistics"> + <properties> + <help>Show physical device statistics for specified ethernet interface</help> + </properties> + <command>/sbin/ethtool -S "$4"</command> + </leafNode> + <leafNode name="transceiver"> + <properties> + <help>Show transceiver information from modules (e.g SFP+, QSFP)</help> + </properties> + <command>/sbin/ethtool -m "$4"</command> + </leafNode> + </children> + </tagNode> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-interfaces-wirelessmodem.xml b/op-mode-definitions/show-interfaces-wirelessmodem.xml index d9690f521..b21bb520c 100644 --- a/op-mode-definitions/show-interfaces-wirelessmodem.xml +++ b/op-mode-definitions/show-interfaces-wirelessmodem.xml @@ -8,7 +8,7 @@ <properties> <help>Show Wireless Modem (WWAN) interface information</help> <completionHelp> - <script>${vyos_completion_dir}/list_wlm_peers.sh</script> + <path>interfaces wirelessmodem</path> </completionHelp> </properties> <command>${vyos_op_scripts_dir}/show_interfaces.py --intf="$4"</command> @@ -17,7 +17,7 @@ <properties> <help>Show specified wirelessmodem interface statistics</help> <completionHelp> - <script>${vyos_completion_dir}/list_wlm_peers.sh</script> + <path>interfaces wirelessmodem</path> </completionHelp> </properties> <command>/usr/sbin/pppstats $4</command> diff --git a/op-mode-definitions/show-ip-access-paths-prefix-community-lists.xml b/op-mode-definitions/show-ip-access-paths-prefix-community-lists.xml new file mode 100644 index 000000000..a5ec65c94 --- /dev/null +++ b/op-mode-definitions/show-ip-access-paths-prefix-community-lists.xml @@ -0,0 +1,116 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="ip"> + <properties> + <help>Show IPv4 routing information</help> + </properties> + <children> + <leafNode name="access-list"> + <properties> + <help>Show all IP access-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show ip access-list"</command> + </leafNode> + <tagNode name="access-list"> + <properties> + <help>Show all IP access-lists</help> + <completionHelp> + <path>policy access-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip access-list $4"</command> + </tagNode> + <leafNode name="as-path-access-list"> + <properties> + <help>Show all as-path-access-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show ip as-path-access-list"</command> + </leafNode> + <tagNode name="as-path-access-list"> + <properties> + <help>Show all as-path-access-lists</help> + <completionHelp> + <path>policy as-path-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip as-path-access-list $4"</command> + </tagNode> + <leafNode name="community-list"> + <properties> + <help>Show IP community-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show bgp community-list"</command> + </leafNode> + <tagNode name="community-list"> + <properties> + <help>Show IP community-lists</help> + <completionHelp> + <path>policy community-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show bgp community-list $4 detail"</command> + </tagNode> + <leafNode name="extcommunity-list"> + <properties> + <help>Show extended IP community-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show bgp extcommunity-list"</command> + </leafNode> + <tagNode name="extcommunity-list"> + <properties> + <help>Show extended IP community-lists</help> + <completionHelp> + <path>policy extcommunity-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show bgp extcommunity-list $4 detail"</command> + </tagNode> + <leafNode name="forwarding"> + <properties> + <help>Show IP forwarding status</help> + </properties> + <command>/usr/bin/vtysh -c "show ip forwarding"</command> + </leafNode> + <leafNode name="large-community-list"> + <properties> + <help>Show IP large-community-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show bgp large-community-list"</command> + </leafNode> + <tagNode name="large-community-list"> + <properties> + <help>Show IP large-community-lists</help> + <completionHelp> + <path>policy large-community-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show bgp large-community-list $4 detail"</command> + </tagNode> + <leafNode name="prefix-list"> + <properties> + <help>Show all IP prefix-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show ip prefix-list"</command> + </leafNode> + <tagNode name="prefix-list"> + <properties> + <help>Show all IP prefix-lists</help> + <completionHelp> + <path>policy prefix-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip prefix-list $4"</command> + </tagNode> + <leafNode name="protocol"> + <properties> + <help>Show IP route-maps per protocol</help> + </properties> + <command>/usr/bin/vtysh -c "show ip protocol"</command> + </leafNode> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-ip-ospf.xml b/op-mode-definitions/show-ip-ospf.xml new file mode 100644 index 000000000..99441d185 --- /dev/null +++ b/op-mode-definitions/show-ip-ospf.xml @@ -0,0 +1,579 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="ip"> + <properties> + <help>Show IPv4 routing information</help> + </properties> + <children> + <node name="ospf"> + <properties> + <help>Show IPv4 Open Shortest Path First (OSPF) routing information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf"</command> + <children> + <leafNode name="border-routers"> + <properties> + <help>Show IPv4 OSPF border-routers information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf border-routers"</command> + </leafNode> + <node name="database"> + <properties> + <help>Show IPv4 OSPF database information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database"</command> + <children> + <node name="asbr-summary"> + <properties> + <help>Show IPv4 OSPF ASBR summary database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database asbr-summary"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF ASBR summary database for given address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database asbr-summary adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF ASBR summary database for given address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="asbr-summary"> + <properties> + <help>Show IPv4 OSPF ASBR summary database information of given address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database asbr-summary"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF ASBR summary database of given address for given advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database asbr-summary $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show summary of self-originate IPv4 OSPF ASBR database</help> + </properties> + <command>show ip ospf database asbr-summary $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="external"> + <properties> + <help>Show IPv4 OSPF external database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database external"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF external database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database external adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF external database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="external"> + <properties> + <help>Show IPv4 OSPF external database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database external"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF external database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database external $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF external database</help> + </properties> + <command>show ip ospf database external $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <leafNode name="max-age"> + <properties> + <help>Show IPv4 OSPF max-age database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database max-age"</command> + </leafNode> + <node name="network"> + <properties> + <help>Show IPv4 OSPF network database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database network"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF network database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database network adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF network database for given address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="network"> + <properties> + <help>Show IPv4 OSPF network database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database network"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF network database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database network $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF network database</help> + </properties> + <command>show ip ospf database network $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="nssa-external"> + <properties> + <help>Show IPv4 OSPF NSSA external database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database nssa-external"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF NSSA external database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database nssa-external adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF NSSA external database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="nssa-external"> + <properties> + <help>Show IPv4 OSPF NSSA external database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database nssa-external"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF NSSA external database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database nssa-external $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF NSSA external database</help> + </properties> + <command>show ip ospf database nssa-external $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="opaque-area"> + <properties> + <help>Show IPv4 OSPF opaque-area database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-area"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-area database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-area adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-area database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="opaque-area"> + <properties> + <help>Show IPv4 OSPF opaque-area database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-area"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-area database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-area $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF opaque-area database</help> + </properties> + <command>show ip ospf database opaque-area $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="opaque-as"> + <properties> + <help>Show IPv4 OSPF opaque-as database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-as"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-as database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-as adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-as database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="opaque-as"> + <properties> + <help>Show IPv4 OSPF opaque-as database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-as"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-as database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-as $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF opaque-as database</help> + </properties> + <command>show ip ospf database opaque-as $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="opaque-link"> + <properties> + <help>Show IPv4 OSPF opaque-link database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-link"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-link database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-link adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-link database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="opaque-link"> + <properties> + <help>Show IPv4 OSPF opaque-link database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-link"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-link database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-link $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF opaque-link database</help> + </properties> + <command>show ip ospf database opaque-link $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="router"> + <properties> + <help>Show IPv4 OSPF router database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database router"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF router database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database router adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF router database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="router"> + <properties> + <help>Show IPv4 OSPF router database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database router"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF router database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database router $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF router database</help> + </properties> + <command>show ip ospf database router $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show IPv4 OSPF self-originate database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database self-originate"</command> + </leafNode> + <node name="summary"> + <properties> + <help>Show summary of IPv4 OSPF database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database summary"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF summary database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database summary adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF summary database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="summary"> + <properties> + <help>Show IPv4 OSPF summary database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database summary"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF summary database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database summary $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF summary database</help> + </properties> + <command>show ip ospf database summary $6 self-originate</command> + </leafNode> + </children> + </tagNode> + </children> + </node> + <node name="interface"> + <properties> + <help>Show IPv4 OSPF interface information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf interface"</command> + </node> + <tagNode name="interface"> + <properties> + <help>Show IPv4 OSPF information for specified interface</help> + <completionHelp> + <script>${vyos_completion_dir}/list_interfaces.py</script> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf interface $5"</command> + </tagNode> + <node name="neighbor"> + <properties> + <help>Show IPv4 OSPF neighbor information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf neighbor"</command> + <children> + <tagNode name="address"> + <properties> + <help>Show IPv4 OSPF neighbor information for specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf neighbor $6"</command> + </tagNode> + <node name="detail"> + <properties> + <help>Show detailed IPv4 OSPF neighbor information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf neighbor detail"</command> + </node> + </children> + </node> + <tagNode name="neighbor"> + <properties> + <help>Show IPv4 OSPF neighbor information for specified IP address or interface</help> + <completionHelp> + <list><x.x.x.x></list> + <script>${vyos_completion_dir}/list_interfaces.py</script> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf neighbor $5"</command> + </tagNode> + <leafNode name="route"> + <properties> + <help>Show IPv4 OSPF route information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf route"</command> + </leafNode> + </children> + </node> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-ip-rip.xml b/op-mode-definitions/show-ip-rip.xml new file mode 100644 index 000000000..b61ab10a7 --- /dev/null +++ b/op-mode-definitions/show-ip-rip.xml @@ -0,0 +1,28 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="ip"> + <properties> + <help>Show IPv4 routing information</help> + </properties> + <children> + <node name="rip"> + <properties> + <help>Show Routing Information Protocol (RIP) information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip rip"</command> + <children> + <leafNode name="status"> + <properties> + <help>Show RIP protocol status</help> + </properties> + <command>/usr/bin/vtysh -c "show ip rip status"</command> + </leafNode> + </children> + </node> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-ip-route.xml b/op-mode-definitions/show-ip-route.xml new file mode 100644 index 000000000..d12d132c0 --- /dev/null +++ b/op-mode-definitions/show-ip-route.xml @@ -0,0 +1,160 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="ip"> + <properties> + <help>Show IPv4 routing information</help> + </properties> + <children> + <node name="route"> + <properties> + <help>Show IP routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route"</command> + <children> + <leafNode name="bgp"> + <properties> + <help>Show IP BGP routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route bgp"</command> + </leafNode> + <node name="cache"> + <properties> + <help>Show kernel route cache</help> + </properties> + <command>ip -s route list cache</command> + </node> + <tagNode name="cache"> + <properties> + <help>Show kernel route cache for a given route</help> + <completionHelp> + <list><x.x.x.x> <x.x.x.x/x></list> + </completionHelp> + </properties> + <command>ip -s route list cache $5</command> + </tagNode> + <leafNode name="connected"> + <properties> + <help>Show IP connected routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route connected"</command> + </leafNode> + <node name="forward"> + <properties> + <help>Show kernel route table</help> + </properties> + <command>ip route list</command> + </node> + <tagNode name="forward"> + <properties> + <help>Show kernel route table for a given route</help> + <completionHelp> + <list><x.x.x.x> <x.x.x.x/x></list> + </completionHelp> + </properties> + <command>ip -s route list $5</command> + </tagNode> + <leafNode name="kernel"> + <properties> + <help>Show IP kernel routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route kernel"</command> + </leafNode> + <leafNode name="ospf"> + <properties> + <help>Show IP OSPF routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route ospf"</command> + </leafNode> + <leafNode name="rip"> + <properties> + <help>Show IP RIP routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route rip"</command> + </leafNode> + <leafNode name="static"> + <properties> + <help>Show IP static routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route static"</command> + </leafNode> + <leafNode name="summary"> + <properties> + <help>Show IP routes summary</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route summary"</command> + </leafNode> + <leafNode name="supernets-only"> + <properties> + <help>Show IP supernet routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route supernets-only"</command> + </leafNode> + <node name="table"> + <properties> + <help>Show IP routes in policy table</help> + </properties> + </node> + <tagNode name="table"> + <properties> + <help>Show IP routes in policy table</help> + <completionHelp> + <list><1-200></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip route table $5"</command> + </tagNode> + <node name="tag"> + <properties> + <help>Show only routes with tag</help> + </properties> + </node> + <tagNode name="tag"> + <properties> + <help>Tag value</help> + <completionHelp> + <list><1-4294967295></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip route tag $5"</command> + </tagNode> + <node name="vrf"> + <properties> + <help>Show IP routes in VRF</help> + </properties> + </node> + <tagNode name="vrf"> + <properties> + <help>Show IP routes in VRF</help> + <completionHelp> + <list><vrf></list> + <path>vrf name</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip route vrf $5"</command> + </tagNode> + </children> + </node> + <tagNode name="route"> + <properties> + <help>Show IP routes of specified IP address or prefix</help> + <completionHelp> + <list><x.x.x.x> <x.x.x.x/x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip route $4"</command> + <children> + <leafNode name="longer-prefixes"> + <properties> + <help>Show longer prefixes of routes for specified IP address or prefix</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route $4"</command> + </leafNode> + </children> + </tagNode> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-license.xml b/op-mode-definitions/show-license.xml new file mode 100644 index 000000000..2ce11567d --- /dev/null +++ b/op-mode-definitions/show-license.xml @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <leafNode name="license"> + <properties> + <help>Show VyOS license information</help> + </properties> + <command>less $_vyatta_less_options --prompt=".license, page %dt of %D" -- ${vyatta_sysconfdir}/LICENSE</command> + </leafNode> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-log.xml b/op-mode-definitions/show-log.xml new file mode 100644 index 000000000..87d78cc49 --- /dev/null +++ b/op-mode-definitions/show-log.xml @@ -0,0 +1,139 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="log"> + <properties> + <help>Show contents of current master log file</help> + </properties> + <command>/bin/journalctl</command> + <children> + <leafNode name="all"> + <properties> + <help>Show contents of all master log files</help> + </properties> + <command>eval $(lesspipe); less $_vyatta_less_options --prompt=".log?m, file %i of %m., page %dt of %D" -- `printf "%s\n" /var/log/messages* | sort -nr`</command> + </leafNode> + <leafNode name="authorization"> + <properties> + <help>Show listing of authorization attempts</help> + </properties> + <command>/bin/journalctl -q SYSLOG_FACILITY=10 SYSLOG_FACILITY=4</command> + </leafNode> + <leafNode name="cluster"> + <properties> + <help>Show log for Cluster</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e heartbeat -e cl_status -e mach_down -e ha_log</command> + </leafNode> + <leafNode name="conntrack-sync"> + <properties> + <help>Show log for Conntrack-sync</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr ) | grep -e conntrackd</command> + </leafNode> + <leafNode name="dhcp"> + <properties> + <help>Show log for Dynamic Host Control Protocol (DHCP)</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep dhcpd</command> + </leafNode> + <leafNode name="https"> + <properties> + <help>Show log for HTTPs</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e nginx</command> + </leafNode> + <leafNode name="lldp"> + <properties> + <help>Show log for LLDP</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e lldpd</command> + </leafNode> + <leafNode name="nat"> + <properties> + <help>Show log for Network Address Translation (NAT)</help> + </properties> + <command>egrep -i "kernel:.*\[NAT-[A-Z]{3,}-[0-9]+(-MASQ)?\]" $(find /var/log -maxdepth 1 -type f -name messages\* | sort -t. -k2nr)</command> + </leafNode> + <leafNode name="nat"> + <properties> + <help>Show log for OpenVPN</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e openvpn</command> + </leafNode> + <leafNode name="snmp"> + <properties> + <help>Show log for Simple Network Monitoring Protocol (SNMP)</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e snmpd</command> + </leafNode> + <tagNode name="tail"> + <properties> + <help>Show last n changes to messages</help> + <completionHelp> + <list><NUMBER></list> + </completionHelp> + </properties> + <command>tail -n "$4" /var/log/messages | ${VYATTA_PAGER:-cat}</command> + </tagNode> + <node name="tail"> + <properties> + <help>Show last 10 lines of /var/log/messages file</help> + </properties> + <command>tail -n 10 /var/log/messages</command> + </node> + <node name="vpn"> + <properties> + <help>Show log for Virtual Private Network (VPN)</help> + </properties> + <children> + <leafNode name="all"> + <properties> + <help>Show log for ALL</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e charon -e accel -e pptpd -e ppp</command> + </leafNode> + <leafNode name="ipsec"> + <properties> + <help>Show log for IPSec</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e charon</command> + </leafNode> + <leafNode name="l2tp"> + <properties> + <help>Show log for L2TP</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e remote-access-aaa-win -e remote-access-zzz-mac -e accel-l2tp -e ppp</command> + </leafNode> + <leafNode name="pptp"> + <properties> + <help>Show log for PPTP</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e accel-pptp -e ppp</command> + </leafNode> + <leafNode name="sstp"> + <properties> + <help>Show log for SSTP</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e accel-sstp -e ppp</command> + </leafNode> + </children> + </node> + <leafNode name="vrrp"> + <properties> + <help>Show log for Virtual Router Redundancy Protocol (VRRP)</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e Keepalived_vrrp</command> + </leafNode> + <leafNode name="webproxy"> + <properties> + <help>Show log for Webproxy</help> + </properties> + <command>cat $(printf "%s\n" /var/log/messages* | sort -nr) | grep -e "squid"</command> + </leafNode> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-poweroff.xml b/op-mode-definitions/show-poweroff.xml new file mode 100644 index 000000000..1fd2afcc3 --- /dev/null +++ b/op-mode-definitions/show-poweroff.xml @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <leafNode name="poweroff"> + <properties> + <help>Show scheduled poweroff</help> + </properties> + <command>${vyos_op_scripts_dir}/powerctrl.py --check</command> + </leafNode> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-reboot.xml b/op-mode-definitions/show-reboot.xml new file mode 100644 index 000000000..c85966bcb --- /dev/null +++ b/op-mode-definitions/show-reboot.xml @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <leafNode name="reboot"> + <properties> + <help>Show scheduled reboot</help> + </properties> + <command>${vyos_op_scripts_dir}/powerctrl.py --check</command> + </leafNode> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/traceroute.xml b/op-mode-definitions/traceroute.xml index 1aea8eef6..340d28280 100644 --- a/op-mode-definitions/traceroute.xml +++ b/op-mode-definitions/traceroute.xml @@ -10,6 +10,12 @@ <command>/usr/bin/traceroute "$2"</command> </tagNode> <node name="traceroute"> + <properties> + <help>Track network path to node</help> + <completionHelp> + <list><hostname> <x.x.x.x> <h:h:h:h:h:h:h:h></list> + </completionHelp> + </properties> <children> <tagNode name="ipv4"> <properties> diff --git a/op-mode-definitions/wake-on-lan.xml b/op-mode-definitions/wake-on-lan.xml new file mode 100644 index 000000000..1a9b88596 --- /dev/null +++ b/op-mode-definitions/wake-on-lan.xml @@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="wake-on-lan"> + <properties> + <help>Send Wake-On-LAN (WOL) Magic Packet</help> + </properties> + <children> + <tagNode name="interface"> + <properties> + <help>Interface where the station is connected</help> + <completionHelp> + <script>${vyos_completion_dir}/list_interfaces.py</script> + </completionHelp> + </properties> + <children> + <tagNode name="host"> + <properties> + <help>Station (MAC) address to wake up</help> + </properties> + <command>sudo /usr/sbin/etherwake -i "$3" "$5"</command> + </tagNode> + </children> + </tagNode> + </children> + </node> +</interfaceDefinition> diff --git a/python/vyos/airbag.py b/python/vyos/airbag.py index b7838d8a2..510ab7f46 100644 --- a/python/vyos/airbag.py +++ b/python/vyos/airbag.py @@ -17,17 +17,20 @@ import sys from datetime import datetime from vyos import debug -from vyos.config import Config from vyos.logger import syslog from vyos.version import get_version from vyos.version import get_full_version_data -# we allow to disable the extra logging -DISABLE = False + +def enable(log=True): + if log: + _intercepting_logger() + _intercepting_exceptions() _noteworthy = [] + def noteworthy(msg): """ noteworthy can be use to take note things which we may not want to @@ -45,8 +48,6 @@ class _IO(object): def write(self, message): self.std.write(message) - if DISABLE: - return for line in message.split('\n'): s = line.rstrip() if s: @@ -90,14 +91,14 @@ def bug_report(dtype, value, trace): # define an exception handler to be run when an exception # reach the end of __main__ and was not intercepted -def intercepter(dtype, value, trace): +def _intercepter(dtype, value, trace): bug_report(dtype, value, trace) if debug.enabled('developer'): import pdb pdb.pm() -def InterceptingLogger(_singleton=[False]): +def _intercepting_logger(_singleton=[False]): skip = _singleton.pop() _singleton.append(True) if skip: @@ -110,7 +111,7 @@ def InterceptingLogger(_singleton=[False]): # lists as default arguments in function is normally dangerous # as they will keep any modification performed, unless this is # what you want to do (in that case to only run the code once) -def InterceptingException(excepthook,_singleton=[False]): +def _intercepting_exceptions(_singleton=[False]): skip = _singleton.pop() _singleton.append(True) if skip: @@ -118,24 +119,7 @@ def InterceptingException(excepthook,_singleton=[False]): # install the handler to replace the default behaviour # which just prints the exception trace on screen - sys.excepthook = excepthook - - -# Do not attempt the extra logging for operational commands -try: - # This fails during boot - insession = Config().in_session() -except: - # we save info on boot to help debugging - insession = True - - -# Installing the interception, it currently does not work when -# running testing so we are checking that we are on the router -# as otherwise it prevents dpkg-buildpackage to work -if get_version() and insession: - InterceptingLogger() - InterceptingException(intercepter) + sys.excepthook = _intercepter # Messages to print diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index eec64e964..ead7e8637 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -103,16 +103,21 @@ def get_ethertype(ethertype_val): else: raise ConfigError('invalid ethertype "{}"'.format(ethertype_val)) +dhcpv6_pd_default_data = { + 'dhcpv6_prm_only': False, + 'dhcpv6_temporary': False, + 'dhcpv6_pd_length': '', + 'dhcpv6_pd_interfaces': [] +} + interface_default_data = { + **dhcpv6_pd_default_data, 'address': [], 'address_remove': [], 'description': '', 'dhcp_client_id': '', 'dhcp_hostname': '', 'dhcp_vendor_class_id': '', - 'dhcpv6_prm_only': False, - 'dhcpv6_temporary': False, - 'dhcpv6_pd': [], 'disable': False, 'disable_link_detect': 1, 'ip_disable_arp_filter': 1, @@ -229,9 +234,9 @@ def intf_to_dict(conf, default): # DHCPv6 prefix delegation (RFC3633) current_level = conf.get_level() - if conf.exists(['dhcpv6-options', 'delegate']): - for interface in conf.list_nodes(['dhcpv6-options', 'delegate']): - conf.set_level(current_level + ['dhcpv6-options', 'delegate', interface]) + if conf.exists(['dhcpv6-options', 'prefix-delegation']): + for interface in conf.list_nodes(['dhcpv6-options', 'prefix-delegation', 'interface']): + conf.set_level(current_level + ['dhcpv6-options', 'prefix-delegation', 'interface', interface]) pd = { 'ifname': interface, 'sla_id': '', @@ -245,10 +250,10 @@ def intf_to_dict(conf, default): if conf.exists(['sla-len']): pd['sla_len'] = conf.return_value(['sla-len']) - if conf.exists(['interface-id']): - pd['if_id'] = conf.return_value(['interface-id']) + if conf.exists(['address']): + pd['if_id'] = conf.return_value(['address']) - intf['dhcpv6_pd'].append(pd) + intf['dhcpv6_pd_interfaces'].append(pd) # re-set config level conf.set_level(current_level) diff --git a/python/vyos/ifconfig/dhcp.py b/python/vyos/ifconfig/dhcp.py index f8fdeb6a9..a8b9a2a87 100644 --- a/python/vyos/ifconfig/dhcp.py +++ b/python/vyos/ifconfig/dhcp.py @@ -86,7 +86,8 @@ class _DHCPv6 (Control): 'ifname': ifname, 'dhcpv6_prm_only': False, 'dhcpv6_temporary': False, - 'dhcpv6_pd': [], + 'dhcpv6_pd_interfaces': [], + 'dhcpv6_pd_length': '' }) self._conf_file = f'/run/dhcp6c/dhcp6c.{ifname}.conf' diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 07efc6d97..2c2396440 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -644,7 +644,7 @@ class Interface(Control): IPv4: add IPv4 address to interface IPv6: add IPv6 address to interface dhcp: start dhclient (IPv4) on interface - dhcpv6: start dhclient (IPv6) on interface + dhcpv6: start WIDE DHCPv6 (IPv6) on interface Returns False if address is already assigned and wasn't re-added. Example: diff --git a/python/vyos/ifconfig/pppoe.py b/python/vyos/ifconfig/pppoe.py index 7504408cf..787245696 100644 --- a/python/vyos/ifconfig/pppoe.py +++ b/python/vyos/ifconfig/pppoe.py @@ -30,4 +30,12 @@ class PPPoEIf(Interface): }, } - # The _create and _delete need to be moved from interface-ppoe to here + # stub this interface is created in the configure script + + def _create(self): + # we can not create this interface as it is managed outside + pass + + def _delete(self): + # we can not create this interface as it is managed outside + pass diff --git a/python/vyos/ifconfig/vtun.py b/python/vyos/ifconfig/vtun.py index 07d39fcbb..60c178b9a 100644 --- a/python/vyos/ifconfig/vtun.py +++ b/python/vyos/ifconfig/vtun.py @@ -31,4 +31,14 @@ class VTunIf(Interface): }, } - # The _create and _delete need to be moved from interface-ppoe to here + # stub this interface is created in the configure script + + def _create(self): + # we can not create this interface as it is managed outside + # it requires configuring OpenVPN + pass + + def _delete(self): + # we can not create this interface as it is managed outside + # it requires configuring OpenVPN + pass diff --git a/python/vyos/ifconfig_vlan.py b/python/vyos/ifconfig_vlan.py index a53136ebf..53a77c651 100644 --- a/python/vyos/ifconfig_vlan.py +++ b/python/vyos/ifconfig_vlan.py @@ -87,8 +87,11 @@ def apply_vlan_config(vlan, config): if config['dhcpv6_temporary']: vlan.dhcp.v6.options['dhcpv6_temporary'] = True - if config['dhcpv6_pd']: - vlan.dhcp.v6.options['dhcpv6_pd'] = config['dhcpv6_pd'] + if config['dhcpv6_pd_length']: + vlan.dhcp.v6.options['dhcpv6_pd_length'] = config['dhcpv6_pd_length'] + + if config['dhcpv6_pd_interfaces']: + vlan.dhcp.v6.options['dhcpv6_pd_interfaces'] = config['dhcpv6_pd_interfaces'] # update interface description used e.g. within SNMP vlan.set_alias(config['description']) diff --git a/scripts/build-command-templates b/scripts/build-command-templates index 767517b29..457adbec2 100755 --- a/scripts/build-command-templates +++ b/scripts/build-command-templates @@ -249,7 +249,8 @@ def process_node(n, tmpl_dir): my_tmpl_dir.append(name) - print("Name of the node: {0}. Created directory: {1}\n".format(name, "/".join(my_tmpl_dir)), end="") + if debug: + print("Name of the node: {0}. Created directory: {1}\n".format(name, "/".join(my_tmpl_dir)), end="") os.makedirs(make_path(my_tmpl_dir), exist_ok=True) props = get_properties(props_elem) diff --git a/src/completion/list_wlm_peers.sh b/src/completion/list_wlm_peers.sh deleted file mode 100755 index 12dd00650..000000000 --- a/src/completion/list_wlm_peers.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -if [ -d /etc/ppp/peers ]; then - cd /etc/ppp/peers - ls wlm* -fi diff --git a/src/conf_mode/arp.py b/src/conf_mode/arp.py index fde7dc521..aac07bd80 100755 --- a/src/conf_mode/arp.py +++ b/src/conf_mode/arp.py @@ -25,6 +25,9 @@ from vyos.config import Config from vyos.util import call from vyos import ConfigError +from vyos import airbag +airbag.enable() + arp_cmd = '/usr/sbin/arp' def get_config(): diff --git a/src/conf_mode/bcast_relay.py b/src/conf_mode/bcast_relay.py index a3bc76ef8..5c7294296 100755 --- a/src/conf_mode/bcast_relay.py +++ b/src/conf_mode/bcast_relay.py @@ -25,6 +25,9 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() + config_file = r'/etc/default/udp-broadcast-relay' default_config_data = { diff --git a/src/conf_mode/dhcp_relay.py b/src/conf_mode/dhcp_relay.py index d24a46220..f093a005e 100755 --- a/src/conf_mode/dhcp_relay.py +++ b/src/conf_mode/dhcp_relay.py @@ -23,6 +23,9 @@ from vyos.template import render from vyos.util import call from vyos import ConfigError +from vyos import airbag +airbag.enable() + config_file = r'/run/dhcp-relay/dhcp.conf' default_config_data = { diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py index 1849ece0a..0eaa14c5b 100755 --- a/src/conf_mode/dhcp_server.py +++ b/src/conf_mode/dhcp_server.py @@ -27,6 +27,9 @@ from vyos import ConfigError from vyos.template import render from vyos.util import call, chown +from vyos import airbag +airbag.enable() + config_file = r'/run/dhcp-server/dhcpd.conf' default_config_data = { diff --git a/src/conf_mode/dhcpv6_relay.py b/src/conf_mode/dhcpv6_relay.py index ecc739063..6ef290bf0 100755 --- a/src/conf_mode/dhcpv6_relay.py +++ b/src/conf_mode/dhcpv6_relay.py @@ -24,6 +24,9 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() + config_file = r'/run/dhcp-relay/dhcpv6.conf' default_config_data = { diff --git a/src/conf_mode/dhcpv6_server.py b/src/conf_mode/dhcpv6_server.py index 9e24ee591..53c8358a5 100755 --- a/src/conf_mode/dhcpv6_server.py +++ b/src/conf_mode/dhcpv6_server.py @@ -26,6 +26,9 @@ from vyos.util import call from vyos.validate import is_subnet_connected, is_ipv6 from vyos import ConfigError +from vyos import airbag +airbag.enable() + config_file = r'/run/dhcp-server/dhcpdv6.conf' default_config_data = { diff --git a/src/conf_mode/dns_forwarding.py b/src/conf_mode/dns_forwarding.py index f87c198f7..692ac2456 100755 --- a/src/conf_mode/dns_forwarding.py +++ b/src/conf_mode/dns_forwarding.py @@ -27,6 +27,9 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() + parser = argparse.ArgumentParser() parser.add_argument("--dhclient", action="store_true", help="Started from dhclient-script") diff --git a/src/conf_mode/dynamic_dns.py b/src/conf_mode/dynamic_dns.py index 3386324ae..5b1883c03 100755 --- a/src/conf_mode/dynamic_dns.py +++ b/src/conf_mode/dynamic_dns.py @@ -25,6 +25,9 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() + config_file = r'/run/ddclient/ddclient.conf' # Mapping of service name to service protocol diff --git a/src/conf_mode/firewall_options.py b/src/conf_mode/firewall_options.py index 0b800f48f..71b2a98b3 100755 --- a/src/conf_mode/firewall_options.py +++ b/src/conf_mode/firewall_options.py @@ -23,6 +23,8 @@ from vyos.config import Config from vyos import ConfigError from vyos.util import call +from vyos import airbag +airbag.enable() default_config_data = { 'intf_opts': [], diff --git a/src/conf_mode/flow_accounting_conf.py b/src/conf_mode/flow_accounting_conf.py index d691e6abd..a9ebab53e 100755 --- a/src/conf_mode/flow_accounting_conf.py +++ b/src/conf_mode/flow_accounting_conf.py @@ -29,6 +29,9 @@ from vyos import ConfigError from vyos.util import cmd from vyos.template import render +from vyos import airbag +airbag.enable() + # default values default_sflow_server_port = 6343 default_netflow_server_port = 2055 diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py index f181a7b35..dbc587d7d 100755 --- a/src/conf_mode/host_name.py +++ b/src/conf_mode/host_name.py @@ -33,6 +33,9 @@ from vyos.config import Config from vyos import ConfigError from vyos.util import cmd, call, run, process_named_running +from vyos import airbag +airbag.enable() + default_config_data = { 'hostname': 'vyos', 'domain_name': '', diff --git a/src/conf_mode/http-api.py b/src/conf_mode/http-api.py index 3b8a67ef6..b8a084a40 100755 --- a/src/conf_mode/http-api.py +++ b/src/conf_mode/http-api.py @@ -27,6 +27,9 @@ from vyos import ConfigError from vyos.util import cmd from vyos.util import call +from vyos import airbag +airbag.enable() + config_file = '/etc/vyos/http-api.conf' vyos_conf_scripts_dir=vyos.defaults.directories['conf_mode'] diff --git a/src/conf_mode/https.py b/src/conf_mode/https.py index 718e8375c..7acb629bd 100755 --- a/src/conf_mode/https.py +++ b/src/conf_mode/https.py @@ -27,6 +27,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = '/etc/nginx/sites-available/default' diff --git a/src/conf_mode/igmp_proxy.py b/src/conf_mode/igmp_proxy.py index 9cd7163f0..49aea9b7f 100755 --- a/src/conf_mode/igmp_proxy.py +++ b/src/conf_mode/igmp_proxy.py @@ -25,6 +25,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = r'/etc/igmpproxy.conf' diff --git a/src/conf_mode/intel_qat.py b/src/conf_mode/intel_qat.py index cc7d4a915..0b2d318fd 100755 --- a/src/conf_mode/intel_qat.py +++ b/src/conf_mode/intel_qat.py @@ -24,6 +24,9 @@ from vyos.config import Config from vyos import ConfigError from vyos.util import popen, run +from vyos import airbag +airbag.enable() + # Define for recovering gl_ipsec_conf = None @@ -56,7 +59,7 @@ def vpn_control(action): def verify(c): # Check if QAT service installed - if not os.path.exists('/etc/init.d/vyos-qat-utilities'): + if not os.path.exists('/etc/init.d/qat_service'): raise ConfigError("Warning: QAT init file not found") if c['qat_conf'] == None: @@ -78,13 +81,13 @@ def apply(c): # Disable QAT service if c['qat_conf'] == None: - run('sudo /etc/init.d/vyos-qat-utilities stop') + run('sudo /etc/init.d/qat_service stop') if c['ipsec_conf']: vpn_control('start') return # Run qat init.d script - run('sudo /etc/init.d/vyos-qat-utilities start') + run('sudo /etc/init.d/qat_service start') if c['ipsec_conf']: # Recovery VPN service vpn_control('start') diff --git a/src/conf_mode/interfaces-bonding.py b/src/conf_mode/interfaces-bonding.py index 0c222c485..a16c4e105 100755 --- a/src/conf_mode/interfaces-bonding.py +++ b/src/conf_mode/interfaces-bonding.py @@ -28,6 +28,9 @@ from vyos.util import call, cmd from vyos.validate import is_member, has_address_configured from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { **interface_default_data, 'arp_mon_intvl': 0, @@ -298,8 +301,11 @@ def apply(bond): if bond['dhcpv6_temporary']: b.dhcp.v6.options['dhcpv6_temporary'] = True - if bond['dhcpv6_pd']: - b.dhcp.v6.options['dhcpv6_pd'] = bond['dhcpv6_pd'] + if bond['dhcpv6_pd_length']: + b.dhcp.v6.options['dhcpv6_pd_length'] = bond['dhcpv6_pd_length'] + + if bond['dhcpv6_pd_interfaces']: + b.dhcp.v6.options['dhcpv6_pd_interfaces'] = bond['dhcpv6_pd_interfaces'] # ignore link state changes b.set_link_detect(bond['disable_link_detect']) diff --git a/src/conf_mode/interfaces-bridge.py b/src/conf_mode/interfaces-bridge.py index 3ff339f0f..1e4fa5816 100755 --- a/src/conf_mode/interfaces-bridge.py +++ b/src/conf_mode/interfaces-bridge.py @@ -28,6 +28,9 @@ from vyos.config import Config from vyos.util import cmd, get_bridge_member_config from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { **interface_default_data, 'aging': 300, @@ -321,8 +324,11 @@ def apply(bridge): if bridge['dhcpv6_temporary']: br.dhcp.v6.options['dhcpv6_temporary'] = True - if bridge['dhcpv6_pd']: - br.dhcp.v6.options['dhcpv6_pd'] = br['dhcpv6_pd'] + if bridge['dhcpv6_pd_length']: + br.dhcp.v6.options['dhcpv6_pd_length'] = br['dhcpv6_pd_length'] + + if bridge['dhcpv6_pd_interfaces']: + br.dhcp.v6.options['dhcpv6_pd_interfaces'] = br['dhcpv6_pd_interfaces'] # assign/remove VRF br.set_vrf(bridge['vrf']) diff --git a/src/conf_mode/interfaces-dummy.py b/src/conf_mode/interfaces-dummy.py index 4a77b0c1a..ec255edd5 100755 --- a/src/conf_mode/interfaces-dummy.py +++ b/src/conf_mode/interfaces-dummy.py @@ -26,6 +26,9 @@ from vyos.config import Config from vyos.validate import is_member from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { 'address': [], 'address_remove': [], diff --git a/src/conf_mode/interfaces-ethernet.py b/src/conf_mode/interfaces-ethernet.py index f45a77a3e..8d657acba 100755 --- a/src/conf_mode/interfaces-ethernet.py +++ b/src/conf_mode/interfaces-ethernet.py @@ -27,6 +27,9 @@ from vyos.validate import is_member from vyos.config import Config from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { **interface_default_data, 'deleted': False, @@ -170,6 +173,10 @@ def verify(eth): f'Interface "{eth["intf"]}" cannot be member of VRF "{eth["vrf"]}" ' f'and "{memberof}" at the same time!')) + if eth['mac'] and eth['is_bond_member']: + print('WARNING: "mac {0}" command will be ignored because {1} is a part of {2}'\ + .format(eth['mac'], eth['intf'], eth['is_bond_member'])) + # use common function to verify VLAN configuration verify_vlan_config(eth) return None @@ -201,8 +208,11 @@ def apply(eth): if eth['dhcpv6_temporary']: e.dhcp.v6.options['dhcpv6_temporary'] = True - if eth['dhcpv6_pd']: - e.dhcp.v6.options['dhcpv6_pd'] = e['dhcpv6_pd'] + if eth['dhcpv6_pd_length']: + e.dhcp.v6.options['dhcpv6_pd_length'] = eth['dhcpv6_pd_length'] + + if eth['dhcpv6_pd_interfaces']: + e.dhcp.v6.options['dhcpv6_pd_interfaces'] = eth['dhcpv6_pd_interfaces'] # ignore link state changes e.set_link_detect(eth['disable_link_detect']) @@ -236,11 +246,12 @@ def apply(eth): e.del_ipv6_eui64_address(addr) # Change interface MAC address - re-set to real hardware address (hw-id) - # if custom mac is removed - if eth['mac']: - e.set_mac(eth['mac']) - elif eth['hw_id']: - e.set_mac(eth['hw_id']) + # if custom mac is removed. Skip if bond member. + if not eth['is_bond_member']: + if eth['mac']: + e.set_mac(eth['mac']) + elif eth['hw_id']: + e.set_mac(eth['hw_id']) # Add IPv6 EUI-based addresses for addr in eth['ipv6_eui64_prefix']: diff --git a/src/conf_mode/interfaces-geneve.py b/src/conf_mode/interfaces-geneve.py index e4109a221..31f6eb6b5 100755 --- a/src/conf_mode/interfaces-geneve.py +++ b/src/conf_mode/interfaces-geneve.py @@ -25,6 +25,9 @@ from vyos.ifconfig import GeneveIf from vyos.validate import is_member from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { 'address': [], 'deleted': False, diff --git a/src/conf_mode/interfaces-l2tpv3.py b/src/conf_mode/interfaces-l2tpv3.py index cdfc6ea84..4ff0bcb57 100755 --- a/src/conf_mode/interfaces-l2tpv3.py +++ b/src/conf_mode/interfaces-l2tpv3.py @@ -26,6 +26,9 @@ from vyos import ConfigError from vyos.util import call from vyos.validate import is_member, is_addr_assigned +from vyos import airbag +airbag.enable() + default_config_data = { 'address': [], 'deleted': False, diff --git a/src/conf_mode/interfaces-loopback.py b/src/conf_mode/interfaces-loopback.py index ddd18ae24..df268cec2 100755 --- a/src/conf_mode/interfaces-loopback.py +++ b/src/conf_mode/interfaces-loopback.py @@ -24,6 +24,9 @@ from vyos.configdict import list_diff from vyos.config import Config from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { 'address': [], 'address_remove': [], diff --git a/src/conf_mode/interfaces-macsec.py b/src/conf_mode/interfaces-macsec.py index 7d6f238f3..a8966148f 100755 --- a/src/conf_mode/interfaces-macsec.py +++ b/src/conf_mode/interfaces-macsec.py @@ -28,6 +28,9 @@ from vyos.util import call from vyos.validate import is_member from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { 'address': [], 'address_remove': [], diff --git a/src/conf_mode/interfaces-openvpn.py b/src/conf_mode/interfaces-openvpn.py index ea8e1a7c4..5afcbe7da 100755 --- a/src/conf_mode/interfaces-openvpn.py +++ b/src/conf_mode/interfaces-openvpn.py @@ -32,6 +32,9 @@ from vyos.util import call, chown, chmod_600, chmod_755 from vyos.validate import is_addr_assigned, is_member, is_ipv4 from vyos import ConfigError +from vyos import airbag +airbag.enable() + user = 'openvpn' group = 'openvpn' @@ -109,6 +112,7 @@ default_config_data = { 'type': 'tun', 'uid': user, 'gid': group, + 'vrf': '' } @@ -630,6 +634,10 @@ def get_config(): if openvpn['redirect_gateway']: openvpn['redirect_gateway'] += ' ipv6' + # retrieve VRF instance + if conf.exists('vrf'): + openvpn['vrf'] = conf.return_value('vrf') + return openvpn def verify(openvpn): @@ -941,6 +949,16 @@ def verify(openvpn): if not openvpn['auth_pass']: raise ConfigError('Password for authentication is missing') + if openvpn['vrf']: + if openvpn['vrf'] not in interfaces(): + raise ConfigError(f'VRF "{openvpn["vrf"]}" does not exist') + + if openvpn['is_bridge_member']: + raise ConfigError(( + f'Interface "{openvpn["intf"]}" cannot be member of VRF ' + f'"{openvpn["vrf"]}" and bridge "{openvpn["is_bridge_member"]}" ' + f'at the same time!')) + return None def generate(openvpn): @@ -1070,6 +1088,11 @@ def apply(openvpn): for addr in openvpn['ipv6_eui64_prefix']: o.add_ipv6_eui64_address(addr) + # assign/remove VRF (ONLY when not a member of a bridge, + # otherwise 'nomaster' removes it from it) + if not openvpn['is_bridge_member']: + o.set_vrf(openvpn['vrf']) + except: pass diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 6cde850c9..231672490 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -21,13 +21,17 @@ from copy import deepcopy from netifaces import interfaces from vyos.config import Config +from vyos.configdict import dhcpv6_pd_default_data from vyos.ifconfig import Interface +from vyos.template import render from vyos.util import chown, chmod_755, call from vyos import ConfigError -from vyos.template import render +from vyos import airbag +airbag.enable() default_config_data = { + **dhcpv6_pd_default_data, 'access_concentrator': '', 'auth_username': '', 'auth_password': '', @@ -36,7 +40,6 @@ default_config_data = { 'deleted': False, 'description': '\0', 'disable': False, - 'dhcpv6_pd': [], 'intf': '', 'idle_timeout': '', 'ipv6_autoconf': False, @@ -137,15 +140,24 @@ def get_config(): if conf.exists('vrf'): pppoe['vrf'] = conf.return_value(['vrf']) - if conf.exists(['dhcpv6-options', 'delegate']): - for interface in conf.list_nodes(['dhcpv6-options', 'delegate']): + if conf.exists(['dhcpv6-options', 'prefix-delegation']): + dhcpv6_pd_path = base_path + [pppoe['intf'], + 'dhcpv6-options', 'prefix-delegation'] + conf.set_level(dhcpv6_pd_path) + + # retriebe DHCPv6-PD prefix helper length as some ISPs only hand out a + # /64 by default (https://phabricator.vyos.net/T2506) + if conf.exists(['length']): + pppoe['dhcpv6_pd_length'] = conf.return_value(['length']) + + for interface in conf.list_nodes(['interface']): + conf.set_level(dhcpv6_pd_path + ['interface', interface]) pd = { 'ifname': interface, 'sla_id': '', 'sla_len': '', 'if_id': '' } - conf.set_level(base_path + [pppoe['intf'], 'dhcpv6-options', 'delegate', interface]) if conf.exists(['sla-id']): pd['sla_id'] = conf.return_value(['sla-id']) @@ -153,10 +165,10 @@ def get_config(): if conf.exists(['sla-len']): pd['sla_len'] = conf.return_value(['sla-len']) - if conf.exists(['interface-id']): - pd['if_id'] = conf.return_value(['interface-id']) + if conf.exists(['address']): + pd['if_id'] = conf.return_value(['address']) - pppoe['dhcpv6_pd'].append(pd) + pppoe['dhcpv6_pd_interfaces'].append(pd) return pppoe @@ -223,7 +235,7 @@ def generate(pppoe): render(script_pppoe_ipv6_up, 'pppoe/ipv6-up.script.tmpl', pppoe, trim_blocks=True, permission=0o755) - if len(pppoe['dhcpv6_pd']) > 0: + if len(pppoe['dhcpv6_pd_interfaces']) > 0: # ipv6.tmpl relies on ifname - this should be made consitent in the # future better then double key-ing the same value pppoe['ifname'] = intf diff --git a/src/conf_mode/interfaces-pseudo-ethernet.py b/src/conf_mode/interfaces-pseudo-ethernet.py index 3e036a753..b142688f6 100755 --- a/src/conf_mode/interfaces-pseudo-ethernet.py +++ b/src/conf_mode/interfaces-pseudo-ethernet.py @@ -26,6 +26,9 @@ from vyos.ifconfig import MACVLANIf, Section from vyos.ifconfig_vlan import apply_all_vlans, verify_vlan_config from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { **interface_default_data, 'deleted': False, @@ -171,8 +174,11 @@ def apply(peth): if peth['dhcpv6_temporary']: p.dhcp.v6.options['dhcpv6_temporary'] = True - if peth['dhcpv6_pd']: - p.dhcp.v6.options['dhcpv6_pd'] = peth['dhcpv6_pd'] + if peth['dhcpv6_pd_length']: + p.dhcp.v6.options['dhcpv6_pd_length'] = peth['dhcpv6_pd_length'] + + if peth['dhcpv6_pd_interfaces']: + p.dhcp.v6.options['dhcpv6_pd_interfaces'] = peth['dhcpv6_pd_interfaces'] # ignore link state changes p.set_link_detect(peth['disable_link_detect']) diff --git a/src/conf_mode/interfaces-tunnel.py b/src/conf_mode/interfaces-tunnel.py index 8e9bb069e..c9964d41c 100755 --- a/src/conf_mode/interfaces-tunnel.py +++ b/src/conf_mode/interfaces-tunnel.py @@ -29,6 +29,9 @@ from vyos.validate import is_ipv4, is_ipv6, is_member from vyos import ConfigError from vyos.dicts import FixedDict +from vyos import airbag +airbag.enable() + class ConfigurationState(Config): """ The current API require a dict to be generated by get_config() diff --git a/src/conf_mode/interfaces-vxlan.py b/src/conf_mode/interfaces-vxlan.py index 84fe3dfc8..39db814b4 100755 --- a/src/conf_mode/interfaces-vxlan.py +++ b/src/conf_mode/interfaces-vxlan.py @@ -25,6 +25,9 @@ from vyos.ifconfig import VXLANIf, Interface from vyos.validate import is_member from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { 'address': [], 'deleted': False, diff --git a/src/conf_mode/interfaces-wireguard.py b/src/conf_mode/interfaces-wireguard.py index 97dcf626b..ab3e073ae 100755 --- a/src/conf_mode/interfaces-wireguard.py +++ b/src/conf_mode/interfaces-wireguard.py @@ -28,6 +28,9 @@ from vyos.util import chown, chmod_750, call from vyos.validate import is_member, is_ipv6 from vyos import ConfigError +from vyos import airbag +airbag.enable() + kdir = r'/config/auth/wireguard' default_config_data = { diff --git a/src/conf_mode/interfaces-wireless.py b/src/conf_mode/interfaces-wireless.py index 0fa20c5f4..0162b642c 100755 --- a/src/conf_mode/interfaces-wireless.py +++ b/src/conf_mode/interfaces-wireless.py @@ -32,6 +32,9 @@ from vyos.util import chown, call from vyos.validate import is_member from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { **interface_default_data, 'cap_ht' : False, @@ -591,8 +594,11 @@ def apply(wifi): if wifi['dhcpv6_temporary']: w.dhcp.v6.options['dhcpv6_temporary'] = True - if wifi['dhcpv6_pd']: - w.dhcp.v6.options['dhcpv6_pd'] = wifi['dhcpv6_pd'] + if wifi['dhcpv6_pd_length']: + w.dhcp.v6.options['dhcpv6_pd_length'] = wifi['dhcpv6_pd_length'] + + if wifi['dhcpv6_pd_interfaces']: + w.dhcp.v6.options['dhcpv6_pd_interfaces'] = wifi['dhcpv6_pd_interfaces'] # ignore link state changes w.set_link_detect(wifi['disable_link_detect']) diff --git a/src/conf_mode/interfaces-wirelessmodem.py b/src/conf_mode/interfaces-wirelessmodem.py index 975e21d9f..a13c70990 100755 --- a/src/conf_mode/interfaces-wirelessmodem.py +++ b/src/conf_mode/interfaces-wirelessmodem.py @@ -27,6 +27,9 @@ from vyos.util import chown, chmod_755, cmd, call from vyos.validate import is_member from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { 'address': [], 'apn': '', diff --git a/src/conf_mode/ipsec-settings.py b/src/conf_mode/ipsec-settings.py index 6282c2cc7..015d1a480 100755 --- a/src/conf_mode/ipsec-settings.py +++ b/src/conf_mode/ipsec-settings.py @@ -25,6 +25,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() ra_conn_name = "remote-access" charon_conf_file = "/etc/strongswan.d/charon.conf" diff --git a/src/conf_mode/le_cert.py b/src/conf_mode/le_cert.py index 2db31d3fc..5b965f95f 100755 --- a/src/conf_mode/le_cert.py +++ b/src/conf_mode/le_cert.py @@ -23,6 +23,9 @@ from vyos import ConfigError from vyos.util import cmd from vyos.util import call +from vyos import airbag +airbag.enable() + vyos_conf_scripts_dir = vyos.defaults.directories['conf_mode'] dependencies = [ diff --git a/src/conf_mode/lldp.py b/src/conf_mode/lldp.py index 6446074d8..1b539887a 100755 --- a/src/conf_mode/lldp.py +++ b/src/conf_mode/lldp.py @@ -27,6 +27,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = "/etc/default/lldpd" vyos_config_file = "/etc/lldpd.d/01-vyos.conf" diff --git a/src/conf_mode/mdns_repeater.py b/src/conf_mode/mdns_repeater.py index a652553f7..b43f9bdd8 100755 --- a/src/conf_mode/mdns_repeater.py +++ b/src/conf_mode/mdns_repeater.py @@ -25,6 +25,9 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() + config_file = r'/etc/default/mdns-repeater' default_config_data = { diff --git a/src/conf_mode/nat.py b/src/conf_mode/nat.py index d491395ac..7294314c6 100755 --- a/src/conf_mode/nat.py +++ b/src/conf_mode/nat.py @@ -28,6 +28,9 @@ from vyos.util import call, cmd from vyos.validate import is_addr_assigned from vyos import ConfigError +from vyos import airbag +airbag.enable() + default_config_data = { 'deleted': False, 'destination': [], diff --git a/src/conf_mode/ntp.py b/src/conf_mode/ntp.py index 85f60293d..a66fddc61 100755 --- a/src/conf_mode/ntp.py +++ b/src/conf_mode/ntp.py @@ -25,6 +25,9 @@ from vyos.util import call from vyos.template import render from vyos import ConfigError +from vyos import airbag +airbag.enable() + config_file = r'/etc/ntp.conf' default_config_data = { diff --git a/src/conf_mode/protocols_bfd.py b/src/conf_mode/protocols_bfd.py index d6577579e..c8e791c78 100755 --- a/src/conf_mode/protocols_bfd.py +++ b/src/conf_mode/protocols_bfd.py @@ -25,6 +25,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = r'/tmp/bfd.frr' diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py new file mode 100755 index 000000000..3aa76d866 --- /dev/null +++ b/src/conf_mode/protocols_bgp.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import jmespath + +from copy import deepcopy +from sys import exit + +from vyos.config import Config +from vyos.template import render +from vyos import ConfigError, airbag +airbag.enable() + +config_file = r'/tmp/bgp.frr' + +default_config_data = { + 'as_number': '' +} + +def get_config(): + bgp = deepcopy(default_config_data) + conf = Config() + + # this lives in the "nbgp" tree until we switch over + base = ['protocols', 'nbgp'] + if not conf.exists(base): + return None + + bgp = deepcopy(default_config_data) + # Get full BGP configuration as dictionary - output the configuration for development + # + # vyos@vyos# commit + # [ protocols nbgp 65000 ] + # {'nbgp': {'65000': {'address-family': {'ipv4-unicast': {'aggregate-address': {'1.1.0.0/16': {}, + # '2.2.2.0/24': {}}}, + # 'ipv6-unicast': {'aggregate-address': {'2001:db8::/32': {}}}}, + # 'neighbor': {'192.0.2.1': {'password': 'foo', + # 'remote-as': '100'}}}}} + # + tmp = conf.get_config_dict(base) + + # extract base key from dict as this is our AS number + bgp['as_number'] = jmespath.search('nbgp | keys(@) [0]', tmp) + + # adjust level of dictionary returned by get_config_dict() + # by using jmesgpath and update dictionary + bgp.update(jmespath.search('nbgp.* | [0]', tmp)) + + from pprint import pprint + pprint(bgp) + # resulting in e.g. + # vyos@vyos# commit + # [ protocols nbgp 65000 ] + # {'address-family': {'ipv4-unicast': {'aggregate-address': {'1.1.0.0/16': {}, + # '2.2.2.0/24': {}}}, + # 'ipv6-unicast': {'aggregate-address': {'2001:db8::/32': {}}}}, + # 'as_number': '65000', + # 'neighbor': {'192.0.2.1': {'password': 'foo', 'remote-as': '100'}}, + # 'timers': {'holdtime': '5'}} + + return bgp + +def verify(bgp): + # bail out early - looks like removal from running config + if not bgp: + return None + + return None + +def generate(bgp): + # bail out early - looks like removal from running config + if not bgp: + return None + + render(config_file, 'frr/bgp.frr.tmpl', bgp) + return None + +def apply(bgp): + return None + +if __name__ == '__main__': + try: + c = get_config() + verify(c) + generate(c) + apply(c) + except ConfigError as e: + print(e) + exit(1) diff --git a/src/conf_mode/protocols_igmp.py b/src/conf_mode/protocols_igmp.py index 821ccb0fc..6f0e2010f 100755 --- a/src/conf_mode/protocols_igmp.py +++ b/src/conf_mode/protocols_igmp.py @@ -24,6 +24,8 @@ from vyos.config import Config from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = r'/tmp/igmp.frr' diff --git a/src/conf_mode/protocols_mpls.py b/src/conf_mode/protocols_mpls.py index 9b946b43a..15785a801 100755 --- a/src/conf_mode/protocols_mpls.py +++ b/src/conf_mode/protocols_mpls.py @@ -21,6 +21,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = r'/tmp/ldpd.frr' diff --git a/src/conf_mode/protocols_pim.py b/src/conf_mode/protocols_pim.py index 15c4a2b0f..8aa324bac 100755 --- a/src/conf_mode/protocols_pim.py +++ b/src/conf_mode/protocols_pim.py @@ -24,6 +24,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = r'/tmp/pimd.frr' diff --git a/src/conf_mode/protocols_static_multicast.py b/src/conf_mode/protocols_static_multicast.py index ba6324393..eeab26d4d 100755 --- a/src/conf_mode/protocols_static_multicast.py +++ b/src/conf_mode/protocols_static_multicast.py @@ -24,6 +24,8 @@ from vyos.config import Config from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = r'/tmp/static_mcast.frr' diff --git a/src/conf_mode/salt-minion.py b/src/conf_mode/salt-minion.py index 8bc35bb45..3343d1247 100755 --- a/src/conf_mode/salt-minion.py +++ b/src/conf_mode/salt-minion.py @@ -26,6 +26,9 @@ from vyos.template import render from vyos.util import call, chown from vyos import ConfigError +from vyos import airbag +airbag.enable() + config_file = r'/etc/salt/minion' master_keyfile = r'/opt/vyatta/etc/config/salt/pki/minion/master_sign.pub' diff --git a/src/conf_mode/service_ipoe-server.py b/src/conf_mode/service_ipoe-server.py index 84443ade3..b539da98e 100755 --- a/src/conf_mode/service_ipoe-server.py +++ b/src/conf_mode/service_ipoe-server.py @@ -27,6 +27,9 @@ from vyos.util import call, get_half_cpus from vyos.validate import is_ipv4 from vyos import ConfigError +from vyos import airbag +airbag.enable() + ipoe_conf = '/run/accel-pppd/ipoe.conf' ipoe_chap_secrets = '/run/accel-pppd/ipoe.chap-secrets' diff --git a/src/conf_mode/service_pppoe-server.py b/src/conf_mode/service_pppoe-server.py index e05b0ab2a..e8777dcad 100755 --- a/src/conf_mode/service_pppoe-server.py +++ b/src/conf_mode/service_pppoe-server.py @@ -27,6 +27,9 @@ from vyos.util import call, get_half_cpus from vyos.validate import is_ipv4 from vyos import ConfigError +from vyos import airbag +airbag.enable() + pppoe_conf = r'/run/accel-pppd/pppoe.conf' pppoe_chap_secrets = r'/run/accel-pppd/pppoe.chap-secrets' diff --git a/src/conf_mode/service_router-advert.py b/src/conf_mode/service_router-advert.py index 620f3eacf..da7019e2c 100755 --- a/src/conf_mode/service_router-advert.py +++ b/src/conf_mode/service_router-advert.py @@ -24,6 +24,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = r'/etc/radvd.conf' diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py index 7530da2dc..2b6140f41 100755 --- a/src/conf_mode/snmp.py +++ b/src/conf_mode/snmp.py @@ -28,6 +28,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file_client = r'/etc/snmp/snmp.conf' config_file_daemon = r'/etc/snmp/snmpd.conf' diff --git a/src/conf_mode/ssh.py b/src/conf_mode/ssh.py index 76fdad8ae..c830497ab 100755 --- a/src/conf_mode/ssh.py +++ b/src/conf_mode/ssh.py @@ -22,6 +22,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = r'/etc/ssh/sshd_config' diff --git a/src/conf_mode/system-ip.py b/src/conf_mode/system-ip.py index 8a1ac8411..85f1e3771 100755 --- a/src/conf_mode/system-ip.py +++ b/src/conf_mode/system-ip.py @@ -22,6 +22,8 @@ from vyos.config import Config from vyos import ConfigError from vyos.util import call +from vyos import airbag +airbag.enable() default_config_data = { 'arp_table': 8192, diff --git a/src/conf_mode/system-ipv6.py b/src/conf_mode/system-ipv6.py index 04a063564..3417c609d 100755 --- a/src/conf_mode/system-ipv6.py +++ b/src/conf_mode/system-ipv6.py @@ -23,6 +23,8 @@ from vyos.config import Config from vyos import ConfigError from vyos.util import call +from vyos import airbag +airbag.enable() ipv6_disable_file = '/etc/modprobe.d/vyos_disable_ipv6.conf' diff --git a/src/conf_mode/system-login-banner.py b/src/conf_mode/system-login-banner.py index 5a34a0b06..5c0adc921 100755 --- a/src/conf_mode/system-login-banner.py +++ b/src/conf_mode/system-login-banner.py @@ -18,6 +18,9 @@ from sys import exit from vyos.config import Config from vyos import ConfigError +from vyos import airbag +airbag.enable() + motd=""" The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the diff --git a/src/conf_mode/system-login.py b/src/conf_mode/system-login.py index 536c5f70e..5990c3777 100755 --- a/src/conf_mode/system-login.py +++ b/src/conf_mode/system-login.py @@ -28,6 +28,9 @@ from vyos.template import render from vyos.util import cmd, call, DEVNULL, chmod_600, chmod_755 from vyos import ConfigError +from vyos import airbag +airbag.enable() + radius_config_file = "/etc/pam_radius_auth.conf" default_config_data = { diff --git a/src/conf_mode/system-options.py b/src/conf_mode/system-options.py index b3dbc82fb..8de3b6fa2 100755 --- a/src/conf_mode/system-options.py +++ b/src/conf_mode/system-options.py @@ -22,6 +22,9 @@ from vyos.config import Config from vyos import ConfigError from vyos.util import run +from vyos import airbag +airbag.enable() + systemd_ctrl_alt_del = '/lib/systemd/system/ctrl-alt-del.target' default_config_data = { diff --git a/src/conf_mode/system-proxy.py b/src/conf_mode/system-proxy.py index cf72a1f96..02536c2ab 100755 --- a/src/conf_mode/system-proxy.py +++ b/src/conf_mode/system-proxy.py @@ -23,6 +23,9 @@ import re from vyos import ConfigError from vyos.config import Config +from vyos import airbag +airbag.enable() + proxy_def = r'/etc/profile.d/vyos-system-proxy.sh' diff --git a/src/conf_mode/system-syslog.py b/src/conf_mode/system-syslog.py index 9da3d9157..8b20e1135 100755 --- a/src/conf_mode/system-syslog.py +++ b/src/conf_mode/system-syslog.py @@ -24,6 +24,8 @@ from vyos import ConfigError from vyos.util import run from vyos.template import render +from vyos import airbag +airbag.enable() def get_config(): c = Config() diff --git a/src/conf_mode/system-timezone.py b/src/conf_mode/system-timezone.py index 25b949a79..0f4513122 100755 --- a/src/conf_mode/system-timezone.py +++ b/src/conf_mode/system-timezone.py @@ -22,6 +22,8 @@ from vyos.config import Config from vyos import ConfigError from vyos.util import call +from vyos import airbag +airbag.enable() default_config_data = { 'name': 'UTC' diff --git a/src/conf_mode/system-wifi-regdom.py b/src/conf_mode/system-wifi-regdom.py index b222df0a9..30ea89098 100755 --- a/src/conf_mode/system-wifi-regdom.py +++ b/src/conf_mode/system-wifi-regdom.py @@ -23,6 +23,8 @@ from vyos.config import Config from vyos import ConfigError from vyos.template import render +from vyos import airbag +airbag.enable() config_80211_file='/etc/modprobe.d/cfg80211.conf' config_crda_file='/etc/default/crda' diff --git a/src/conf_mode/task_scheduler.py b/src/conf_mode/task_scheduler.py index b171e9576..51d8684cb 100755 --- a/src/conf_mode/task_scheduler.py +++ b/src/conf_mode/task_scheduler.py @@ -23,6 +23,8 @@ import sys from vyos.config import Config from vyos import ConfigError +from vyos import airbag +airbag.enable() crontab_file = "/etc/cron.d/vyos-crontab" diff --git a/src/conf_mode/tftp_server.py b/src/conf_mode/tftp_server.py index 94c8bcf03..d31851bef 100755 --- a/src/conf_mode/tftp_server.py +++ b/src/conf_mode/tftp_server.py @@ -28,6 +28,8 @@ from vyos import ConfigError from vyos.util import call from vyos.template import render +from vyos import airbag +airbag.enable() config_file = r'/etc/default/tftpd' diff --git a/src/conf_mode/vpn_l2tp.py b/src/conf_mode/vpn_l2tp.py index f312f2a17..febe8c3b7 100755 --- a/src/conf_mode/vpn_l2tp.py +++ b/src/conf_mode/vpn_l2tp.py @@ -30,6 +30,8 @@ from vyos.validate import is_ipv4 from vyos import ConfigError from vyos.template import render +from vyos import airbag +airbag.enable() l2tp_conf = '/run/accel-pppd/l2tp.conf' l2tp_chap_secrets = '/run/accel-pppd/l2tp.chap-secrets' diff --git a/src/conf_mode/vpn_pptp.py b/src/conf_mode/vpn_pptp.py index 085c9c2c6..5c8b53e1d 100755 --- a/src/conf_mode/vpn_pptp.py +++ b/src/conf_mode/vpn_pptp.py @@ -26,6 +26,9 @@ from vyos.template import render from vyos.util import call, get_half_cpus from vyos import ConfigError +from vyos import airbag +airbag.enable() + pptp_conf = '/run/accel-pppd/pptp.conf' pptp_chap_secrets = '/run/accel-pppd/pptp.chap-secrets' diff --git a/src/conf_mode/vpn_sstp.py b/src/conf_mode/vpn_sstp.py index 7c3e3f515..e080ce0dd 100755 --- a/src/conf_mode/vpn_sstp.py +++ b/src/conf_mode/vpn_sstp.py @@ -27,6 +27,9 @@ from vyos.util import call, run, get_half_cpus from vyos.validate import is_ipv4 from vyos import ConfigError +from vyos import airbag +airbag.enable() + sstp_conf = '/run/accel-pppd/sstp.conf' sstp_chap_secrets = '/run/accel-pppd/sstp.chap-secrets' diff --git a/src/conf_mode/vrf.py b/src/conf_mode/vrf.py index eb73293a9..e8f523e36 100755 --- a/src/conf_mode/vrf.py +++ b/src/conf_mode/vrf.py @@ -27,6 +27,8 @@ from vyos.util import read_file, cmd from vyos import ConfigError from vyos.template import render +from vyos import airbag +airbag.enable() config_file = r'/etc/iproute2/rt_tables.d/vyos-vrf.conf' diff --git a/src/conf_mode/vrrp.py b/src/conf_mode/vrrp.py index 1a5ad1f8c..292eb0c78 100755 --- a/src/conf_mode/vrrp.py +++ b/src/conf_mode/vrrp.py @@ -29,6 +29,8 @@ from vyos.template import render from vyos.ifconfig.vrrp import VRRP +from vyos import airbag +airbag.enable() def get_config(): vrrp_groups = [] diff --git a/src/conf_mode/vyos_cert.py b/src/conf_mode/vyos_cert.py index 8b8953cb7..fb4644d5a 100755 --- a/src/conf_mode/vyos_cert.py +++ b/src/conf_mode/vyos_cert.py @@ -27,6 +27,9 @@ from vyos.config import Config from vyos import ConfigError from vyos.util import cmd +from vyos import airbag +airbag.enable() + vyos_conf_scripts_dir = vyos.defaults.directories['conf_mode'] # XXX: this model will need to be extended for tag nodes diff --git a/src/migration-scripts/interfaces/9-to-10 b/src/migration-scripts/interfaces/9-to-10 new file mode 100755 index 000000000..4aa2c42b5 --- /dev/null +++ b/src/migration-scripts/interfaces/9-to-10 @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# - rename CLI node 'dhcpv6-options delgate' to 'dhcpv6-options prefix-delegation +# interface' +# - rename CLI node 'interface-id' for prefix-delegation to 'address' as it +# represents the local interface IPv6 address assigned by DHCPv6-PD + +from sys import exit, argv +from vyos.configtree import ConfigTree + +if __name__ == '__main__': + if (len(argv) < 1): + print("Must specify file name!") + exit(1) + + file_name = argv[1] + with open(file_name, 'r') as f: + config_file = f.read() + + config = ConfigTree(config_file) + + for intf_type in config.list_nodes(['interfaces']): + for intf in config.list_nodes(['interfaces', intf_type]): + # cache current config tree + base_path = ['interfaces', intf_type, intf, 'dhcpv6-options', + 'delegate'] + + if config.exists(base_path): + # cache new config tree + new_path = ['interfaces', intf_type, intf, 'dhcpv6-options', + 'prefix-delegation'] + if not config.exists(new_path): + config.set(new_path) + + # copy to new node + config.copy(base_path, new_path + ['interface']) + + # rename interface-id to address + for interface in config.list_nodes(new_path + ['interface']): + config.rename(new_path + ['interface', interface, 'interface-id'], 'address') + + # delete old noe + config.delete(base_path) + + try: + with open(file_name, 'w') as f: + f.write(config.to_string()) + except OSError as e: + print("Failed to save the modified config: {}".format(e)) + exit(1) diff --git a/src/op_mode/dynamic_dns.py b/src/op_mode/dynamic_dns.py index e4e5043d5..021acfd73 100755 --- a/src/op_mode/dynamic_dns.py +++ b/src/op_mode/dynamic_dns.py @@ -36,12 +36,6 @@ update-status: {{ entry.status }} """ def show_status(): - # Do nothing if service is not configured - c = Config() - if not c.exists_effective('service dns dynamic'): - print("Dynamic DNS not configured") - sys.exit(0) - data = { 'hosts': [] } @@ -86,22 +80,25 @@ def show_status(): def update_ddns(): call('systemctl stop ddclient.service') - os.remove(cache_file) + if os.path.exists(cache_file): + os.remove(cache_file) call('systemctl start ddclient.service') -def main(): +if __name__ == '__main__': parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group() group.add_argument("--status", help="Show DDNS status", action="store_true") group.add_argument("--update", help="Update DDNS on a given interface", action="store_true") args = parser.parse_args() + # Do nothing if service is not configured + c = Config() + if not c.exists_effective('service dns dynamic'): + print("Dynamic DNS not configured") + sys.exit(1) + if args.status: show_status() elif args.update: update_ddns() - - -if __name__ == '__main__': - main() diff --git a/src/op_mode/show_acceleration.py b/src/op_mode/show_acceleration.py index 6d44b0f66..752db3deb 100755 --- a/src/op_mode/show_acceleration.py +++ b/src/op_mode/show_acceleration.py @@ -39,16 +39,16 @@ def show_qat_status(): detect_qat_dev() # Check QAT service - if not os.path.exists('/etc/init.d/vyos-qat-utilities'): + if not os.path.exists('/etc/init.d/qat_service'): print("\t QAT service not installed") sys.exit(1) # Show QAT service - call('sudo /etc/init.d/vyos-qat-utilities status') + call('sudo /etc/init.d/qat_service status') # Return QAT devices def get_qat_devices(): - data_st, err = popen('sudo /etc/init.d/vyos-qat-utilities status', decode='utf-8') + data_st, err = popen('sudo /etc/init.d/qat_service status', decode='utf-8') if not err: elm_lst = re.findall('qat_dev\d', data_st) print('\n'.join(elm_lst)) @@ -57,7 +57,7 @@ def get_qat_devices(): def get_qat_proc_path(qat_dev): q_type = "" q_bsf = "" - output, err = popen('sudo /etc/init.d/vyos-qat-utilities status', decode='utf-8') + output, err = popen('sudo /etc/init.d/qat_service status', decode='utf-8') if not err: # Parse QAT service output data_st = output.split("\n") diff --git a/src/op_mode/show_vpn_ra.py b/src/op_mode/show_vpn_ra.py index 2323193b1..73688c4ea 100755 --- a/src/op_mode/show_vpn_ra.py +++ b/src/op_mode/show_vpn_ra.py @@ -24,8 +24,8 @@ from vyos.util import popen def get_sessions(): absent_pptp = False absent_l2tp = False - pptp_cmd = ["accel-cmd", "-p 2003", "show sessions"] - l2tp_cmd = ["accel-cmd", "-p 2004", "show sessions"] + pptp_cmd = "accel-cmd -p 2003 show sessions" + l2tp_cmd = "accel-cmd -p 2004 show sessions" err_pattern = "^Connection.+failed$" # This value for chack only output header without sessions. len_def_header = 170 diff --git a/src/services/vyos-hostsd b/src/services/vyos-hostsd index 6017cea82..bf5d67cfa 100755 --- a/src/services/vyos-hostsd +++ b/src/services/vyos-hostsd @@ -28,6 +28,7 @@ import zmq import collections import jinja2 +from vyos.util import popen, process_named_running debug = True @@ -212,13 +213,17 @@ def handle_message(msg_json): op = get_option(msg, 'op') _type = get_option(msg, 'type') + changes = 0 + if op == 'delete': tag = get_option(msg, 'tag') if _type == 'name_servers': delete_name_servers(STATE, tag) + changes += 1 elif _type == 'hosts': delete_hosts(STATE, tag) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'add': @@ -226,8 +231,10 @@ def handle_message(msg_json): entries = get_option(msg, 'data') if _type == 'name_servers': add_name_servers(STATE, entries, tag) + changes += 1 elif _type == 'hosts': add_hosts(STATE, entries, tag) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'set': @@ -236,6 +243,7 @@ def handle_message(msg_json): data = get_option(msg, 'data') if _type == 'host_name': set_host_name(STATE, data) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'get': @@ -255,6 +263,12 @@ def handle_message(msg_json): with open(STATE_FILE, 'w') as f: json.dump(STATE, f) + if changes > 0: + if process_named_running("pdns_recursor"): + (ret,return_code) = popen("sudo rec_control --socket-dir=/run/powerdns reload-zones") + if return_code > 0: + logger.exception("PowerDNS rec_control failed to reload") + def exit_handler(sig, frame): """ Clean up the state when shutdown correctly """ logger.info("Cleaning up state") diff --git a/src/system/on-dhcp-event.sh b/src/system/on-dhcp-event.sh index 385ae460f..57f492401 100755 --- a/src/system/on-dhcp-event.sh +++ b/src/system/on-dhcp-event.sh @@ -20,7 +20,6 @@ client_ip=$3 client_mac=$4 domain=$5 file=/etc/hosts -changes=0 if [ -z "$client_name" ]; then logger -s -t on-dhcp-event "Client name was empty, using MAC \"$client_mac\" instead" @@ -44,13 +43,11 @@ case "$action" in fi # add host /usr/bin/vyos-hostsd-client --add-hosts --tag "DHCP-$client_ip" --host "$client_fqdn_name,$client_ip" - ((changes++)) ;; release) # delete mapping for released address # delete host /usr/bin/vyos-hostsd-client --delete-hosts --tag "DHCP-$client_ip" - ((changes++)) ;; *) @@ -59,15 +56,6 @@ case "$action" in ;; esac -if [ $changes -gt 0 ]; then - echo Success - pid=`pgrep pdns_recursor` - if [ -n "$pid" ]; then - sudo rec_control --socket-dir=/run/powerdns reload-zones - fi -else - echo No changes made -fi exit 0 diff --git a/src/validators/vrf-name b/src/validators/vrf-name index 878893c46..7b6313888 100755 --- a/src/validators/vrf-name +++ b/src/validators/vrf-name @@ -14,30 +14,28 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. - import re -import sys - +from sys import argv, exit if __name__ == '__main__': - if len(sys.argv) != 2: - sys.exit(1) + if len(argv) != 2: + exit(1) - vrf = sys.argv[1] + vrf = argv[1] length = len(vrf) - if length not in range(1, 17): - sys.exit('VRF instance name must be 16 characters or less') + if length not in range(1, 16): + exit(1) # Treat loopback interface "lo" explicitly. Adding "lo" explicitly to the # following regex pattern would deny any VRF name starting with lo - thuse # local-vrf would be illegal - and that we do not want. if vrf == "lo": - exit(f'"{vrf}" is invalid as VRF name as it is an interface name') + exit(1) pattern = "^(?!(bond|br|dum|eth|lan|eno|ens|enp|enx|gnv|ipoe|l2tp|l2tpeth|" \ "vtun|ppp|pppoe|peth|tun|vti|vxlan|wg|wlan|wlm)\d+(\.\d+(v.+)?)?$).*$" if not re.match(pattern, vrf): - sys.exit(f'"{vrf}" is invalid as VRF name as it is an interface name') + exit(1) - sys.exit(0) + exit(0) |