Пример #1
0
def _resetDMP(sid,explicit_unmap=False):
# If mpath has been turned on since the sr/vdi was attached, we
# might be trying to unmap it before the daemon has been started
# This is unnecessary (and will fail) so just return.
    deactivate_MPdev(sid)
    if not _is_mpath_daemon_running():
        util.SMlog("Warning: Trying to unmap mpath device when multipathd not running")
        return

# If the multipath daemon is running, but we were initially plugged
# with multipathing set to no, there may be no map for us in the multipath
# tables. In that case, list_paths will return [], but remove_map might
# throw an exception. Catch it and ignore it.
    if explicit_unmap:
        util.SMlog("Explicit unmap")
        devices = mpath_cli.list_paths(sid)

        try:
            mpath_cli.remove_map(sid)
        except:
            util.SMlog("Warning: Removing the path failed")
            pass
        
        for device in devices:
            mpath_cli.remove_path(device)
    else:
        mpath_cli.ensure_map_gone(sid)

    path = "/dev/mapper/%s" % sid
    
    if not util.wait_for_nopath(path, 10):
        util.SMlog("MPATH: WARNING - path did not disappear [%s]" % path)
    else:
        util.SMlog("MPATH: path disappeared [%s]" % path)
Пример #2
0
def remove_stale_luns(hostids, lunid, expectedPath, mpath):
    try:
        for hostid in hostids:
            # get all LUNs of the format hostid:x:y:lunid
            luns = glob.glob('/dev/disk/by-scsibus/*-%s:*:*:%s' %
                             (hostid, lunid))

            # try to get the scsiid for each of these luns
            for lun in luns:
                try:
                    getSCSIid(lun)
                    # if it works, we have a problem as this device should not
                    # be present and be valid on this system
                    util.SMlog("Warning! The lun %s should not be present and" \
                                    " be valid on this system." % lun)
                except:
                    # Now do the rest.
                    pass

                # get the HBTL
                basename = os.path.basename(lun)
                hbtl_list = basename.split(':')
                hbtl = basename.split('-')[1]

                # the first one in scsiid-hostid
                hbtl_list[0] = hbtl_list[0].split('-')[1]

                expectedPath = expectedPath + '*' + hbtl
                if not os.path.exists(expectedPath):
                    # wait for sometime and check if the expected path exists
                    # check if a rescan was done outside of this process
                    time.sleep(2)

                if os.path.exists(expectedPath):
                    # do not remove device, this might be dangerous
                    util.SMlog("Path %s appeared before checking for "\
                        "stale LUNs, ignore this LUN %s." % (expectedPath, lun))
                    continue

                # remove the scsi device
                l = [os.path.realpath(lun), hbtl_list[0], hbtl_list[1], \
                     hbtl_list[2], hbtl_list[3]]
                scsi_dev_ctrl(l, 'remove')

                # if multipath is enabled, do a best effort cleanup
                if mpath:
                    try:
                        path = os.path.basename(os.path.realpath(lun))
                        mpath_cli.remove_path(path)
                    except Exception, e:
                        util.SMlog("Failed to remove path %s, ignoring "\
                            "exception as path may not be present." % path)
    except Exception, e:
        util.SMlog("Exception removing stale LUNs, new devices may not come"\
                   " up properly! Error: %s" % str(e))
Пример #3
0
def remove_stale_luns(hostids, lunid, expectedPath, mpath):
    try:
        for hostid in hostids:            
            # get all LUNs of the format hostid:x:y:lunid
            luns = glob.glob('/dev/disk/by-scsibus/*-%s:*:*:%s' % (hostid, lunid))
            
            # try to get the scsiid for each of these luns
            for lun in luns:
                try:
                    getSCSIid(lun)
                    # if it works, we have a problem as this device should not
                    # be present and be valid on this system
                    util.SMlog("Warning! The lun %s should not be present and" \
                                    " be valid on this system." % lun)
                except:
                    # Now do the rest.
                    pass
                
                # get the HBTL
                basename = os.path.basename(lun)
                hbtl_list = basename.split(':')
                hbtl = basename.split('-')[1]
                
                # the first one in scsiid-hostid
                hbtl_list[0] = hbtl_list[0].split('-')[1]
                
                expectedPath = expectedPath + '*' + hbtl
                if not os.path.exists(expectedPath):
                    # wait for sometime and check if the expected path exists
                    # check if a rescan was done outside of this process
                    time.sleep(2)
                
                if os.path.exists(expectedPath):
                    # do not remove device, this might be dangerous
                    util.SMlog("Path %s appeared before checking for "\
                        "stale LUNs, ignore this LUN %s." (expectedPath, lun))
                    continue                        
                    
                # remove the scsi device
                l = [os.path.realpath(lun), hbtl_list[0], hbtl_list[1], \
                     hbtl_list[2], hbtl_list[3]]
                scsi_dev_ctrl(l, 'remove')
                
                # if multipath is enabled, do a best effort cleanup
                if mpath:
                    try:
                        path = os.path.basename(os.path.realpath(lun))
                        mpath_cli.remove_path(path)
                    except Exception, e:
                        util.SMlog("Failed to remove path %s, ignoring "\
                            "exception as path may not be present." % path)
    except Exception, e:
        util.SMlog("Exception removing stale LUNs, new devices may not come"\
                   " up properly! Error: %s" % str(e))
Пример #4
0
def _resetDMP(sid, explicit_unmap=False, delete_nodes=False):
    # If mpath has been turned on since the sr/vdi was attached, we
    # might be trying to unmap it before the daemon has been started
    # This is unnecessary (and will fail) so just return.
    deactivate_MPdev(sid)
    if not _is_mpath_daemon_running():
        util.SMlog(
            "Warning: Trying to unmap mpath device when multipathd not running"
        )
        return

# If the multipath daemon is running, but we were initially plugged
# with multipathing set to no, there may be no map for us in the multipath
# tables. In that case, list_paths will return [], but remove_map might
# throw an exception. Catch it and ignore it.
    if explicit_unmap:
        util.SMlog("Explicit unmap")

        # Remove map from conf file, if any
        try:
            wwid_conf.edit_wwid(sid, True)
        except:
            util.SMlog("WARNING: exception raised while attempting to"
                       " modify multipath.conf")
        try:
            mpath_cli.reconfigure()
        except:
            util.SMlog("WARNING: exception raised while attempting to"
                       " reconfigure")
        time.sleep(5)

        devices = mpath_cli.list_paths(sid)

        try:
            mpath_cli.remove_map(sid)
        except:
            util.SMlog("Warning: Removing the path failed")
            pass

        for device in devices:
            mpath_cli.remove_path(device)
            if delete_nodes:
                _delete_node(device)
    else:
        mpath_cli.ensure_map_gone(sid)

    path = "/dev/mapper/%s" % sid

    if not util.wait_for_nopath(path, 10):
        util.SMlog("MPATH: WARNING - path did not disappear [%s]" % path)
    else:
        util.SMlog("MPATH: path disappeared [%s]" % path)
Пример #5
0
def remove(scsi_id):
    paths=mpath_cli.list_paths(scsi_id)
    mpath_cli.remove_map(scsi_id)
    for path in paths:
        mpath_cli.remove_path(path)
Пример #6
0
def remove(scsi_id):
    paths=mpath_cli.list_paths(scsi_id)
    mpath_cli.remove_map(scsi_id)
    for path in paths:
        mpath_cli.remove_path(path)