Example #1
0
def enable_booth(env: LibraryEnvironment, instance_name=None):
    """
    Enable 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.enable_service(env.cmd_runner(), "booth", instance_name)
    except external.EnableServiceError as e:
        raise LibraryError(
            ReportItem.error(
                reports.messages.ServiceActionFailed(
                    reports.const.SERVICE_ACTION_ENABLE,
                    "booth",
                    e.message,
                    instance=instance_name,
                )
            )
        )
    env.report_processor.report(
        ReportItem.info(
            reports.messages.ServiceActionSucceeded(
                reports.const.SERVICE_ACTION_ENABLE,
                "booth",
                instance=instance_name,
            )
        )
    )
Example #2
0
 def test_not_systemctl(self, mock_systemctl):
     mock_systemctl.return_value = False
     self.mock_runner.run.return_value = ("", 0)
     lib.enable_service(self.mock_runner, self.service)
     self.mock_runner.run.assert_called_once_with(
         ["chkconfig", self.service, "on"]
     )
Example #3
0
 def test_systemctl(self, mock_systemctl):
     mock_systemctl.return_value = True
     self.mock_runner.run.return_value = ("", 0)
     lib.enable_service(self.mock_runner, self.service)
     self.mock_runner.run.assert_called_once_with(
         ["systemctl", "enable", self.service + ".service"]
     )
Example #4
0
 def test_instance_not_systemctl(self, mock_systemctl):
     mock_systemctl.return_value = False
     self.mock_runner.run.return_value = ("", "", 0)
     lib.enable_service(self.mock_runner, self.service, instance="test")
     self.mock_runner.run.assert_called_once_with(
         [_chkconfig, self.service, "on"]
     )
Example #5
0
 def test_systemctl(self, mock_systemctl):
     mock_systemctl.return_value = True
     self.mock_runner.run.return_value = ("", "Created symlink", 0)
     lib.enable_service(self.mock_runner, self.service)
     self.mock_runner.run.assert_called_once_with(
         [_systemctl, "enable", self.service + ".service"]
     )
Example #6
0
 def test_instance_systemctl(self, mock_systemctl):
     mock_systemctl.return_value = True
     self.mock_runner.run.return_value = ("", "Created symlink", 0)
     lib.enable_service(self.mock_runner, self.service, instance="test")
     self.mock_runner.run.assert_called_once_with([
         _systemctl, "enable",
         "{0}@{1}.service".format(self.service, "test")
     ])
Example #7
0
 def test_instance_systemctl(self, mock_systemctl):
     mock_systemctl.return_value = True
     self.mock_runner.run.return_value = ("", "Created symlink", 0)
     lib.enable_service(self.mock_runner, self.service, instance="test")
     self.mock_runner.run.assert_called_once_with([
         _systemctl,
         "enable",
         "{0}@{1}.service".format(self.service, "test")
     ])
Example #8
0
def enable_booth(env, name=None):
    """
    Enable 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.enable_service(env.cmd_runner(), "booth", name)
    except external.EnableServiceError as e:
        raise LibraryError(
            reports.service_enable_error("booth", e.message, instance=name))
    env.report_processor.process(
        reports.service_enable_success("booth", instance=name))
Example #9
0
 def test_not_systemctl_failed(self, mock_systemctl):
     mock_systemctl.return_value = False
     self.mock_runner.run.return_value = ("", "error", 1)
     self.assertRaises(
         lib.EnableServiceError,
         lambda: lib.enable_service(self.mock_runner, self.service))
     self.mock_runner.run.assert_called_once_with(
         [_chkconfig, self.service, "on"])
Example #10
0
 def test_systemctl_failed(self, mock_systemctl):
     mock_systemctl.return_value = True
     self.mock_runner.run.return_value = ("", "Failed", 1)
     self.assertRaises(
         lib.EnableServiceError,
         lambda: lib.enable_service(self.mock_runner, self.service))
     self.mock_runner.run.assert_called_once_with(
         [_systemctl, "enable", self.service + ".service"])
Example #11
0
def enable_booth(env):
    """
    Enable specified instance of booth service. Currently it is supported only
    systemd systems.

    env -- LibraryEnvironment
    """
    external.ensure_is_systemd()
    name = env.booth.name
    try:
        external.enable_service(env.cmd_runner(), "booth", name)
    except external.EnableServiceError as e:
        raise LibraryError(reports.service_enable_error(
            "booth", e.message, instance=name
        ))
    env.report_processor.process(reports.service_enable_success(
        "booth", instance=name
    ))
Example #12
0
 def test_not_systemctl_failed(self, mock_systemctl):
     mock_systemctl.return_value = False
     self.mock_runner.run.return_value = ("", 1)
     self.assertRaises(
         lib.EnableServiceError,
         lambda: lib.enable_service(self.mock_runner, self.service)
     )
     self.mock_runner.run.assert_called_once_with(
         ["chkconfig", self.service, "on"]
     )
Example #13
0
 def test_systemctl_failed(self, mock_systemctl):
     mock_systemctl.return_value = True
     self.mock_runner.run.return_value = ("", 1)
     self.assertRaises(
         lib.EnableServiceError,
         lambda: lib.enable_service(self.mock_runner, self.service)
     )
     self.mock_runner.run.assert_called_once_with(
         ["systemctl", "enable", self.service + ".service"]
     )
Example #14
0
def enable_booth(env, instance_name=None):
    """
    Enable 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.enable_service(env.cmd_runner(), "booth", instance_name)
    except external.EnableServiceError as e:
        raise LibraryError(
            reports.service_enable_error("booth",
                                         e.message,
                                         instance=instance_name))
    env.report_processor.process(
        reports.service_enable_success("booth", instance=instance_name))
Example #15
0
def qdevice_enable(runner):
    """
    make qdevice start automatically on boot on local host
    """
    external.enable_service(runner, __service_name)
Example #16
0
def qdevice_enable(runner):
    """
    make qdevice start automatically on boot on local host
    """
    external.enable_service(runner, __service_name)