Exemple #1
0
    def getSizeInMegabytes(self):
        assert self.sizeUnit in ['KB', 'MB']

        if self.sizeUnit == 'MB':
            return self.size
        elif self.sizeUnit == 'KB':
            return util.getValueInMegabytesFromSectors(self.size,
                                                       self.sectorSize)
Exemple #2
0
    def getSizeInMegabytes(self):
        assert self.sizeUnit in ['KB', 'MB']

        if self.sizeUnit == 'MB':
            return self.size
        elif self.sizeUnit == 'KB':
            return util.getValueInMegabytesFromSectors(self.size,
                                                       self.sectorSize)
Exemple #3
0
    def __str__(self):
        buf = ""
        for entry in self.partitions:
            length = entry.getLength()

            buf += "%d: pos=%d start=%d end=%d size=%d (%d MB)\n" % \
            (entry.partitionType, entry.partitionId, entry.startSector,
             entry.endSector, length,
             util.getValueInMegabytesFromSectors(length))
        return buf
Exemple #4
0
def runtimeActionFindMaxVmdkSize():
    '''Look through userchoices settings and determine how large we can allow
       the vmdk to be.
    '''

    datastoreSet = None

    devName = userchoices.getEsxDatastoreDevice()

    # find the free space on an existing datastore
    if not devName:
        volumeName = userchoices.getVmdkDatastore()

        datastoreSet = datastore.DatastoreSet()
        vol = datastoreSet.getEntryByName(volumeName)
        assert vol

        # Max vmdk size is 256 * fileblocksize from
        # File_VMFSSupportsFileSize in filePosix.c

        return min(vol.getFreeSize() / util.SIZE_MB / util.SIZE_MB,
                   vol.blockSize * 256 / util.SIZE_MB)

    else:
        dev = DiskSet()[devName]

        # get the physical size of the device
        size = util.getValueInMegabytesFromSectors(dev.size, dev.sectorSize)

        requests = userchoices.getPhysicalPartitionRequests(dev.name)
        assert requests

        # we have to guess how big the vmfs3 partition is going to be, so
        # remove any other partitions on the disk from our total size
        for req in requests:
            if not req.grow and req.fsType.name != 'vmfs3':
                size -= req.minimumSize

        return min(fsset.vmfs3FileSystem.blockSizeMB * 256 * util.SIZE_MB,
                   size - VMDK_OVERHEAD_SIZE)
Exemple #5
0
def runtimeActionFindMaxVmdkSize():
    '''Look through userchoices settings and determine how large we can allow
       the vmdk to be.
    '''

    datastoreSet = None

    devName = userchoices.getEsxDatastoreDevice()

    # find the free space on an existing datastore
    if not devName:
        volumeName = userchoices.getVmdkDatastore()

        datastoreSet = datastore.DatastoreSet()
        vol = datastoreSet.getEntryByName(volumeName)
        assert vol

        # Max vmdk size is 256 * fileblocksize from
        # File_VMFSSupportsFileSize in filePosix.c

        return min(vol.getFreeSize() / util.SIZE_MB / util.SIZE_MB,
                   vol.blockSize * 256 / util.SIZE_MB)

    else:
        dev = DiskSet()[devName]
        
        # get the physical size of the device
        size = util.getValueInMegabytesFromSectors(dev.size, dev.sectorSize)

        requests = userchoices.getPhysicalPartitionRequests(dev.name)
        assert requests

        # we have to guess how big the vmfs3 partition is going to be, so
        # remove any other partitions on the disk from our total size
        for req in requests:
            if not req.grow and req.fsType.name != 'vmfs3':
                size -= req.minimumSize

        return min(fsset.vmfs3FileSystem.blockSizeMB * 256 * util.SIZE_MB,
                   size - VMDK_OVERHEAD_SIZE)
Exemple #6
0
 def getSizeInMegabytes(self):
     return util.getValueInMegabytesFromSectors(self.getLength())