Esempio n. 1
0
    def notifyKernel(self):
        if not self.device:
            return

        if self.device.startswith("/dev/mapper/"):
            try:
                name = devicemapper.dm_node_from_name(os.path.basename(self.device))
            except Exception, e:
                ctx.logger.warning("failed to get dm node for %s" % self.device)
                return
Esempio n. 2
0
    def updateSysfsPath(self):
        """ Update this device's sysfs path. """
        if not self.parents:
            self.sysfsPath = ''

        elif self.parents[0]._devDir == "/dev/mapper":
            dm_node = devicemapper.dm_node_from_name(self.name)
            path = os.path.join("/sys", self.sysfsBlockDir, dm_node)
            self.sysfsPath = os.path.realpath(path)[4:]

        else:
            Device.updateSysfsPath(self)
Esempio n. 3
0
    def notifyKernel(self):
        if not self.device:
            return

        if self.device.startswith("/dev/mapper/"):
            try:
                name = devicemapper.dm_node_from_name(
                    os.path.basename(self.device))
            except Exception, e:
                ctx.logger.warning("failed to get dm node for %s" %
                                   self.device)
                return
Esempio n. 4
0
    def updateSysfsPath(self):
        """ Update this device's sysfs path. """
        if not self.parents:
            self.sysfsPath = ''

        elif self.parents[0]._devDir == "/dev/mapper":
            dm_node = devicemapper.dm_node_from_name(self.name)
            path = os.path.join("/sys", self.sysfsBlockDir, dm_node)
            self.sysfsPath = os.path.realpath(path)[4:]

        else:
            Device.updateSysfsPath(self)
Esempio n. 5
0
def swap_status(device):
    alt_dev = None
    if device.startswith("/dev/mapper/"):
        # get the real device node for device-mapper devices since the ones
        # with meaningful names are just symlinks
        try:
            alt_dev = "/dev/%s" % devicemapper.dm_node_from_name(device.split("/")[-1])
        except devicemapper.DeviceMapperError:
            alt_dev = None

    lines = open("/proc/swaps").readlines()
    status = False
    for line in lines:
        if not line.strip():
            continue

        swap_dev = line.split()[0]
        if swap_dev in [device, alt_dev]:
            status = True
            break

    return status
Esempio n. 6
0
def swap_status(device):
    alt_dev = None
    if device.startswith("/dev/mapper/"):
        # get the real device node for device-mapper devices since the ones
        # with meaningful names are just symlinks
        try:
            alt_dev = "/dev/%s" % devicemapper.dm_node_from_name(
                device.split("/")[-1])
        except devicemapper.DeviceMapperError:
            alt_dev = None

    lines = open("/proc/swaps").readlines()
    status = False
    for line in lines:
        if not line.strip():
            continue

        swap_dev = line.split()[0]
        if swap_dev in [device, alt_dev]:
            status = True
            break

    return status
Esempio n. 7
0
    def getDMNode(self):
        """ Return the dm-X (eg: dm-0) device node for this device. """
        if not self.exists:
            raise DeviceError("device has not been created", self.name)

        return devicemapper.dm_node_from_name(self.name)
Esempio n. 8
0
    def getDMNode(self):
        """ Return the dm-X (eg: dm-0) device node for this device. """
        if not self.exists:
            raise DeviceMapperError("device has not been created", self.name)

        return devicemapper.dm_node_from_name(self.name)