예제 #1
0
파일: __init__.py 프로젝트: Sedl/servus
    def size(self):
        '''Returns the size of the disk in bytes

        :raises IOError: if the disk doesn't exist
        '''
        if self._size is not None:
            return self._size
        if self.is_blockdevice:
            self._size = blktools.get_disksize(self.majorminor)
        elif self._attached:
            self._size = blktools.get_disksize(self.majorminor)
        return self._size
예제 #2
0
파일: qemu.py 프로젝트: Sedl/servus
def next_nbd():
    '''Returns the next free nbd device'''
    nbds = [ os.path.join('/dev', d) for d in os.listdir('/dev') \
            if d.startswith('nbd')]
    ids = sorted([get_majorminor(os.path.join('/dev', nbd)) + (nbd,) \
            for nbd in nbds])
    for id_ in ids:
        if not get_disksize(id_[:2]):
            return id_[2]