]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
SystemDState: Use correct output_cmd for rgw
authorZack Cerza <zack@redhat.com>
Wed, 3 May 2017 21:33:56 +0000 (15:33 -0600)
committerZack Cerza <zack@redhat.com>
Thu, 21 Sep 2017 18:49:10 +0000 (12:49 -0600)
We had this right for systemctl commands, but not for the journalctl
command.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/orchestra/daemon/state.py
teuthology/orchestra/daemon/systemd.py

index 4ab7d3864c0dc8fae015bffc15cdc762cabde809..9fdf77b9a776226f648fbcd90d25d4ed8bfe0d9d 100644 (file)
@@ -25,7 +25,7 @@ class DaemonState(object):
         self.command_args = command_args
         self.command_kwargs = command_kwargs
         self.role = role
-        self.type_ = self.role.split('.')[-1]
+        self.cluster, self.type_ = self.role.split('.')[0:2]
         self.id_ = id_
         self.log = command_kwargs.get('logger', log)
         self.proc = None
@@ -161,4 +161,4 @@ class DaemonState(object):
             try:
                 run.wait([self.proc])
             finally:
-                self.proc = None
\ No newline at end of file
+                self.proc = None
index 5ee8fc490da445f2d378f8ce607a084665016d45..2dd72f00e36ba54fe70339aa2b52f5df4f1c41c1 100644 (file)
@@ -11,36 +11,44 @@ log = logging.getLogger(__name__)
 systemd_cmd_templ = 'sudo systemctl {action} {daemon}@{id_}'
 
 
-def get_systemd_cmd(action, daemon, id_):
-    if daemon == 'rgw':
-        daemon = 'radosgw'
-        id_ = 'rgw.%s' % id_
-    daemon = 'ceph-%s' % daemon
-    cmd = systemd_cmd_templ.format(
-        action=action,
-        daemon=daemon,
-        id_=id_,
-    )
-    return cmd
-
-
 class SystemDState(DaemonState):
     def __init__(self, remote, role, id_, *command_args,
                  **command_kwargs):
         super(SystemDState, self).__init__(
-                remote, role, id_, *command_args, **command_kwargs)
-        self.log = command_kwargs.get('logger', log)
+            remote, role, id_, *command_args, **command_kwargs)
         self._set_commands()
+        self.log = command_kwargs.get('logger', log)
+
+    @property
+    def daemon_type(self):
+        if self.type_ == 'rgw':
+            return 'radosgw'
+        return self.type_
+
+    def _get_systemd_cmd(self, action):
+        cmd = systemd_cmd_templ.format(
+            action=action,
+            daemon='%s-%s' % (self.cluster, self.daemon_type),
+            id_=self.id_.replace('client.', ''),
+        )
+        return cmd
 
     def _set_commands(self):
-        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_)
-        self.status_cmd = get_systemd_cmd('status', self.type_, self.id_)
+        self.start_cmd = self._get_systemd_cmd('start')
+        self.stop_cmd = self._get_systemd_cmd('stop')
+        self.restart_cmd = self._get_systemd_cmd('restart')
+        self.show_cmd = self._get_systemd_cmd('show')
+        self.status_cmd = self._get_systemd_cmd('status')
+        cluster_and_type = '%s-%s' % (self.cluster, self.daemon_type)
+        if self.type_ == self.daemon_type:
+            syslog_id = cluster_and_type
+        else:
+            syslog_id = self.daemon_type
         self.output_cmd = 'sudo journalctl -u ' \
-            '{role}@{id_} -t {role} -n 10'.format(
-                role=self.role.replace('.', '-'), id_=self.id_,
+            '{0}@{1} -t {2} -n 10'.format(
+                cluster_and_type,
+                self.id_.replace('client.', ''),
+                syslog_id,
             )
 
     def check_status(self):
@@ -203,4 +211,4 @@ class SystemDState(DaemonState):
         clear remote run command value after waiting for exit.
         """
         # TODO: This ought to be possible, no?
-        self.log.error("wait_for_exit() is not supported with systemd")
\ No newline at end of file
+        self.log.error("wait_for_exit() is not supported with systemd")