Skip to content

Commit

Permalink
review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tahmed-dev committed Aug 19, 2020
1 parent ff3df0d commit 26e5564
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
{%- if include_sflow == "y" %}{% do features.append(("sflow", "disabled", false, "enabled")) %}{% endif %}
{%- if include_system_telemetry == "y" %}{% do features.append(("telemetry", "enabled", true, "enabled")) %}{% endif %}
"FEATURE": {
{%- for feature, state, delay_start, autorestart in features %}
{# has_timer field if set, will start the feature systemd .timer unit instead of .service unit #}
{%- for feature, state, has_timer, autorestart in features %}
"{{feature}}": {
"state": "{{state}}",
"delay_start" : {{delay_start | lower()}},
"has_timer" : {{has_timer | lower()}},
"auto_restart": "{{autorestart}}",
"high_mem_alert": "disabled"
}{% if not loop.last %},{% endif -%}
Expand Down
8 changes: 4 additions & 4 deletions files/image_config/hostcfgd/hostcfgd
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def obfuscate(data):
return data


def update_feature_state(feature_name, state, delay_start=False):
feature_suffix = "timer" if delay_start else "service"
def update_feature_state(feature_name, state, has_timer=False):
feature_suffix = "timer" if has_timer else "service"
if state == "enabled":
start_cmds = []
start_cmds.append("sudo systemctl unmask {}.{}".format(feature_name, feature_suffix))
Expand Down Expand Up @@ -286,7 +286,7 @@ class HostConfigDaemon:
syslog.syslog(syslog.LOG_WARNING, "Eanble state of feature '{}' is None".format(feature_name))
continue

update_feature_state(feature_name, state, feature_table[feature_name]['delay_start'])
update_feature_state(feature_name, state, feature_table[feature_name]['has_timer'])

def aaa_handler(self, key, data):
self.aaacfg.aaa_update(key, data)
Expand Down Expand Up @@ -328,7 +328,7 @@ class HostConfigDaemon:
syslog.syslog(syslog.LOG_WARNING, "Enable state of feature '{}' is None".format(feature_name))
return

update_feature_state(feature_name, state, feature_table[feature_name]['delay_start'])
update_feature_state(feature_name, state, feature_table[feature_name]['has_timer'])

def start(self):
# Update all feature states once upon starting
Expand Down

0 comments on commit 26e5564

Please sign in to comment.