def prepare_cfg_subnet(step, subnet, pool, eth = None): get_common_logger().debug("Configure subnet...") if not "conf_subnet" in world.cfg: world.cfg["conf_subnet"] = "" world.cfg["subnet"] = subnet pointer = '{' if subnet == "default": subnet = "192.168.0.0 netmask 255.255.255.0" if pool == "default": pool = "192.168.0.1 192.168.0.254" else: # switch from /XX for XXX.XXX.XXX.XXX subnet = netmask(subnet) # isc-dhcp uses whitespace to separate. pool = pool.replace('-', ' ') #world.cfg["conf_subnet"] += ''' world.subcfg[world.dhcp["subnet_cnt"]][0] += ''' subnet {subnet} {pointer} range {pool}; '''.format(**locals())
def prepare_cfg_subnet(step, subnet, pool, eth=None): get_common_logger().debug("Configure subnet...") if not "conf_subnet" in world.cfg: world.cfg["conf_subnet"] = "" world.cfg["subnet"] = subnet pointer = '{' if subnet == "default": subnet = "192.168.0.0 netmask 255.255.255.0" if pool == "default": pool = "192.168.0.1 192.168.0.254" else: # switch from /XX for XXX.XXX.XXX.XXX subnet = netmask(subnet) # isc-dhcp uses whitespace to separate. pool = pool.replace('-', ' ') #world.cfg["conf_subnet"] += ''' world.subcfg[world.dhcp["subnet_cnt"]][0] += ''' subnet {subnet} {pointer} range {pool}; '''.format(**locals())
def start_srv(start, process): """ Start ISC-DHCP with generated config. """ if not "conf_option" in world.cfg: world.cfg["conf_option"] = "" world.cfg['log_file'] = build_log_path() fabric_sudo_command('cat /dev/null >' + world.cfg['log_file']) world.cfg["dhcp_log_file"] = world.cfg['log_file'] log = "local7" if world.f_cfg.isc_dhcp_log_facility != "": log = world.f_cfg.isc_dhcp_log_facility world.cfg['log_facility'] = '''\nlog-facility {log};\n'''.format( **locals()) add_defaults() cfg_write() get_common_logger().debug("Start ISC-DHCP with generated config:") convert_cfg_file(world.cfg["cfg_file"]) fabric_send_file(world.cfg["cfg_file"] + '_processed', world.cfg["cfg_file"] + '_processed') copy_configuration_file(world.cfg["cfg_file"] + '_processed') remove_local_file(world.cfg["cfg_file"]) #set_ethernet_interface() stop_srv() world.cfg['leases'] = build_leases_path() #fabric_sudo_command('echo y |rm ' + world.cfg['leases']) fabric_sudo_command('touch ' + world.cfg['leases']) result = fabric_sudo_command('(' + world.f_cfg.software_install_path + 'sbin/dhcpd -cf server.cfg_processed' + ' -lf ' + world.cfg['leases'] + '&); sleep ' + str(world.f_cfg.sleep_time_1) + ';') check_process_result(start, result, process) # clear configs in case we would like make couple configs in one test world.cfg["conf_time"] = "" world.cfg["log_facility"] = "" world.cfg["custom_lines"] = "" world.cfg["conf_option"] = "" world.cfg["conf_vendor"] = ""
def start_srv(start, process): """ Start ISC-DHCP with generated config. """ if not "conf_option" in world.cfg: world.cfg["conf_option"] = "" world.cfg['log_file'] = build_log_path() fabric_sudo_command('cat /dev/null >' + world.cfg['log_file']) world.cfg["dhcp_log_file"] = world.cfg['log_file'] log = "local7" if ISC_DHCP_LOG_FACILITY != "": log = ISC_DHCP_LOG_FACILITY world.cfg['log_facility'] = '''\nlog-facility {log};\n'''.format(**locals()) add_defaults() cfg_write() get_common_logger().debug("Start ISC-DHCP with generated config:") convert_cfg_file(world.cfg["cfg_file"]) fabric_send_file(world.cfg["cfg_file"] + '_processed', world.cfg["cfg_file"] + '_processed') copy_configuration_file(world.cfg["cfg_file"] + '_processed') remove_local_file(world.cfg["cfg_file"]) #set_ethernet_interface() stop_srv() world.cfg['leases'] = build_leases_path() fabric_sudo_command('echo y |rm ' + world.cfg['leases']) fabric_sudo_command('touch ' + world.cfg['leases']) result = fabric_sudo_command('(' + SOFTWARE_INSTALL_DIR + 'sbin/dhcpd -cf server.cfg_processed' + ' -lf ' + world.cfg['leases'] + '&); sleep ' + str(SLEEP_TIME_1) + ';') check_process_result(start, result, process) # clear configs in case we would like make couple configs in one test world.cfg["conf_time"] = "" world.cfg["log_facility"] = "" world.cfg["custom_lines"] = "" world.cfg["conf_option"] = "" world.cfg["conf_vendor"] = ""
def start_srv(start, process): configuration = True start = True clean = True # Switch one of three processess to false, which? That is decided in # Server failed to start. During (\S+) process.) step. if process is None and start: pass elif process == 'configuration': configuration = False elif process == 'start': start = False elif process == 'clean': clean = False else: assert False, "Process: '" + process + "' not supported." cfg_write() get_common_logger().debug("Bind10, dhcp4 configuration procedure:") run_bindctl(clean, 'clean') # clean and stop run_bindctl(start, 'start') # start run_bindctl(configuration, 'configuration') # conf
def run_bindctl(succeed, opt): """ Run bindctl with prepered config file """ world.cfg[ 'leases'] = world.f_cfg.software_install_path + 'var/bind10/kea-leases4.csv' if opt == "clean": get_common_logger().debug('cleaning kea configuration') cfg_file = 'kea4-stop.cfg' prepare_cfg_kea4_for_kea4_stop(cfg_file) prepare_config_file(cfg_file) fabric_send_file(cfg_file + '_processed', cfg_file + '_processed') remove_local_file(cfg_file + '_processed') if opt == "start": if world.f_cfg.save_logs: set_logger() get_common_logger().debug('starting fresh kea') cfg_file = 'kea4-start.cfg' prepare_cfg_kea4_for_kea4_start(cfg_file) prepare_config_file(cfg_file) fabric_send_file(cfg_file + '_processed', cfg_file + '_processed') remove_local_file(cfg_file + '_processed') if opt == "configuration": get_common_logger().debug('kea configuration') cfg_file = world.cfg["cfg_file"] prepare_config_file(cfg_file) add_last = open(cfg_file + "_processed", 'a') # add 'config commit' we don't put it before add_last.write("config commit") add_last.close() fabric_send_file(cfg_file + '_processed', cfg_file + '_processed') copy_configuration_file(cfg_file + '_processed') remove_local_file(cfg_file + '_processed') world.cfg["conf"] = "" if opt == "restart": restart_srv() result = fabric_run_command('(echo "execute file ' + cfg_file + '_processed" | ' + world.f_cfg.software_install_path + 'bin/bindctl ); sleep 1') search_for_errors(succeed, opt, result, ["ImportError:", '"config revert".', "Error"]) parsing_bind_stdout(result.stdout, opt, ['Broken pipe'])