From: Zack Cerza Date: Wed, 3 May 2017 21:33:56 +0000 (-0600) Subject: SystemDState: Use correct output_cmd for rgw X-Git-Tag: 1.1.0~384^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=36bcbaf40aeb931663f1d71394fa7da6667ff6e6;p=teuthology.git SystemDState: Use correct output_cmd for rgw We had this right for systemctl commands, but not for the journalctl command. Signed-off-by: Zack Cerza --- diff --git a/teuthology/orchestra/daemon/state.py b/teuthology/orchestra/daemon/state.py index 4ab7d3864..9fdf77b9a 100644 --- a/teuthology/orchestra/daemon/state.py +++ b/teuthology/orchestra/daemon/state.py @@ -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 diff --git a/teuthology/orchestra/daemon/systemd.py b/teuthology/orchestra/daemon/systemd.py index 5ee8fc490..2dd72f00e 100644 --- a/teuthology/orchestra/daemon/systemd.py +++ b/teuthology/orchestra/daemon/systemd.py @@ -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")