Beispiel #1
0
def findXenSourceProducts():
    """Scans the host and finds XenSource product installations.
    Returns list of ExistingInstallation objects.

    Currently requires supervisor privileges due to mounting
    filesystems."""

    installs = []

    for disk in diskutil.getQualifiedDiskList():
        (boot, root, state, storage, logs) = diskutil.probeDisk(disk)

        inst = None
        try:
            if root[0] == diskutil.INSTALL_RETAIL:
                inst = ExistingRetailInstallation(disk, boot[1], root[1],
                                                  state[1], storage)
        except Exception, e:
            xelogging.log(
                "A problem occurred whilst scanning for existing installations:"
            )
            xelogging.log_exception(e)
            xelogging.log("This is not fatal.  Continuing anyway.")

        if inst:
            xelogging.log("Found an installation: %s on %s" %
                          (str(inst), disk))
            installs.append(inst)
Beispiel #2
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
Beispiel #3
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, 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
Beispiel #4
0
def findXenSourceProducts():
    """Scans the host and finds XenSource product installations.
    Returns list of ExistingInstallation objects.

    Currently requires supervisor privileges due to mounting
    filesystems."""

    installs = []

    for disk in diskutil.getQualifiedDiskList():
        (boot, state, storage) = diskutil.probeDisk(disk)

        inst = None
        try:
            if boot[0] == diskutil.INSTALL_RETAIL:
                inst = ExistingRetailInstallation(disk, boot[1], state[1], storage)
        except Exception, e:
            xelogging.log("A problem occurred whilst scanning for existing installations:")
            xelogging.log_exception(e)
            xelogging.log("This is not fatal.  Continuing anyway.")

        if inst:
            xelogging.log("Found an installation: %s" % str(inst))
            installs.append(inst)
Beispiel #5
0
def sorted_disk_list():
    return sorted(set(diskutil.getQualifiedDiskList()),
                  lambda x, y: len(x) == len(y) and cmp(x, y) or (len(x) - len(y)))
Beispiel #6
0
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
Beispiel #7
0
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