@@ -77,7 +77,7 @@ class Feature(object):
77
77
self .state = self ._get_feature_table_key_render_value (feature_cfg .get ('state' ), device_config or {}, ['enabled' , 'disabled' , 'always_enabled' , 'always_disabled' ])
78
78
self .auto_restart = feature_cfg .get ('auto_restart' , 'disabled' )
79
79
self .delayed = safe_eval (feature_cfg .get ('delayed' , 'False' ))
80
- self .has_global_scope = safe_eval (feature_cfg .get ('has_global_scope' , 'True' ))
80
+ self .has_global_scope = safe_eval (self . _get_feature_table_key_render_value ( feature_cfg .get ('has_global_scope' , 'True' ), device_config or {}, [ 'True' , 'False' ] ))
81
81
self .has_per_asic_scope = safe_eval (self ._get_feature_table_key_render_value (feature_cfg .get ('has_per_asic_scope' , 'False' ), device_config or {}, ['True' , 'False' ]))
82
82
self .has_per_dpu_scope = safe_eval (feature_cfg .get ('has_per_dpu_scope' , 'False' ))
83
83
@@ -198,7 +198,7 @@ class FeatureHandler(object):
198
198
# Enable/disable the container service if the feature state was changed from its previous state.
199
199
if self ._cached_config [feature_name ].state != feature .state :
200
200
if self .update_feature_state (feature ):
201
- self .sync_feature_asic_scope (feature )
201
+ self .sync_feature_scope (feature )
202
202
self ._cached_config [feature_name ] = feature
203
203
else :
204
204
self .resync_feature_state (self ._cached_config [feature_name ])
@@ -222,7 +222,7 @@ class FeatureHandler(object):
222
222
self ._cached_config .setdefault (feature_name , feature )
223
223
self .update_systemd_config (feature )
224
224
self .update_feature_state (feature )
225
- self .sync_feature_asic_scope (feature )
225
+ self .sync_feature_scope (feature )
226
226
self .resync_feature_state (feature )
227
227
228
228
def update_feature_state (self , feature ):
@@ -270,10 +270,10 @@ class FeatureHandler(object):
270
270
271
271
return True
272
272
273
- def sync_feature_asic_scope (self , feature_config ):
274
- """Updates the has_per_asic_scope field in the FEATURE|* tables as the field
273
+ def sync_feature_scope (self , feature_config ):
274
+ """Updates the has_global_scope or has_per_asic_scope field in the FEATURE|* tables as the field
275
275
might have to be rendered based on DEVICE_METADATA table or Device Running configuration.
276
- Disable the ASIC instance service unit file it the render value is False and update config
276
+ Disable the Global/ ASIC instance service unit file it the render value is False and update config
277
277
278
278
Args:
279
279
feature: An object represents a feature's configuration in `FEATURE`
@@ -284,12 +284,11 @@ class FeatureHandler(object):
284
284
"""
285
285
feature_names , feature_suffixes = self .get_multiasic_feature_instances (feature_config , True )
286
286
for feature_name in feature_names :
287
- if '@' not in feature_name :
288
- continue
289
287
unit_file_state = self .get_systemd_unit_state ("{}.{}" .format (feature_name , feature_suffixes [- 1 ]))
290
288
if not unit_file_state :
291
289
continue
292
- if unit_file_state != "disabled" and not feature_config .has_per_asic_scope :
290
+ if unit_file_state != "disabled" and \
291
+ ((not feature_config .has_per_asic_scope and '@' in feature_name ) or (not feature_config .has_global_scope and '@' not in feature_name )):
293
292
cmds = []
294
293
for suffix in reversed (feature_suffixes ):
295
294
cmds .append (["sudo" , "systemctl" , "stop" , "{}.{}" .format (feature_name , suffix )])
@@ -305,10 +304,12 @@ class FeatureHandler(object):
305
304
self .set_feature_state (feature_config , self .FEATURE_STATE_FAILED )
306
305
return
307
306
self ._config_db .mod_entry (FEATURE_TBL , feature_config .name , {'has_per_asic_scope' : str (feature_config .has_per_asic_scope )})
307
+ self ._config_db .mod_entry (FEATURE_TBL , feature_config .name , {'has_global_scope' : str (feature_config .has_global_scope )})
308
308
309
309
# sync has_per_asic_scope to CONFIG_DB in namespaces in multi-asic platform
310
310
for ns , db in self .ns_cfg_db .items ():
311
311
db .mod_entry (FEATURE_TBL , feature_config .name , {'has_per_asic_scope' : str (feature_config .has_per_asic_scope )})
312
+ db .mod_entry (FEATURE_TBL , feature_config .name , {'has_global_scope' : str (feature_config .has_global_scope )})
312
313
313
314
def update_systemd_config (self , feature_config ):
314
315
"""Updates `Restart=` field in feature's systemd configuration file
@@ -364,7 +365,7 @@ class FeatureHandler(object):
364
365
def get_multiasic_feature_instances (self , feature , all_instance = False ):
365
366
# Create feature name suffix depending feature is running in host or namespace or in both
366
367
feature_names = (
367
- ([feature .name ] if feature .has_global_scope or not self .is_multi_npu else []) +
368
+ ([feature .name ] if feature .has_global_scope or all_instance or not self .is_multi_npu else []) +
368
369
([(feature .name + '@' + str (asic_inst )) for asic_inst in range (device_info .get_num_npus ())
369
370
if self .is_multi_npu and (all_instance or feature .has_per_asic_scope )]) +
370
371
([(feature .name + '@' + device_info .DPU_NAME_PREFIX + str (dpu_inst )) for dpu_inst in range (self .num_dpus )
0 commit comments