예제 #1
0
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,
            )
        )
    )
예제 #2
0
 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"]
     )
예제 #3
0
 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")
     ])
예제 #4
0
 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"]
     )
예제 #5
0
 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"]
     )
예제 #6
0
 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")
     ])
예제 #7
0
 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"]
     )
예제 #8
0
 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"]
     )
예제 #9
0
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))
예제 #10
0
 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"])
예제 #11
0
 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"])
예제 #12
0
파일: booth.py 프로젝트: tomjelinek/pcs
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
    ))
예제 #13
0
 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"]
     )
예제 #14
0
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))
예제 #15
0
def qdevice_stop(runner):
    """
    stop qdevice now on local host
    """
    external.stop_service(runner, __service_name)
예제 #16
0
def qdevice_stop(runner):
    """
    stop qdevice now on local host
    """
    external.stop_service(runner, __service_name)