Esempio n. 1
0
def setupMultipath():
    """
    Set up the multipath daemon configuration to the known and
    supported state. The original configuration, if any, is saved
    """
    if os.path.exists(MPATH_CONF):
        misc.rotateFiles(os.path.dirname(MPATH_CONF), os.path.basename(MPATH_CONF), MAX_CONF_COPIES, cp=True, persist=True)
    f = tempfile.NamedTemporaryFile()
    f.write(MPATH_CONF_TEMPLATE)
    f.flush()
    cmd = [constants.EXT_CP, f.name, MPATH_CONF]
    rc = misc.execCmd(cmd)[0]
    if rc != 0:
        raise se.MultipathSetupError()
    # f close removes file - must be after copy
    f.close()
    misc.persistFile(MPATH_CONF)

    # Flush all unused multipath device maps
    misc.execCmd([constants.EXT_MULTIPATH, "-F"])

    cmd = [constants.EXT_SERVICE, "multipathd", "restart"]
    rc = misc.execCmd(cmd)[0]
    if rc != 0:
        # No dice - try to reload instead of restart
        cmd = [constants.EXT_SERVICE, "multipathd", "reload"]
        rc = misc.execCmd(cmd)[0]
        if rc != 0:
            raise se.MultipathRestartError()
Esempio n. 2
0
def setupMultipath():
    """
    Set up the multipath daemon configuration to the known and
    supported state. The original configuration, if any, is saved
    """
    if os.path.exists(MPATH_CONF):
        misc.rotateFiles(os.path.dirname(MPATH_CONF),
                         os.path.basename(MPATH_CONF),
                         MAX_CONF_COPIES,
                         cp=True,
                         persist=True)
    with tempfile.NamedTemporaryFile() as f:
        f.write(MPATH_CONF_TEMPLATE % {'scsi_id_path': _scsi_id.cmd})
        f.flush()
        cmd = [constants.EXT_CP, f.name, MPATH_CONF]
        rc = misc.execCmd(cmd, sudo=True)[0]
        if rc != 0:
            raise se.MultipathSetupError()
    misc.persistFile(MPATH_CONF)

    # Flush all unused multipath device maps
    misc.execCmd([constants.EXT_MULTIPATH, "-F"], sudo=True)

    cmd = [constants.EXT_VDSM_TOOL, "service-reload", "multipathd"]
    rc = misc.execCmd(cmd, sudo=True)[0]
    if rc != 0:
        raise se.MultipathReloadError()
Esempio n. 3
0
def setupMultipath():
    """
    Set up the multipath daemon configuration to the known and
    supported state. The original configuration, if any, is saved
    """
    if os.path.exists(MPATH_CONF):
        misc.rotateFiles(
            os.path.dirname(MPATH_CONF),
            os.path.basename(MPATH_CONF), MAX_CONF_COPIES,
            cp=True, persist=True)
    with tempfile.NamedTemporaryFile() as f:
        f.write(MPATH_CONF_TEMPLATE % {'scsi_id_path': _scsi_id.cmd})
        f.flush()
        cmd = [constants.EXT_CP, f.name, MPATH_CONF]
        rc = misc.execCmd(cmd, sudo=True)[0]
        if rc != 0:
            raise se.MultipathSetupError()
    misc.persistFile(MPATH_CONF)

    # Flush all unused multipath device maps
    misc.execCmd([constants.EXT_MULTIPATH, "-F"], sudo=True)

    cmd = [constants.EXT_VDSM_TOOL, "service-reload", "multipathd"]
    rc = misc.execCmd(cmd, sudo=True)[0]
    if rc != 0:
        raise se.MultipathReloadError()
Esempio n. 4
0
def setupMultipath():
    """
    Set up the multipath daemon configuration to the known and
    supported state. The original configuration, if any, is saved
    """
    if os.path.exists(MPATH_CONF):
        misc.rotateFiles(os.path.dirname(MPATH_CONF),
                         os.path.basename(MPATH_CONF),
                         MAX_CONF_COPIES,
                         cp=True,
                         persist=True)
    f = tempfile.NamedTemporaryFile()
    f.write(MPATH_CONF_TEMPLATE)
    f.flush()
    cmd = [constants.EXT_CP, f.name, MPATH_CONF]
    rc = misc.execCmd(cmd)[0]
    if rc != 0:
        raise se.MultipathSetupError()
    # f close removes file - must be after copy
    f.close()
    misc.persistFile(MPATH_CONF)

    # Flush all unused multipath device maps
    misc.execCmd([constants.EXT_MULTIPATH, "-F"])

    cmd = [constants.EXT_SERVICE, "multipathd", "restart"]
    rc = misc.execCmd(cmd)[0]
    if rc != 0:
        # No dice - try to reload instead of restart
        cmd = [constants.EXT_SERVICE, "multipathd", "reload"]
        rc = misc.execCmd(cmd)[0]
        if rc != 0:
            raise se.MultipathRestartError()