From eedd04171ff3c6017e52830e8e07ec437e1c6663 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 25 Mar 2009 14:15:44 -0700 Subject: Generate interface templates as part of build Rather than 100's of copies of the same template, use the same process as the firewall module to generate the templates. For this, the are meta-templates in interface-templates directory which get processed and $IFNAME is replaced by the appropriate CLI syntax to refer back to the directory name. Changing a quagga template in most cases can be done by fixing the meta-template. --- interface-templates/ip/node.def | 1 + .../ip/ospf/authentication/md5/key-id/node.def | 16 ++++++++++++++++ .../md5/key-id/node.tag/md5-key/node.def | 9 +++++++++ .../ospf/authentication/md5/key-id/node.tag/node.def | 1 + .../ip/ospf/authentication/md5/node.def | 5 +++++ interface-templates/ip/ospf/authentication/node.def | 2 ++ .../ospf/authentication/plaintext-password/node.def | 10 ++++++++++ interface-templates/ip/ospf/bandwidth/node.def | 7 +++++++ interface-templates/ip/ospf/cost/node.def | 11 +++++++++++ interface-templates/ip/ospf/dead-interval/node.def | 8 ++++++++ interface-templates/ip/ospf/hello-interval/node.def | 8 ++++++++ interface-templates/ip/ospf/mtu-ignore/node.def | 3 +++ interface-templates/ip/ospf/network/node.def | 11 +++++++++++ interface-templates/ip/ospf/node.def | 2 ++ interface-templates/ip/ospf/priority/node.def | 8 ++++++++ .../ip/ospf/retransmit-interval/node.def | 10 ++++++++++ interface-templates/ip/ospf/transmit-delay/node.def | 8 ++++++++ .../ip/rip/authentication/md5/node.def | 8 ++++++++ .../ip/rip/authentication/md5/node.tag/node.def | 1 + .../rip/authentication/md5/node.tag/password/node.def | 19 +++++++++++++++++++ interface-templates/ip/rip/authentication/node.def | 1 + .../ip/rip/authentication/plaintext-password/node.def | 13 +++++++++++++ interface-templates/ip/rip/node.def | 2 ++ .../ip/rip/split-horizon/disable/node.def | 6 ++++++ interface-templates/ip/rip/split-horizon/node.def | 1 + .../ip/rip/split-horizon/poison-reverse/node.def | 9 +++++++++ 26 files changed, 180 insertions(+) create mode 100644 interface-templates/ip/node.def create mode 100644 interface-templates/ip/ospf/authentication/md5/key-id/node.def create mode 100644 interface-templates/ip/ospf/authentication/md5/key-id/node.tag/md5-key/node.def create mode 100644 interface-templates/ip/ospf/authentication/md5/key-id/node.tag/node.def create mode 100644 interface-templates/ip/ospf/authentication/md5/node.def create mode 100644 interface-templates/ip/ospf/authentication/node.def create mode 100644 interface-templates/ip/ospf/authentication/plaintext-password/node.def create mode 100644 interface-templates/ip/ospf/bandwidth/node.def create mode 100644 interface-templates/ip/ospf/cost/node.def create mode 100644 interface-templates/ip/ospf/dead-interval/node.def create mode 100644 interface-templates/ip/ospf/hello-interval/node.def create mode 100644 interface-templates/ip/ospf/mtu-ignore/node.def create mode 100644 interface-templates/ip/ospf/network/node.def create mode 100644 interface-templates/ip/ospf/node.def create mode 100644 interface-templates/ip/ospf/priority/node.def create mode 100644 interface-templates/ip/ospf/retransmit-interval/node.def create mode 100644 interface-templates/ip/ospf/transmit-delay/node.def create mode 100644 interface-templates/ip/rip/authentication/md5/node.def create mode 100644 interface-templates/ip/rip/authentication/md5/node.tag/node.def create mode 100644 interface-templates/ip/rip/authentication/md5/node.tag/password/node.def create mode 100644 interface-templates/ip/rip/authentication/node.def create mode 100644 interface-templates/ip/rip/authentication/plaintext-password/node.def create mode 100644 interface-templates/ip/rip/node.def create mode 100644 interface-templates/ip/rip/split-horizon/disable/node.def create mode 100644 interface-templates/ip/rip/split-horizon/node.def create mode 100644 interface-templates/ip/rip/split-horizon/poison-reverse/node.def (limited to 'interface-templates/ip') diff --git a/interface-templates/ip/node.def b/interface-templates/ip/node.def new file mode 100644 index 00000000..92e252e1 --- /dev/null +++ b/interface-templates/ip/node.def @@ -0,0 +1 @@ +help: Set IPv4 parameters for specified interface diff --git a/interface-templates/ip/ospf/authentication/md5/key-id/node.def b/interface-templates/ip/ospf/authentication/md5/key-id/node.def new file mode 100644 index 00000000..630bd3f0 --- /dev/null +++ b/interface-templates/ip/ospf/authentication/md5/key-id/node.def @@ -0,0 +1,16 @@ +tag: +type: u32 +help: Set MD5 key id +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 255; "ID must be between (1-255)" +commit:expression: $VAR(md5-key/) != ""; "Must add the md5-key for key-id $VAR(@)" +delete:touch /tmp/ospf-md5.$PPID + +end: if [ -f /tmp/ospf-md5.$PPID ] + then vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "no ip ospf message-digest-key $VAR(@)" + rm /tmp/ospf-md5.$PPID \ + else vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "ip ospf message-digest-key $VAR(@) md5 $VAR(md5-key/@)" + fi +comp_help: possible completions: + <1-255> Set the key id diff --git a/interface-templates/ip/ospf/authentication/md5/key-id/node.tag/md5-key/node.def b/interface-templates/ip/ospf/authentication/md5/key-id/node.tag/md5-key/node.def new file mode 100644 index 00000000..5efd3ef7 --- /dev/null +++ b/interface-templates/ip/ospf/authentication/md5/key-id/node.tag/md5-key/node.def @@ -0,0 +1,9 @@ +type: txt +help: Set md5 key +syntax:expression: exec " \ + if [ `echo -n '$VAR(@)' | wc -c` -gt 16 ]; then \ + echo MD5 key must be 16 characters or less ; \ + exit 1 ; \ + fi ; " +comp_help: possible completions: + MD5 Key (16 characters or less) diff --git a/interface-templates/ip/ospf/authentication/md5/key-id/node.tag/node.def b/interface-templates/ip/ospf/authentication/md5/key-id/node.tag/node.def new file mode 100644 index 00000000..d14a2583 --- /dev/null +++ b/interface-templates/ip/ospf/authentication/md5/key-id/node.tag/node.def @@ -0,0 +1 @@ +help: Set md5 key diff --git a/interface-templates/ip/ospf/authentication/md5/node.def b/interface-templates/ip/ospf/authentication/md5/node.def new file mode 100644 index 00000000..9389c838 --- /dev/null +++ b/interface-templates/ip/ospf/authentication/md5/node.def @@ -0,0 +1,5 @@ +help: Set MD5 key id +update:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "no ip ospf authentication" -c "ip ospf authentication message-digest" +delete:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" + -c "no ip ospf authentication" diff --git a/interface-templates/ip/ospf/authentication/node.def b/interface-templates/ip/ospf/authentication/node.def new file mode 100644 index 00000000..ff352a01 --- /dev/null +++ b/interface-templates/ip/ospf/authentication/node.def @@ -0,0 +1,2 @@ +help: Set OSPF interface authentication + diff --git a/interface-templates/ip/ospf/authentication/plaintext-password/node.def b/interface-templates/ip/ospf/authentication/plaintext-password/node.def new file mode 100644 index 00000000..4b31f0d8 --- /dev/null +++ b/interface-templates/ip/ospf/authentication/plaintext-password/node.def @@ -0,0 +1,10 @@ +type: txt +help: Configure plain text password +syntax:expression: pattern $VAR(@) "^[^[:space:]]{1,8}$" ; "Password must be 8 characters or less" +update:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "no ip ospf authentication " -c "ip ospf authentication " \ + -c "ip ospf authentication-key $VAR(@)" +delete:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "no ip ospf authentication " -c "no ip ospf authentication-key" +comp_help: possible completions: + Plain text password (8 characters or less) diff --git a/interface-templates/ip/ospf/bandwidth/node.def b/interface-templates/ip/ospf/bandwidth/node.def new file mode 100644 index 00000000..1f77079f --- /dev/null +++ b/interface-templates/ip/ospf/bandwidth/node.def @@ -0,0 +1,7 @@ +type: u32 +help: Set bandwidth for specified interface (kilobits/sec) +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 10000000; "Must be between 1-10000000" +update: vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "bandwidth $VAR(@)" +delete: vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "no bandwidth" +comp_help: possible completions: + <1-10000000> Set bandwidth in kilobits/sec (for calculating OSPF cost) diff --git a/interface-templates/ip/ospf/cost/node.def b/interface-templates/ip/ospf/cost/node.def new file mode 100644 index 00000000..da8b545e --- /dev/null +++ b/interface-templates/ip/ospf/cost/node.def @@ -0,0 +1,11 @@ +type: u32 +help: Set interface cost +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 65535; "Must be between 1-65535" +update:vyatta-vtysh -c "configure terminal" \ + -c "interface $IFNAME" \ + -c "ip ospf cost $VAR(@)" +delete:vyatta-vtysh -c "configure terminal" \ + -c "interface $IFNAME" \ + -c "no ip ospf cost" +comp_help: possible completions: + <1-65535> Set Cost diff --git a/interface-templates/ip/ospf/dead-interval/node.def b/interface-templates/ip/ospf/dead-interval/node.def new file mode 100644 index 00000000..72988f9c --- /dev/null +++ b/interface-templates/ip/ospf/dead-interval/node.def @@ -0,0 +1,8 @@ +type: u32 +help: Set interval after which a neighbor is declared dead +default: 40 +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 65535; "Must be between 1-65535" +update:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "ip ospf dead-interval $VAR(@)" +delete:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "no ip ospf dead-interval "; " +comp_help: possible completions: + <1-65535> Seconds (default 40) diff --git a/interface-templates/ip/ospf/hello-interval/node.def b/interface-templates/ip/ospf/hello-interval/node.def new file mode 100644 index 00000000..9da68fb1 --- /dev/null +++ b/interface-templates/ip/ospf/hello-interval/node.def @@ -0,0 +1,8 @@ +type: u32 +help: Set interval between hello packets +default: 10 +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 65535; "Must be between 1-65535" +update:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "ip ospf hello-interval $VAR(@)" +delete:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "no ip ospf hello-interval" +comp_help: possible completions: + <1-65535> Seconds (default 10) diff --git a/interface-templates/ip/ospf/mtu-ignore/node.def b/interface-templates/ip/ospf/mtu-ignore/node.def new file mode 100644 index 00000000..e2c897e7 --- /dev/null +++ b/interface-templates/ip/ospf/mtu-ignore/node.def @@ -0,0 +1,3 @@ +help: Disable Maximum Transmission Unit (MTU) mismatch detection +create:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "ip ospf mtu-ignore" +delete:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "no ip ospf mtu-ignore" diff --git a/interface-templates/ip/ospf/network/node.def b/interface-templates/ip/ospf/network/node.def new file mode 100644 index 00000000..bac9d333 --- /dev/null +++ b/interface-templates/ip/ospf/network/node.def @@ -0,0 +1,11 @@ +type: txt +help: Set network type +syntax:expression: $VAR(@) in "broadcast", "non-broadcast", "point-to-multipoint", "point-to-point"; \ + "Must be (broadcast|non-broadcast|point-to-multipoint|point-to-point)" +update:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "ip ospf network $VAR(@)" +delete:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "no ip ospf network" +comp_help: possible completions: + broadcast Set broadcast network type + non-broadcast Set non-broadcast network type + point-to-multipoint Set point-to-multipoint network type + point-to-point Set point-to-point network type diff --git a/interface-templates/ip/ospf/node.def b/interface-templates/ip/ospf/node.def new file mode 100644 index 00000000..31980774 --- /dev/null +++ b/interface-templates/ip/ospf/node.def @@ -0,0 +1,2 @@ +help: Set Open Shortest Path First (OSPF) parameters for specified interface +create: sudo /opt/vyatta/sbin/quagga-manager check ospfd diff --git a/interface-templates/ip/ospf/priority/node.def b/interface-templates/ip/ospf/priority/node.def new file mode 100644 index 00000000..152cff9a --- /dev/null +++ b/interface-templates/ip/ospf/priority/node.def @@ -0,0 +1,8 @@ +type: u32 +help: Set router priority +default: 1 +syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 255; "Must be between 0-255" +update:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "ip ospf priority $VAR(@)" +delete:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "no ip ospf priority " +comp_help: possible completions: + <0-255> Priority (default 1) diff --git a/interface-templates/ip/ospf/retransmit-interval/node.def b/interface-templates/ip/ospf/retransmit-interval/node.def new file mode 100644 index 00000000..41dbe810 --- /dev/null +++ b/interface-templates/ip/ospf/retransmit-interval/node.def @@ -0,0 +1,10 @@ +type: u32 +help: Set interval between retransmitting lost link state advertisements +default: 5 +syntax:expression: $VAR(@) >= 3 && $VAR(@) <= 65535; "Must be between 3-65535" +update: vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "ip ospf retransmit-interval $VAR(@)" +delete: vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "no ip ospf retransmit-interval" +comp_help: possible completions: + <3-65535> Seconds (default 5) diff --git a/interface-templates/ip/ospf/transmit-delay/node.def b/interface-templates/ip/ospf/transmit-delay/node.def new file mode 100644 index 00000000..761424da --- /dev/null +++ b/interface-templates/ip/ospf/transmit-delay/node.def @@ -0,0 +1,8 @@ +type: u32 +help: Set link state transmit delay +default: 1 +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 65535; "Must be between 1-65535" +update:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "ip ospf transmit-delay $VAR(@)" +delete:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "no ip ospf transmit-delay" +comp_help: possible completions: + <1-65535> Seconds (default 1) diff --git a/interface-templates/ip/rip/authentication/md5/node.def b/interface-templates/ip/rip/authentication/md5/node.def new file mode 100644 index 00000000..8d165fe6 --- /dev/null +++ b/interface-templates/ip/rip/authentication/md5/node.def @@ -0,0 +1,8 @@ +tag: +type: u32 +help: Set MD5 authentication key ID +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 255; \ + "ID must be between 1 and 255" + +commit:expression: $VAR(../plaintext-password/) == "" ; \ + "plaintext-password already set" diff --git a/interface-templates/ip/rip/authentication/md5/node.tag/node.def b/interface-templates/ip/rip/authentication/md5/node.tag/node.def new file mode 100644 index 00000000..488acd8c --- /dev/null +++ b/interface-templates/ip/rip/authentication/md5/node.tag/node.def @@ -0,0 +1 @@ +help: Set authentication password diff --git a/interface-templates/ip/rip/authentication/md5/node.tag/password/node.def b/interface-templates/ip/rip/authentication/md5/node.tag/password/node.def new file mode 100644 index 00000000..1d675b0b --- /dev/null +++ b/interface-templates/ip/rip/authentication/md5/node.tag/password/node.def @@ -0,0 +1,19 @@ +type: txt +help: Set authentication password +syntax:expression: pattern $VAR(@) "^[^[:space:]]{1,16}" ; "MD5 key must be 16 characters or less" + +update:vyatta-vtysh \ + -c "configure terminal" -c "interface $IFNAME" \ + -c "ip rip authentication mode md5" \ + -c "ip rip authentication key-chain $IFNAME-rip" \ + -c "key chain $IFNAME-rip" -c "key $VAR(../@)" \ + -c "key-string $VAR(@)" + +delete:vyatta-vtysh --noerror \ + -c "configure terminal" -c "interface $IFNAME" \ + -c "no ip rip authentication mode md5" \ + -c "no ip rip authentication key-chain $IFNAME-rip" \ + -c "no key chain $IFNAME-rip" " + +comp_help: possible completions: + MD5 Key (16 characters or less) diff --git a/interface-templates/ip/rip/authentication/node.def b/interface-templates/ip/rip/authentication/node.def new file mode 100644 index 00000000..8756de35 --- /dev/null +++ b/interface-templates/ip/rip/authentication/node.def @@ -0,0 +1 @@ +help: Set authentication method diff --git a/interface-templates/ip/rip/authentication/plaintext-password/node.def b/interface-templates/ip/rip/authentication/plaintext-password/node.def new file mode 100644 index 00000000..f4fefb78 --- /dev/null +++ b/interface-templates/ip/rip/authentication/plaintext-password/node.def @@ -0,0 +1,13 @@ +type: txt +help: Set plain text password +syntax:expression: pattern $VAR(@) "^[^[:space:]{1,16}$" ; "Password must be 16 characters or less" +commit:expression: $VAR(../md5/) == "" ; "md5 password already set" + +update: vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "ip rip authentication mode text" -c "ip rip authentication string $VAR(@)"; + +delete: vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "no ip rip authentication mode" -c "no ip rip authentication string $VAR(@)"; + +comp_help: possible completions: + Password (16 characters or less) diff --git a/interface-templates/ip/rip/node.def b/interface-templates/ip/rip/node.def new file mode 100644 index 00000000..b01a779f --- /dev/null +++ b/interface-templates/ip/rip/node.def @@ -0,0 +1,2 @@ +help: Set Routing Information Protocol (RIP) for specified interface +create: sudo /opt/vyatta/sbin/quagga-manager check ripd diff --git a/interface-templates/ip/rip/split-horizon/disable/node.def b/interface-templates/ip/rip/split-horizon/disable/node.def new file mode 100644 index 00000000..10c57ba4 --- /dev/null +++ b/interface-templates/ip/rip/split-horizon/disable/node.def @@ -0,0 +1,6 @@ +help: Disable split horizon on specified interface +create:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "no ip rip split-horizon " +delete:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" -c "ip rip split-horizon " " + +commit:expression: ($VAR(../poison-reverse/) == ""); \ + "You cannot have 'split-horizon poison-reverse' enabled with 'split-horizon' disabled for $IFNAME" diff --git a/interface-templates/ip/rip/split-horizon/node.def b/interface-templates/ip/rip/split-horizon/node.def new file mode 100644 index 00000000..ba39b616 --- /dev/null +++ b/interface-templates/ip/rip/split-horizon/node.def @@ -0,0 +1 @@ +help: Set to control split horizon parameters on this interface diff --git a/interface-templates/ip/rip/split-horizon/poison-reverse/node.def b/interface-templates/ip/rip/split-horizon/poison-reverse/node.def new file mode 100644 index 00000000..07cb8944 --- /dev/null +++ b/interface-templates/ip/rip/split-horizon/poison-reverse/node.def @@ -0,0 +1,9 @@ +help: Enable poison reverse for split-horizon +create:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "ip rip split-horizon poisoned-reverse" + +delete:vyatta-vtysh -c "configure terminal" -c "interface $IFNAME" \ + -c "no ip rip split-horizon" -c "ip rip split-horizon " + +commit:expression: ($VAR(../disable/) == ""); \ + "You cannot have 'split-horizon poison-reverse' enabled with 'split-horizon' disabled for $IFNAME" -- cgit v1.2.3