def dm_node_from_name(name): dm_node = block.getDmNodeFromName(name) if dm_node is not None: return dm_node devnum = yali.util.run_batch("dmsetup", ["info", "--columns", "--noheadings", "-o", "devno",name])[1] (major, sep, minor) = devnum.strip().partition(":") if not sep: raise DeviceMapperError("dm device does not exist") dm_node = "dm-%d" % int(minor) ctx.logger.debug("dm_node_from_name(%s) returning '%s'" % (name, dm_node)) return dm_node
def dm_node_from_name(map_name): dm_node = block.getDmNodeFromName(map_name) if dm_node is not None: return dm_node devnum = iutil.execWithCapture( "dmsetup", ["info", "--columns", "--noheadings", "-o", "devno", map_name], stderr="/dev/tty5") (major, sep, minor) = devnum.strip().partition(":") if not sep: raise DMError("dm device does not exist") dm_node = "dm-%d" % int(minor) log.debug("dm_node_from_name(%s) returning '%s'" % (map_name, dm_node)) return dm_node
def dm_node_from_name(map_name): dm_node = block.getDmNodeFromName(map_name) if dm_node is not None: return dm_node devnum = iutil.execWithCapture("dmsetup", ["info", "--columns", "--noheadings", "-o", "devno", map_name], stderr="/dev/tty5") (major, sep, minor) = devnum.strip().partition(":") if not sep: raise DMError("dm device does not exist") dm_node = "dm-%d" % int(minor) log.debug("dm_node_from_name(%s) returning '%s'" % (map_name, dm_node)) return dm_node
def dm_node_from_name(map_name): named_path = "/dev/mapper/%s" % map_name try: # /dev/mapper/ nodes are usually symlinks to /dev/dm-N node = os.path.basename(os.readlink(named_path)) except OSError: try: # dm devices' names are based on the block device minor st = os.stat(named_path) minor = os.minor(st.st_rdev) node = "dm-%d" % minor except OSError: # try pyblock node = block.getDmNodeFromName(map_name) if not node: raise DMError("dm_node_from_name(%s) has failed." % node) return node