Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hostcfgd] Add support to enable/disable optional features #3653

Merged
merged 9 commits into from
Nov 26, 2019
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')
pra-moh marked this conversation as resolved.
Show resolved Hide resolved
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
jleveque marked this conversation as resolved.
Show resolved Hide resolved
syslog.syslog(syslog.LOG_INFO, "FEATURES {} is enabled and started".format(key))
if status == "disabled":
pra-moh marked this conversation as resolved.
Show resolved Hide resolved
sudo systemctl stop key
sudo systemctl disable key
jleveque marked this conversation as resolved.
Show resolved Hide resolved
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