def stop_booth(env: LibraryEnvironment, instance_name=None): """ Stop specified instance of booth service, systemd systems supported only. env string instance_name -- booth instance name """ external.ensure_is_systemd() booth_env = env.get_booth_env(instance_name) _ensure_live_env(env, booth_env) instance_name = booth_env.instance_name try: external.stop_service(env.cmd_runner(), "booth", instance_name) except external.StopServiceError as e: raise LibraryError( ReportItem.error( reports.messages.ServiceActionFailed( reports.const.SERVICE_ACTION_STOP, "booth", e.message, instance=instance_name, ) ) ) env.report_processor.report( ReportItem.info( reports.messages.ServiceActionSucceeded( reports.const.SERVICE_ACTION_STOP, "booth", instance=instance_name, ) ) )
def test_instance_not_systemctl(self, mock_systemctl): mock_systemctl.return_value = False self.mock_runner.run.return_value = ("Stopping...", "", 0) lib.stop_service(self.mock_runner, self.service, instance="test") self.mock_runner.run.assert_called_once_with( [_service, self.service, "stop"] )
def test_instance_systemctl(self, mock_systemctl): mock_systemctl.return_value = True self.mock_runner.run.return_value = ("", "", 0) lib.stop_service(self.mock_runner, self.service, instance="test") self.mock_runner.run.assert_called_once_with([ _systemctl, "stop", "{0}@{1}.service".format(self.service, "test") ])
def test_not_systemctl(self, mock_systemctl): mock_systemctl.return_value = False self.mock_runner.run.return_value = ("", 0) lib.stop_service(self.mock_runner, self.service) self.mock_runner.run.assert_called_once_with( ["service", self.service, "stop"] )
def test_systemctl(self, mock_systemctl): mock_systemctl.return_value = True self.mock_runner.run.return_value = ("", "", 0) lib.stop_service(self.mock_runner, self.service) self.mock_runner.run.assert_called_once_with( [_systemctl, "stop", self.service + ".service"] )
def stop_booth(env, name=None): """ Stop specified instance of booth service. Currently it is supported only systemd systems. env -- LibraryEnvironment name -- string, name of booth instance """ external.ensure_is_systemd() try: external.stop_service(env.cmd_runner(), "booth", name) except external.StopServiceError as e: raise LibraryError( reports.service_stop_error("booth", e.message, instance=name)) env.report_processor.process( reports.service_stop_success("booth", instance=name))
def test_not_systemctl_failed(self, mock_systemctl): mock_systemctl.return_value = False self.mock_runner.run.return_value = ("", "unrecognized", 1) self.assertRaises( lib.StopServiceError, lambda: lib.stop_service(self.mock_runner, self.service)) self.mock_runner.run.assert_called_once_with( [_service, self.service, "stop"])
def test_systemctl_failed(self, mock_systemctl): mock_systemctl.return_value = True self.mock_runner.run.return_value = ("", "Failed", 1) self.assertRaises( lib.StopServiceError, lambda: lib.stop_service(self.mock_runner, self.service)) self.mock_runner.run.assert_called_once_with( [_systemctl, "stop", self.service + ".service"])
def stop_booth(env): """ Stop specified instance of booth service. Currently it is supported only systemd systems. env -- LibraryEnvironment """ external.ensure_is_systemd() name = env.booth.name try: external.stop_service(env.cmd_runner(), "booth", name) except external.StopServiceError as e: raise LibraryError(reports.service_stop_error( "booth", e.message, instance=name )) env.report_processor.process(reports.service_stop_success( "booth", instance=name ))
def test_not_systemctl_failed(self, mock_systemctl): mock_systemctl.return_value = False self.mock_runner.run.return_value = ("", 1) self.assertRaises( lib.StopServiceError, lambda: lib.stop_service(self.mock_runner, self.service) ) self.mock_runner.run.assert_called_once_with( ["service", self.service, "stop"] )
def stop_booth(env, instance_name=None): """ Stop specified instance of booth service, systemd systems supported only. LibraryEnvironment env string instance_name -- booth instance name """ external.ensure_is_systemd() booth_env = env.get_booth_env(instance_name) _ensure_live_env(env, booth_env) instance_name = booth_env.instance_name try: external.stop_service(env.cmd_runner(), "booth", instance_name) except external.StopServiceError as e: raise LibraryError( reports.service_stop_error("booth", e.message, instance=instance_name)) env.report_processor.process( reports.service_stop_success("booth", instance=instance_name))
def qdevice_stop(runner): """ stop qdevice now on local host """ external.stop_service(runner, __service_name)