How to use the watchmaker.workers.salt.SaltWindows function in watchmaker

To help you get started, we’ve selected a few watchmaker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plus3it / watchmaker / tests / test_saltworker.py View on Github external
def test_win_ash_role_none():
    """Test that Pythonic None can be used without error rather than 'None'."""
    # setup ========================
    system_params = {}
    salt_config = {}
    system_params["prepdir"] = "4e91a26a-c325-5548-9e99-e0cea505eca6"
    system_params["logdir"] = "1a74aa66-1eb5-5f6e-bbdc-a247cfabdcb7"
    system_params["workingdir"] = "3cbd1221-01f3-5ed8-8df1-79918a1ebe3d"

    # try "normal" first, with a value. try with none below.
    salt_config["ash_role"] = "ff059d6b-b614-5b55-8b94-4d29570b8da8"

    saltworker_win = SaltWindows(system_params, **salt_config)

    saltworker_win.working_dir = system_params["workingdir"]
    saltworker_win._prepare_for_install = MagicMock(return_value=None)
    saltworker_win.service_status = MagicMock(return_value=None)
    saltworker_win._install_package = MagicMock(return_value=None)
    saltworker_win.service_stop = MagicMock(return_value=None)
    saltworker_win._build_salt_formula = MagicMock(return_value=None)
    saltworker_win.service_enable = MagicMock(return_value=None)
    saltworker_win.service_disable = MagicMock(return_value=None)
    saltworker_win.service_start = MagicMock(return_value=None)
    saltworker_win._set_grain = MagicMock(return_value=None)
    saltworker_win.process_grains = MagicMock(return_value=None)
    saltworker_win.run_salt = MagicMock(
        return_value={"retcode": 0, "stdout": b"", "stderr": b""}
    )
    saltworker_win.process_states = MagicMock(return_value=None)
github plus3it / watchmaker / tests / test_saltworker.py View on Github external
def test_windows_prep_install(mock_safe, mock_makedirs, mock_codec):
    """Ensure that prep portion of install runs as expected."""
    system_params = {}
    salt_config = {}
    system_params["prepdir"] = "ac2bf0c3-7985-569f-bfbd-3a8d8a13ce7d"
    system_params["logdir"] = "5b0976f8-fcbc-50af-9459-8060589e70d9"
    system_params["workingdir"] = "860f630a-f85d-5ed2-bd7a-bbdb48a53b2b"

    salt_config["installer_url"] = "5f0c8635-4a10-5802-8145-732052a0b44b"
    salt_config["ash_role"] = "fddc3dc3-3684-5924-bf55-bb1dbc4e4c08"

    saltworker_win = SaltWindows(system_params, **salt_config)

    saltworker_win.create_working_dir = MagicMock(
        return_value=system_params["workingdir"]
    )
    saltworker_win._prepare_for_install()

    # assertions ===================
    saltworker_win.create_working_dir.assert_called_with(
        system_params["workingdir"], "Salt-"
    )
    mock_makedirs.assert_called_with(saltworker_win.salt_conf_path)
    mock_codec.assert_called_with(
        os.path.join(saltworker_win.salt_conf_path, "minion"),
        "w", encoding="utf-8"
    )
    mock_safe.assert_called_with(
github plus3it / watchmaker / tests / test_saltworker.py View on Github external
def test_windows_missing_prepdir():
    """Ensure that error raised when missing prep directory."""
    system_params = {}
    salt_config = {}

    system_params["logdir"] = "logdir"
    system_params["workingdir"] = "workingdir"

    with pytest.raises(KeyError, match="prepdir"):
        SaltWindows(system_params, **salt_config)
github plus3it / watchmaker / tests / test_saltworker.py View on Github external
def test_windows_missing_workingdir():
    """Ensure that error raised when missing working directory."""
    system_params = {}
    salt_config = {}

    system_params["logdir"] = "logdir"
    system_params["prepdir"] = "prepdir"

    with pytest.raises(KeyError, match="workingdir"):
        SaltWindows(system_params, **salt_config)
github plus3it / watchmaker / tests / test_saltworker.py View on Github external
def test_windows_install():
    """Ensure that install runs as expected."""
    system_params = {}
    salt_config = {}
    system_params["prepdir"] = "0dcd877d-56cb-50c2-954a-80d1084b2216"
    system_params["logdir"] = "647c2a49-baf9-511b-a17a-d6ebf0edd91c"
    system_params["workingdir"] = "3d6ab2ef-09ad-59f1-a365-ee5f22c95c79"

    salt_config["installer_url"] = "20c913cf-d825-533e-8649-4ab2fed5d9c1"
    salt_config["ash_role"] = "f1d27775-9a3d-5e87-ab42-a79ac329ae4b"

    saltworker_win = SaltWindows(system_params, **salt_config)

    saltworker_win._prepare_for_install = MagicMock(return_value=None)
    saltworker_win._install_package = MagicMock(return_value=None)
    saltworker_win.service_stop = MagicMock(return_value=None)
    saltworker_win._build_salt_formula = MagicMock(return_value=None)
    saltworker_win.service_disable = MagicMock(return_value=True)
    saltworker_win._set_grain = MagicMock(return_value=None)
    saltworker_win.process_grains = MagicMock(return_value=None)
    saltworker_win.run_salt = MagicMock(return_value=None)
    saltworker_win.working_dir = system_params["workingdir"]
    saltworker_win.cleanup = MagicMock(return_value=None)

    saltworker_win.install()

    # assertions ===================
    assert saltworker_win._prepare_for_install.call_count == 1
github plus3it / watchmaker / tests / test_saltworker.py View on Github external
def test_windows_defaults():
    """Ensure that default values are populated as expected."""
    system_params = {}
    salt_config = {}

    system_params["prepdir"] = "8cbda638-6b60-5628-870b-40fdf8add9f8"
    system_params["logdir"] = "21fa57e2-9302-5934-978d-4ae40d5a2a55"
    system_params["workingdir"] = "c990ee27-ff12-5d7e-9957-1d27d114c0ff"

    salt_config["installer_url"] = "5de41ea1-902c-5e7c-ae86-89587057c6b3"
    salt_config["ash_role"] = "b116b3e1-ee3f-5a83-9dd1-3d01d0d5e343"

    win_salt = SaltWindows(system_params, **salt_config)

    # assertions ===================
    assert win_salt.installer_url == salt_config["installer_url"]
    assert win_salt.ash_role == salt_config["ash_role"]
    assert win_salt.salt_root == os.sep.join(("C:", "Salt"))
    assert win_salt.salt_call == os.sep.join(("C:", "Salt", "salt-call.bat"))
    assert win_salt.salt_wam_root == os.sep.join(
        (system_params["prepdir"], "Salt"))
    assert win_salt.salt_conf_path == os.sep.join(
        (system_params["prepdir"], "Salt", "conf")
    )
    assert win_salt.salt_srv == os.sep.join(
        (system_params["prepdir"], "Salt", "srv"))
    assert win_salt.salt_win_repo == os.sep.join(
        (system_params["prepdir"], "Salt", "srv", "winrepo")
    )
github plus3it / watchmaker / tests / test_saltworker.py View on Github external
def test_windows_missing_logdir():
    """Ensure that error raised when missing log directory."""
    system_params = {}
    salt_config = {}

    system_params["prepdir"] = "prepdir"
    system_params["workingdir"] = "workingdir"

    with pytest.raises(KeyError, match="logdir"):
        SaltWindows(system_params, **salt_config)
github plus3it / watchmaker / src / watchmaker / managers / worker_manager.py View on Github external
def _worker_execution(self):
        pass

    def _worker_validation(self):
        pass

    def cleanup(self):
        """Execute cleanup function."""
        pass


class WindowsWorkersManager(WorkersManagerBase):
    """Manage the worker cadence for Windows systems."""

    WORKERS = {
        'salt': SaltWindows
    }

    def _worker_execution(self):
        pass

    def _worker_validation(self):
        pass

    def cleanup(self):
        """Execute cleanup function."""
        pass