Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
 def cmpQuotedString(stringToQuote):
     shellString = "'%s'" % grubupdate.shquote(stringToQuote)
     actual = shlex.split(shellString)[0]
     
     assert stringToQuote == actual
Ejemplo n.º 10
0
def _genTimezone():
    choice = userchoices.getTimezone()

    flags = ""
    
    return "timezone%s '%s'\n" % (flags, shquote(choice['tzName']))
Ejemplo n.º 11
0
def _genTimezone():
    choice = userchoices.getTimezone()

    flags = ""

    return "timezone%s '%s'\n" % (flags, shquote(choice['tzName']))
Ejemplo n.º 12
0
    def cmpQuotedString(stringToQuote):
        shellString = "'%s'" % grubupdate.shquote(stringToQuote)
        actual = shlex.split(shellString)[0]

        assert stringToQuote == actual