示例#1
0
def get_local_disk(answers):
    diskEntries = diskutil.getQualifiedDiskList()

    entries = []
    target_is_sr = {}

    for de in diskEntries:
        (vendor, model, size) = diskutil.getExtendedDiskInfo(de)
        # determine current usage
        target_is_sr[de] = False
        (boot, root, state, storage, logs) = diskutil.probeDisk(de)
        if storage[0]:
            target_is_sr[de] = True
        (vendor, model, size) = diskutil.getExtendedDiskInfo(de)
        stringEntry = "%s - %s [%s %s]" % (diskutil.getHumanDiskName(de),
                                           diskutil.getHumanDiskSize(size),
                                           vendor, model)
        e = (stringEntry, de)
        entries.append(e)

    # default value:
    default = None
    if 'dest-disk' in answers:
        default = selectDefault(answers['dest-disk'], entries)

    tui.update_help_line([None, "<F5> more info"])

    scroll, height = snackutil.scrollHeight(4, len(entries))
    (button, entry) = snackutil.ListboxChoiceWindowEx(
        tui.screen,
        "Select Device",
        "Please select the device to store the report on.",
        entries, ['Ok', 'Back'],
        55,
        scroll,
        height,
        default,
        help='getlocaldisk:info',
        hotkeys={'F5': disk_more_info})

    tui.screen.popHelpLine()

    if button == 'back': return uicontroller.LEFT_BACKWARDS

    # entry contains the 'de' part of the tuple passed in
    answers['dest-disk'] = entry

    return uicontroller.RIGHT_FORWARDS
示例#2
0
文件: report.py 项目: xtha/pxe
def get_local_disk(answers):
    diskEntries = diskutil.getQualifiedDiskList()

    entries = []
    target_is_sr = {}
    
    for de in diskEntries:
        (vendor, model, size) = diskutil.getExtendedDiskInfo(de)
        # determine current usage
        target_is_sr[de] = False
        (boot, state, storage) = diskutil.probeDisk(de)
        if storage[0]:
            target_is_sr[de] = True
        (vendor, model, size) = diskutil.getExtendedDiskInfo(de)
        stringEntry = "%s - %s [%s %s]" % (diskutil.getHumanDiskName(de), diskutil.getHumanDiskSize(size), vendor, model)
        e = (stringEntry, de)
        entries.append(e)

    # default value:
    default = None
    if 'dest-disk' in answers:
        default = selectDefault(answers['dest-disk'], entries)

    tui.update_help_line([None, "<F5> more info"])

    scroll, height = snackutil.scrollHeight(4, len(entries))
    (button, entry) = snackutil.ListboxChoiceWindowEx(
        tui.screen,
        "Select Device",
        "Please select the device to store the report on.",
        entries,
        ['Ok', 'Back'], 55, scroll, height, default, help = 'getlocaldisk:info',
        hotkey = 'F5', hotkey_cb = disk_more_info)

    tui.screen.popHelpLine()

    if button == 'back': return uicontroller.LEFT_BACKWARDS

    # entry contains the 'de' part of the tuple passed in
    answers['dest-disk'] = entry

    return uicontroller.RIGHT_FORWARDS
示例#3
0
def raid_array_ui(answers):
    disk_entries = sorted_disk_list()
    raid_disks = [de for de in disk_entries if diskutil.is_raid(de)]
    raid_slaves = [slave for master in raid_disks for slave in diskutil.getDeviceSlaves(master)]
    entries = []
    for de in disk_entries:
        if de not in raid_slaves and de not in raid_disks:
            vendor, model, size = diskutil.getExtendedDiskInfo(de)
            string_entry = "%s - %s [%s %s]" % (
                diskutil.getHumanDiskName(de), diskutil.getHumanDiskSize(size), vendor, model)
            entries.append((string_entry, de))
    if len(entries) < 2:
        return SKIP_SCREEN
    text = TextboxReflowed(54, "Do you want to group disks in a software RAID 1 array?  \n\n" +
                           "The array will be created immediately and erase all the target disks.")
    buttons = ButtonBar(tui.screen, [('Create', 'create'), ('Back', 'back')])
    scroll, _ = snackutil.scrollHeight(3, len(entries))
    cbt = CheckboxTree(3, scroll)
    for (c_text, c_item) in entries:
        cbt.append(c_text, c_item, False)
    gf = GridFormHelp(tui.screen, 'RAID Array', 'guestdisk:info', 1, 4)
    gf.add(text, 0, 0, padding=(0, 0, 0, 1))
    gf.add(cbt, 0, 1, padding=(0, 0, 0, 1))
    gf.add(buttons, 0, 3, growx=1)
    gf.addHotKey('F5')

    tui.update_help_line([None, "<F5> disk info"])
    loop = True
    while loop:
        rc = gf.run()
        if rc == 'F5':
            disk_more_info(cbt.getCurrent())
        else:
            loop = False
    tui.screen.popWindow()
    tui.screen.popHelpLine()

    button = buttons.buttonPressed(rc)
    if button == 'create':
        selected = cbt.getSelection()
        txt = 'The content of the disks %s will be deleted when you activate "Ok"' % (str(selected))
        title = 'RAID array creation'
        confirmation = snackutil.ButtonChoiceWindowEx(tui.screen, title, txt, ('Ok', 'Cancel'), 40, default=1)
        if confirmation == 'ok':
            answers['raid'] = {'/dev/md127': selected}
            tui.progress.showMessageDialog("Please wait", "Creating raid array...")
            diskutil.create_raid(answers['raid'])
            tui.progress.clearModelessDialog()
    return REPEAT_STEP
示例#4
0
def select_guest_disks(answers):
    diskEntries = filter_out_raid_member(sorted_disk_list())

    # CA-38329: filter out device mapper nodes (except primary disk) as these won't exist
    # at XenServer boot and therefore cannot be added as physical volumes to Local SR.
    # Also, since the DM nodes are multipathed SANs it doesn't make sense to include them
    # in the "Local" SR.
    allowed_in_local_sr = lambda dev: (dev == answers['primary-disk']) or (not isDeviceMapperNode(dev))
    diskEntries = filter(allowed_in_local_sr, diskEntries)

    if len(diskEntries) == 0 or constants.CC_PREPARATIONS:
        answers['guest-disks'] = []
        return SKIP_SCREEN

    # set up defaults:
    if answers.has_key('guest-disks'):
        currently_selected = answers['guest-disks']
    else:
        currently_selected = answers['primary-disk']
    srtype = constants.SR_TYPE_LVM
    if 'sr-type' in answers:
        srtype = answers['sr-type']

    # Make a list of entries: (text, item)
    entries = []
    for de in diskEntries:
        (vendor, model, size) = diskutil.getExtendedDiskInfo(de)
        entry = "%s - %s [%s %s]" % (diskutil.getHumanDiskName(de), diskutil.getHumanDiskSize(size), vendor, model)
        entries.append((entry, de))
        
    text = TextboxReflowed(54, "Which disks would you like to use for %s storage?  \n\nOne storage repository will be created that spans the selected disks.  You can choose not to prepare any storage if you wish to create an advanced configuration after installation." % BRAND_GUEST)
    buttons = ButtonBar(tui.screen, [('Ok', 'ok'), ('Back', 'back')])
    scroll, _ = snackutil.scrollHeight(3, len(entries))
    cbt = CheckboxTree(3, scroll)
    for (c_text, c_item) in entries:
        cbt.append(c_text, c_item, c_item in currently_selected)
    txt = "Use EXT instead of LVM for local storage repository"
    tb = Checkbox(txt, srtype == constants.SR_TYPE_EXT and 1 or 0)

    explanations = Textbox(54, 2,
                           "LVM: block based. May be faster. Thick provisioning.\n"
                           "EXT: file based. May be slower. Thin provisioning.")

    gf = GridFormHelp(tui.screen, 'Virtual Machine Storage', 'guestdisk:info', 1, 5)
    gf.add(text, 0, 0, padding = (0, 0, 0, 1))
    gf.add(cbt, 0, 1, padding = (0, 0, 0, 1))
    gf.add(tb, 0, 2, padding = (0, 0, 0, 0))
    gf.add(explanations, 0, 3, padding = (0, 0, 0, 1))
    gf.add(buttons, 0, 4, growx = 1)
    gf.addHotKey('F5')
    
    tui.update_help_line([None, "<F5> more info"])

    loop = True
    while loop:
        rc = gf.run()
        if rc == 'F5':
            disk_more_info(cbt.getCurrent())
        else:
            loop = False
    tui.screen.popWindow()
    tui.screen.popHelpLine()
    
    button = buttons.buttonPressed(rc)
    
    if button == 'back': return LEFT_BACKWARDS

    answers['guest-disks'] = cbt.getSelection()
    answers['sr-type'] = tb.selected() and constants.SR_TYPE_EXT or constants.SR_TYPE_LVM
    answers['sr-on-primary'] = answers['primary-disk'] in answers['guest-disks']

    # if the user select no disks for guest storage, check this is what
    # they wanted:
    if answers['guest-disks'] == []:
        button = ButtonChoiceWindow(
            tui.screen,
            "Warning",
            """You didn't select any disks for %s storage.  Are you sure this is what you want?

If you proceed, please refer to the user guide for details on provisioning storage after installation.""" % BRAND_GUEST,
            ['Continue', 'Back'], help = 'noguest'
            )
        if button == 'back': return REPEAT_STEP

    return RIGHT_FORWARDS
示例#5
0
def select_primary_disk(answers):
    button = None
    diskEntries = filter_out_raid_member(sorted_disk_list())
    entries = []
    target_is_sr = {}

    if answers['create-new-partitions']:
        min_primary_disk_size = constants.min_primary_disk_size
    else:
        min_primary_disk_size = constants.min_primary_disk_size_old
    for de in diskEntries:
        (vendor, model, size) = diskutil.getExtendedDiskInfo(de)
        if min_primary_disk_size <= diskutil.blockSizeToGBSize(size):
            # determine current usage
            target_is_sr[de] = False
            (boot, root, state, storage, logs) = diskutil.probeDisk(de)
            if storage[0]:
                target_is_sr[de] = True
            (vendor, model, size) = diskutil.getExtendedDiskInfo(de)
            stringEntry = "%s - %s [%s %s]" % (diskutil.getHumanDiskName(de), diskutil.getHumanDiskSize(size), vendor, model)
            e = (stringEntry, de)
            entries.append(e)

    # we should have at least one disk
    if len(entries) == 0:
        ButtonChoiceWindow(tui.screen,
                           "No Primary Disk",
                           "No disk with sufficient space to install %s on was found." % MY_PRODUCT_BRAND,
                           ['Cancel'])
        return EXIT

    # if only one disk, set default:
    if len(entries) == 1:
        answers['primary-disk'] = entries[0][1]
    else:
        # default value:
        default = None
        if answers.has_key('primary-disk'):
            default = selectDefault(answers['primary-disk'], entries)

        tui.update_help_line([None, "<F5> more info"])

        scroll, height = snackutil.scrollHeight(4, len(entries))
        (button, entry) = snackutil.ListboxChoiceWindowEx(
            tui.screen,
            "Select Primary Disk",
            """Please select the disk you would like to install %s on (disks with insufficient space are not shown).

You may need to change your system settings to boot from this disk.""" % (MY_PRODUCT_BRAND),
            entries,
            ['Ok', 'Software RAID', 'Back'], 55, scroll, height, default, help = 'pridisk:info',
            hotkeys = {'F5': disk_more_info})

        tui.screen.popHelpLine()

        # entry contains the 'de' part of the tuple passed in
        answers['primary-disk'] = entry

    if 'installation-to-overwrite' in answers:
        answers['target-is-sr'] = target_is_sr[answers['primary-disk']]

    # Warn if not all of the disk is usable.
    # This can happen if we are unable to use GPT because we are currently
    # using DOS and need to preserve some utility partitions.
    blocks = diskutil.getDiskDeviceSize(answers['primary-disk'])
    tool = PartitionTool(answers['primary-disk'])
    if diskutil.blockSizeToGBSize(blocks) > constants.max_primary_disk_size_dos and tool.partTableType == 'DOS':
        if constants.GPT_SUPPORT and tool.utilityPartitions():
            val = snackutil.ButtonChoiceWindowEx(tui.screen,
                               "Large Disk Detected",
                               "The disk selected is larger than the %d GB limit imposed by the DOS partitioning scheme.  Would you like to remove the OEM partitions that require the DOS partitioning scheme, so that the whole disk can be used?" % constants.max_primary_disk_size_dos,
                               ['Yes', 'No'], default=1)
            answers['zap-utility-partitions'] = (val == 'yes')
        elif not constants.GPT_SUPPORT:
            ButtonChoiceWindow(tui.screen,
                               "Large Disk Detected",
                               "The disk selected to install %s to is greater than %d GB.  The partitioning scheme is limited to this value and therefore the remainder of this disk will be unavailable." % (MY_PRODUCT_BRAND, constants.max_primary_disk_size_dos),
                               ['Ok'])

    if button == None: return RIGHT_FORWARDS
    if button == 'software raid':
        return raid_array_ui(answers)
    if button == 'back': return LEFT_BACKWARDS

    return RIGHT_FORWARDS
示例#6
0
文件: screens.py 项目: xtha/pxe
def select_guest_disks(answers):
    diskEntries = diskutil.getQualifiedDiskList()

    # CA-38329: filter out device mapper nodes (except primary disk) as these won't exist
    # at XenServer boot and therefore cannot be added as physical volumes to Local SR.
    # Also, since the DM nodes are multipathed SANs it doesn't make sense to include them
    # in the "Local" SR.
    allowed_in_local_sr = lambda dev: (dev == answers['primary-disk']) or (not isDeviceMapperNode(dev))
    diskEntries = filter(allowed_in_local_sr, diskEntries)

    if len(diskEntries) == 0:
        answers['guest-disks'] = []
        return SKIP_SCREEN

    # set up defaults:
    if answers.has_key('guest-disks'):
        currently_selected = answers['guest-disks']
    else:
        currently_selected = answers['primary-disk']
    srtype = constants.SR_TYPE_LVM
    if 'sr-type' in answers:
        srtype = answers['sr-type']

    # Make a list of entries: (text, item)
    entries = []
    for de in diskEntries:
        (vendor, model, size) = diskutil.getExtendedDiskInfo(de)
        entry = "%s - %s [%s %s]" % (diskutil.getHumanDiskName(de), diskutil.getHumanDiskSize(size), vendor, model)
        entries.append((entry, de))
        
    text = TextboxReflowed(54, "Which disks would you like to use for %s storage?  \n\nOne storage repository will be created that spans the selected disks.  You can choose not to prepare any storage if you wish to create an advanced configuration after installation." % BRAND_GUEST)
    buttons = ButtonBar(tui.screen, [('Ok', 'ok'), ('Back', 'back')])
    scroll, _ = snackutil.scrollHeight(3, len(entries))
    cbt = CheckboxTree(3, scroll)
    for (c_text, c_item) in entries:
        cbt.append(c_text, c_item, c_item in currently_selected)
    tb = Checkbox("Enable thin provisioning (Optimized storage for XenDesktop)",
                  srtype == constants.SR_TYPE_EXT and 1 or 0)
    
    gf = GridFormHelp(tui.screen, 'Virtual Machine Storage', 'guestdisk:info', 1, 4)
    gf.add(text, 0, 0, padding = (0, 0, 0, 1))
    gf.add(cbt, 0, 1, padding = (0, 0, 0, 1))
    gf.add(tb, 0, 2, padding = (0, 0, 0, 1))
    gf.add(buttons, 0, 3, growx = 1)
    gf.addHotKey('F5')
    
    tui.update_help_line([None, "<F5> more info"])

    loop = True
    while loop:
        rc = gf.run()
        if rc == 'F5':
            disk_more_info(cbt.getCurrent())
        else:
            loop = False
    tui.screen.popWindow()
    tui.screen.popHelpLine()
    
    button = buttons.buttonPressed(rc)
    
    if button == 'back': return LEFT_BACKWARDS

    answers['guest-disks'] = cbt.getSelection()
    answers['sr-type'] = tb.selected() and constants.SR_TYPE_EXT or constants.SR_TYPE_LVM

    # if the user select no disks for guest storage, check this is what
    # they wanted:
    if answers['guest-disks'] == []:
        button = ButtonChoiceWindow(
            tui.screen,
            "Warning",
            """You didn't select any disks for %s storage.  Are you sure this is what you want?

If you proceed, please refer to the user guide for details on provisioning storage after installation.""" % BRAND_GUEST,
            ['Continue', 'Back'], help = 'noguest'
            )
        if button == 'back': return REPEAT_STEP

    return RIGHT_FORWARDS
示例#7
0
文件: screens.py 项目: xtha/pxe
def select_primary_disk(answers):
    button = None
    diskEntries = diskutil.getQualifiedDiskList()

    entries = []
    target_is_sr = {}
    
    for de in diskEntries:
        (vendor, model, size) = diskutil.getExtendedDiskInfo(de)
        if constants.min_primary_disk_size <= diskutil.blockSizeToGBSize(size):
            # determine current usage
            target_is_sr[de] = False
            (boot, state, storage) = diskutil.probeDisk(de)
            if storage[0]:
                target_is_sr[de] = True
            (vendor, model, size) = diskutil.getExtendedDiskInfo(de)
            stringEntry = "%s - %s [%s %s]" % (diskutil.getHumanDiskName(de), diskutil.getHumanDiskSize(size), vendor, model)
            e = (stringEntry, de)
            entries.append(e)

    # we should have at least one disk
    if len(entries) == 0:
        ButtonChoiceWindow(tui.screen,
                           "No Primary Disk",
                           "No disk with sufficient space to install %s on was found." % MY_PRODUCT_BRAND,
                           ['Cancel'])
        return EXIT

    # if only one disk, set default:
    if len(entries) == 1:
        answers['primary-disk'] = entries[0][1]
    else:
        # default value:
        default = None
        if answers.has_key('primary-disk'):
            default = selectDefault(answers['primary-disk'], entries)

        tui.update_help_line([None, "<F5> more info"])

        scroll, height = snackutil.scrollHeight(4, len(entries))
        (button, entry) = snackutil.ListboxChoiceWindowEx(
            tui.screen,
            "Select Primary Disk",
            """Please select the disk you would like to install %s on (disks with insufficient space are not shown).

You may need to change your system settings to boot from this disk.""" % (MY_PRODUCT_BRAND),
            entries,
            ['Ok', 'Back'], 55, scroll, height, default, help = 'pridisk:info',
            hotkey = 'F5', hotkey_cb = disk_more_info)

        tui.screen.popHelpLine()

        # entry contains the 'de' part of the tuple passed in
        answers['primary-disk'] = entry

    if 'installation-to-overwrite' in answers:
        answers['target-is-sr'] = target_is_sr[answers['primary-disk']]

    # Warn if not all of the disk is usable.
    # This can happen if we are unable to use GPT because we are currently
    # using DOS and need to preserve some utility partitions.
    blocks = diskutil.getDiskDeviceSize(answers['primary-disk'])
    tool = PartitionTool(answers['primary-disk'])
    if diskutil.blockSizeToGBSize(blocks) > constants.max_primary_disk_size_dos and tool.partTableType == 'DOS':
        if constants.GPT_SUPPORT and tool.utilityPartitions():
            val = snackutil.ButtonChoiceWindowEx(tui.screen,
                               "Large Disk Detected",
                               "The disk selected is larger than the %d GB limit imposed by the DOS partitioning scheme.  Would you like to remove the OEM partitions that require the DOS partitioning scheme, so that the whole disk can be used?" % constants.max_primary_disk_size_dos,
                               ['Yes', 'No'], default=1)
            answers['zap-utility-partitions'] = (val == 'yes')
        else:
            ButtonChoiceWindow(tui.screen,
                               "Large Disk Detected",
                               "The disk selected to install %s to is greater than %d GB.  The partitioning scheme is limited to this value and therefore the remainder of this disk will be unavailable." % (MY_PRODUCT_BRAND, constants.max_primary_disk_size_dos),
                               ['Ok'])

    if button == None: return SKIP_SCREEN
    if button == 'back': return LEFT_BACKWARDS

    return RIGHT_FORWARDS