File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -118,10 +118,35 @@ def validate_config_db_config(self, config_db_as_json):
118
118
sy .loadData (tmp_config_db_as_json )
119
119
120
120
sy .validate_data_tree ()
121
- return True
121
+
122
+ # TODO: modularize custom validations better
123
+ return self .validate_bgp_peer_group (config_db_as_json )
122
124
except sonic_yang .SonicYangException as ex :
123
125
return False
124
126
127
+ # TODO: unit-test
128
+ def validate_bgp_peer_group (self , config_db ):
129
+ if "BGP_PEER_RANGE" not in config_db :
130
+ return True
131
+
132
+ visited = {}
133
+ table = config_db ["BGP_PEER_RANGE" ]
134
+ for peer_group_name in table :
135
+ peer_group = table [peer_group_name ]
136
+ if "ip_range" not in peer_group :
137
+ continue
138
+
139
+ # TODO: convert string IpAddress object for better handling of IPs
140
+ # TODO: does validation only fails if exact match of IP, or if there is an intersection?
141
+ ip_range = peer_group ["ip_range" ]
142
+ for ip in ip_range :
143
+ if ip in visited :
144
+ # TODO: Return also error once https://github.com/Azure/sonic-utilities/pull/1991 lands in prod
145
+ return False #, f"{ip} is duplicated in BGP_PEER_RANGE: {set([peer_group_name, visited[ip]])}"
146
+ visited [ip ] = peer_group_name
147
+
148
+ return True #, None
149
+
125
150
def crop_tables_without_yang (self , config_db_as_json ):
126
151
sy = self .create_sonic_yang_with_loaded_models ()
127
152
You can’t perform that action at this time.
0 commit comments