Skip to content
20 changes: 20 additions & 0 deletions files/image_config/hostcfgd/hostcfgd
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,33 @@ class HostConfigDaemon:
add = False

self.iptables.iptables_handler(key, data, add)

def feature_status_handler(self, key, data):
status_data = self.config_db.get_table('FEATURES')
for key in status_data.keys():
if not key:
syslog.syslog(syslog.LOG_WARNING, "FEATURES key is missing")
return
status = status_data[key]['status']
if not status:
syslog.syslog(syslog.LOG_WARNING, "status is missing for {}".format(key))
return
if status == "enabled":
sudo systemctl enable key
sudo systemctl start key
syslog.syslog(syslog.LOG_INFO, "FEATURES {} is enabled and started".format(key))
if status == "disabled":
sudo systemctl stop key
sudo systemctl disable key
syslog.syslog(syslog.LOG_INFO, "FEATURES {} is stopped and disabled".format(key))

def start(self):
self.config_db.subscribe('AAA', lambda table, key, data: self.aaa_handler(key, data))
self.config_db.subscribe('TACPLUS_SERVER', lambda table, key, data: self.tacacs_server_handler(key, data))
self.config_db.subscribe('TACPLUS', lambda table, key, data: self.tacacs_global_handler(key, data))
self.config_db.subscribe('DEVICE_METADATA', lambda table, key, data: self.hostname_handler(key, data))
self.config_db.subscribe('LOOPBACK_INTERFACE', lambda table, key, data: self.lpbk_handler(key, data))
self.config_db.subscribe('FEATURES', lambda table, key, data: self.feature_status_handler(key, data))
self.config_db.listen()


Expand Down