def _genBoot(): flags = "" choice = userchoices.getBoot() if choice['doNotInstall']: flags += " --location=none" else: flags += " --location=%s" % choice['location'] if choice['kernelParams']: flags += " --append='%s'" % shquote(choice['kernelParams']) if choice['password']: flagName = "--password" if choice['passwordType'] == userchoices.BOOT_PASSWORD_TYPE_MD5: flagName = "--md5pass" flags += " %s='%s'" % (flagName, shquote(choice['password'])) if choice['driveOrder']: flags += " --driveorder=%s" % ",".join( [disk.name for disk in choice['driveOrder']]) if choice['upgrade']: flags += " --upgrade" return "bootloader %s\n" % flags
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
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
def _genVirtualPartitions(): retval = "" for vdev in userchoices.getVirtualPartitionRequestsDevices(): reqs = userchoices.getVirtualPartitionRequests(vdev) for req in reqs: partStr = _genPartitionRequest(vdev, req) retval += "%s --onvirtualdisk='%s'\n" % (partStr, shquote(vdev)) return retval
def _genPartitionRequest(dev, req): flags = "" flags += " --fstype=%s" % req.fsType.name if isinstance(req.fsType, fsset.vmfs3FileSystem): virtDev = userchoices.getVirtualDevicesByPhysicalDeviceName(dev) if len(virtDev): assert len(virtDev) == 1 virtDevName = virtDev[0]['device'].name if userchoices.checkVirtualPartitionRequestsHasDevice(virtDevName): virtualRequests = userchoices.getVirtualPartitionRequests( virtDevName) virtSize = virtualRequests.getMinimumSize() + \ devices.VMDK_OVERHEAD_SIZE if req.minimumSize < virtSize: req.minimumSize = virtSize flags += " --size=%d" % req.minimumSize if req.maximumSize: flags += " --maxsize=%d" % req.maximumSize if req.grow: flags += " --grow" if req.primaryPartition: flags += " --asprimary" if req.badBlocks: flags += " --badblocks" partName = req.mountPoint if not partName: if isinstance(req.fsType, fsset.vmfs3FileSystem): partName = req.fsType.volumeName elif isinstance(req.fsType, fsset.swapFileSystem): partName = "swap" return "part '%s' %s" % (shquote(partName or "none"), flags)
def cmpQuotedString(stringToQuote): shellString = "'%s'" % grubupdate.shquote(stringToQuote) actual = shlex.split(shellString)[0] assert stringToQuote == actual
def _genTimezone(): choice = userchoices.getTimezone() flags = "" return "timezone%s '%s'\n" % (flags, shquote(choice['tzName']))