Beispiel #1
0
def test_backup_file_missing(tmpdir):
    path = str(tmpdir.join("orig"))

    backup = fileUtils.backup_file(path)

    assert backup is None
    assert tmpdir.listdir() == []
Beispiel #2
0
def test_backup_file_create(tmpdir):
    path = str(tmpdir.join("orig"))
    with open(path, "w") as f:
        f.write("old")

    backup = fileUtils.backup_file(path)

    assert backup.startswith(path + ".")
    with open(backup) as f:
        assert f.read() == "old"
Beispiel #3
0
def configure():
    """
    Disable and mask lvmetad daemon, and install vdsm managed lvmlocal.conf.
    """
    if not _lvm_conf_configured():
        backup = fileUtils.backup_file(_LVMLOCAL_CUR)
        if backup:
            _log("Previous lvmlocal.conf copied to %s", backup)

        # TODO: we should merge the contents of the exisiting file and vdsm
        # settings, in case the user has some useful setting in the
        # lvmlocal.conf.
        _log("Installing %s at %s", _LVMLOCAL_VDSM, _LVMLOCAL_CUR)
        with open(_LVMLOCAL_VDSM, "rb") as f:
            fileUtils.atomic_write(_LVMLOCAL_CUR, f.read(), relabel=True)
Beispiel #4
0
def configure():
    """
    Set up the multipath daemon configuration to the known and
    supported state. The original configuration, if any, is saved
    """
    backup = fileUtils.backup_file(_CONF_FILE)
    if backup:
        sys.stdout.write("Previous multipath.conf copied to %s\n" % backup)

    data = _CONF_DATA.encode('utf-8')
    fileUtils.atomic_write(_CONF_FILE, data, relabel=True)

    # We want to handle these cases:
    #
    # 1. multipathd is not running and the kernel module is not loaded. We
    #    don't have any online multipath devices, so there is nothing to
    #    reconfigure, but we want to make sure that multipathd is happy with
    #    new multipath configuration.
    #
    # 2. multipathd is not running but the kernel module is loaded. We may have
    #    online devices that need reconfiguration.
    #
    # 3. multipathd is running with older configuration not compatible with
    #    vdsm configuration.
    #
    # 4. multipathd is running with older vdsm configuration. Reloading is
    #    needed to update devices with new configuration.
    #
    # When we have online devices using incompatible configuration, they may
    # use "user friendly" names (/dev/mapper/mpath{N}) instead of consistent
    # names (/dev/mapper/{WWID}). Restarting multipathd with the new
    # configuration will rename the devices, however due to multipathd bug,
    # these devices may not pick all configuration changes. Reconfiguring
    # multipathd ensures that all configurations changes are applied.
    #
    # To simplify handing of all cases, we first start multipathd service. This
    # eliminates cases 1 and 2. Case 3 and 4 are handled by reconfiguring
    # multipathd.
    #
    # If any of those steps fails, we want to fail the configuration.

    service.service_start("multipathd")
    commands.run([_MULTIPATHD.cmd, "reconfigure"])
Beispiel #5
0
def configure():
    """
    Disable and mask lvmetad daemon, and install vdsm managed lvmlocal.conf.
    """
    if not _lvm_conf_configured():
        backup = fileUtils.backup_file(_LVMLOCAL_CUR)
        if backup:
            _log("Previous lvmlocal.conf copied to %s", backup)

        # TODO: we should merge the contents of the exisiting file and vdsm
        # settings, in case the user has some useful setting in the
        # lvmlocal.conf.
        _log("Installing %s at %s", _LVMLOCAL_VDSM, _LVMLOCAL_CUR)
        with open(_LVMLOCAL_VDSM, "rb") as f:
            fileUtils.atomic_write(_LVMLOCAL_CUR, f.read(), relabel=True)

    # TODO: remove disabling lvmetad once we don't support Fedora 30. On
    # Fedora 31 and RHEL8 lvmetad is not supported anymore.
    if not _lvmetad_configured():
        _systemctl("mask", _LVMETAD_SERVICE, _LVMETAD_SOCKET)
        _systemctl("disable", _LVMETAD_SERVICE, _LVMETAD_SOCKET)
        _systemctl("stop", _LVMETAD_SERVICE, _LVMETAD_SOCKET)