def ask_user(user_conf): if user_conf['role'] != 'controller': # nothing shoule be done for other kinds of node for now return LOG.info('Stage: openstack configuration\n') utils.fmt_print('==== OPENSTACK CONFIGURE ====') while True: # fmt_print('Confirm admin password:'******'The password to use for keystone admin user: '******'Confirm admin password: '******'os_pwd'] = pwd break else: utils.fmt_print('Sorry, passwords do not match') compute_hosts_txt = "IP adresses of compute hosts(seperated by ',', eg '10.10.1.2,10.10.1.3'): " user_conf['compute_hosts'] = utils.ask_user(compute_hosts_txt, check=utils.check_ip_list) # cinder config config_cinder(user_conf)
def ask_user(user_conf): LOG.info('Stage: hostname configuration\n') utils.fmt_print('==== HOSTNAME CONFIGURE ====') txt = 'Do you want to set the hostname(yes, no) [yes]: ' set_host = utils.ask_user(txt, ('yes, no'), 'yes') if set_host.lower() == 'yes': txt = 'Input the FQDN hostname you want to use for this host: ' user_conf['hostname'] = utils.ask_user(txt, check=utils.check_hostname)
def _ask_ntp(user_conf): LOG.info('Stage: ntp server configuration\n') utils.fmt_print('==== NTP SERVER CONFIGURE ====') txt = 'Do you have some local ntp servers to use(yes, no) [yes]: ' set_ntp = utils.ask_user(txt, ('yes, no'), 'yes') if set_ntp.lower() == 'yes': txt = 'Input the ntp server ip(seperated by ",", eg 10.10.1.1,10.10.1,2): ' user_conf['ntp_server'] = utils.ask_user(txt, check=utils.check_ip_list) else: user_conf['ntp_server'] = ''
def _ask_tun_nic(user_conf): txt = "which nic do you want to use as tunnel " \ "interface: %s [%s]: " % (nics, nics[1]) user_conf['tun_nic'] = utils.ask_user(txt, nics, nics[1]) txt = "Do you want this setup to configure the tunnel " \ "network? (Yes, No) [Yes]: " confirm = utils.ask_user(txt, ('yes, no'), 'yes') if confirm.lower() == 'yes': user_conf['cfg_tun'] = True utils.fmt_print("==== NETWORK CONFIGURATION FOR TUNNEL " "INTERFACE ====") user_conf['tun_nic_ip'] = utils.ask_user( 'ip address: ', check=utils.check_ip) user_conf['tun_nic_netmask'] = utils.ask_user( 'netmask [255.255.255.0]: ', default_val='255.255.255.0', check=_check_netmask(user_conf['tun_nic_ip']))
def main(): set_logger() cfgs = dict() entry_points = [ (e.name, e.load()) for e in pkg_resources.iter_entry_points( 'es_setup.cfg') ] for (_, fn) in entry_points: fn(cfgs) cfgs = dict(sorted(cfgs.iteritems(), key=lambda cfgs: cfgs[0])) # sort # OK, we enter our core logic LOG.info('Stage: Initializing\n') # first, ask user some question rebuild = 'no' if os.path.exists(user_conf_file): txt = "You have built eayunstack, do you want to reuse the same " \ "configuration (yes, no) [no]: " rebuild = utils.ask_user(txt, ('yes, no'), 'no') if rebuild.lower() == 'yes': with file(user_conf_file, 'r') as f: s = f.read().strip('\n') user_conf.update((eval(s))) if rebuild.lower() == 'no': for c in cfgs: cfgs[c].ask_user(user_conf) # save for next using with file(user_conf_file, 'w') as f: f.write(str(user_conf)) # then, we output the result user set just LOG.info('Stage: Setup validation\n') utils.fmt_print('--== CONFIGURATION PREVIEW ==--') for c in cfgs: cfgs[c].validation(user_conf) txt = 'Please confirm installation settings (OK, Cancel) [OK]: ' confirm = utils.ask_user(txt, ('ok, cancel'), 'ok') if confirm.lower() == 'cancel': sys.exit() # last, run every configuration module to setup LOG.info('Stage: Transaction setup') for c in cfgs: cfgs[c].run(user_conf)
def _ask_mgt_nic(user_conf): txt = "which nic do you want to use as management " \ "interface: %s [%s]: " % (nics, nics[0]) user_conf['mgt_nic'] = utils.ask_user(txt, nics, nics[0]) txt = "Do you want this setup to configure the management " \ "network? (Yes, No) [Yes]: " confirm = utils.ask_user(txt, ('yes, no'), 'yes') if confirm.lower() == 'yes': user_conf['cfg_mgt'] = True utils.fmt_print("==== NETWORK CONFIGURATION FOR MANAGEMENT " "INTERFACE ====") user_conf['mgt_nic_ip'] = utils.ask_user( 'ip address: ', check=utils.check_ip) user_conf['mgt_nic_netmask'] = utils.ask_user( 'netmask [255.255.255.0]: ', default_val='255.255.255.0', check=_check_netmask(user_conf['mgt_nic_ip'])) default_gw = utils.first_host_in_subnet( user_conf['mgt_nic_ip'], user_conf['mgt_nic_netmask']) user_conf['mgt_nic_gw'] = utils.ask_user( 'gateway [%s]: ' % default_gw, default_val=default_gw, check=_check_gw(user_conf['mgt_nic_ip'], user_conf['mgt_nic_netmask']))
def ask_user(user_conf): LOG.info('Stage: role configuration\n') utils.fmt_print('==== ROLE CONFIGURE ====') txt = 'Which role do you want to configure this host as? (controller, network, computer) [controller]: ' user_conf['role'] = utils.ask_user(txt, ('controller', 'network', 'computer'), 'controller')