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})
def getNext(self): global _deviceName, _vmfsVolume if self.xml.get_widget('DatastorecreateRadioButton').get_active(): if self.xml.get_widget('DatastoreCheckButton').get_active(): deviceName = self.defaultDeviceName else: deviceName = _deviceName if not deviceName: MessageWindow(None, 'Invalid Datastore Device', 'Specify a device for creating the datastore.') raise exception.StayOnScreen # Set the volume name for the new vmfs partition volumeName = self.xml.get_widget("DatastorenameEntry").get_text() try: fsset.vmfs3FileSystem.sanityCheckVolumeLabel(volumeName) except ValueError, msg: MessageWindow(None, "Datastore Name Invalid", msg[0]) raise exception.StayOnScreen # if we're using the same disk for the datastore that we're # using for installing esx, only clear one disk, otherwise # clear both if deviceName == self.defaultDeviceName or self.preserveVmfs: clearDrives = [deviceName] else: clearDrives = [deviceName, self.defaultDeviceName] volumePath = os.path.join('/vmfs/volumes', volumeName) if (os.path.exists(volumePath) or os.path.islink(volumePath)) \ and not checkForClearedVolume(clearDrives, self.datastoreSet, volumeName): MessageWindow(None, "Datastore Name Already Used", "The specified name is already used by another datastore. " "Specify a new name that is unique.") raise exception.StayOnScreen # if we're preserving the vmfs partition on a different drive # then we don't need the full set of partitions. if not self.preserveVmfs: partition.addDefaultPartitionRequests( self.diskSet[self.defaultDeviceName], False) physicalRequests = [ (None, 100, 0, True, fsset.vmfs3FileSystem(volumeName)), ] dev = self.diskSet[deviceName] userchoices.addPhysicalPartitionRequests(dev.name, partition.createPartitionRequestSet(dev, physicalRequests)) userchoices.setClearPartitions(drives=clearDrives) userchoices.setEsxDatastoreDevice(dev.name) userchoices.setVmdkDatastore(volumeName)
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})
def getNext(self): global _deviceName, _vmfsVolume if self.xml.get_widget('DatastorecreateRadioButton').get_active(): if self.xml.get_widget('DatastoreCheckButton').get_active(): deviceName = self.defaultDeviceName else: deviceName = _deviceName if not deviceName: MessageWindow(None, 'Invalid Datastore Device', 'Specify a device for creating the datastore.') raise exception.StayOnScreen # Set the volume name for the new vmfs partition volumeName = self.xml.get_widget("DatastorenameEntry").get_text() try: fsset.vmfs3FileSystem.sanityCheckVolumeLabel(volumeName) except ValueError, msg: MessageWindow(None, "Datastore Name Invalid", msg[0]) raise exception.StayOnScreen # if we're using the same disk for the datastore that we're # using for installing esx, only clear one disk, otherwise # clear both if deviceName == self.defaultDeviceName or self.preserveVmfs: clearDrives = [deviceName] else: clearDrives = [deviceName, self.defaultDeviceName] volumePath = os.path.join('/vmfs/volumes', volumeName) if (os.path.exists(volumePath) or os.path.islink(volumePath)) \ and not checkForClearedVolume(clearDrives, self.datastoreSet, volumeName): MessageWindow( None, "Datastore Name Already Used", "The specified name is already used by another datastore. " "Specify a new name that is unique.") raise exception.StayOnScreen # if we're preserving the vmfs partition on a different drive # then we don't need the full set of partitions. if not self.preserveVmfs: partition.addDefaultPartitionRequests( self.diskSet[self.defaultDeviceName], False) physicalRequests = [ (None, 100, 0, True, fsset.vmfs3FileSystem(volumeName)), ] dev = self.diskSet[deviceName] userchoices.addPhysicalPartitionRequests( dev.name, partition.createPartitionRequestSet(dev, physicalRequests)) userchoices.setClearPartitions(drives=clearDrives) userchoices.setEsxDatastoreDevice(dev.name) userchoices.setVmdkDatastore(volumeName)
userchoices.setVmdkDatastore(volumeName) else: if not _vmfsVolume: MessageWindow( None, "Invalid Datastore", "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
userchoices.setEsxDatastoreDevice(dev.name) userchoices.setVmdkDatastore(volumeName) else: if not _vmfsVolume: MessageWindow(None, "Invalid Datastore", "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