sonic-buildimage/files/build_scripts/mask_disabled_services.py
Tamer Ahmed 51ab39fcb2
[hostcfgd]: Add Ability To Configure Feature During Run-time (#6700)
Features may be enabled/disabled for the same topology based on run-time
configuration. This PR adds the ability to enable/disable feature based
on config db data.

signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
2021-03-13 05:56:27 -08:00

14 lines
511 B
Python
Executable File

#!/usr/bin/env python3
import json
import subprocess
INIT_CFG_FILE_PATH = '/etc/sonic/init_cfg.json'
with open(INIT_CFG_FILE_PATH) as init_cfg_file:
init_cfg = json.load(init_cfg_file)
if 'FEATURE' in init_cfg:
for feature_name, feature_props in init_cfg['FEATURE'].items():
if 'state' in feature_props and feature_props['state'] != 'enabled' and feature_props['state'] != 'always_enabled':
subprocess.run(['systemctl', 'mask', '{}.service'.format(feature_name)])