[hostcfgd]: wait till system initialization is done before starting hostcfgd (#6232)

- Why I did it
The change is done to make sure the system initialization is done before updating the feature states

- How I did it
use the command "systemctl is-system-running --wait"  to wait till system has finished booting up before updating the feature states
This commit is contained in:
arlakshm 2020-12-17 17:03:28 -08:00 committed by GitHub
parent a624aa01c7
commit 317a4b3410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -300,6 +300,7 @@ class HostConfigDaemon:
self.kdumpCfg = KdumpCfg(self.config_db)
self.kdumpCfg.load(self.config_db.get_table('KDUMP'))
def load(self):
aaa = self.config_db.get_table('AAA')
tacacs_global = self.config_db.get_table('TACPLUS')
@ -447,6 +448,13 @@ class HostConfigDaemon:
syslog.syslog(syslog.LOG_INFO, 'Kdump handler...')
self.kdumpCfg.kdump_update(key, data, False)
def wait_till_system_init_done(self):
# No need to print the output in the log file so using the "--quiet"
# flag
systemctl_cmd = "sudo systemctl is-system-running --wait --quiet"
subprocess.call(systemctl_cmd, shell=True)
def start(self):
self.config_db.subscribe('AAA', lambda table, key, data: self.aaa_handler(key, data))
@ -456,6 +464,12 @@ class HostConfigDaemon:
self.config_db.subscribe('FEATURE', lambda table, key, data: self.feature_state_handler(key, data))
self.config_db.subscribe('KDUMP', lambda table, key, data: self.kdump_handler(key, data))
syslog.syslog(syslog.LOG_INFO,
"Waiting for systemctl to finish initialization")
self.wait_till_system_init_done()
syslog.syslog(syslog.LOG_INFO,
"systemctl has finished initialization -- proceeding ...")
# Update all feature states once upon starting
self.update_all_feature_states()