def more_media_sequence(answers): uis = tui.installer.screens Step = uicontroller.Step more_media_fn = lambda a: 'more-media' in a and a['more-media'] seq = [ Step(uis.use_extra_media), Step( tui.repo.select_repo_source, args=[ "Select Supplemental Pack source", "Please select the type of source you would like to use for this Supplemental Pack", False ], predicates=[more_media_fn]), Step(uis.setup_runtime_networking, predicates=[more_media_fn, need_networking]), Step(tui.repo.get_source_location, args=[False, False], predicates=[more_media_fn, is_using_remote_media_fn]), Step(tui.repo.verify_source, args=['installation', False], predicates=[more_media_fn]), ] uicontroller.runSequence(seq, answers) return answers
def main(args): results = {} dests = [] ui = None xelogging.openLog('/dev/tty3') if len(args) == 0: ui = tui else: dests = args if ui: ui.init_ui() results['network-hardware'] = netutil.scanConfiguration() local_dest = lambda a: a['dest-media'] == 'local' remote_dest = lambda a: a['dest-media'] != 'local' seq = [ uicontroller.Step(select_report_media), uicontroller.Step(tui.network.requireNetworking, predicates=[remote_dest]), uicontroller.Step(get_local_disk, predicates=[local_dest]), uicontroller.Step(select_report_dest), ] rc = uicontroller.runSequence(seq, results) if rc == uicontroller.RIGHT_FORWARDS: xelogging.log("ANSWERS DICTIONARY:") xelogging.log(str(results)) if results['dest-media'] == 'local': dests.append("dev://" + results['dest-address']) elif results['dest-media'] == 'ftp': dests.append(results['dest-address']) elif results['dest-media'] == 'nfs': dests.append("nfs://" + results['dest-address']) # create tarball collectLogs('/tmp', '/tmp') report_saved = False for dest in dests: xelogging.log("Saving report to: " + dest) try: a = xcp.accessor.createAccessor(dest, False) a.start() fh = open('/tmp/support.tar.bz2') a.writeFile(fh, 'support.tar.bz2') fh.close() a.finish() report_saved = True except Exception, e: xelogging.log("Failed: " + str(e)) report_saved = False
def main(args): results = {} dests = [] ui = None xelogging.openLog('/dev/tty3') if len(args) == 0: ui = tui else: dests = args if ui: ui.init_ui() results['network-hardware'] = netutil.scanConfiguration() local_dest = lambda a: a['dest-media'] == 'local' remote_dest = lambda a: a['dest-media'] != 'local' seq = [ uicontroller.Step(select_report_media), uicontroller.Step(tui.network.requireNetworking, predicates = [remote_dest]), uicontroller.Step(get_local_disk, predicates = [local_dest]), uicontroller.Step(select_report_dest), ] rc = uicontroller.runSequence(seq, results) if rc == uicontroller.RIGHT_FORWARDS: xelogging.log("ANSWERS DICTIONARY:") xelogging.log(str(results)) if results['dest-media'] == 'local': dests.append("dev://" + results['dest-address']) elif results['dest-media'] == 'ftp': dests.append(results['dest-address']) elif results['dest-media'] == 'nfs': dests.append("nfs://" + results['dest-address']) # create tarball collectLogs('/tmp', '/tmp') report_saved = False for dest in dests: xelogging.log("Saving report to: " + dest) try: a = xcp.accessor.createAccessor(dest, False) a.start() fh = open('/tmp/support.tar.bz2') a.writeFile(fh, 'support.tar.bz2') fh.close() a.finish() report_saved = True except Exception, e: xelogging.log("Failed: " + str(e)) report_saved = False
def driver_disk_sequence(answers, driver_repos, loaded_drivers): uic = uicontroller seq = [ uic.Step(tui.repo.select_repo_source, args = ["Select Driver Source", "Please select where you would like to load the Supplemental Pack containing the driver from:", False]), uic.Step(tui.network.requireNetworking, predicates = [lambda a: a['source-media'] != 'local']), uic.Step(tui.repo.get_source_location, predicates = [lambda a: a['source-media'] != 'local'], args = [False]), uic.Step(tui.repo.confirm_load_repo, args=['driver', driver_repos]), uic.Step(eula_screen), ] rc = uicontroller.runSequence(seq, answers) if rc == LEFT_BACKWARDS: return None return (answers['source-media'], answers['source-address'])
def driver_disk_sequence(answers, driver_repos): uic = uicontroller seq = [ uic.Step( tui.repo.select_repo_source, args=[ "Select Driver Source", "Please select where you would like to load the Supplemental Pack containing the driver from:", False ]), uic.Step(tui.network.requireNetworking, predicates=[lambda a: a['source-media'] != 'local']), uic.Step(tui.repo.get_source_location, predicates=[lambda a: a['source-media'] != 'local'], args=[False]), uic.Step(tui.repo.confirm_load_repo, args=['driver', driver_repos]), ] rc = uicontroller.runSequence(seq, answers) if rc == LEFT_BACKWARDS: return None return (answers['source-media'], answers['source-address'])
def runMainSequence(results, ram_warning, vt_warning, suppress_extra_cd_dialog): """ Runs the main installer sequence and updates results with a set of values ready for the backend. """ uis = tui.installer.screens Step = uicontroller.Step def only_unupgradeable_products(answers): return len(answers['installed-products']) > 0 and \ len(answers['upgradeable-products']) == 0 and \ len(answers['backups']) == 0 def upgrade_but_no_settings_predicate(answers): return answers['install-type'] == constants.INSTALL_TYPE_REINSTALL and \ (not answers.has_key('installation-to-overwrite') or \ not answers['installation-to-overwrite'].settingsAvailable()) has_multiple_nics = lambda a: len(a['network-hardware'].keys()) > 1 is_reinstall_fn = lambda a: a['install-type'] == constants.INSTALL_TYPE_REINSTALL is_clean_install_fn = lambda a: a['install-type'] == constants.INSTALL_TYPE_FRESH is_not_restore_fn = lambda a: a['install-type'] != constants.INSTALL_TYPE_RESTORE is_using_remote_media_fn = lambda a: 'source-media' in a and a['source-media'] in ['url', 'nfs'] def requires_backup(answers): return answers.has_key("installation-to-overwrite") and \ upgrade.getUpgrader(answers['installation-to-overwrite']).requires_backup def optional_backup(answers): return answers.has_key("installation-to-overwrite") and \ upgrade.getUpgrader(answers['installation-to-overwrite']).optional_backup def requires_repartition(answers): return 'installation-to-overwrite' in answers and \ upgrade.getUpgrader(answers['installation-to-overwrite']).repartition def target_is_sr(answers): return 'target-is-sr' in answers and answers['target-is-sr'] def target_no_space(answers): if 'primary-disk' in answers: tool = LVMTool() sr = tool.srPartition(answers['primary-disk']) if sr: return tool.deviceFreeSpace(sr) < 2 * constants.root_size * 2 ** 20 return False def preserve_settings(answers): return answers.has_key('preserve-settings') and \ answers['preserve-settings'] not_preserve_settings = lambda a: not preserve_settings(a) def local_media_predicate(answers): if 'extra-repos' in answers: if True in map(lambda r: r[0] == 'local', answers['extra-repos']): return False return answers.has_key('source-media') and \ answers['source-media'] == 'local' and not suppress_extra_cd_dialog def need_networking(answers): if 'source-media' in answers and \ answers['source-media'] in ['url', 'nfs']: return True if 'installation-to-overwrite' in answers: settings = answers['installation-to-overwrite'].readSettings() return (settings['master'] != None) return False def preserve_timezone(answers): if not_preserve_settings(answers): return False if not answers.has_key('installation-to-overwrite'): return False settings = answers['installation-to-overwrite'].readSettings() return settings.has_key('timezone') and not settings.has_key('request-timezone') not_preserve_timezone = lambda a: not preserve_timezone(a) def ha_enabled(answers): settings = {} if answers.has_key('installation-to-overwrite'): settings = answers['installation-to-overwrite'].readSettings() return settings.has_key('ha-armed') and settings['ha-armed'] def out_of_order_pool_upgrade_fn(answers): if 'installation-to-overwrite' not in answers: return False ret = False settings = answers['installation-to-overwrite'].readSettings() if settings['master']: if not netutil.networkingUp(): pass try: s = xmlrpclib.Server("http://"+settings['master']) session = s.session.slave_login("", settings['pool-token'])["Value"] pool = s.pool.get_all(session)["Value"][0] master = s.pool.get_master(session, pool)["Value"] software_version = s.host.get_software_version(session, master)["Value"] s.session.logout(session) # compare versions master_ver = product.Version.from_string(software_version['product_version']) if master_ver < product.THIS_PRODUCT_VERSION: ret = True except: pass return ret # initialise the list of installed/upgradeable products. tui.progress.showMessageDialog("Please wait", "Checking for existing products...") results['installed-products'] = product.find_installed_products() results['upgradeable-products'] = upgrade.filter_for_upgradeable_products(results['installed-products']) results['backups'] = product.findXenSourceBackups() tui.progress.clearModelessDialog() if not results.has_key('install-type'): results['install-type'] = constants.INSTALL_TYPE_FRESH results['preserve-settings'] = False seq = [ Step(uis.welcome_screen), Step(uis.eula_screen), Step(uis.hardware_warnings, args=[ram_warning, vt_warning], predicates=[lambda _:(ram_warning or vt_warning)]), Step(uis.overwrite_warning, predicates=[only_unupgradeable_products]), Step(uis.get_installation_type, predicates=[lambda _:len(results['upgradeable-products']) > 0 or len(results['backups']) > 0]), Step(uis.upgrade_settings_warning, predicates=[upgrade_but_no_settings_predicate]), Step(uis.ha_master_upgrade, predicates=[is_reinstall_fn, ha_enabled]), Step(uis.remind_driver_repos, predicates=[is_reinstall_fn, preserve_settings]), Step(uis.backup_existing_installation, predicates=[is_reinstall_fn, optional_backup]), Step(uis.force_backup_screen, predicates=[is_reinstall_fn, requires_backup]), Step(uis.select_primary_disk, predicates=[is_clean_install_fn]), Step(uis.check_sr_space, predicates=[target_is_sr, target_no_space]), Step(uis.repartition_existing, predicates=[is_reinstall_fn, requires_repartition]), Step(uis.select_guest_disks, predicates=[is_clean_install_fn]), Step(uis.confirm_erase_volume_groups, predicates=[is_clean_install_fn]), Step(tui.repo.select_repo_source, args=["Select Installation Source", "Please select the type of source you would like to use for this installation"], predicates=[is_not_restore_fn]), Step(uis.use_extra_media, args=[vt_warning], predicates=[local_media_predicate]), Step(uis.setup_runtime_networking, predicates=[need_networking]), Step(uis.master_not_upgraded, predicates=[out_of_order_pool_upgrade_fn]), Step(tui.repo.get_source_location, args=[True], predicates=[is_using_remote_media_fn]), Step(tui.repo.verify_source, args=['installation', True], predicates=[is_not_restore_fn]), Step(uis.get_root_password, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.get_admin_interface, predicates=[is_not_restore_fn, has_multiple_nics, not_preserve_settings]), Step(uis.get_admin_interface_configuration, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.get_name_service_configuration, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.get_timezone_region, predicates=[is_not_restore_fn, not_preserve_timezone]), Step(uis.get_timezone_city, predicates=[is_not_restore_fn, not_preserve_timezone]), Step(uis.get_time_configuration_method, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.get_ntp_servers, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.confirm_installation), ] return uicontroller.runSequence(seq, results)
def more_media_sequence(installed_repos, still_need): """ Displays the sequence of screens required to load additional media to install from. installed_repos is a dictionary of repository IDs of repositories we already installed from, to help avoid issues where multiple CD drives are present. Returns tuple: (install more, then ask again, repo_list)""" Step = uicontroller.Step def get_more_media(_): """ 'Please insert disk' dialog. """ done = False while not done: text = '' for need in still_need: if text == '': text = "The following Supplemental Packs must be supplied to complete installation:\n\n" text += " * %s\n" % need text += "\nWhen there are no more Supplemental Packs to install press Skip." more = ButtonChoiceWindow(tui.screen, "New Media", "Please insert your Supplemental Pack now.\n" + text, ['Ok', 'Skip'], 40) if more == "skip": # they hit cancel: confirm = "skip" if len(still_need) > 0: # check they mean it check_text = "The following Supplemental Packs could contain packages which are essential:\n\n" for need in still_need: check_text += " * %s\n" % need check_text += "\nAre you sure you wish to skip installing them?" confirm = ButtonChoiceWindow(tui.screen, "Essential Packages", check_text, ['Back', 'Skip']) if confirm == "skip": rv = EXIT done = True else: # they hit OK - check there is a disc repos = repository.repositoriesFromDefinition('local', '') if len(repos) == 0: ButtonChoiceWindow( tui.screen, "Error", "No installation files were found - please check your disc and try again.", ['Back']) else: # found repositories - can leave this screen rv = RIGHT_FORWARDS done = True return rv def check_requires(_): """ Check prerequisites and report if any are missing. """ missing_repos = [] main_repo_missing = False repos = repository.repositoriesFromDefinition('local', '') for r in repos: missing_repos += r.check_requires(installed_repos) if len(missing_repos) == 0: return SKIP_SCREEN text2 = '' for r in missing_repos: if r.startswith(constants.MAIN_REPOSITORY_NAME): main_repo_missing = True text2 += " * %s\n" % r if main_repo_missing: text = "This Supplemental Pack is not compatible with this version of %s." % (version.PRODUCT_BRAND or version.PLATFORM_NAME) else: text = "The following dependencies have not yet been installed:\n\n" + text2 + \ "\nPlease install them first and try again." ButtonChoiceWindow( tui.screen, "Error", text, ['Back']) return LEFT_BACKWARDS seq = [ Step(get_more_media), Step(check_requires), Step(tui.repo.confirm_load_repo, args = ['Supplemental Pack', installed_repos]) ] results = {} direction = uicontroller.runSequence(seq, results) return (direction == RIGHT_FORWARDS, direction != EXIT, 'repos' in results and results['repos'] or [])
def runMainSequence(results, ram_warning, vt_warning, suppress_extra_cd_dialog): """ Runs the main installer sequence and updates results with a set of values ready for the backend. """ uis = tui.installer.screens Step = uicontroller.Step def only_unupgradeable_products(answers): return len(answers['installed-products']) > 0 and \ len(answers['upgradeable-products']) == 0 and \ len(answers['backups']) == 0 def upgrade_but_no_settings_predicate(answers): return answers['install-type'] == constants.INSTALL_TYPE_REINSTALL and \ ('installation-to-overwrite' not in answers or \ not answers['installation-to-overwrite'].settingsAvailable()) has_multiple_nics = lambda a: len(a['network-hardware'].keys()) > 1 is_reinstall_fn = lambda a: a['install-type' ] == constants.INSTALL_TYPE_REINSTALL is_clean_install_fn = lambda a: a['install-type' ] == constants.INSTALL_TYPE_FRESH def requires_backup(answers): return "installation-to-overwrite" in answers and \ upgrade.getUpgrader(answers['installation-to-overwrite']).requires_backup def optional_backup(answers): return "installation-to-overwrite" in answers and \ upgrade.getUpgrader(answers['installation-to-overwrite']).optional_backup def requires_repartition(answers): return 'installation-to-overwrite' in answers and \ upgrade.getUpgrader(answers['installation-to-overwrite']).repartition def preserve_settings(answers): return 'preserve-settings' in answers and \ answers['preserve-settings'] not_preserve_settings = lambda a: not preserve_settings(a) def preserve_timezone(answers): if not_preserve_settings(answers): return False if 'installation-to-overwrite' not in answers: return False settings = answers['installation-to-overwrite'].readSettings() return 'timezone' in settings and 'request-timezone' not in settings not_preserve_timezone = lambda a: not preserve_timezone(a) def ha_enabled(answers): settings = {} if 'installation-to-overwrite' in answers: settings = answers['installation-to-overwrite'].readSettings() return 'ha-armed' in settings and settings['ha-armed'] def out_of_order_pool_upgrade_fn(answers): if 'installation-to-overwrite' not in answers: return False ret = False settings = answers['installation-to-overwrite'].readSettings() if settings['master']: if not netutil.networkingUp(): pass try: s = xmlrpclib.Server("http://" + settings['master']) session = s.session.slave_login( "", settings['pool-token'])["Value"] pool = s.pool.get_all(session)["Value"][0] master = s.pool.get_master(session, pool)["Value"] software_version = s.host.get_software_version( session, master)["Value"] s.session.logout(session) # compare versions master_ver = product.Version.from_string( software_version['product_version']) if master_ver < product.THIS_PRODUCT_VERSION: ret = True except: pass return ret if 'install-type' not in results: results['install-type'] = constants.INSTALL_TYPE_FRESH results['preserve-settings'] = False seq = [ Step(uis.welcome_screen), Step(uis.eula_screen), Step(uis.hardware_warnings, args=[ram_warning, vt_warning], predicates=[lambda _: (ram_warning or vt_warning)]), Step(uis.overwrite_warning, predicates=[only_unupgradeable_products]), Step(uis.get_installation_type, predicates=[ lambda _: len(results['upgradeable-products']) > 0 or len( results['backups']) > 0 ]), Step(uis.upgrade_settings_warning, predicates=[upgrade_but_no_settings_predicate]), Step(uis.ha_master_upgrade, predicates=[is_reinstall_fn, ha_enabled]), Step(uis.remind_driver_repos, predicates=[is_reinstall_fn, preserve_settings]), Step(uis.backup_existing_installation, predicates=[is_reinstall_fn, optional_backup]), Step(uis.force_backup_screen, predicates=[is_reinstall_fn, requires_backup]), Step(uis.select_primary_disk, predicates=[is_clean_install_fn]), Step(uis.repartition_existing, predicates=[is_reinstall_fn, requires_repartition]), Step(uis.select_guest_disks, predicates=[is_clean_install_fn]), Step(uis.confirm_erase_volume_groups, predicates=[is_clean_install_fn]) ] + get_main_source_location_sequence() + [ Step(uis.master_not_upgraded, predicates=[out_of_order_pool_upgrade_fn]), Step(uis.get_root_password, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.get_admin_interface, predicates=[ is_not_restore_fn, has_multiple_nics, not_preserve_settings ]), Step(uis.get_admin_interface_configuration, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.get_name_service_configuration, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.get_timezone_region, predicates=[is_not_restore_fn, not_preserve_timezone]), Step(uis.get_timezone_city, predicates=[is_not_restore_fn, not_preserve_timezone]), Step(uis.get_time_configuration_method, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.get_ntp_servers, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.set_time, predicates=[is_not_restore_fn, not_preserve_settings]), Step(uis.confirm_installation), ] return uicontroller.runSequence(seq, results)
def reconfigure_source_location_sequence(answers): uicontroller.runSequence(get_main_source_location_sequence(), answers) return answers
def requireNetworking(answers, defaults=None, msg=None, keys=['net-admin-interface', 'net-admin-configuration']): """ Display the correct sequence of screens to get networking configuration. Bring up the network according to this configuration. If answers is a dictionary, set answers[keys[0]] to the interface chosen, and answers[keys[1]] to the interface configuration chosen, and answers['runtime-iface-configuration'] to current manual network config, in format (all-dhcp, manual-config). If defaults.has_key[keys[0]] then use defaults[keys[0]] as the default network interface. If defaults.has_key[keys[1]] then use defaults[keys[1]] as the default network interface configuration.""" interface_key = keys[0] config_key = keys[1] nethw = answers['network-hardware'] if len(nethw.keys()) == 0: tui.progress.OKDialog("Networking", "No available ethernet device found") return REPEAT_STEP # Display a screen asking which interface to configure, then what the # configuration for that interface should be: def select_interface(answers, default, msg): """ Show the dialog for selecting an interface. Sets answers['interface'] to the name of the interface selected (a string). """ if answers.has_key('interface'): default = answers['interface'] if msg == None: msg = "%s Setup needs network access to continue.\n\nWhich network interface would you like to configure to access your %s product repository?" % ( version.PRODUCT_BRAND or version.PLATFORM_NAME, version.PRODUCT_BRAND or version.PLATFORM_NAME) direction, iface = select_netif(msg, nethw, True, default) if direction == RIGHT_FORWARDS: answers['reuse-networking'] = (iface == None) if iface: answers['interface'] = iface return direction def specify_configuration(answers, txt, defaults): """ Show the dialog for setting nic config. Sets answers['config'] to the configuration used. Assumes answers['interface'] is a string identifying by name the interface to configure. """ if 'reuse-networking' in answers and answers['reuse-networking']: return RIGHT_FORWARDS direction, conf = get_iface_configuration(nethw[answers['interface']], txt, defaults=defaults, include_dns=True) if direction == RIGHT_FORWARDS: answers['config'] = conf return direction conf_dict = {} def_iface = None def_conf = None if type(defaults) == dict: if defaults.has_key(interface_key): def_iface = defaults[interface_key] if defaults.has_key(config_key): def_conf = defaults[config_key] if len(nethw.keys()) > 1 or netutil.networkingUp(): seq = [ uicontroller.Step(select_interface, args=[def_iface, msg]), uicontroller.Step(specify_configuration, args=[None, def_conf]) ] else: text = "%s Setup needs network access to continue.\n\nHow should networking be configured at this time?" % ( version.PRODUCT_BRAND or version.PLATFORM_NAME) conf_dict['interface'] = nethw.keys()[0] seq = [uicontroller.Step(specify_configuration, args=[text, def_conf])] direction = uicontroller.runSequence(seq, conf_dict) if direction == RIGHT_FORWARDS and 'config' in conf_dict: netutil.writeNetInterfaceFiles( {conf_dict['interface']: conf_dict['config']}) netutil.writeResolverFile( {conf_dict['interface']: conf_dict['config']}, '/etc/resolv.conf') tui.progress.showMessageDialog( "Networking", "Configuring network interface, please wait...", ) ifaceName = conf_dict['config'].getInterfaceName( conf_dict['interface']) netutil.ifdown(ifaceName) # check that we have *some* network: if netutil.ifup(ifaceName) != 0 or not netutil.interfaceUp(ifaceName): tui.progress.clearModelessDialog() tui.progress.OKDialog( "Networking", "The network still does not appear to be active. Please check your settings, and try again." ) direction = REPEAT_STEP else: if answers and type(answers) == dict: # write out results answers[interface_key] = conf_dict['interface'] answers[config_key] = conf_dict['config'] # update cache of manual configurations manual_config = {} all_dhcp = False if answers.has_key('runtime-iface-configuration'): manual_config = answers['runtime-iface-configuration'][1] manual_config[conf_dict['interface']] = conf_dict['config'] answers['runtime-iface-configuration'] = (all_dhcp, manual_config) tui.progress.clearModelessDialog() return direction
def requireNetworking(answers, defaults=None, msg=None, keys=['net-admin-interface', 'net-admin-configuration']): """ Display the correct sequence of screens to get networking configuration. Bring up the network according to this configuration. If answers is a dictionary, set answers[keys[0]] to the interface chosen, and answers[keys[1]] to the interface configuration chosen, and answers['runtime-iface-configuration'] to current manual network config, in format (all-dhcp, manual-config). If defaults.has_key[keys[0]] then use defaults[keys[0]] as the default network interface. If defaults.has_key[keys[1]] then use defaults[keys[1]] as the default network interface configuration.""" interface_key = keys[0] config_key = keys[1] nethw = answers['network-hardware'] if len(nethw.keys()) == 0: tui.progress.OKDialog("Networking", "No available ethernet device found") return REPEAT_STEP # Display a screen asking which interface to configure, then what the # configuration for that interface should be: def select_interface(answers, default, msg): """ Show the dialog for selecting an interface. Sets answers['interface'] to the name of the interface selected (a string). """ if answers.has_key('interface'): default = answers['interface'] if msg == None: msg = "%s Setup needs network access to continue.\n\nWhich network interface would you like to configure to access your %s product repository?" % (version.PRODUCT_BRAND or version.PLATFORM_NAME, version.PRODUCT_BRAND or version.PLATFORM_NAME) direction, iface = select_netif(msg, nethw, True, default) if direction == RIGHT_FORWARDS: answers['reuse-networking'] = (iface == None) if iface: answers['interface'] = iface return direction def specify_configuration(answers, txt, defaults): """ Show the dialog for setting nic config. Sets answers['config'] to the configuration used. Assumes answers['interface'] is a string identifying by name the interface to configure. """ if 'reuse-networking' in answers and answers['reuse-networking']: return RIGHT_FORWARDS direction, conf = get_iface_configuration(nethw[answers['interface']], txt, defaults=defaults, include_dns=True) if direction == RIGHT_FORWARDS: answers['config'] = conf return direction conf_dict = {} def_iface = None def_conf = None if type(defaults) == dict: if defaults.has_key(interface_key): def_iface = defaults[interface_key] if defaults.has_key(config_key): def_conf = defaults[config_key] if len(nethw.keys()) > 1 or netutil.networkingUp(): seq = [ uicontroller.Step(select_interface, args=[def_iface, msg]), uicontroller.Step(specify_configuration, args=[None, def_conf]) ] else: text = "%s Setup needs network access to continue.\n\nHow should networking be configured at this time?" % (version.PRODUCT_BRAND or version.PLATFORM_NAME) conf_dict['interface'] = nethw.keys()[0] seq = [ uicontroller.Step(specify_configuration, args=[text, def_conf]) ] direction = uicontroller.runSequence(seq, conf_dict) if direction == RIGHT_FORWARDS and 'config' in conf_dict: netutil.writeDebStyleInterfaceFile( {conf_dict['interface']: conf_dict['config']}, '/etc/network/interfaces' ) netutil.writeResolverFile( {conf_dict['interface']: conf_dict['config']}, '/etc/resolv.conf' ) tui.progress.showMessageDialog( "Networking", "Configuring network interface, please wait...", ) netutil.ifdown(conf_dict['interface']) # check that we have *some* network: if netutil.ifup(conf_dict['interface']) != 0 or not netutil.interfaceUp(conf_dict['interface']): tui.progress.clearModelessDialog() tui.progress.OKDialog("Networking", "The network still does not appear to be active. Please check your settings, and try again.") direction = REPEAT_STEP else: if answers and type(answers) == dict: # write out results answers[interface_key] = conf_dict['interface'] answers[config_key] = conf_dict['config'] # update cache of manual configurations manual_config = {} all_dhcp = False if answers.has_key('runtime-iface-configuration'): manual_config = answers['runtime-iface-configuration'][1] manual_config[conf_dict['interface']] = conf_dict['config'] answers['runtime-iface-configuration'] = (all_dhcp, manual_config) tui.progress.clearModelessDialog() return direction