コード例 #1
0
def test_v4_host_reservation_conflicts_duplicate_mac_reservations(backend):
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.50')
    if backend == 'memfile':
        srv_control.host_reservation_in_subnet(
            'ip-address', '192.168.50.10', 0, 'hw-address',
            'ff:01:02:03:ff:04')  # the same MAC address
        srv_control.host_reservation_in_subnet(
            'ip-address', '192.168.50.12', 0, 'hw-address',
            'ff:01:02:03:ff:04')  # the same MAC address
        srv_control.build_and_send_config_files()
        srv_control.start_srv_during_process('DHCP', 'configuration')

        # expected error logs
        srv_msg.log_contains(r'ERROR \[kea-dhcp4.dhcp4')
        srv_msg.log_contains(r'failed to add new host using the HW address')
    else:
        srv_control.add_hooks('libdhcp_host_cmds.so')
        srv_control.open_control_channel()
        srv_control.dump_db_reservation(backend)
        srv_control.new_db_backend_reservation(backend, 'hw-address',
                                               'ff:01:02:03:ff:11')
        srv_control.update_db_backend_reservation('hostname',
                                                  'reserved-hostname', backend,
                                                  1)
        srv_control.update_db_backend_reservation('ipv4_address',
                                                  '192.168.50.2', backend, 1)
        srv_control.update_db_backend_reservation('dhcp4_subnet_id', 1,
                                                  backend, 1)

        srv_control.new_db_backend_reservation(backend, 'hw-address',
                                               'ff:01:02:03:ff:11')
        srv_control.update_db_backend_reservation('hostname',
                                                  'reserved-hostname', backend,
                                                  2)
        srv_control.update_db_backend_reservation('ipv4_address',
                                                  '192.168.50.3', backend, 2)
        srv_control.update_db_backend_reservation('dhcp4_subnet_id', 1,
                                                  backend, 2)

        # expect failure due to db constrain on unique hw-address
        srv_control.upload_db_reservation(backend, exp_failed=True)
コード例 #2
0
def test_v4_host_reservation_conflicts_duplicate_reservations_different_subnets(
        backend):
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.50')
    if backend == 'memfile':
        srv_control.config_srv_another_subnet_no_interface(
            '192.168.51.0/24', '192.168.51.1-192.168.51.50')
        srv_control.host_reservation_in_subnet('ip-address', '192.168.50.10',
                                               0, 'hw-address',
                                               'ff:01:02:03:ff:04')
        srv_control.host_reservation_in_subnet('ip-address', '192.168.51.12',
                                               1, 'hw-address',
                                               'ff:01:02:03:ff:04')
    else:
        srv_control.dump_db_reservation(backend)
        srv_control.new_db_backend_reservation(backend, 'hw-address',
                                               'ff:01:02:03:ff:11')
        srv_control.update_db_backend_reservation('hostname',
                                                  'reserved-hostname', backend,
                                                  1)
        srv_control.update_db_backend_reservation('ipv4_address',
                                                  '192.168.50.2', backend, 1)
        srv_control.update_db_backend_reservation('dhcp4_subnet_id', 1,
                                                  backend, 1)

        srv_control.new_db_backend_reservation(backend, 'hw-address',
                                               'ff:01:02:03:ff:11')
        srv_control.update_db_backend_reservation('hostname',
                                                  'reserved-hostname', backend,
                                                  2)
        srv_control.update_db_backend_reservation('ipv4_address',
                                                  '192.168.51.3', backend, 2)
        srv_control.update_db_backend_reservation('dhcp4_subnet_id', 2,
                                                  backend, 2)
        srv_control.upload_db_reservation(backend)

    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')
コード例 #3
0
def test_v4_host_reservation_conflicts_rebind_address_which_reservation_changed_during_reconfigure(
        backend):

    misc.test_setup()
    srv_control.set_time('renew-timer', 3)
    srv_control.set_time('rebind-timer', 4)
    srv_control.set_time('valid-lifetime', 500)
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.50')
    srv_control.open_control_channel()
    srv_control.agent_control_channel(world.f_cfg.mgmt_address)
    if backend == 'memfile':
        srv_control.host_reservation_in_subnet('ip-address', '192.168.50.5', 0,
                                               'hw-address',
                                               'ff:01:02:03:ff:01')
    else:
        srv_control.add_hooks('libdhcp_host_cmds.so')
        srv_control.enable_db_backend_reservation(backend)

    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    if backend != 'memfile':
        _add_reservation({
            "hw-address": "ff:01:02:03:ff:01",
            "ip-address": "192.168.50.5"
        })

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'OFFER')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01')
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.5')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ACK')
    srv_msg.response_check_content('yiaddr', '192.168.50.5')

    srv_msg.forge_sleep(5, 'seconds')

    misc.test_setup()
    srv_control.set_time('renew-timer', 3)
    srv_control.set_time('rebind-timer', 4)
    srv_control.set_time('valid-lifetime', 500)
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.1-192.168.50.50')
    srv_control.open_control_channel()
    srv_control.agent_control_channel(world.f_cfg.mgmt_address)
    if backend == 'memfile':
        srv_control.host_reservation_in_subnet('ip-address', '192.168.50.50',
                                               0, 'hw-address',
                                               'ff:01:02:03:ff:01')
    else:
        srv_control.dump_db_reservation(backend)
        srv_control.add_hooks('libdhcp_host_cmds.so')
        srv_control.enable_db_backend_reservation(backend)

    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'reconfigured')

    if backend != 'memfile':
        _add_reservation({
            "hw-address": "ff:01:02:03:ff:01",
            "ip-address": "192.168.50.50"
        })

    misc.test_procedure()
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.5')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'NAK')

    srv_msg.forge_sleep(6, 'seconds')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'OFFER')
    srv_msg.response_check_content('yiaddr', '192.168.50.50')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01')
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.50')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ACK')
    srv_msg.response_check_content('yiaddr', '192.168.50.50')
コード例 #4
0
def test_v4_host_reservation_conflicts_reconfigure_server_add_reservation_for_host_that_has_lease(
        backend):
    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.5-192.168.50.5')
    srv_control.open_control_channel()
    srv_control.agent_control_channel(world.f_cfg.mgmt_address)
    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'OFFER')

    misc.test_procedure()
    srv_msg.client_copy_option('server_id')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ACK')
    srv_msg.response_check_content('yiaddr', '192.168.50.5')

    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.5-192.168.50.5')
    srv_control.open_control_channel()
    srv_control.agent_control_channel(world.f_cfg.mgmt_address)
    if backend == 'memfile':
        srv_control.host_reservation_in_subnet('ip-address', '192.168.50.50',
                                               0, 'hw-address',
                                               'ff:01:02:03:ff:04')
    else:
        srv_control.dump_db_reservation(backend)
        srv_control.add_hooks('libdhcp_host_cmds.so')
        srv_control.enable_db_backend_reservation(backend)

    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'reconfigured')

    if backend != 'memfile':
        _add_reservation({
            "hw-address": "ff:01:02:03:ff:04",
            "ip-address": "192.168.50.50"
        })

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_dont_wait_for_message()

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'OFFER')
    srv_msg.response_check_content('yiaddr', '192.168.50.50')

    misc.test_procedure()
    srv_msg.client_copy_option('server_id')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ACK')
    srv_msg.response_check_content('yiaddr', '192.168.50.50')

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'OFFER')

    misc.test_procedure()
    srv_msg.client_copy_option('server_id')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:01')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ACK')
    srv_msg.response_check_content('yiaddr', '192.168.50.5')
コード例 #5
0
def test_v4_host_reservation_conflicts_change_reserved_address_during_reconfigure(
        backend):
    misc.test_setup()
    # reconfigure different address for same MAC from outside of the pool
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.5-192.168.50.9')
    srv_control.open_control_channel()
    srv_control.agent_control_channel(world.f_cfg.mgmt_address)
    if backend == 'memfile':
        srv_control.host_reservation_in_subnet('ip-address', '192.168.50.10',
                                               0, 'hw-address',
                                               'ff:01:02:03:ff:04')
    else:
        srv_control.add_hooks('libdhcp_host_cmds.so')
        srv_control.enable_db_backend_reservation(backend)

    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'started')

    if backend != 'memfile':
        _add_reservation({
            "hw-address": "ff:01:02:03:ff:04",
            "ip-address": "192.168.50.10"
        })

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'OFFER')

    misc.test_procedure()
    srv_msg.client_copy_option('server_id')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ACK')
    srv_msg.response_check_content('yiaddr', '192.168.50.10')

    misc.test_setup()
    srv_control.config_srv_subnet('192.168.50.0/24',
                                  '192.168.50.5-192.168.50.9')
    srv_control.open_control_channel()
    srv_control.agent_control_channel(world.f_cfg.mgmt_address)
    if backend == 'memfile':
        srv_control.host_reservation_in_subnet('ip-address', '192.168.50.30',
                                               0, 'hw-address',
                                               'ff:01:02:03:ff:04')
    else:
        srv_control.dump_db_reservation(backend)
        srv_control.add_hooks('libdhcp_host_cmds.so')
        srv_control.enable_db_backend_reservation(backend)

    srv_control.build_and_send_config_files()
    srv_control.start_srv('DHCP', 'reconfigured')

    if backend != 'memfile':
        _add_reservation({
            "hw-address": "ff:01:02:03:ff:04",
            "ip-address": "192.168.50.30"
        })

    misc.test_procedure()
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('DISCOVER')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'OFFER')

    misc.test_procedure()
    srv_msg.client_copy_option('server_id')
    srv_msg.client_does_include_with_value('requested_addr', '192.168.50.30')
    srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04')
    srv_msg.client_send_msg('REQUEST')

    misc.pass_criteria()
    srv_msg.send_wait_for_message('MUST', 'ACK')
    srv_msg.response_check_content('yiaddr', '192.168.50.30')