예제 #1
0
def send_ctrl_cmd_via_http(command,
                           address='$(MGMT_ADDRESS)',
                           port='8000',
                           exp_result=0):
    if isinstance(command, dict):
        substitute_vars(command)
        address, port = test_define_value(address, port)
    else:
        address, port, command = test_define_value(address, port, command)
    return multi_protocol_functions.send_ctrl_cmd_via_http(
        command, address, int(port), exp_result)
예제 #2
0
def send_ctrl_cmd_via_socket(command,
                             socket_name=None,
                             destination_address=world.f_cfg.mgmt_address,
                             exp_result=0,
                             exp_failed=False):
    if isinstance(command, dict):
        substitute_vars(command)
        destination_address = test_define_value(destination_address)[0]
    else:
        destination_address, command = test_define_value(
            destination_address, command)
    return multi_protocol_functions.send_ctrl_cmd_via_socket(
        command, socket_name, destination_address, exp_result, exp_failed)
예제 #3
0
def file_includes_line(condition, line):
    """
    Check if downloaded file includes line.
    Be aware that tested line is every thing after "line: " until end of the line.
    """
    line = test_define_value(line)[0]
    multi_protocol_functions.file_includes_line(condition, line)
예제 #4
0
def copy_remote(remote_path):
    """
    Download file from remote server. It is stored in test directory.
    And named "downloaded_file"
    """
    remote_path = test_define_value(remote_path)[0]
    multi_protocol_functions.copy_file_from_server(remote_path)
예제 #5
0
def log_includes_count(server_type, count, line):
    """
    Check if Log includes line.
    Be aware that tested line is every thing after "line: " until end of the line.
    """
    count, line = test_define_value(count, line)
    multi_protocol_functions.log_contains_count(server_type, count, line)
예제 #6
0
def execute_kea_shell(args):
    args = test_define_value(args)[0]
    path = world.f_cfg.sbin_join('kea-shell')
    result = multi_protocol_functions.execute_shell_cmd(path, args)
    result = json.loads(result)
    assert result[0]['result'] == 0
    return result
예제 #7
0
def config_srv_prefix(prefix, subnet, length, delegated_length):
    """
    Adds server configuration with specified prefix.
    """
    prefix, length, delegated_length, subnet = test_define_value(
        prefix, length, delegated_length, subnet)
    dhcp.prepare_cfg_prefix(prefix, length, delegated_length, subnet)
예제 #8
0
def clear_some_data(data_type,
                    service='dhcp',
                    dest=world.f_cfg.mgmt_address,
                    software_install_path=world.f_cfg.software_install_path,
                    db_user=world.f_cfg.db_user,
                    db_passwd=world.f_cfg.db_passwd,
                    db_name=world.f_cfg.db_name):
    dest, db_name, db_user, db_passwd, install_path = test_define_value(
        dest, db_name, db_user, db_passwd, software_install_path)

    if service == 'dhcp':
        if data_type == "leases":
            dhcp.clear_leases(destination_address=dest,
                              db_name=db_name,
                              db_user=db_user,
                              db_passwd=db_passwd)
        elif data_type == "logs":
            dhcp.clear_logs(destination_address=dest)
        elif data_type == "all":
            dhcp.clear_all(destination_address=dest,
                           db_name=db_name,
                           db_user=db_user,
                           db_passwd=db_passwd)
    elif service.lower() == 'dns':
        # let's just dump all without logs
        dns.clear_all(remove_logs=False, destination_address=dest)
예제 #9
0
def file_contains_line(file_path, condition, line):
    """
    Check if Log includes line.
    Be aware that tested line is every thing after "line: " until end of the line.
    """
    file_path, line = test_define_value(file_path, line)
    multi_protocol_functions.regular_file_contain(file_path, condition, line)
예제 #10
0
def shared_subnet(subnet_id, shared_subnet_id):
    """
    Configure shared subnets.
    """
    subnet_id, shared_subnet_id = test_define_value(subnet_id,
                                                    shared_subnet_id)
    dhcp.add_to_shared_subnet(subnet_id, int(shared_subnet_id))
예제 #11
0
def start_srv(name,
              type_of_action,
              config_set=None,
              dest=world.f_cfg.mgmt_address):
    """
    Decide which you want, start server of failed start (testing incorrect configuration)
    Also decide in which part should it failed.
    """
    dest = test_define_value(dest)[0]
    check_remote_address(dest)
    if name not in ["DHCP", "DNS"]:
        assert False, "I don't think there is support for something else than DNS or DHCP"
    if type_of_action == "started":
        if name == "DHCP":
            log.info(
                '-----------------  KEA START %s -------------------------------------------------------',
                dest)
            dhcp.start_srv(True, None, destination_address=dest)
        elif name == "DNS":
            log.info(
                '-----------------  BIND START %s -------------------------------------------------------',
                dest)
            if config_set is not None:
                use_dns_set_number(config_set)
            dns.start_srv(True, None, destination_address=dest)
    elif type_of_action == "stopped":
        if name == "DHCP":
            log.info(
                '-----------------  KEA STOP %s  -------------------------------------------------------',
                dest)
            dhcp.stop_srv(destination_address=dest)
        elif name == "DNS":
            log.info(
                '-----------------  BIND STOP %s  -------------------------------------------------------',
                dest)
            dns.stop_srv(destination_address=dest)
    elif type_of_action == "restarted":
        if name == "DHCP":
            log.info(
                '-----------------  KEA RESTART %s  -------------------------------------------------------',
                dest)
            dhcp.restart_srv(destination_address=dest)
        elif name == "DNS":
            log.info(
                '-----------------  BIND RESTART %s  -------------------------------------------------------',
                dest)
            dns.restart_srv(destination_address=dest)
    elif type_of_action == "reconfigured":
        if name == "DHCP":
            log.info(
                '-----------------  KEA RECONFIG %s  -------------------------------------------------------',
                dest)
            dhcp.reconfigure_srv(destination_address=dest)
        elif name == "DNS":
            log.info(
                '-----------------  BIND RECONFIG %s  -------------------------------------------------------',
                dest)
            dns.reconfigure_srv(destination_address=dest)
    else:
        assert False, "we don't support '%s' action." % str(type_of_action)
예제 #12
0
def remote_start_srv(name, type_of_action, destination_address):
    """
    Decide which you want, start server of failed start (testing incorrect configuration)
    Also decide in which part should it failed.
    """
    destination_address = test_define_value(destination_address)[0]
    check_remote_address(destination_address)
    if name not in ["DHCP", "DNS"]:
        assert False, "I don't think there is support for something else than DNS or DHCP"
    if type_of_action == "started":
        if name == "DHCP":
            dhcp.start_srv(True, None, destination_address)
        elif name == "DNS":
            dns.start_srv(True, None, destination_address)
    elif type_of_action == "stopped":
        if name == "DHCP":
            dhcp.stop_srv(destination_address=destination_address)
        elif name == "DNS":
            dns.stop_srv(destination_address=destination_address)
    elif type_of_action == "restarted":
        if name == "DHCP":
            dhcp.restart_srv(destination_address=destination_address)
        elif name == "DNS":
            dns.restart_srv(destination_address=destination_address)
    elif type_of_action == "reconfigured":
        if name == "DHCP":
            dhcp.reconfigure_srv(destination_address=destination_address)
        elif name == "DNS":
            dns.reconfigure_srv(destination_address=destination_address)
    else:
        assert False, "we don't support this action."
예제 #13
0
def config_srv_opt(option_name, option_value):
    """
    Add to configuration options like: preference, dns servers..
    This step causes to set in to main space!
    """
    option_name, option_value = test_define_value(option_name, option_value)
    dhcp.prepare_cfg_add_option(option_name, option_value, world.cfg["space"])
예제 #14
0
def config_srv_opt_space(space, option_name, option_value):
    """
    Add to configuration options like: preference, dns servers.. but you can specify
    to which space should that be included.
    """
    option_name, option_value, space = test_define_value(
        option_name, option_value, space)
    dhcp.prepare_cfg_add_option(option_name, option_value, space)
예제 #15
0
def dns_log_contains(condition, line):
    """
    Check if DNS log includes line.
    Be aware that tested line is every thing after "line: " until end of the line.
    """
    line = test_define_value(line)[0]
    multi_protocol_functions.regular_file_contain(world.cfg["dns_log_file"],
                                                  condition, line)
예제 #16
0
def table_contains_line(table_name, db_type, condition, line):
    """
    Check if in table X in database type Y include line.
    Be aware that tested line is every thing after "line: " until end of the line.
    """
    table_name, db_type, line = test_define_value(table_name, db_type, line)
    multi_protocol_functions.db_table_contain(table_name, db_type, condition,
                                              line)
예제 #17
0
def client_does_include_with_value(opt_type, value):
    """
    You can choose to include options to message with proposed value. Mostly used only with
    DHCPv4. Also reason why that step is called "Client adds to message" not
    "Client does (NOT )?include" as other step is that lettuce step parser is really... weak.
    What ever I'll do with that always takes wrong step.
    """
    opt_type, value = test_define_value(opt_type, value)
    dhcpmsg.client_does_include(None, opt_type, value)
예제 #18
0
def build_and_send_config_files(cfg=None, dest=world.f_cfg.mgmt_address):
    """
    :param cfg:
    :param dest:
    :return:
    """
    dest = test_define_value(dest)[0]
    check_remote_address(dest)
    dhcp.build_and_send_config_files(cfg=cfg, destination_address=dest)
예제 #19
0
def config_srv_custom_opt_space(space, opt_name, opt_code, opt_type,
                                opt_value):
    """
    Same step like "Server is configured with custom option.." but specify that option on different space then main.
    """
    opt_name, opt_code, opt_type, opt_value, space = test_define_value(
        opt_name, opt_code, opt_type, opt_value, space)
    dhcp.prepare_cfg_add_custom_option(opt_name, opt_code, opt_type, opt_value,
                                       space)
예제 #20
0
def host_reservation_in_subnet_add_value(reservation_number, subnet,
                                         reservation_type, reserved_value):
    """
    Ability to configure simple host reservations in subnet.
    """
    reservation_type, reserved_value = test_define_value(
        reservation_type, reserved_value)
    dhcp.host_reservation_extension(int(reservation_number), int(subnet),
                                    reservation_type, reserved_value)
예제 #21
0
def client_sets_value(sender_type, value_name, new_value):
    """
    User can set values like: address, T1 or DUID to make test scenario
    more accurate.
    """
    # that is also used for DNS messages and RelayForward message but sender_type was
    # introduced just to keep tests cleaner - it's unused in the code.
    value_name, new_value = test_define_value(value_name, new_value)
    dhcpmsg.client_sets_value(value_name, new_value)
예제 #22
0
def set_conf_parameter_global(parameter_name, value):
    """
    Can be used on the end of configuration process, just before starting server.
    :param step:
    :param parameter_name:
    :param value:
    :return:
    """
    parameter_name, value = test_define_value(parameter_name, value)
    dhcp.set_conf_parameter_global(parameter_name, value)
예제 #23
0
def run_command(command):
    """
    Add single line to configuration, there is no validation within this step.
    Be aware what you are putting this and in what moment. If you use that
    I recommend set variable "SAVE_CONFIG_FILES" to True.

    Includes everything after "command: " to the end of the line.
    """
    command = test_define_value(command)[0]
    dhcp.add_line_in_global(command)
예제 #24
0
def host_reservation(reservation_type, reserved_value, unique_host_value_type,
                     unique_host_value):
    """
    Ability to configure simple host reservations.
    """
    reservation_type, reserved_value, unique_host_value_type, unique_host_value = test_define_value(
        reservation_type, reserved_value, unique_host_value_type,
        unique_host_value)
    dhcp.host_reservation(reservation_type, reserved_value,
                          unique_host_value_type, unique_host_value, None)
예제 #25
0
def client_send_msg_via_interface(iface, addr, msgname):
    """
    This step actually build message (e.g. SOLICIT) with all details
    specified in steps like:
    Client sets (\w+) value to (\S+).
    Client does include (\S+).
    and others..
    Message builded here will be send in step: Server must response with...
    """
    msgname, iface, addr = test_define_value(msgname, iface, addr)
    dhcpmsg.client_send_msg(msgname, iface, addr)
예제 #26
0
def host_reservation_in_subnet(reservation_type, reserved_value, subnet,
                               unique_host_value_type, unique_host_value):
    """
    Ability to configure simple host reservations in subnet.
    """
    reservation_type, reserved_value, unique_host_value_type, unique_host_value = test_define_value(
        reservation_type, reserved_value, unique_host_value_type,
        unique_host_value)
    dhcp.host_reservation(reservation_type, reserved_value,
                          unique_host_value_type, unique_host_value,
                          int(subnet))
예제 #27
0
def set_conf_parameter_subnet(parameter_name, value, subnet_id):
    """
    Can be used on the end of configuration process, just before starting server.
    :param step:
    :param parameter_name:
    :param value:
    :return:
    """
    parameter_name, value, subnet_id = test_define_value(
        parameter_name, value, subnet_id)
    dhcp.set_conf_parameter_subnet(parameter_name, value, int(subnet_id))
예제 #28
0
def config_srv_subnet(subnet, pool):
    """
    Adds server configuration with specified subnet and pool.
    subnet may define specific subnet or use the word "default"
    pool may define specific pool range or use the word "default"

    Setting subnet in that way, will cause to set in on interface you set in
    init_all.py as variable "SERVER_IFACE" leave it to None if you don want to set
    interface.
    """
    subnet, pool = test_define_value(subnet, pool)
    dhcp.prepare_cfg_subnet(subnet, pool)
예제 #29
0
def config_srv_custom_opt(opt_name, opt_code, opt_type, opt_value):
    """
    Prepare server configuration with the specified custom option.
    opt_name name of the option, e.g. foo
    opt_code code of the option, e.g. 100
    opt_type type of the option, e.g. uint8 (see bind10 guide for complete list)
    opt_value value of the option, e.g. 1
    """
    opt_name, opt_code, opt_type, opt_value = test_define_value(
        opt_name, opt_code, opt_type, opt_value)
    dhcp.prepare_cfg_add_custom_option(opt_name, opt_code, opt_type, opt_value,
                                       world.cfg["space"])
예제 #30
0
def build_and_send_config_files(connection_type, configuration_type, cfg=None):
    """
    Step used to choosing configuration type and channel to send it.
    :param step:
    :param connection_type:
    :param configuration_type:
    """
    connection_type, configuration_type = test_define_value(
        connection_type, configuration_type)
    dhcp.build_and_send_config_files(connection_type,
                                     configuration_type,
                                     cfg=cfg)