From 5dbd2e36550043a15ed34108d1537e545ecdb4ae Mon Sep 17 00:00:00 2001
From: sever-sever <v.gletenko@vyos.io>
Date: Tue, 29 Sep 2020 10:35:31 +0000
Subject: vrrp: T2933: Add option virtual-address-excluded

---
 data/templates/vrrp/keepalived.conf.tmpl |  8 ++++++++
 interface-definitions/vrrp.xml.in        | 19 +++++++++++++++++++
 src/conf_mode/vrrp.py                    |  1 +
 3 files changed, 28 insertions(+)

diff --git a/data/templates/vrrp/keepalived.conf.tmpl b/data/templates/vrrp/keepalived.conf.tmpl
index 08b821f70..210621681 100644
--- a/data/templates/vrrp/keepalived.conf.tmpl
+++ b/data/templates/vrrp/keepalived.conf.tmpl
@@ -70,6 +70,14 @@ vrrp_instance {{ group.name }} {
     {% endfor -%}
     }
 
+    {% if group.virtual_addresses_excluded -%}
+    virtual_ipaddress_excluded {
+    {% for addr in group.virtual_addresses_excluded -%}
+        {{ addr }}
+    {% endfor -%}
+    }
+    {% endif -%}
+
     {% if group.health_check_script -%}
     track_script {
         healthcheck_{{ group.name }}
diff --git a/interface-definitions/vrrp.xml.in b/interface-definitions/vrrp.xml.in
index 120c7d218..ec0a71a95 100644
--- a/interface-definitions/vrrp.xml.in
+++ b/interface-definitions/vrrp.xml.in
@@ -222,6 +222,25 @@
                   </valueHelp>
                 </properties>
               </leafNode>
+              <leafNode name="virtual-address-excluded">
+                <properties>
+                  <help>Virtual address (If you need additional IPv4 and IPv6 in same group)</help>
+                  <valueHelp>
+                    <format>ipv4</format>
+                    <description>IP address</description>
+                  </valueHelp>
+                  <valueHelp>
+                    <format>ipv6</format>
+                    <description>IPv6 address</description>
+                  </valueHelp>
+                  <multi/>
+                  <constraint>
+                    <validator name="ipv4-host"/>
+                    <validator name="ipv6-host"/>
+                  </constraint>
+                  <constraintErrorMessage>Virtual address must be a valid IPv4 or IPv6 address with prefix length (e.g. 192.0.2.3/24 or 2001:db8:ff::10/64)</constraintErrorMessage>
+                </properties>
+              </leafNode>
               <leafNode name="vrid">
                 <properties>
                   <help>Virtual router identifier</help>
diff --git a/src/conf_mode/vrrp.py b/src/conf_mode/vrrp.py
index f1ceb261b..4510dd3e7 100755
--- a/src/conf_mode/vrrp.py
+++ b/src/conf_mode/vrrp.py
@@ -62,6 +62,7 @@ def get_config(config=None):
         group["sync_group"] = config.return_value("sync-group")
         group["preempt_delay"] = config.return_value("preempt-delay")
         group["virtual_addresses"] = config.return_values("virtual-address")
+        group["virtual_addresses_excluded"] = config.return_values("virtual-address-excluded")
 
         group["auth_password"] = config.return_value("authentication password")
         group["auth_type"] = config.return_value("authentication type")
-- 
cgit v1.2.3