From d8d466bff36bbe2fb87cc7c1156ba307cb41a794 Mon Sep 17 00:00:00 2001
From: sever-sever <v.gletenko@vyos.io>
Date: Mon, 1 Feb 2021 17:28:11 +0000
Subject: vrf: T3278: Add XML for conf-mode

---
 Makefile                                   |   1 +
 interface-definitions/protocols-vrf.xml.in | 359 +++++++++++++++++++++++++++++
 2 files changed, 360 insertions(+)
 create mode 100644 interface-definitions/protocols-vrf.xml.in

diff --git a/Makefile b/Makefile
index 66b1e8bb7..19911fa58 100644
--- a/Makefile
+++ b/Makefile
@@ -47,6 +47,7 @@ interface_definitions: $(config_xml_obj)
 	rm -f $(TMPL_DIR)/vpn/node.def
 	rm -f $(TMPL_DIR)/vpn/ipsec/node.def
 	rm -rf $(TMPL_DIR)/vpn/nipsec
+	rm -rf $(TMPL_DIR)/protocols/nvrf
 
 	# XXX: required until OSPF and RIP is migrated from vyatta-cfg-quagga to vyos-1x
 	mkdir $(TMPL_DIR)/interfaces/loopback/node.tag/ipv6
diff --git a/interface-definitions/protocols-vrf.xml.in b/interface-definitions/protocols-vrf.xml.in
new file mode 100644
index 000000000..d58f85b02
--- /dev/null
+++ b/interface-definitions/protocols-vrf.xml.in
@@ -0,0 +1,359 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Protocol VRF configuration -->
+<interfaceDefinition>
+  <node name="protocols">
+    <children>
+       <tagNode name="nvrf" owner="${vyos_conf_scripts_dir}/vrf.py">
+        <properties>
+          <help>Name of VRF to add route for</help>
+          <valueHelp>
+            <format>txt</format>
+            <description>Name of VRF to add route for</description>
+          </valueHelp>
+          <completionHelp>
+            <path>protocols vrf</path>
+          </completionHelp>
+        </properties>
+        <children>
+          <node name="static">
+            <properties>
+              <help>Static route parameters</help>
+            </properties>
+            <children>
+              <tagNode name="interface-route">
+                <properties>
+                  <help>Interface based static route</help>
+                  <valueHelp>
+                    <format>ipv4net</format>
+                    <description>Interface based static route</description>
+                  </valueHelp>
+                  <constraint>
+                    <validator name="ipv4-prefix"/>
+                  </constraint>
+                </properties>
+                <children>
+                  <tagNode name="next-hop-interface">
+                    <properties>
+                      <help>Next-hop interface [REQUIRED]</help>
+                      <completionHelp>
+                        <script>${vyos_completion_dir}/list_interfaces.py</script>
+                      </completionHelp>
+                    </properties>
+                    <children>
+                      <leafNode name="disable">
+                        <properties>
+                          <help>Disable IPv4 interface static route</help>
+                          <valueless/>
+                        </properties>
+                      </leafNode>
+                      <leafNode name="distance">
+                        <properties>
+                          <help>Distance for this route</help>
+                          <valueHelp>
+                            <format>u32:1-255</format>
+                            <description>Distance for this route</description>
+                          </valueHelp>
+                          <constraint>
+                            <validator name="numeric" argument="--range 1-255"/>
+                          </constraint>
+                        </properties>
+                      </leafNode>
+                      <leafNode name="next-hop-vrf">
+                        <properties>
+                          <help>VRF to leak route</help>
+                          <valueHelp>
+                            <format>txt</format>
+                            <description>Name of VRF to leak to</description>
+                          </valueHelp>
+                          <valueHelp>
+                            <format>default</format>
+                            <description>Name of VRF to leak to</description>
+                          </valueHelp>
+                          <completionHelp>
+                            <list>default</list>
+                            <path>protocols vrf</path>
+                          </completionHelp>
+                          <constraint>
+                            <regex>^[a-zA-Z0-9\-_]{1,100}$</regex>
+                          </constraint>
+                        </properties>
+                      </leafNode>
+                    </children>
+                  </tagNode> 
+                </children>
+              </tagNode>
+              <tagNode name="interface-route6">
+                <properties>
+                  <help>Interface based IPv6 static route</help>
+                  <valueHelp>
+                    <format>ipv6net</format>
+                    <description>Interface based IPv6 static route</description>
+                  </valueHelp>
+                  <constraint>
+                    <validator name="ipv6-prefix"/>
+                  </constraint>
+                </properties>
+                <children>
+                  <tagNode name="next-hop-interface">
+                    <properties>
+                      <help>Next-hop interface [REQUIRED]</help>
+                      <completionHelp>
+                        <script>${vyos_completion_dir}/list_interfaces.py</script>
+                      </completionHelp>
+                    </properties>
+                    <children>
+                      <leafNode name="disable">
+                        <properties>
+                          <help>Disable IPv6 interface static route</help>
+                          <valueless/>
+                        </properties>
+                      </leafNode>
+                      <leafNode name="distance">
+                        <properties>
+                          <help>Distance for this route</help>
+                          <valueHelp>
+                            <format>u32:1-255</format>
+                            <description>Distance for this route</description>
+                          </valueHelp>
+                          <constraint>
+                            <validator name="numeric" argument="--range 1-255"/>
+                          </constraint>
+                        </properties>
+                      </leafNode>
+                      <leafNode name="next-hop-vrf">
+                        <properties>
+                          <help>VRF to leak route</help>
+                          <valueHelp>
+                            <format>txt</format>
+                            <description>Name of VRF to leak to</description>
+                          </valueHelp>
+                          <valueHelp>
+                            <format>default</format>
+                            <description>Name of VRF to leak to</description>
+                          </valueHelp>
+                          <completionHelp>
+                            <list>default</list>
+                            <path>protocols vrf</path>
+                          </completionHelp>
+                          <constraint>
+                            <regex>^[a-zA-Z0-9\-_]{1,100}$</regex>
+                          </constraint>
+                        </properties>
+                      </leafNode>
+                    </children>
+                  </tagNode> 
+                </children>
+              </tagNode>
+              <tagNode name="route">
+                <properties>
+                  <help>VRF static IPv4 route</help>
+                  <valueHelp>
+                    <format>ipv4net</format>
+                    <description>VRF static IPv4 route</description>
+                  </valueHelp>
+                  <constraint>
+                    <validator name="ipv4-prefix"/>
+                  </constraint>
+                </properties>
+                <children>
+                  <node name="blackhole">
+                    <properties>
+                      <help>Silently discard pkts when matched</help>
+                    </properties>
+                    <children>
+                      <leafNode name="distance">
+                        <properties>
+                          <help>Distance value for this route</help>
+                          <valueHelp>
+                            <format>u32:1-255</format>
+                            <description>Distance for this route</description>
+                          </valueHelp>
+                          <constraint>
+                            <validator name="numeric" argument="--range 1-255"/>
+                          </constraint>
+                        </properties>
+                      </leafNode>
+                    </children>
+                  </node>
+                  <leafNode name="dhcp-interface">
+                    <properties>
+                      <help>DHCP interface that supplies the next-hop IP address for this static route</help>
+                      <completionHelp>
+                        <script>${vyos_completion_dir}/list_interfaces.py</script>
+                      </completionHelp>
+                      <valueHelp>
+                        <format>txt</format>
+                        <description>DHCP interface</description>
+                      </valueHelp>
+                    </properties>
+                  </leafNode>
+                  <tagNode name="next-hop">
+                    <properties>
+                      <help>Next-hop router</help>
+                      <valueHelp>
+                        <format>ipv4</format>
+                        <description>Next-hop router</description>
+                      </valueHelp>
+                      <constraint>
+                        <validator name="ipv4-address"/>
+                      </constraint>
+                    </properties>
+                    <children>
+                      <leafNode name="disable">
+                        <properties>
+                          <help>Disable IPv4 interface static route</help>
+                          <valueless/>
+                        </properties>
+                      </leafNode>
+                      <leafNode name="distance">
+                        <properties>
+                          <help>Distance for this route</help>
+                          <valueHelp>
+                            <format>u32:1-255</format>
+                            <description>Distance for this route</description>
+                          </valueHelp>
+                          <constraint>
+                            <validator name="numeric" argument="--range 1-255"/>
+                          </constraint>
+                        </properties>
+                      </leafNode>
+                      <leafNode name="next-hop-interface">
+                        <properties>
+                          <help>IPv4 gateway interface name</help>
+                          <completionHelp>
+                            <script>${vyos_completion_dir}/list_interfaces.py</script>
+                          </completionHelp>
+                          <valueHelp>
+                            <format>txt</format>
+                            <description>IPv4 gateway interface name</description>
+                          </valueHelp>
+                        </properties>
+                      </leafNode>
+                      <leafNode name="next-hop-vrf">
+                        <properties>
+                          <help>VRF to leak route</help>
+                          <valueHelp>
+                            <format>txt</format>
+                            <description>Name of VRF to leak to</description>
+                          </valueHelp>
+                          <valueHelp>
+                            <format>default</format>
+                            <description>Name of VRF to leak to</description>
+                          </valueHelp>
+                          <completionHelp>
+                            <list>default</list>
+                            <path>protocols vrf</path>
+                          </completionHelp>
+                          <constraint>
+                            <regex>^[a-zA-Z0-9\-_]{1,100}$</regex>
+                          </constraint>
+                        </properties>
+                      </leafNode>
+                    </children>
+                  </tagNode>
+                </children>
+              </tagNode>
+              <tagNode name="route6">
+                <properties>
+                  <help>VRF static IPv6 route</help>
+                  <valueHelp>
+                    <format>ipv6net</format>
+                    <description>VRF static IPv6 route</description>
+                  </valueHelp>
+                  <constraint>
+                    <validator name="ipv6-prefix"/>
+                  </constraint>
+                </properties>
+                <children>
+                  <node name="blackhole">
+                    <properties>
+                      <help>Silently discard pkts when matched</help>
+                    </properties>
+                    <children>
+                      <leafNode name="distance">
+                        <properties>
+                          <help>Distance value for this route</help>
+                          <valueHelp>
+                            <format>u32:1-255</format>
+                            <description>Distance for this route</description>
+                          </valueHelp>
+                          <constraint>
+                            <validator name="numeric" argument="--range 1-255"/>
+                          </constraint>
+                        </properties>
+                      </leafNode>
+                    </children>
+                  </node>
+                  <tagNode name="next-hop">
+                    <properties>
+                      <help>Next-hop IPv6 router [REQUIRED]</help>
+                      <valueHelp>
+                        <format>ipv6</format>
+                        <description>Next-hop IPv6 router [REQUIRED]</description>
+                      </valueHelp>
+                      <constraint>
+                        <validator name="ipv6-address"/>
+                      </constraint>
+                    </properties>
+                    <children>
+                      <leafNode name="disable">
+                        <properties>
+                          <help>Disable IPv6 interface static route</help>
+                          <valueless/>
+                        </properties>
+                      </leafNode>
+                      <leafNode name="distance">
+                        <properties>
+                          <help>Distance for this route</help>
+                          <valueHelp>
+                            <format>u32:1-255</format>
+                            <description>Distance for this route</description>
+                          </valueHelp>
+                          <constraint>
+                            <validator name="numeric" argument="--range 1-255"/>
+                          </constraint>
+                        </properties>
+                      </leafNode>
+                      <leafNode name="interface">
+                        <properties>
+                          <help>IPv6 gateway interface name</help>
+                          <completionHelp>
+                            <script>${vyos_completion_dir}/list_interfaces.py</script>
+                          </completionHelp>
+                          <valueHelp>
+                            <format>txt</format>
+                            <description>IPv6 gateway interface name</description>
+                          </valueHelp>
+                        </properties>
+                      </leafNode>
+                      <leafNode name="next-hop-vrf">
+                        <properties>
+                          <help>VRF to leak route</help>
+                          <valueHelp>
+                            <format>txt</format>
+                            <description>Name of VRF to leak to</description>
+                          </valueHelp>
+                          <valueHelp>
+                            <format>default</format>
+                            <description>Name of VRF to leak to</description>
+                          </valueHelp>
+                          <completionHelp>
+                            <list>default</list>
+                            <path>protocols vrf</path>
+                          </completionHelp>
+                          <constraint>
+                            <regex>^[a-zA-Z0-9\-_]{1,100}$</regex>
+                          </constraint>
+                        </properties>
+                      </leafNode>
+                    </children>
+                  </tagNode>
+                </children>
+              </tagNode>
+            </children>
+          </node>
+        </children>
+      </tagNode>
+    </children>
+  </node>
+</interfaceDefinition>
-- 
cgit v1.2.3