Page MenuHomeDevCentral

D4009.diff
No OneTemporary

D4009.diff

diff --git a/_modules/node.py b/_modules/node.py
--- a/_modules/node.py
+++ b/_modules/node.py
@@ -517,14 +517,27 @@
for fhrp in interface.get("fhrp", []):
if fhrp["protocol"] == "carp":
+
+ vhid = fhrp.get("id")
+
+ # ignore invalid CARP entries
+ # when vhid or vip are empty in netbox,
+ # in the pillar configuration we'll see that entry carp fhrp = []
+ if vhid is None:
+ return []
+
# Salt will actually recreate a dictionary, so it won't respect the order
# even with OrderedDict
entry = OrderedDict()
entry["device"] = device
entry["interface_name"] = interface_name
- entry["vhid"] = fhrp["id"]
+ entry["vhid"] = vhid
entry["vip"] = fhrp["vip"]
- entry["advskew"] = fhrp.get("advskew", 0)
+ # peer is not always required, if we work in multicast, we won't have peer
+ peer = fhrp.get("peer")
+ if peer is not None:
+ entry["peer"] = peer
+ entry["advskew"] = fhrp["advskew"]
carp_entries.append(entry)
diff --git a/_tests/data/forests.yaml b/_tests/data/forests.yaml
--- a/_tests/data/forests.yaml
+++ b/_tests/data/forests.yaml
@@ -20,6 +20,7 @@
- protocol: carp
id: 1
vip: 1.2.3.10
+ peer: 1.2.3.5
advskew: 0
intranought:
device: net02
diff --git a/_tests/modules/test_node.py b/_tests/modules/test_node.py
--- a/_tests/modules/test_node.py
+++ b/_tests/modules/test_node.py
@@ -153,6 +153,7 @@
"interface_name": "public",
"vhid": 1,
"vip": "1.2.3.10",
+ "peer": "1.2.3.5",
"advskew": 0,
}
]

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 20, 00:51 (22 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3545780
Default Alt Text
D4009.diff (1 KB)

Event Timeline