Esempio n. 1
0
def disk_more_info(context):
    if not context: return True

    usage = 'unknown'
    (boot, root, state, storage, logs) = diskutil.probeDisk(context)
    if root[0]:
        usage = "%s installation" % MY_PRODUCT_BRAND
    elif storage[0]:
        usage = 'VM storage'
    else:
        # Determine disk is being used as an LVM SR with no partitioning
        rv, out = util.runCmd2([ 'pvs', context, '-o', 'vg_name', '--noheadings' ], with_stdout=True)
        if rv == 0:
            vg_name = out.strip()
            if vg_name.startswith('VG_XenStorage-'):
                usage = 'VM Storage'

    tui.update_help_line([' ', ' '])
    snackutil.TableDialog(tui.screen, "Details", ("Disk:", diskutil.getHumanDiskName(context)),
                          ("Vendor:", diskutil.getDiskDeviceVendor(context)),
                          ("Model:", diskutil.getDiskDeviceModel(context)),
                          ("Serial:", diskutil.getDiskSerialNumber(context)),
                          ("Size:", diskutil.getHumanDiskSize(diskutil.getDiskDeviceSize(context))),
                          ("Current usage:", usage))
    tui.screen.popHelpLine()
    return True
Esempio n. 2
0
File: screens.py Progetto: xtha/pxe
def disk_more_info(context):
    if not context: return True

    usage = 'unknown'
    (boot, state, storage) = diskutil.probeDisk(context)
    if boot[0]:
        usage = "%s installation" % MY_PRODUCT_BRAND
    elif storage[0]:
        usage = 'VM storage'
    else:
        # Determine disk is being used as an LVM SR with no partitioning
        rv, out = util.runCmd2([ 'pvs', context, '-o', 'vg_name', '--noheadings' ], with_stdout=True)
        if rv == 0:
            vg_name = out.strip()
            if vg_name.startswith('VG_XenStorage-'):
                usage = 'VM Storage'

    tui.update_help_line([' ', ' '])
    snackutil.TableDialog(tui.screen, "Details", ("Disk:", diskutil.getHumanDiskName(context)),
                          ("Vendor:", diskutil.getDiskDeviceVendor(context)),
                          ("Model:", diskutil.getDiskDeviceModel(context)),
                          ("Serial:", diskutil.getDiskSerialNumber(context)),
                          ("Size:", diskutil.getHumanDiskSize(diskutil.getDiskDeviceSize(context))),
                          ("Current usage:", usage))
    tui.screen.popHelpLine()
    return True
Esempio n. 3
0
File: report.py Progetto: xtha/pxe
def disk_more_info(context):
    if not context: return True

    usage = 'unknown'
    (boot, state, storage) = diskutil.probeDisk(context)
    if boot[0]:
        usage = "%s installation" % (PRODUCT_BRAND or PLATFORM_NAME)
    elif storage[0]:
        usage = 'VM storage'

    tui.update_help_line([' ', ' '])
    snackutil.TableDialog(tui.screen, "Details", ("Disk:", diskutil.getHumanDiskName(context)),
                          ("Vendor:", diskutil.getDiskDeviceVendor(context)),
                          ("Model:", diskutil.getDiskDeviceModel(context)),
                          ("Size:", diskutil.getHumanDiskSize(diskutil.getDiskDeviceSize(context))),
                          ("Current usage:", usage))
    tui.screen.popHelpLine()
    return True
Esempio n. 4
0
def disk_more_info(context):
    if not context: return True

    usage = 'unknown'
    (boot, root, state, storage, logs) = diskutil.probeDisk(context)
    if root[0]:
        usage = "%s installation" % (PRODUCT_BRAND or PLATFORM_NAME)
    elif storage[0]:
        usage = 'VM storage'

    tui.update_help_line([' ', ' '])
    snackutil.TableDialog(
        tui.screen, "Details", ("Disk:", diskutil.getHumanDiskName(context)),
        ("Vendor:", diskutil.getDiskDeviceVendor(context)),
        ("Model:", diskutil.getDiskDeviceModel(context)),
        ("Size:", diskutil.getHumanDiskSize(
            diskutil.getDiskDeviceSize(context))), ("Current usage:", usage))
    tui.screen.popHelpLine()
    return True
Esempio n. 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
Esempio n. 6
0
File: screens.py Progetto: 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