Пример #1
0
    def commit(self):
        """Commit updates.  By the time we get here, we assume:
        * volume name has been sanity checked
        * requested size has been checked
        """

        assert self.deviceName, 'datastore device name not set'
        assert self.volumeName, 'datastore volume name not set'
        log.debug("DataStoreWindow.commit device %s volume %s" %
                  (self.deviceName, self.volumeName))

        # Check if drives to clear are in use; if so stop this madness.
        diskSet = devices.DiskSet()
        if self.deviceName == self.esxDeviceName:
            clearDrives = [self.deviceName]
        else:
            clearDrives = [self.deviceName, self.esxDeviceName]
            # presumably self.choseCreateNewDatastoreOnEsxDevice == False

        log.debug("Cleared drives = %s" % (', '.join(clearDrives)))
        volumePath = os.path.join('/vmfs/volumes', self.volumeName)

        if (os.path.exists(volumePath) or os.path.islink(volumePath)) \
           and not checkForClearedVolume(clearDrives, self.datastoreSet,
                                         self.volumeName):
            log.debug("Volume name in use")
            self.setSubstepEnv({'next': self.warnInUse})
            return

        # build partition requests, add to userchoices
        partition.addDefaultPartitionRequests(diskSet[self.esxDeviceName],
                                              False)

        if self.choseCreateNewDatastore:
            physicalRequests = [
                (None, 100, 0, True, fsset.vmfs3FileSystem(self.volumeName)),
            ]
            dev = diskSet[self.deviceName]
            userchoices.addPhysicalPartitionRequests(
                self.deviceName,
                partition.createPartitionRequestSet(dev, physicalRequests))

            userchoices.setClearPartitions(drives=clearDrives)

            userchoices.setEsxDatastoreDevice(dev.name)
            userchoices.setVmdkDatastore(self.volumeName)
        else:  # use existing datastore
            userchoices.setClearPartitions(drives=[self.esxDeviceName])

            userchoices.clearVirtualDevices()

            userchoices.setEsxDatastoreDevice(None)
            userchoices.setVmdkDatastore(self.volumeName)

        # size check
        size = partition.getRequestsSize(partition.getDefaultVirtualRequests())
        if size > devices.runtimeActionFindMaxVmdkSize():
            self.setSubstepEnv({'next': self.warnTooSmall})
            return
        self.setSubstepEnv({'next': self.stepForward})
Пример #2
0
    def commit(self):
        """Commit updates.  By the time we get here, we assume:
        * volume name has been sanity checked
        * requested size has been checked
        """

        assert self.deviceName, 'datastore device name not set'
        assert self.volumeName, 'datastore volume name not set'
        log.debug("DataStoreWindow.commit device %s volume %s" %
                (self.deviceName, self.volumeName))

        # Check if drives to clear are in use; if so stop this madness.
        diskSet = devices.DiskSet()
        if self.deviceName == self.esxDeviceName:
            clearDrives = [self.deviceName]
        else:
            clearDrives = [self.deviceName, self.esxDeviceName]
            # presumably self.choseCreateNewDatastoreOnEsxDevice == False

        log.debug("Cleared drives = %s" % (', '.join(clearDrives)))
        volumePath = os.path.join('/vmfs/volumes', self.volumeName)

        if (os.path.exists(volumePath) or os.path.islink(volumePath)) \
           and not checkForClearedVolume(clearDrives, self.datastoreSet,
                                         self.volumeName):
            log.debug("Volume name in use")
            self.setSubstepEnv({'next': self.warnInUse})
            return

        # build partition requests, add to userchoices
        partition.addDefaultPartitionRequests(diskSet[self.esxDeviceName],
                                              False)

        if self.choseCreateNewDatastore:
            physicalRequests = [
                (None, 100, 0, True, fsset.vmfs3FileSystem(self.volumeName)),
            ]
            dev = diskSet[self.deviceName]
            userchoices.addPhysicalPartitionRequests(self.deviceName,
                partition.createPartitionRequestSet(dev, physicalRequests))

            userchoices.setClearPartitions(drives=clearDrives)

            userchoices.setEsxDatastoreDevice(dev.name)
            userchoices.setVmdkDatastore(self.volumeName)
        else:   # use existing datastore
            userchoices.setClearPartitions(drives=[self.esxDeviceName])

            userchoices.clearVirtualDevices()

            userchoices.setEsxDatastoreDevice(None)
            userchoices.setVmdkDatastore(self.volumeName)

        # size check
        size = partition.getRequestsSize(partition.getDefaultVirtualRequests())
        if size > devices.runtimeActionFindMaxVmdkSize():
            self.setSubstepEnv({'next': self.warnTooSmall})
            return
        self.setSubstepEnv({'next': self.stepForward})
Пример #3
0
    def getNext(self):
        haveMountPoint = bool(userchoices.getPartitionMountRequests())

        userchoices.clearPhysicalPartitionRequests()
        userchoices.clearPartitionMountRequests()
        userchoices.clearExistingVmdkLocation()

        (model, diskIter) = self.view.get_selection().get_selected()
        if diskIter and model.get(diskIter, STORAGEVIEW_DISK_ENTRY)[0]:
            drive = model.get(diskIter, STORAGEVIEW_DISK_ENTRY)[0]

            log.debug("Selected drive %s" % (drive))

            diskSet = devices.DiskSet()
            datastoreSet = datastore.DatastoreSet()

            rc = storage_widgets.promptDeviceHasExistingData(drive)

            if rc == storage_widgets.EXISTING_DATA_STAY_ON_SCREEN:
                raise exception.StayOnScreen
            elif rc == storage_widgets.EXISTING_DATA_PRESERVE_VMFS:
                vmdkPath = \
                    esxconf.runtimeActionExtractVmdkPathFromInitrd(drive)
                vmdkSize = \
                    devices.runtimeActionFindExistingVmdkSize(vmdkPath)

                log.debug("VMDK Size = %d Path = %s" % (vmdkSize, vmdkPath))

                if vmdkSize > 0:
                    vmdkCheckBox = True

                    # only turn off the preserveVmdk check button if
                    # we're on the install location screen since the user
                    # can choose to put the vmdk on a different datastore
                    # on the esxlocation screen

                    if self.SCREEN_NAME == 'installlocation':
                        ds = datastoreSet.getEntriesByDriveName(drive)[0]
                        freeSize = ds.getFreeSize() / 1024 / 1024
                        requestSize = partition.getRequestsSize(
                                          partition.getDefaultVirtualRequests())

                        if freeSize + vmdkSize <= requestSize + VMFS_OVERHEAD:
                            MessageWindow(None, "No Free Space",
                                storage_widgets.COSVMDK_TOTALLY_FULL)
                            raise exception.StayOnScreen

                        elif freeSize < requestSize:
                            vmdkCheckBox = False

                    preserveVmdk = PreserveCosVmdkWindow(vmdkCheckBox).run()
                    if preserveVmdk == -1:
                        raise exception.StayOnScreen
                    elif preserveVmdk == 1:
                        pass
                    else:
                        userchoices.setExistingVmdkLocation(vmdkPath)

                # Set up virtual disk and settings
                datastore.preserveDatastoreOnDrive(drive)

                if self.SCREEN_NAME == 'esxlocation':
                    userchoices.setEsxPhysicalDevice(drive)
                    userchoices.setResetEsxLocation(True)

            elif rc == storage_widgets.EXISTING_DATA_CLEAR_DRIVE:
                if self.SCREEN_NAME == 'installlocation':
                    partition.addDefaultPartitionRequests(diskSet[drive])

                else:
                    # clear out the datastore options if the user has changed
                    # their mind about which drive to use -- this will get
                    # changed back to false on the next screen
                    if drive != userchoices.getEsxPhysicalDevice() or \
                       haveMountPoint:
                        userchoices.setResetEsxLocation(True)
                    else:
                        userchoices.setResetEsxLocation(False)

                    userchoices.setEsxPhysicalDevice(drive)
            else:
                raise ValueError, "Got unexpected return code"

        else:
            MessageWindow(self.controlState.gui.getWindow(),
                "Storage Selection Error",
                "You must select a place to install ESX.")
            raise exception.StayOnScreen
Пример #4
0
                    "No datastore has been selected. "
                    "Select a datatore for ESX to use.")
                raise exception.StayOnScreen

            if not self.preserveVmfs:
                partition.addDefaultPartitionRequests(
                    self.diskSet[self.defaultDeviceName], False)

                userchoices.setClearPartitions(drives=[self.defaultDeviceName])

            userchoices.setEsxDatastoreDevice(None)
            userchoices.setVmdkDatastore(_vmfsVolume)

        # find the size of the virtual partitions and then remove the
        # size of any existing COS since it can be removed to free up space
        size = partition.getRequestsSize(partition.getDefaultVirtualRequests())
        size += VMFS_OVERHEAD

        if self.vmdkSize > 0:
            size -= self.vmdkSize

        if size > devices.runtimeActionFindMaxVmdkSize():
            MessageWindow(None, "No Free Space",
                          storage_widgets.COSVMDK_TOTALLY_FULL)
            raise exception.StayOnScreen

        #print "Max vmdk = %d" % devices.runtimeActionFindMaxVmdkSize()


class CreateDataStoreWindow(CommonWindow):
    def __init__(self, xml, diskSet, parent):
Пример #5
0
    def getNext(self):
        haveMountPoint = bool(userchoices.getPartitionMountRequests())

        userchoices.clearPhysicalPartitionRequests()
        userchoices.clearPartitionMountRequests()
        userchoices.clearExistingVmdkLocation()

        (model, diskIter) = self.view.get_selection().get_selected()
        if diskIter and model.get(diskIter, STORAGEVIEW_DISK_ENTRY)[0]:
            drive = model.get(diskIter, STORAGEVIEW_DISK_ENTRY)[0]

            log.debug("Selected drive %s" % (drive))

            diskSet = devices.DiskSet()
            datastoreSet = datastore.DatastoreSet()

            rc = storage_widgets.promptDeviceHasExistingData(drive)

            if rc == storage_widgets.EXISTING_DATA_STAY_ON_SCREEN:
                raise exception.StayOnScreen
            elif rc == storage_widgets.EXISTING_DATA_PRESERVE_VMFS:
                vmdkPath = \
                    esxconf.runtimeActionExtractVmdkPathFromInitrd(drive)
                vmdkSize = \
                    devices.runtimeActionFindExistingVmdkSize(vmdkPath)

                log.debug("VMDK Size = %d Path = %s" % (vmdkSize, vmdkPath))

                if vmdkSize > 0:
                    vmdkCheckBox = True

                    # only turn off the preserveVmdk check button if
                    # we're on the install location screen since the user
                    # can choose to put the vmdk on a different datastore
                    # on the esxlocation screen

                    if self.SCREEN_NAME == 'installlocation':
                        ds = datastoreSet.getEntriesByDriveName(drive)[0]
                        freeSize = ds.getFreeSize() / 1024 / 1024
                        requestSize = partition.getRequestsSize(
                            partition.getDefaultVirtualRequests())

                        if freeSize + vmdkSize <= requestSize + VMFS_OVERHEAD:
                            MessageWindow(None, "No Free Space",
                                          storage_widgets.COSVMDK_TOTALLY_FULL)
                            raise exception.StayOnScreen

                        elif freeSize < requestSize:
                            vmdkCheckBox = False

                    preserveVmdk = PreserveCosVmdkWindow(vmdkCheckBox).run()
                    if preserveVmdk == -1:
                        raise exception.StayOnScreen
                    elif preserveVmdk == 1:
                        pass
                    else:
                        userchoices.setExistingVmdkLocation(vmdkPath)

                # Set up virtual disk and settings
                datastore.preserveDatastoreOnDrive(drive)

                if self.SCREEN_NAME == 'esxlocation':
                    userchoices.setEsxPhysicalDevice(drive)
                    userchoices.setResetEsxLocation(True)

            elif rc == storage_widgets.EXISTING_DATA_CLEAR_DRIVE:
                if self.SCREEN_NAME == 'installlocation':
                    partition.addDefaultPartitionRequests(diskSet[drive])

                else:
                    # clear out the datastore options if the user has changed
                    # their mind about which drive to use -- this will get
                    # changed back to false on the next screen
                    if drive != userchoices.getEsxPhysicalDevice() or \
                       haveMountPoint:
                        userchoices.setResetEsxLocation(True)
                    else:
                        userchoices.setResetEsxLocation(False)

                    userchoices.setEsxPhysicalDevice(drive)
            else:
                raise ValueError, "Got unexpected return code"

        else:
            MessageWindow(self.controlState.gui.getWindow(),
                          "Storage Selection Error",
                          "You must select a place to install ESX.")
            raise exception.StayOnScreen
Пример #6
0
                    "No datastore has been selected. "
                    "Select a datatore for ESX to use.")
                raise exception.StayOnScreen 

            if not self.preserveVmfs:
                partition.addDefaultPartitionRequests(
                    self.diskSet[self.defaultDeviceName], False)

                userchoices.setClearPartitions(drives=[self.defaultDeviceName])
            
            userchoices.setEsxDatastoreDevice(None)
            userchoices.setVmdkDatastore(_vmfsVolume)

        # find the size of the virtual partitions and then remove the
        # size of any existing COS since it can be removed to free up space
        size = partition.getRequestsSize(partition.getDefaultVirtualRequests())
        size += VMFS_OVERHEAD

        if self.vmdkSize > 0:
            size -= self.vmdkSize

        if size > devices.runtimeActionFindMaxVmdkSize():
            MessageWindow(None, "No Free Space",
                storage_widgets.COSVMDK_TOTALLY_FULL)
            raise exception.StayOnScreen

        #print "Max vmdk = %d" % devices.runtimeActionFindMaxVmdkSize()


class CreateDataStoreWindow(CommonWindow):
    def __init__(self, xml, diskSet, parent):