--- /dev/null
+import logging
+
+from teuthology.orchestra.daemon.state import DaemonState
+
+log = logging.getLogger(__name__)
+
+class CephadmUnit(DaemonState):
+ def __init__(self, remote, role, id_, *command_args,
+ **command_kwargs):
+ super(CephadmUnit, self).__init__(
+ remote, role, id_, *command_args, **command_kwargs)
+ self._set_commands()
+ self.log = command_kwargs.get('logger', log)
+ self.use_cephadm = command_kwargs.get('use_cephadm')
+ self.is_started = command_kwargs.get('started', False)
+ if self.is_started:
+ self._start_logger()
+
+ def name(self):
+ return '%s.%s' % (self.type_, self.id_)
+
+ def _get_systemd_cmd(self, action):
+ return ' '.join([
+ 'sudo', 'systemctl',
+ action,
+ 'ceph-%s@%s.%s' % (self.fsid, self.type_, self.id_),
+ ])
+
+ def _set_commands(self):
+ 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')
+
+ def _start_logger(self):
+ name = '%s.%s' % (self.type_, self.id_)
+ self.remote_logger = self.remote.run(
+ args=['sudo', self.use_cephadm, 'logs',
+ '-f',
+ '--fsid', self.fsid,
+ '--name', name],
+ logger=logging.getLogger(self.cluster + '.' + name),
+ label=name,
+ wait=False)
+
+ def _join_logger(self):
+ self.remote_logger.wait()
+ self.remote_logger = None
+
+ def reset(self):
+ """
+ Does nothing in this implementation
+ """
+ pass
+
+ def restart(self, *args, **kwargs):
+ """
+ Restart with a new command passed in the arguments
+
+ :param args: positional arguments passed to remote.run
+ :param kwargs: keyword arguments passed to remote.run
+ """
+ if not self.running():
+ self.log.info('Restarting %s (starting--it wasn\'t running)...' % self.name())
+ self.remote.sh(self.start_cmd)
+ self._start_logger()
+ self.is_started = True
+ else:
+ self.log.info('Restarting %s...' % self.name())
+ self.remote.sh(self.restart_cmd)
+ self._join_logger()
+ self._start_logger()
+
+ def restart_with_args(self, extra_args):
+ """
+ Restart, adding new paramaters to the current command.
+
+ :param extra_args: Extra keyword arguments to be added.
+ """
+ raise NotImplementedError
+
+ def running(self):
+ """
+ Are we running?
+ """
+ return self.is_started
+
+ def signal(self, sig, silent=False):
+ """
+ Send a signal to associated remote command
+
+ :param sig: signal to send
+ """
+ raise NotImplementedError
+
+ def start(self, timeout=300):
+ """
+ Start this daemon instance.
+ """
+ if self.running():
+ self.log.warn('Restarting a running daemon')
+ self.restart()
+ return
+ self.remote.run(self.start_cmd)
+ self._start_logger()
+
+ def stop(self, timeout=300):
+ """
+ Stop this daemon instance.
+
+ Note: this can raise a CommandFailedError,
+ CommandCrashedError, or ConnectionLostError.
+
+ :param timeout: timeout to pass to orchestra.run.wait()
+ """
+ if not self.running():
+ self.log.error('Tried to stop a non-running daemon')
+ return
+ self.log.info('Stopping %s...' % self.name())
+ self.remote.sh(self.stop_cmd)
+ self.is_started = False
+ self._join_logger()
+ self.log.info('Stopped %s' % self.name())
+
+ # FIXME why are there two wait methods?
+ def wait(self, timeout=300):
+ """
+ Wait for daemon to exit
+
+ Wait for daemon to stop (but don't trigger the stop). Pass up
+ any exception. Mark the daemon as not running.
+ """
+ raise NotImplementedError
+
+ def wait_for_exit(self):
+ """
+ clear remote run command value after waiting for exit.
+ """
+ raise NotImplementedError
+++ /dev/null
-import logging
-
-from teuthology.orchestra.daemon.state import DaemonState
-
-log = logging.getLogger(__name__)
-
-class CephDaemonUnit(DaemonState):
- def __init__(self, remote, role, id_, *command_args,
- **command_kwargs):
- super(CephDaemonUnit, self).__init__(
- remote, role, id_, *command_args, **command_kwargs)
- self._set_commands()
- self.log = command_kwargs.get('logger', log)
- self.use_ceph_daemon = command_kwargs.get('use_ceph_daemon')
- self.is_started = command_kwargs.get('started', False)
- if self.is_started:
- self._start_logger()
-
- def name(self):
- return '%s.%s' % (self.type_, self.id_)
-
- def _get_systemd_cmd(self, action):
- return ' '.join([
- 'sudo', 'systemctl',
- action,
- 'ceph-%s@%s.%s' % (self.fsid, self.type_, self.id_),
- ])
-
- def _set_commands(self):
- 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')
-
- def _start_logger(self):
- name = '%s.%s' % (self.type_, self.id_)
- self.remote_logger = self.remote.run(
- args=['sudo', self.use_ceph_daemon, 'logs',
- '-f',
- '--fsid', self.fsid,
- '--name', name],
- logger=logging.getLogger(self.cluster + '.' + name),
- label=name,
- wait=False)
-
- def _join_logger(self):
- self.remote_logger.wait()
- self.remote_logger = None
-
- def reset(self):
- """
- Does nothing in this implementation
- """
- pass
-
- def restart(self, *args, **kwargs):
- """
- Restart with a new command passed in the arguments
-
- :param args: positional arguments passed to remote.run
- :param kwargs: keyword arguments passed to remote.run
- """
- if not self.running():
- self.log.info('Restarting %s (starting--it wasn\'t running)...' % self.name())
- self.remote.sh(self.start_cmd)
- self._start_logger()
- self.is_started = True
- else:
- self.log.info('Restarting %s...' % self.name())
- self.remote.sh(self.restart_cmd)
- self._join_logger()
- self._start_logger()
-
- def restart_with_args(self, extra_args):
- """
- Restart, adding new paramaters to the current command.
-
- :param extra_args: Extra keyword arguments to be added.
- """
- raise NotImplementedError
-
- def running(self):
- """
- Are we running?
- """
- return self.is_started
-
- def signal(self, sig, silent=False):
- """
- Send a signal to associated remote command
-
- :param sig: signal to send
- """
- raise NotImplementedError
-
- def start(self, timeout=300):
- """
- Start this daemon instance.
- """
- if self.running():
- self.log.warn('Restarting a running daemon')
- self.restart()
- return
- self.remote.run(self.start_cmd)
- self._start_logger()
-
- def stop(self, timeout=300):
- """
- Stop this daemon instance.
-
- Note: this can raise a CommandFailedError,
- CommandCrashedError, or ConnectionLostError.
-
- :param timeout: timeout to pass to orchestra.run.wait()
- """
- if not self.running():
- self.log.error('Tried to stop a non-running daemon')
- return
- self.log.info('Stopping %s...' % self.name())
- self.remote.sh(self.stop_cmd)
- self.is_started = False
- self._join_logger()
- self.log.info('Stopped %s' % self.name())
-
- # FIXME why are there two wait methods?
- def wait(self, timeout=300):
- """
- Wait for daemon to exit
-
- Wait for daemon to stop (but don't trigger the stop). Pass up
- any exception. Mark the daemon as not running.
- """
- raise NotImplementedError
-
- def wait_for_exit(self):
- """
- clear remote run command value after waiting for exit.
- """
- raise NotImplementedError
from teuthology import misc
from teuthology.orchestra.daemon.state import DaemonState
from teuthology.orchestra.daemon.systemd import SystemDState
-from teuthology.orchestra.daemon.cephdaemonunit import CephDaemonUnit
+from teuthology.orchestra.daemon.cephadmunit import CephadmUnit
class DaemonGroup(object):
"""
Collection of daemon state instances
"""
- def __init__(self, use_systemd=False, use_ceph_daemon=None):
+ def __init__(self, use_systemd=False, use_cephadm=None):
"""
self.daemons is a dictionary indexed by role. Each entry is a
dictionary of DaemonState values indexed by an id parameter.
"""
self.daemons = {}
self.use_systemd = use_systemd
- self.use_ceph_daemon = use_ceph_daemon
+ self.use_cephadm = use_cephadm
def add_daemon(self, remote, type_, id_, *args, **kwargs):
"""
self.daemons[role][id_] = None
klass = DaemonState
- if self.use_ceph_daemon:
- klass = CephDaemonUnit
- kwargs['use_ceph_daemon'] = self.use_ceph_daemon
+ if self.use_cephadm:
+ klass = CephadmUnit
+ kwargs['use_cephadm'] = self.use_cephadm
elif self.use_systemd and \
not any(i == 'valgrind' for i in args) and \
remote.init_system == 'systemd':