def confirm_proceed(): b = snackutil.ButtonChoiceWindowEx( tui.screen, "Confirm Local Disk Format", "WARNING: proceeding with this installation will reinstall your local hard disk with %s %s" % (PRODUCT_BRAND, PRODUCT_VERSION), ['Proceed', 'Cancel'], default=1, width=50) return b in ['proceed', None]
def confirm_restore(backup_partition, disk): b = snackutil.ButtonChoiceWindowEx( tui.screen, "Confirm Restore", "Are you sure you want to restore your installation on %s with the backup on %s?\n\nYour existing installation will be overwritten with the backup (though VMs will still be intact).\n\nTHIS OPERATION CANNOT BE UNDONE." % (disk[5:], backup_partition[5:]), ['Restore', 'Cancel'], default=1, width=50) return b in ['restore', None]
def use_extra_media(answers): rc = snackutil.ButtonChoiceWindowEx( tui.screen, "Supplemental Packs", "Would you like to install any Supplemental Packs?", ['Yes', 'No'], default=1, help='suppack' ) answers['more-media'] = (rc != 'no') return RIGHT_FORWARDS
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
def overwrite_warning(answers): warning_string = "Continuing will result in a clean installation, all existing configuration will be lost." if PRODUCT_VERSION: warning_string += "\n\nAlternatively, please contact a Technical Support Representative for the recommended upgrade path." button = snackutil.ButtonChoiceWindowEx( tui.screen, "Warning", ("Only product installations that cannot be upgraded have been detected.\n\n%s" % warning_string), ['Ok', 'Back'], width = 60, help = "overwrtwarn", default = 1, ) if button == 'back': return LEFT_BACKWARDS return RIGHT_FORWARDS
def eula_screen(answers): eula_file = open(constants.EULA_PATH, 'r') eula = string.join(eula_file.readlines()) eula_file.close() while True: button = snackutil.ButtonChoiceWindowEx( tui.screen, "End User License Agreement", eula, ['Accept EULA', 'Back'], width=60, default=1, help = 'eula') if button == 'accept eula': return RIGHT_FORWARDS elif button == 'back': return LEFT_BACKWARDS else: ButtonChoiceWindow( tui.screen, "End User License Agreement", "You must select 'Accept EULA' (by highlighting it with the cursor keys, then pressing either Space or Enter) in order to install this product.", ['Ok'])
def confirm_installation(answers): if answers['install-type'] == constants.INSTALL_TYPE_RESTORE: backup = answers['backup-to-restore'] label = "Confirm Restore" text = "Are you sure you want to restore your installation with the backup on %s?\n\nYour existing installation will be overwritten with the backup (though VMs will still be intact).\n\nTHIS OPERATION CANNOT BE UNDONE." % diskutil.getHumanDiskName(backup.partition) ok = 'Restore %s' % MY_PRODUCT_BRAND else: label = "Confirm Installation" text1 = "We have collected all the information required to install %s. " % MY_PRODUCT_BRAND if answers['install-type'] == constants.INSTALL_TYPE_FRESH: disks = map(diskutil.getHumanDiskName, answers['guest-disks']) if diskutil.getHumanDiskName(answers['primary-disk']) not in disks: disks.append(diskutil.getHumanDiskName(answers['primary-disk'])) disks.sort() if len(disks) == 1: term = 'disk' else: term = 'disks' disks_used = generalui.makeHumanList(disks) text2 = "Please confirm you wish to proceed: all data on %s %s will be destroyed!" % (term, disks_used) elif answers['install-type'] == constants.INSTALL_TYPE_REINSTALL: if answers['primary-disk'] == answers['installation-to-overwrite'].primary_disk: text2 = "The installation will be performed over %s" % str(answers['installation-to-overwrite']) else: text2 = "Setup will migrate the %s installation from %s to %s" % (str(answers['installation-to-overwrite']), diskutil.getHumanDiskName(answers['installation-to-overwrite'].primary_disk), diskutil.getHumanDiskName(answers['primary-disk'])) text2 += ", preserving existing %s in your storage repository." % BRAND_GUESTS text = text1 + "\n\n" + text2 ok = 'Install %s' % MY_PRODUCT_BRAND button = snackutil.ButtonChoiceWindowEx( tui.screen, label, text, [ok, 'Back'], default = 1, width = 50, help = 'confirm' ) if button == None or button == 'back': return LEFT_BACKWARDS return RIGHT_FORWARDS
def backup_existing_installation(answers): # default selection: if answers.has_key('backup-existing-installation'): if answers['backup-existing-installation']: default = 0 else: default = 1 else: default = 0 button = snackutil.ButtonChoiceWindowEx( tui.screen, "Back-up Existing Installation?", """Would you like to back-up your existing installation before re-installing %s? The backup will be placed on the backup partition of the destination disk (%s), overwriting any previous backups on that volume.""" % (MY_PRODUCT_BRAND, answers['installation-to-overwrite'].primary_disk), ['Yes', 'No', 'Back'], default = default, help = 'optbackup' ) if button == 'back': return LEFT_BACKWARDS answers['backup-existing-installation'] = (button == 'yes') return RIGHT_FORWARDS
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
def welcome_screen(answers): driver_answers = {'driver-repos': []} tui.update_help_line([None, "<F9> load driver"]) def load_driver(driver_answers): tui.screen.popHelpLine() tui.update_help_line([None, ' ']) drivers = driver.doInteractiveLoadDriver(tui, driver_answers) xelogging.log(drivers) xelogging.log(driver_answers) if drivers[0]: if 'extra-repos' not in answers: answers['extra-repos'] = [] answers['extra-repos'].append(drivers) return True global loop global popup loop = True def fn9(): global loop global popup loop = True popup = 'driver' return False def fn10(): global loop global popup loop = True popup = 'storage' return False while loop: loop = False popup = None driver_answers['network-hardware'] = answers['network-hardware'] = netutil.scanConfiguration() button = snackutil.ButtonChoiceWindowEx(tui.screen, "Welcome to %s Setup" % MY_PRODUCT_BRAND, """This setup tool can be used to install or upgrade %s on your system or restore your server from backup. Installing %s will erase all data on the disks selected for use. Please make sure you have backed up any data you wish to preserve before proceeding. To load a device driver press <F9>. To setup advanced storage classes press <F10>. """ % (MY_PRODUCT_BRAND, MY_PRODUCT_BRAND), ['Ok', 'Reboot'], width = 60, help = "welcome", hotkeys = {'F9': fn9, 'F10': fn10}) if popup == 'driver': load_driver(driver_answers) tui.update_help_line([None, "<F9> load driver"]) elif popup == 'storage': tui.fcoe.select_fcoe_ifaces(answers) tui.update_help_line([None, "<F9> load driver"]) tui.screen.popHelpLine() if button == 'reboot': return EXIT xelogging.log("Waiting for partitions to appear...") util.runCmd2(util.udevsettleCmd()) time.sleep(1) diskutil.mpath_part_scan() # ensure partitions/disks are not locked by LVM lvm = LVMTool() lvm.deactivateAll() del lvm tui.progress.showMessageDialog("Please wait", "Checking for existing products...") answers['installed-products'] = product.find_installed_products() answers['upgradeable-products'] = upgrade.filter_for_upgradeable_products(answers['installed-products']) answers['backups'] = product.findXenSourceBackups() tui.progress.clearModelessDialog() diskutil.log_available_disks() # CA-41142, ensure we have at least one network interface and one disk before proceeding label = None if len(diskutil.getDiskList()) == 0: label = "No Disks" text = "hard disks" text_short = "disks" if len(answers['network-hardware'].keys()) == 0: label = "No Network Interfaces" text = "network interfaces" text_short = "interfaces" if label: text = """This host does not appear to have any %s. If %s are present you may need to load a device driver on the previous screen for them to be detected.""" % (text, text_short) ButtonChoiceWindow(tui.screen, label, text, ["Back"], width = 48) return REPEAT_STEP return RIGHT_FORWARDS