|
|
|
@ -900,33 +900,30 @@ def readFile(filename):
|
|
|
|
|
|
|
|
|
|
def getUUIDDict(revers=False):
|
|
|
|
|
"""Get dict UUID -> dev"""
|
|
|
|
|
devuuid = '/dev/disk/by-uuid'
|
|
|
|
|
datafunc = lambda x,y: (x,y)
|
|
|
|
|
blkidProcess = process("/sbin/blkid","-s","UUID","-c","/dev/null")
|
|
|
|
|
if revers:
|
|
|
|
|
datafunc = lambda x,y: (y,x)
|
|
|
|
|
else:
|
|
|
|
|
datafunc = lambda x,y: (x,y)
|
|
|
|
|
DEV,UUID = 0,1
|
|
|
|
|
reSplit = re.compile('^([^:]+):.*UUID="([^"]+)"',re.S)
|
|
|
|
|
return dict(
|
|
|
|
|
map(lambda x:datafunc("UUID=%s"%path.basename(x),
|
|
|
|
|
path.normpath(path.join(devuuid,os.readlink(x)))),
|
|
|
|
|
filter(path.islink,
|
|
|
|
|
listDirectory(devuuid,fullPath=True))))
|
|
|
|
|
map(lambda x:datafunc("UUID=%s"%x[UUID],
|
|
|
|
|
getUdevDeviceInfo(name=x[DEV]).get('DEVNAME',x[DEV])),
|
|
|
|
|
map(lambda x:x.groups(),
|
|
|
|
|
filter(lambda x:x,
|
|
|
|
|
map(reSplit.search,
|
|
|
|
|
blkidProcess)))))
|
|
|
|
|
|
|
|
|
|
def detectDeviceForPartition(dev):
|
|
|
|
|
"""Detect parent device for partition by /sys/block (sysfs)"""
|
|
|
|
|
reDeviceSplit = re.compile("^(.*/)?(.*?)(\d+)$")
|
|
|
|
|
device = map(lambda x:filter(lambda x:x in dev,
|
|
|
|
|
x[1]),
|
|
|
|
|
os.walk('/sys/block'))
|
|
|
|
|
if device:
|
|
|
|
|
device = device[0]
|
|
|
|
|
parentdevices = \
|
|
|
|
|
filter(lambda x: path.split(dev)[-1] in \
|
|
|
|
|
reduce(lambda y,z:y+z[1],
|
|
|
|
|
os.walk(path.join('/sys/block',x)),[]), device)
|
|
|
|
|
if parentdevices:
|
|
|
|
|
return parentdevices[0]
|
|
|
|
|
res = reDeviceSplit.search(dev)
|
|
|
|
|
if res:
|
|
|
|
|
return res.groups()[1]
|
|
|
|
|
"""Detect parent device for partition by udev and return property"""
|
|
|
|
|
prop = getUdevDeviceInfo(name=dev)
|
|
|
|
|
if prop.get('DEVTYPE','') != 'partition':
|
|
|
|
|
return ''
|
|
|
|
|
parentpath = path.dirname(prop.get('DEVPATH',''))
|
|
|
|
|
if parentpath:
|
|
|
|
|
devProp = getUdevDeviceInfo(path=parentpath)
|
|
|
|
|
return devProp.get('DEVNAME','')
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def getProgPath(progname):
|
|
|
|
|