コード例 #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
ファイル: test_external.py プロジェクト: tomjelinek/pcs
 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
ファイル: test_lib_external.py プロジェクト: dchirikov/pcs
 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
ファイル: test_external.py プロジェクト: tomjelinek/pcs
 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
ファイル: test_external.py プロジェクト: tomjelinek/pcs
 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
ファイル: test_external.py プロジェクト: simhaonline/pcs
 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
ファイル: test_external.py プロジェクト: simhaonline/pcs
 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
ファイル: test_external.py プロジェクト: miladalipour99/pcs
 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
ファイル: test_external.py プロジェクト: miladalipour99/pcs
 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
ファイル: test_lib_external.py プロジェクト: dchirikov/pcs
 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
ファイル: qdevice_net.py プロジェクト: zht750808/pcs
def qdevice_stop(runner):
    """
    stop qdevice now on local host
    """
    external.stop_service(runner, __service_name)
コード例 #16
0
ファイル: qdevice_net.py プロジェクト: norbertoaquino/pcs
def qdevice_stop(runner):
    """
    stop qdevice now on local host
    """
    external.stop_service(runner, __service_name)