Exemplo n.º 1
0
def _genEsxLocation():
    choices = userchoices.getPartitionMountRequests()

    if choices:
        assert len(choices) == 1
        bootReq = choices[0]
        comment = ""
    else:
        comment = \
            "# Uncomment the esxlocation line and comment out the clearpart\n" \
            "# and physical partitions to do a non-destructive reinstall.\n" \
            "#"
        for dev in userchoices.getPhysicalPartitionRequestsDevices():
            reqset = userchoices.getPhysicalPartitionRequests(dev)
            for req in reqset:
                if req.mountPoint == '/boot':
                    bootReq = req
                    break
    
    flags = ""
    if bootReq.clearContents:
        flags += " --clearcontents"
        
    flags += " --uuid=%s" % bootReq.fsType.getUuid(bootReq.consoleDevicePath)

    return "%sesxlocation%s\n" % (comment, flags)
Exemplo n.º 2
0
    def start(self):
        "Initial step."

        # ESX device is previous user choice or location of /boot.
        self.esxDeviceName = userchoices.getEsxPhysicalDevice()
        devs = userchoices.getPhysicalPartitionRequestsDevices()
        for dev in devs:
            request = userchoices.getPhysicalPartitionRequests(dev)
            if request.findRequestByMountPoint('/boot'):
                self.esxDeviceName = dev
        assert self.esxDeviceName

        self.clearDrives = [self.esxDeviceName]

        createNewDataStoreFunc = self.createNewDataStore
        if not devices.DiskSet()[self.esxDeviceName].supportsVmfs:
            createNewDataStoreFunc = self.createNewDataStoreDiffDev

        ui = {
            'title': title,
            'body': dataStoreText,
            'menu': {
                '1': createNewDataStoreFunc,
                '2': self.useExistingDataStore,
                '<': self.stepBack,
                '?': self.help,
            }
        }
        self.setSubstepEnv(ui)
Exemplo n.º 3
0
def _genEsxLocation():
    choices = userchoices.getPartitionMountRequests()

    if choices:
        assert len(choices) == 1
        bootReq = choices[0]
        comment = ""
    else:
        comment = \
            "# Uncomment the esxlocation line and comment out the clearpart\n" \
            "# and physical partitions to do a non-destructive reinstall.\n" \
            "#"
        for dev in userchoices.getPhysicalPartitionRequestsDevices():
            reqset = userchoices.getPhysicalPartitionRequests(dev)
            for req in reqset:
                if req.mountPoint == '/boot':
                    bootReq = req
                    break

    flags = ""
    if bootReq.clearContents:
        flags += " --clearcontents"

    flags += " --uuid=%s" % bootReq.fsType.getUuid(bootReq.consoleDevicePath)

    return "%sesxlocation%s\n" % (comment, flags)
Exemplo n.º 4
0
    def start(self):
        "Initial step."

        # ESX device is previous user choice or location of /boot.
        self.esxDeviceName = userchoices.getEsxPhysicalDevice()
        devs = userchoices.getPhysicalPartitionRequestsDevices()
        for dev in devs:
            request = userchoices.getPhysicalPartitionRequests(dev)
            if request.findRequestByMountPoint('/boot'):
                self.esxDeviceName = dev
        assert self.esxDeviceName

        self.clearDrives = [self.esxDeviceName]

        createNewDataStoreFunc = self.createNewDataStore
        if not devices.DiskSet()[self.esxDeviceName].supportsVmfs:
            createNewDataStoreFunc = self.createNewDataStoreDiffDev
        
        ui = {
            'title': title,
            'body': dataStoreText,
            'menu': {
                '1': createNewDataStoreFunc,
                '2': self.useExistingDataStore,
                '<': self.stepBack,
                '?': self.help,
            }
        }
        self.setSubstepEnv(ui)
Exemplo n.º 5
0
def reviewStorage(values):
    allReqs = partition.PartitionRequestSet()

    values['esxDriveName'] = ""

    newVmfs = False
    devices = userchoices.getPhysicalPartitionRequestsDevices()
    for dev in devices:
        reqs = userchoices.getPhysicalPartitionRequests(dev)
        reqs.fitRequestsOnDevice()
        bootPart = reqs.findRequestByMountPoint('/boot')
        if bootPart:
            values['esxDriveName'] = htmlEscape(dev)

        for req in reqs:
            if isinstance(req.fsType, fsset.vmfs3FileSystem):
                newVmfs = True
                
        allReqs += reqs

    if newVmfs:
        values['datastoreType'] = 'New'
    else:
        values['datastoreType'] = 'Existing'

    vdevices = userchoices.getVirtualDevices()
    for vdevChoice in vdevices:
        vdev = vdevChoice['device']
        values['datastoreName'] = htmlEscape(vdev.vmfsVolume)
        if vdev.physicalDeviceName:
            values['datastoreDev'] = htmlEscape(vdev.physicalDeviceName)
        else:
            datastoreSet = datastore.DatastoreSet()
            cosVolume = datastoreSet.getEntryByName(vdev.vmfsVolume)
            values['datastoreDev'] = htmlEscape(cosVolume.driveName)

    vdeviceNames = userchoices.getVirtualPartitionRequestsDevices()
    for vdevName in vdeviceNames:
        reqs = userchoices.getVirtualPartitionRequests(vdevName)
        reqs.fitRequestsOnDevice()
        allReqs += reqs

    values['datastoreParts'] = ""
    allReqs.sort(sortByMountPoint=True)
    for req in allReqs:
        size = util.formatValue(req.apparentSize * util.SIZE_MB)
        if req.mountPoint:
            mountPoint = htmlEscape(req.mountPoint)
        else:
            mountPoint = ""

        values['datastoreParts'] += (
            '<tabs count="1" />%s'
            '<tabs count="1" /><verbatim value="%10s" />'
            '<tabs count="1" />%s<br/>' % (req.fsType.name, size, mountPoint))
Exemplo n.º 6
0
def hostActionPartitionPhysicalDevices(context):
    requestDevices = userchoices.getPhysicalPartitionRequestsDevices()
    context.cb.pushStatusGroup(len(requestDevices))

    for deviceName in requestDevices:
        virtualDevs = \
            userchoices.getVirtualDevicesByPhysicalDeviceName(deviceName)

        requests = userchoices.getPhysicalPartitionRequests(deviceName)
        context.cb.pushStatus("Partitioning %s (%s)" %
                              (requests.device.name, requests.device.path))

        requests.sort()
        requests.fitPartitionsOnDevice()
        requests.savePartitions()

        # TODO: check for badblocks?

        createDeviceNodes()

        context.cb.pushStatusGroup(len(requests))
        for request in requests:
            if request.fsType.formattable:
                if request.fsType.name == "vmfs3":
                    path = requests.device.getPartitionDevicePath(
                        request.partitionId)
                    volumeName = request.fsType.volumeName

                    # If we don't have a name for the vmfs volume and
                    # we have a virtual device, then we need to set
                    # the volume name for autopartitioning.

                    # XXX - we're assuming that we only have one vmfs device
                    # per volume right now

                    if virtualDevs and not volumeName:
                        volumeName = fsset.findVmfsVolumeName()
                        request.fsType.volumeName = volumeName

                        assert len(virtualDevs) == 1

                        virtualDevs[0]['device'].vmfsVolume = volumeName
                else:
                    path = request.consoleDevicePath

                context.cb.pushStatus("Formatting %s" % path)
                request.fsType.formatDevice(path)
                context.cb.popStatus()
        context.cb.popStatusGroup()
        context.cb.popStatus()
    context.cb.popStatusGroup()
Exemplo n.º 7
0
def _genPhysicalPartitions():
    retval = ""

    for dev in userchoices.getPhysicalPartitionRequestsDevices():
        reqs = userchoices.getPhysicalPartitionRequests(dev)
        for req in reqs:
            partStr = _genPartitionRequest(dev, req)
            flags1 = " --ondisk=%s" % dev
            retval += "%s %s\n" % (partStr, flags1)

            if isFirstDisk([dev]):
                flags2 = " --onfirstdisk"
                retval += \
                    "# Uncomment to use first detected disk:\n" \
                    "#%s %s\n" % (partStr, flags2)

    return retval
Exemplo n.º 8
0
def _genPhysicalPartitions():
    retval = ""

    for dev in userchoices.getPhysicalPartitionRequestsDevices():
        reqs = userchoices.getPhysicalPartitionRequests(dev)
        for req in reqs:
            partStr = _genPartitionRequest(dev, req)
            flags1 = " --ondisk=%s" % dev
            retval += "%s %s\n" % (partStr, flags1)

            if isFirstDisk([dev]):
                flags2 = " --onfirstdisk"
                retval += \
                    "# Uncomment to use first detected disk:\n" \
                    "#%s %s\n" % (partStr, flags2)

    return retval
Exemplo n.º 9
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)
Exemplo n.º 10
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)
Exemplo n.º 11
0
def _allUserPartitionRequestSets():
    '''Return all the PartitionRequestSets in userchoices in a list.'''
    retval = []

    for physDevice in userchoices.getPhysicalPartitionRequestsDevices():
        retval.append(userchoices.getPhysicalPartitionRequests(physDevice))

    for virtDevice in userchoices.getVirtualPartitionRequestsDevices():
        if not userchoices.checkVirtualPartitionRequestsHasDevice(virtDevice):
            # no partitions on the vmdk
            continue

        retval.append(userchoices.getVirtualPartitionRequests(virtDevice))

    # Only add the partition mount requests if there are any, otherwise there
    # appears to be user partition requests when there really aren't.
    if userchoices.getPartitionMountRequests():
        mountSet = PartitionRequestSet()
        mountSet.requests = userchoices.getPartitionMountRequests()
        retval.append(mountSet)

    return retval
Exemplo n.º 12
0
def getPartitionRequestSize(dev):
    size = 0
    size += userchoices.getPhysicalPartitionRequests(dev).getMinimumSize()

    return size
Exemplo n.º 13
0
def getPartitionRequestSize(dev):
    size = 0
    size += userchoices.getPhysicalPartitionRequests(dev).getMinimumSize()

    return size