Skip to content

Commit 193a961

Browse files
authored
Update rules with dm change for backward compatibility (#650)
* update rules with dm change * remove external type from vxlan vrf and network check * remove epdb * fix lint errors
1 parent bd8c085 commit 193a961

File tree

2 files changed

+66
-39
lines changed

2 files changed

+66
-39
lines changed

roles/validate/files/rules/common_vxlan/402_overlay_vrfs.py

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,45 @@ def match(cls, data_model):
1010
fabric_trm_status = False
1111
vrfs = []
1212

13-
if data_model.get("vxlan", None):
14-
if data_model["vxlan"].get("global", None):
15-
if data_model["vxlan"].get("global").get("netflow", None):
16-
fabric_netflow_status = data_model["vxlan"]["global"]["netflow"].get("enable", False)
17-
18-
if data_model["vxlan"].get("underlay", None):
19-
if data_model["vxlan"].get("underlay").get("multicast", None):
20-
if data_model["vxlan"].get("underlay").get("multicast").get("ipv4", None):
21-
fabric_trm_status = data_model["vxlan"]["underlay"]["multicast"]["ipv4"].get("trm_enable", False)
22-
23-
vrf_keys = ['vxlan', 'overlay', 'vrfs']
13+
# Map fabric types to the keys used in the data model based on controller fabric types
14+
fabric_type_map = {
15+
"VXLAN_EVPN": "ibgp",
16+
"eBGP_VXLAN": "ebgp",
17+
}
18+
19+
fabric_type = fabric_type_map.get(data_model['vxlan']['fabric']['type'])
20+
21+
netflow_keys = ['vxlan', 'global', fabric_type]
22+
check = cls.data_model_key_check(data_model, netflow_keys)
23+
if fabric_type in check['keys_found']:
24+
netflow_keys = ['vxlan', 'global', fabric_type, 'netflow', 'enable']
25+
check = cls.data_model_key_check(data_model, netflow_keys)
26+
27+
if fabric_type in check['keys_not_found'] or 'enable' in check['keys_not_found']:
28+
netflow_keys = ['vxlan', 'global', 'netflow', 'enable']
29+
check = cls.data_model_key_check(data_model, netflow_keys)
30+
31+
if 'enable' in check['keys_found']:
32+
fabric_netflow_status = cls.safeget(data_model, netflow_keys)
33+
if fabric_netflow_status is None:
34+
fabric_netflow_status = False
35+
36+
underlay_trm_keys = ['vxlan', 'underlay', 'multicast', 'ipv4', 'trm_enable']
37+
check = cls.data_model_key_check(data_model, underlay_trm_keys)
38+
if 'trm_enable' in check['keys_found']:
39+
# Cannot use safeget yet without updating code check below as it looks for False vs None
40+
# fabric_trm_status = cls.safeget(data_model, trm_keys)
41+
fabric_trm_status = data_model["vxlan"]["underlay"]["multicast"]["ipv4"].get("trm_enable", False)
42+
43+
vrf_keys = ['vxlan', 'overlay', 'vrfs']
44+
check = cls.data_model_key_check(data_model, vrf_keys)
45+
if 'vrfs' in check['keys_data']:
46+
vrfs = data_model["vxlan"]["overlay"]["vrfs"]
47+
else:
48+
vrf_keys = ['vxlan', 'overlay_services', 'vrfs']
2449
check = cls.data_model_key_check(data_model, vrf_keys)
2550
if 'vrfs' in check['keys_data']:
26-
vrfs = data_model["vxlan"]["overlay"]["vrfs"]
27-
else:
28-
vrf_keys = ['vxlan', 'overlay_services', 'vrfs']
29-
check = cls.data_model_key_check(data_model, vrf_keys)
30-
if 'vrfs' in check['keys_data']:
31-
vrfs = data_model["vxlan"]["overlay_services"]["vrfs"]
51+
vrfs = data_model["vxlan"]["overlay_services"]["vrfs"]
3252

3353
for vrf in vrfs:
3454
current_vrf_netflow_status = vrf.get("netflow_enable", None)

roles/validate/files/rules/common_vxlan/403_overlay_networks.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,35 @@ def match(cls, data_model):
1010
fabric_trm_status = False
1111
networks = []
1212

13-
if data_model.get("vxlan", None):
14-
if data_model["vxlan"].get("global", None):
15-
if data_model["vxlan"].get("global").get("netflow", None):
16-
fabric_netflow_status = data_model["vxlan"]["global"]["netflow"].get("enable", False)
17-
18-
# Uncomment 19-22 when verified to work and remove line 13-16.
19-
# netflow_keys = ['vxlan', 'global', 'netflow', 'enable']
20-
# check = cls.data_model_key_check(data_model, netflow_keys)
21-
# if 'enable' in check['keys_data']:
22-
# fabric_netflow_status = cls.safeget(data_model, netflow_keys)
23-
24-
if data_model.get("vxlan", None):
25-
if data_model["vxlan"].get("underlay", None):
26-
if data_model["vxlan"].get("underlay").get("multicast", None):
27-
if data_model["vxlan"].get("underlay").get("multicast").get("ipv4", None):
28-
fabric_trm_status = data_model["vxlan"]["underlay"]["multicast"]["ipv4"].get("trm_enable", False)
29-
30-
# Uncomment 31-34 when verified to work and remove line 25-28.
31-
# trm_keys = ['vxlan', 'underlay', 'multicast', 'trm_enabled']
32-
# check = cls.data_model_key_check(data_model, trm_keys)
33-
# if 'trm_enable' in check['keys_data']:
34-
# fabric_trm_status = cls.safeget(data_model, trm_keys)
13+
# Map fabric types to the keys used in the data model based on controller fabric types
14+
fabric_type_map = {
15+
"VXLAN_EVPN": "ibgp",
16+
"eBGP_VXLAN": "ebgp",
17+
}
18+
19+
fabric_type = fabric_type_map.get(data_model['vxlan']['fabric']['type'])
20+
21+
netflow_keys = ['vxlan', 'global', fabric_type]
22+
check = cls.data_model_key_check(data_model, netflow_keys)
23+
if fabric_type in check['keys_found']:
24+
netflow_keys = ['vxlan', 'global', fabric_type, 'netflow', 'enable']
25+
check = cls.data_model_key_check(data_model, netflow_keys)
26+
27+
if fabric_type in check['keys_not_found'] or 'enable' in check['keys_not_found']:
28+
netflow_keys = ['vxlan', 'global', 'netflow', 'enable']
29+
check = cls.data_model_key_check(data_model, netflow_keys)
30+
31+
if 'enable' in check['keys_found']:
32+
fabric_netflow_status = cls.safeget(data_model, netflow_keys)
33+
if fabric_netflow_status is None:
34+
fabric_netflow_status = False
35+
36+
underlay_trm_keys = ['vxlan', 'underlay', 'multicast', 'ipv4', 'trm_enable']
37+
check = cls.data_model_key_check(data_model, underlay_trm_keys)
38+
if 'trm_enable' in check['keys_found']:
39+
# Cannot use safeget yet without updating code check below as it looks for False vs None
40+
# fabric_trm_status = cls.safeget(data_model, trm_keys)
41+
fabric_trm_status = data_model["vxlan"]["underlay"]["multicast"]["ipv4"].get("trm_enable", False)
3542

3643
network_keys = ['vxlan', 'overlay', 'networks']
3744
check = cls.data_model_key_check(data_model, network_keys)

0 commit comments

Comments
 (0)