Пример #1
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))
Пример #2
0
def hostActionMountFileSystems(context):
    # XXX - we only use one virtual device for now
    virtualDevs = userchoices.getVirtualDevices()
    assert len(virtualDevs) == 1 or len(virtualDevs) == 0

    requests = allUserPartitionRequests()
    requests.sort(sortByMountPoint=True)

    for request in requests:
        # skip vmfs partitions since they can't be mounted
        if not request.mountPoint:
            continue

        mountPoint = os.path.normpath(consts.HOST_ROOT + request.mountPoint)

        if not os.path.exists(mountPoint):
            os.makedirs(mountPoint)

        log.debug("Mounting %s -> %s" % \
                  (request.consoleDevicePath, mountPoint))
        request.fsType.mount(request.consoleDevicePath, mountPoint)

        if request.clearContents:
            # Clear out the contents of the drive.  Removing the files might be
            # preferable to a reformat since we preserve the UUID.
            for name in os.listdir(mountPoint):
                path = os.path.join(mountPoint, name)
                if os.path.isdir(path):
                    shutil.rmtree(path)
                else:
                    os.remove(path)

    if userchoices.getUpgrade():
        upgradeMounts = [(consts.ESX3_INSTALLATION,
                          userchoices.getRootUUID()['uuid'])]

        if userchoices.isCombinedBootAndRootForUpgrade():
            log.debug("Linking boot")
            # No /boot partition, need to create a link to the old one.
            os.symlink(
                os.path.join(consts.ESX3_INSTALLATION.lstrip('/'), "boot"),
                os.path.join(consts.HOST_ROOT, "boot"))
        else:
            upgradeMounts.append(("/boot", userchoices.getBootUUID()['uuid']))

        for partMountPoint, uuid in upgradeMounts:
            mountPoint = os.path.normpath(consts.HOST_ROOT + partMountPoint)
            if not os.path.exists(mountPoint):
                os.makedirs(mountPoint)

            log.debug("Mounting %s -> %s" % (uuid, mountPoint))
            rc = util.mount(uuid, mountPoint, isUUID=True)
            assert rc == 0  # TODO: handle errors
Пример #3
0
def testAddDefaultPartitionRequests():
    setupDoubleDiskPartitions()

    diskSet = devices.DiskSet(forceReprobe=True)
    partition.addDefaultPartitionRequests(diskSet["vml.1111"])
    partition.addDefaultPartitionRequests(diskSet["vml.1112"])

    assert len(userchoices.getPhysicalPartitionRequestsDevices()) == 1
    assert len(userchoices.getVirtualPartitionRequestsDevices()) == 1
    assert len(userchoices.getVirtualDevices()) == 1

    assert userchoices.getPhysicalPartitionRequestsDevices()[0] == \
           'vml.1112'
Пример #4
0
    def setupVirtualDevice(self):
        # If the virtual device has already been set up before, use the
        # the requests in it, otherwise start with a fresh set
        virtualDevs = userchoices.getVirtualDevices()
        assert len(virtualDevs) == 1

        virtualDev = virtualDevs[0]['device']

        # Update these since they might have been changed by the prev screen.
        virtualDev.physicalDeviceName = userchoices.getEsxDatastoreDevice()
        virtualDev.vmfsVolume = userchoices.getVmdkDatastore()

        self.requests = userchoices.getVirtualPartitionRequests(virtualDev.name)
Пример #5
0
    def commit(self):
        virtualDevs = userchoices.getVirtualDevices()
        assert len(virtualDevs) == 1

        # set the size of the vmdk
        virtualDevs[0]['device'].size = self.requests.getMinimumSize()

        errors = partition.sanityCheckPartitionRequests(checkSizing=True)
        if errors:
            msg = errInvalidPartitionsText + '\n\n'.join(errors)
            self.errorPushPop(title, msg + TransMenu.Back)
            return

        self.setSubstepEnv({'next': self.stepForward})
Пример #6
0
    def setupVirtualDevice(self):
        # If the virtual device has already been set up before, use the
        # the requests in it, otherwise start with a fresh set
        virtualDevs = userchoices.getVirtualDevices()
        assert len(virtualDevs) == 1

        virtualDev = virtualDevs[0]['device']

        # Update these since they might have been changed by the prev screen.
        virtualDev.physicalDeviceName = userchoices.getEsxDatastoreDevice()
        virtualDev.vmfsVolume = userchoices.getVmdkDatastore()

        self.requests = userchoices.getVirtualPartitionRequests(
            virtualDev.name)
Пример #7
0
    def commit(self):
        virtualDevs = userchoices.getVirtualDevices()
        assert len(virtualDevs) == 1

        # set the size of the vmdk
        virtualDevs[0]['device'].size = self.requests.getMinimumSize()

        errors = partition.sanityCheckPartitionRequests(checkSizing=True)
        if errors:
            msg = errInvalidPartitionsText + '\n\n'.join(errors)
            self.errorPushPop(title, msg + TransMenu.Back)
            return

        self.setSubstepEnv({'next': self.stepForward})
Пример #8
0
    def getNext(self):
        virtualDevs = userchoices.getVirtualDevices()
        assert len(virtualDevs) == 1

        # set the size of the vmdk
        virtualDevs[0]['device'].size = self.requests.getMinimumSize()

        errors = partition.sanityCheckPartitionRequests(checkSizing=True)
        if errors:
            msg = '\n\n'.join(errors)
            MessageWindow(None,
                          "Invalid Partition Layout",
                          "The following error(s) were detected with the "
                          "current partition layout:\n\n%s" % msg)
            raise exception.StayOnScreen
Пример #9
0
    def _buildDisksToSearch(self, searchVirtual=False):
        '''Build a list of disks to search, including non-standard disks and,
        optionally, virtual disks.
        '''

        retval = self.disks.values()

        # TODO: it's kind of ugly that this has knowledge of userchoices
        #       in the future, this knowledge should be removed.
        if searchVirtual:
            virtualDevices = userchoices.getVirtualDevices()
            for virtualDevice in virtualDevices:
                virtDiskDev = virtualDevice['device']
                retval.append(virtDiskDev)

        retval.extend(self.nonStandardDisks)

        return retval
Пример #10
0
    def _buildDisksToSearch(self, searchVirtual=False):
        '''Build a list of disks to search, including non-standard disks and,
        optionally, virtual disks.
        '''
        
        retval = self.disks.values()
        
        # TODO: it's kind of ugly that this has knowledge of userchoices
        #       in the future, this knowledge should be removed.
        if searchVirtual:
            virtualDevices = userchoices.getVirtualDevices()
            for virtualDevice in virtualDevices:
                virtDiskDev = virtualDevice['device']
                retval.append( virtDiskDev )

        retval.extend(self.nonStandardDisks)

        return retval
Пример #11
0
def _genVirtualDisk():
    retval = ""

    for vdevDict in userchoices.getVirtualDevices():
        vdev = vdevDict['device']
        flags = ""

        flags += " --size=%d" % vdev.size

        m = re.match(r'^[^\-]+-\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$', vdev.imagePath)
        if not m:
            flags += " --path='%s'" % shquote(
                "%s/%s" % (vdev.imagePath, vdev.imageName))
        flags += " --onvmfs='%s'" % shquote(vdev.vmfsVolume)

        retval += "virtualdisk '%s'%s\n" % (shquote(vdev.name), flags)

    return retval
Пример #12
0
def _genVirtualDisk():
    retval = ""

    for vdevDict in userchoices.getVirtualDevices():
        vdev = vdevDict['device']
        flags = ""

        flags += " --size=%d" % vdev.size

        m = re.match(r'^[^\-]+-\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$',
                     vdev.imagePath)
        if not m:
            flags += " --path='%s'" % shquote("%s/%s" %
                                              (vdev.imagePath, vdev.imageName))
        flags += " --onvmfs='%s'" % shquote(vdev.vmfsVolume)

        retval += "virtualdisk '%s'%s\n" % (shquote(vdev.name), flags)

    return retval
Пример #13
0
    def __init__(self):
        super(SetupVmdkWindow, self).__init__()
        self.substep = self.start

        self.diskSet = devices.DiskSet()
        self.maxVmdkSize = devices.runtimeActionFindMaxVmdkSize()

        self.requests = None

        # Download the package data so we can figure out the minimum partition
        # sizes
        weaselConfig = systemsettings.WeaselConfig()
        packagesXML = packages.getPackagesXML(weaselConfig.packageGroups)
        packageData = packages.PackageData(packagesXML.fullInstallDepot)

        self.fileSizes = packageData.fileDict

        if not userchoices.getVirtualDevices():
            self.reset()
        else:
            self.setupVirtualDevice()
Пример #14
0
    def __init__(self):
        super(SetupVmdkWindow, self).__init__()
        self.substep = self.start

        self.diskSet = devices.DiskSet()
        self.maxVmdkSize = devices.runtimeActionFindMaxVmdkSize()

        self.requests = None

        # Download the package data so we can figure out the minimum partition
        # sizes
        weaselConfig = systemsettings.WeaselConfig()
        packagesXML = packages.getPackagesXML(weaselConfig.packageGroups)
        packageData = packages.PackageData(packagesXML.fullInstallDepot)

        self.fileSizes = packageData.fileDict

        if not userchoices.getVirtualDevices():
            self.reset()
        else:
            self.setupVirtualDevice()
Пример #15
0
    def setupVirtualDevice(self):
        # If the virtual device has already been set up before, use the
        # the requests in it, otherwise start with a fresh set
        virtualDevs = userchoices.getVirtualDevices()
        assert len(virtualDevs) == 1

        virtualDev = virtualDevs[0]['device']

        # Update these since they might have been changed by the prev screen.
        virtualDev.physicalDeviceName = userchoices.getEsxDatastoreDevice()
        virtualDev.vmfsVolume = userchoices.getVmdkDatastore()

        self.requests = userchoices.getVirtualPartitionRequests(virtualDev.name)

        self.setConsoleVMSize()
        # TODO: If the datastore was changed and it is too small to fit the
        # current vmdk partitioning scheme we need to do a reset.
        
        storage_widgets.setupPartitioningView(self.view)
        storage_widgets.populatePartitioningModel(self.view, self.scrolled,
                                                  self.requests)
Пример #16
0
def hostActionPartitionVirtualDevices(context):
    virtualDevs = userchoices.getVirtualDevices()
    assert len(virtualDevs) == 1 or len(virtualDevs) == 0

    if not virtualDevs:
        return

    # There's two steps for each dev, partitioning it and formatting the parts.
    context.cb.pushStatusGroup(len(virtualDevs) * 2)
    # XXX - we only care about one virtual device for now
    virtualDevs[0]['device'].create()
    virtualDevs[0]['device'].mount()

    deviceName = virtualDevs[0]['device'].name

    context.cb.pushStatus("Partitioning %s" % deviceName)
    if userchoices.checkVirtualPartitionRequestsHasDevice(deviceName):
        requests = userchoices.getVirtualPartitionRequests(deviceName)
        requests.device = virtualDevs[0]['device']
        requests.sort()
        requests.fitPartitionsOnDevice()
        requests.savePartitions()
    else:
        # The virtualdisk does not have any partitions (can happen in scripted
        # install...)
        requests = []
    context.cb.popStatus()

    createDeviceNodes()

    context.cb.pushStatus("Formatting Virtual Devices")
    context.cb.pushStatusGroup(len(requests))
    for request in requests:
        if request.fsType.formattable:
            context.cb.pushStatus("Formatting %s" % request.consoleDevicePath)
            request.fsType.formatDevice(request.consoleDevicePath)
            context.cb.popStatus()
    context.cb.popStatusGroup()
    context.cb.popStatus()
    context.cb.popStatusGroup()
Пример #17
0
def hostActionSetupVmdk(_context):
    virtualDevs = userchoices.getVirtualDevices()
    assert len(virtualDevs) == 1

    virtualDev = virtualDevs[0]['device']

    vmfsVolPath = ""

    dsSet = datastore.DatastoreSet()
    for ds in dsSet:
        if virtualDev.vmfsVolume in (ds.name, ds.uuid):
            vmfsVolPath = ds.consolePath

    assert vmfsVolPath, "no console path for %s" % virtualDev.vmfsVolume

    path = os.path.normpath(
        os.path.join(vmfsVolPath, virtualDev.imagePath, virtualDev.imageName))

    sysInfo = vmkctl.SystemInfoImpl()
    try:
        sysInfo.SetServiceConsoleVmdk(path)
    except vmkctl.HostCtlException, msg:
        log.warn("Couldn't set vmdk path.  The system may not boot correctly.")
Пример #18
0
def hostActionSetupVmdk(_context):
    virtualDevs = userchoices.getVirtualDevices()
    assert len(virtualDevs) == 1

    virtualDev = virtualDevs[0]['device']

    vmfsVolPath = ""

    dsSet = datastore.DatastoreSet()
    for ds in dsSet:
        if virtualDev.vmfsVolume in (ds.name, ds.uuid):
            vmfsVolPath = ds.consolePath

    assert vmfsVolPath, "no console path for %s" % virtualDev.vmfsVolume

    path = os.path.normpath(
        os.path.join(vmfsVolPath, virtualDev.imagePath, virtualDev.imageName))

    sysInfo = vmkctl.SystemInfoImpl()
    try:
        sysInfo.SetServiceConsoleVmdk(path)
    except vmkctl.HostCtlException, msg:
        log.warn("Couldn't set vmdk path.  The system may not boot correctly.")
Пример #19
0
def removeOldVirtualDevices():
    for oldVirtDevice in userchoices.getVirtualPartitionRequestsDevices():
        userchoices.delVirtualPartitionRequests(oldVirtDevice)

    for oldVirtualDevice in userchoices.getVirtualDevices():
        userchoices.delVirtualDevice(oldVirtualDevice)