#!/usr/bin/python import storage env = storage.Environment(True) c = storage.createStorageInterface(env) containers = storage.DequeContainerInfo() c.getContainers(containers) for container in containers: print "Device:", container.device if container.type == storage.DISK: diskinfo = storage.DiskInfo() c.getDiskInfo(container.name, diskinfo) print " Size:", storage.byteToHumanString(1024 * diskinfo.sizeK, True, 2, False) print " Cylinder Size:", storage.byteToHumanString(diskinfo.cylSize, True, 2, False) partitioninfos = storage.DequePartitionInfo() c.getPartitionInfo(container.name, partitioninfos) for partitioninfo in partitioninfos: print " Device:", partitioninfo.v.device print " Size:", storage.byteToHumanString(1024 * partitioninfo.v.sizeK, True, 2, False)
#!/usr/bin/python from storage import Environment, createStorageInterface, saveDeviceGraph, saveMountGraph, destroyStorageInterface env = Environment(True) c = createStorageInterface(env) saveDeviceGraph(c, "device.gv") saveMountGraph(c, "mount.gv") destroyStorageInterface(c)
#!/usr/bin/python import storage storage.initDefaultLogger() env = storage.Environment(True) storageInterface = storage.createStorageInterface(env) rootdev = "/dev/system/root" swapdev = "/dev/system/swap" bootdev = "/dev/sda1" nodev = "/dev/system/xyz123" disk = "/dev/sdb" print storageInterface.getIgnoreFstab(rootdev) print storageInterface.getCrypt(rootdev) print storageInterface.getMountPoint(rootdev) print storageInterface.getMountPoint(swapdev) print storageInterface.getMountPoint("/dev/system/space") print storageInterface.getMountPoint(nodev) print storageInterface.nextFreePartition(disk, storage.PRIMARY) print storageInterface.nextFreeMd() print "MOUNTBY DEVICE:", storage.MOUNTBY_DEVICE, " UUID:", storage.MOUNTBY_UUID, " LABEL:", storage.MOUNTBY_LABEL, " ID:", storage.MOUNTBY_ID, " PATH:", storage.MOUNTBY_PATH print storageInterface.getMountBy(rootdev) print storageInterface.getMountBy(bootdev) print storageInterface.getDefaultMountBy() storage.destroyStorageInterface(storageInterface)