Beispiel #1
0
    def _detect_event(self, device):
        mpath_uuid = device.get("DM_UUID", "")
        if not mpath_uuid.startswith("mpath-"):
            return None
        mpath_uuid = mpath_uuid[6:]

        if device["ACTION"] == "change":
            dm_action = device.get("DM_ACTION")
            if dm_action == "PATH_FAILED":
                event_type = PATH_FAILED
            elif dm_action == "PATH_REINSTATED":
                event_type = PATH_REINSTATED
            else:
                self.log.debug("Unsupported DM_ACTION %r", dm_action)
                return
            valid_paths = int(device.get("DM_NR_VALID_PATHS"))
            dm_seqnum = int(device.get("DM_SEQNUM"))
            path = devicemapper.device_name(device.get("DM_PATH"))
        elif device["ACTION"] == "remove":
            event_type = MPATH_REMOVED
            valid_paths = None
            path = None
            dm_seqnum = None
        else:
            return None

        return MultipathEvent(event_type, mpath_uuid, path, valid_paths,
                              dm_seqnum)
Beispiel #2
0
Datei: udev.py Projekt: nirs/vdsm
    def _detect_event(self, device):
        mpath_uuid = device.get("DM_UUID", "")
        if not mpath_uuid.startswith("mpath-"):
            return None
        mpath_uuid = mpath_uuid[6:]

        if device["ACTION"] == "change":
            dm_action = device.get("DM_ACTION")
            if dm_action == "PATH_FAILED":
                event_type = PATH_FAILED
            elif dm_action == "PATH_REINSTATED":
                event_type = PATH_REINSTATED
            else:
                self.log.debug("Unsupported DM_ACTION %r", dm_action)
                return
            valid_paths = int(device.get("DM_NR_VALID_PATHS"))
            dm_seqnum = int(device.get("DM_SEQNUM"))
            path = devicemapper.device_name(device.get("DM_PATH"))
        elif device["ACTION"] == "remove":
            event_type = MPATH_REMOVED
            valid_paths = None
            path = None
            dm_seqnum = None
        else:
            return None

        return MultipathEvent(event_type, mpath_uuid, path, valid_paths,
                              dm_seqnum)
def test_block_device_name():
    devs = glob.glob("/sys/block/*/dev")
    dev_name = os.path.basename(os.path.dirname(devs[0]))
    with open(devs[0], 'r') as f:
        major_minor = f.readline().rstrip()
        assert devicemapper.device_name(major_minor) == dev_name
Beispiel #4
0
def test_block_device_name():
    devs = glob.glob("/sys/block/*/dev")
    dev_name = os.path.basename(os.path.dirname(devs[0]))
    with open(devs[0], 'r') as f:
        major_minor = f.readline().rstrip()
        assert devicemapper.device_name(major_minor) == dev_name