]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
DaemonState.check_status(): support systemd
authorZack Cerza <zack@redhat.com>
Tue, 25 Apr 2017 20:02:33 +0000 (14:02 -0600)
committerZack Cerza <zack@redhat.com>
Thu, 21 Sep 2017 18:49:10 +0000 (12:49 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/orchestra/daemon.py

index b5944249c152a5af8724b00e3c3b5b9f02da6600..99353ed5b78673cf799e73a967013af9fa38ed49 100644 (file)
@@ -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):