@@ -126,13 +126,13 @@ def check_version_for_bmp(self):
126
126
output_version = device_info .get_sonic_version_info ()
127
127
build_version = output_version ['build_version' ]
128
128
129
- if re .match (r'^(\d{8 })' , build_version ):
130
- version_number = int (re .findall (r'\d{8 }' , build_version )[0 ])
131
- if version_number < 20241130 :
129
+ if re .match (r'^(\d{6 })' , build_version ):
130
+ version_number = int (re .findall (r'\d{6 }' , build_version )[0 ])
131
+ if version_number < 202411 :
132
132
return False
133
- elif re .match (r'^internal-(\d{8 })' , build_version ):
134
- internal_version_number = int (re .findall (r'\d{8 }' , build_version )[0 ])
135
- if internal_version_number < 20241130 :
133
+ elif re .match (r'^internal-(\d{6 })' , build_version ):
134
+ internal_version_number = int (re .findall (r'\d{6 }' , build_version )[0 ])
135
+ if internal_version_number < 202411 :
136
136
return False
137
137
else :
138
138
return True
@@ -144,11 +144,21 @@ def get_config_from_minigraph(self):
144
144
self .module .fail_json (msg = "Failed to get config from minigraph: {}" .format (err ))
145
145
return out
146
146
147
- def get_multiasic_feature_config (self , feature_key ):
147
+ def get_multiasic_feature_config (self ):
148
148
rc , out , err = self .module .run_command ("show runningconfiguration all" )
149
149
if rc != 0 :
150
150
self .module .fail_json (msg = "Failed to get config from runningconfiguration: {}" .format (err ))
151
- running_config_db = json .loads (out )
151
+
152
+ return out
153
+
154
+ def overwrite_feature_golden_config_db_multiasic (self , config , feature_key ):
155
+ full_config = json .loads (config )
156
+ if config == "{}" or "FEATURE" not in config ["localhost" ]:
157
+ # need dump running config FEATURE + selected feature
158
+ gold_config_db = json .loads (self .get_multiasic_feature_config ())
159
+ else :
160
+ # need existing config + selected feature
161
+ gold_config_db = full_config
152
162
153
163
feature_data = {
154
164
feature_key : {
@@ -163,53 +173,11 @@ def get_multiasic_feature_config(self, feature_key):
163
173
"support_syslog_rate_limit" : "false"
164
174
}
165
175
}
166
-
167
- features_data = {}
168
- for key , value in running_config_db .items ():
169
- if "FEATURE" in value :
170
- updated_feature = value ["FEATURE" ]
171
- updated_feature .update (feature_data )
172
- features_data [key ] = {"FEATURE" : updated_feature }
173
-
174
- return json .dumps (features_data , indent = 4 )
175
-
176
- def overwrite_feature_golden_config_db_multiasic (self , config , feature_key ):
177
- full_config = config
178
- onlyFeature = config == "{}" # FEATURE needs special handling since it does not support incremental update.
179
- if config == "{}" : # FEATURE needs special handling since it does not support incremental update.
180
- full_config = self .get_multiasic_feature_config (feature_key )
181
-
182
- ori_config_db = json .loads (full_config )
183
- if "FEATURE" not in ori_config_db : # need dump running config FEATURE + selected feature
184
- feature_data = json .loads (self .get_multiasic_feature_config (feature_key ))
185
- ori_config_db_with_feature = {}
186
- for key , value in ori_config_db .items ():
187
- ori_config_db_with_feature = value .get ("FEATURE" , {})
188
- ori_config_db_with_feature .update (feature_data )
189
- value ["FEATURE" ] = ori_config_db_with_feature
190
- ori_config_db_with_feature [key ] = value
191
- gold_config_db = ori_config_db_with_feature
192
- else : # need existing config + selected feature
193
- if not onlyFeature :
194
- feature_data = {
195
- feature_key : {
196
- "auto_restart" : "enabled" ,
197
- "check_up_status" : "false" ,
198
- "delayed" : "False" ,
199
- "has_global_scope" : "False" ,
200
- "has_per_asic_scope" : "True" ,
201
- "high_mem_alert" : "disabled" ,
202
- "set_owner" : "local" ,
203
- "state" : "enabled" ,
204
- "support_syslog_rate_limit" : "false"
205
- }
206
- }
207
- for section , section_data in ori_config_db .items ():
208
- if "FEATURE" in section_data :
209
- feature_section = section_data ["FEATURE" ]
210
- feature_section .update (feature_data )
211
- section_data ["FEATURE" ] = feature_section
212
- gold_config_db = ori_config_db
176
+ for namespace , ns_data in gold_config_db .items ():
177
+ if "FEATURE" in ns_data :
178
+ feature_section = ns_data ["FEATURE" ]
179
+ feature_section .update (feature_data )
180
+ ns_data ["FEATURE" ] = feature_section
213
181
214
182
return json .dumps (gold_config_db , indent = 4 )
215
183
0 commit comments