From 832dc1dc7e2377aa90ed8a1c6f2103b6ce9d1db8 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Tue, 25 Apr 2017 14:02:33 -0600 Subject: [PATCH] DaemonState.check_status(): support systemd Signed-off-by: Zack Cerza --- teuthology/orchestra/daemon.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/teuthology/orchestra/daemon.py b/teuthology/orchestra/daemon.py index b5944249c1..99353ed5b7 100644 --- a/teuthology/orchestra/daemon.py +++ b/teuthology/orchestra/daemon.py @@ -58,6 +58,7 @@ class DaemonState(object): self.start_cmd = get_systemd_cmd('start', self.type_, self.id_) self.stop_cmd = get_systemd_cmd('stop', self.type_, self.id_) self.restart_cmd = get_systemd_cmd('restart', self.type_, self.id_) + self.show_cmd = get_systemd_cmd('show', self.type_, self.id_) @property def pid(self): @@ -255,6 +256,24 @@ class DaemonState(object): """ if self.proc: return self.proc.poll() + elif self.use_init: + proc = self.remote.run( + args=self.show_cmd + ' | grep -i state', + stdout=StringIO(), + ) + + def parse_line(line): + key, value = line.strip().split('=', 1) + return {key.strip(): value.strip()} + show_dict = dict() + for line in proc.stdout.readlines(): + show_dict.update(parse_line(line)) + active_state = show_dict['ActiveState'] + sub_state = show_dict['SubState'] + if active_state != 'active': + self.log.info("State is: %s/%s", active_state, sub_state) + + class DaemonGroup(object): -- 2.39.5