def test_v4_hosts_cmds_get_reservation_pgsql_2(): misc.test_setup() srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.100', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files('SSH', 'config-file') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.100') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command": "reservation-get","arguments":{"subnet-id":1,"identifier-type": "hw-address","identifier":"ff:01:02:03:ff:04"}}')
def test_v4_host_reservation_pgsql_one_address_outside_pool_dual_backend_2(): misc.test_setup() # outside of the pool srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.30-192.168.50.50') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('next_server', '1.1.1.1', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.host_reservation_in_subnet('address', '192.168.50.11', '0', 'hw-address', 'ff:01:02:03:ff:03') srv_control.build_and_send_config_files('SSH', 'config-file') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:03') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.11') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.11') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:03') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.11') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_v6_host_reservation_pgsql_duid_ll_matching(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::100')
def test_v4_host_reservation_mysql_multiple_address_reservation_empty_pool(): misc.test_setup() # request address from different mac that has been reserved srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'MySQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'MySQL', '1') srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:03') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', '2') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.11', 'MySQL', '2') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'MySQL', '2') srv_control.upload_db_reservation('MySQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') 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()
def test_v6_host_reservation_pgsql_hwaddrr_matching(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::100') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::100')
def test_v4_host_reservation_mysql_one_address_inside_pool_different_mac(): misc.test_setup() # request address from different mac that has been reserved srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'MySQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'MySQL', '1') srv_control.upload_db_reservation('MySQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') 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', None, 'OFFER') srv_msg.response_check_content('Response', 'NOT ', 'yiaddr', '192.168.50.10') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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', None, 'NAK') srv_msg.response_check_content('Response', None, 'yiaddr', '0.0.0.0')
def test_v4_hosts_cmds_get_reservation_pgsql_2(): misc.test_setup() srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel() srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.100', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files('SSH', 'config-file') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.100') srv_msg.send_ctrl_cmd_via_socket('{"command": "reservation-get","arguments":{"subnet-id":1,"identifier-type": "hw-address","identifier":"ff:01:02:03:ff:04"}}')
def test_v6_host_reservation_mysql_duid_llt_matching(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation( 'MySQL', 'duid', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') # Create new MySQL reservation identified by hw-address f6:f5:f4:f3:f2:01. srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'MySQL', 1) srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'MySQL', 1) srv_control.upload_db_reservation('MySQL') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::100')
def test_v4_hosts_cmds_conflicts_duplicate_ip_reservations(hosts_db): misc.test_setup() srv_control.add_hooks('libdhcp_host_cmds.so') 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.enable_db_backend_reservation(hosts_db) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') srv_msg.send_ctrl_cmd_via_socket( {"command": "reservation-add", "arguments": {"reservation": { "subnet-id": 1, "hw-address": "ff:01:02:03:ff:01", "ip-address": "192.168.50.10"}}}) # the same IP - it should fail srv_msg.send_ctrl_cmd_via_socket( {"command": "reservation-add", "arguments": {"reservation": { "subnet-id": 1, "hw-address": "ff:01:02:03:ff:02", "ip-address": "192.168.50.10"}}}, exp_result=1)
def test_v4_host_reservation_mysql_one_address_inside_pool_different_mac(): misc.test_setup() # request address from different mac that has been reserved srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', 1) srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'MySQL', 1) srv_control.update_db_backend_reservation('dhcp4_subnet_id', 1, 'MySQL', 1) srv_control.upload_db_reservation('MySQL') 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: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.10', expected=False) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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.response_check_content('yiaddr', '0.0.0.0')
def test_v4_hosts_cmds_get_reservation_mysql(): misc.test_setup() srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel() srv_control.enable_db_backend_reservation('MySQL') 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') srv_msg.response_check_content('yiaddr', '192.168.50.50') srv_msg.send_ctrl_cmd_via_socket('{"command":"reservation-add","arguments":{"reservation":{"subnet-id":1,"hw-address":"ff:01:02:03:ff:04","ip-address":"192.168.50.100"}}}') 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.100') srv_msg.send_ctrl_cmd_via_socket('{"command": "reservation-get","arguments":{"subnet-id":1,"identifier-type": "hw-address","identifier":"ff:01:02:03:ff:04"}}')
def test_v4_hosts_cmds_del_reservation_mysql_2(): misc.test_setup() # address reserved without using command srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel() srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', 1) srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.100', 'MySQL', 1) srv_control.update_db_backend_reservation('dhcp4_subnet_id', 1, 'MySQL', 1) srv_control.upload_db_reservation('MySQL') 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') srv_msg.response_check_content('yiaddr', '192.168.50.100') srv_msg.send_ctrl_cmd_via_socket('{"command":"reservation-del","arguments":{"subnet-id":1,"ip-address":"192.168.50.100"}}') 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')
def test_v6_hooks_flexid_pgsql_2(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.add_line({"host-reservation-identifiers": ["duid", "flex-id"]}) srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook(1, 'identifier-expression', 'vendor[4491].option[1026].hex') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'flex-id', '01:02:03:04:05:06') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', 1) srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'PostgreSQL', 1) srv_control.ipv6_address_db_backend_reservation('3000::f', '$(EMPTY)', 'PostgreSQL', 1) srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'enterprisenum', '4491') srv_msg.client_does_include('Client', 'vendor-class') srv_msg.add_vendor_suboption('Client', 1026, '01:02:03:04:05:06') srv_msg.client_does_include('Client', 'vendor-specific-info') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::f')
def test_v6_host_reservation_mysql_duid_ll_matching_option_inforequest(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'MySQL', '1') srv_control.option_db_record_reservation('7', '10', 'dhcp6', '1', '$(EMPTY)', '1', 'subnet', 'MySQL', '1') srv_control.upload_db_reservation('MySQL') srv_control.config_srv('preference', '0', '123') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_requests_option('7') srv_msg.client_send_msg('INFOREQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', 'NOT ', '3') srv_msg.response_check_include_option('Response', None, '7') srv_msg.response_check_option_content('Response', '7', None, 'value', '123') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_requests_option('7') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', 'NOT ', '3') srv_msg.response_check_include_option('Response', None, '7') srv_msg.response_check_option_content('Response', '7', None, 'value', '10') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:21') srv_msg.client_requests_option('7') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_include_option('Response', None, '7') srv_msg.response_check_option_content('Response', '7', None, 'value', '123')
def test_v4_host_reservation_mysql_one_address_outside_pool_dual_backend(): misc.test_setup() # outside of the pool srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.30-192.168.50.50') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', 1) srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'MySQL', 1) srv_control.update_db_backend_reservation('dhcp4_subnet_id', 1, 'MySQL', 1) srv_control.upload_db_reservation('MySQL') srv_control.host_reservation_in_subnet('ip-address', '192.168.50.11', 0, 'hw-address', 'ff:01:02:03:ff:03') 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') srv_msg.response_check_content('yiaddr', '192.168.50.10') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:03') 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.11') srv_msg.response_check_option_content(1, 'value', '255.255.255.0') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.11') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:03') 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.11') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
def test_v6_host_reservation_mysql_all_values_duid(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', 1) srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'MySQL', 1) srv_control.ipv6_prefix_db_backend_reservation('3001::', 40, '$(EMPTY)', 'MySQL', 1) srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'MySQL', 1) srv_control.upload_db_reservation('MySQL') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', True) srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'IA-PD') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('IA_PD') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'some-different-name') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', 'fqdn') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::100') srv_msg.response_check_include_option(25) srv_msg.response_check_option_content(25, 'sub-option', 26) srv_msg.response_check_suboption_content(26, 25, 'prefix', '3001::') srv_msg.response_check_include_option(39) srv_msg.response_check_option_content(39, 'fqdn', 'reserved-hostname.my.domain.com.')
def test_v4_hosts_cmds_libreload(): misc.test_setup() srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.enable_db_backend_reservation('MySQL') srv_control.build_and_send_config_files('SSH', 'config-file') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.50') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command":"reservation-add","arguments":{"reservation":{"subnet-id":1,"hw-address":"ff:01:02:03:ff:04","ip-address":"192.168.50.100"}}}') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.100') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.100') 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', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.100') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command": "libreload","arguments": {}}') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command":"reservation-del","arguments":{"subnet-id":1,"ip-address":"192.168.50.100"}}') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.50')
def test_v6_host_reservation_mysql_all_values_duid_2(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.config_srv_prefix('3001::', '0', '32', '33') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'duid', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', '1') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'MySQL', '1') srv_control.ipv6_prefix_db_backend_reservation('3001::', '40', '$(EMPTY)', 'MySQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'MySQL', '1') srv_control.upload_db_reservation('MySQL') srv_control.add_ddns_server('127.0.0.1', '53001') srv_control.add_ddns_server_options('enable-updates', 'true') srv_control.add_ddns_server_options('qualifying-suffix', 'my.domain.com') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'IA-PD') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('IA_PD') srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_sets_value('Client', 'FQDN_domain_name', 'some-different-name') srv_msg.client_sets_value('Client', 'FQDN_flags', 'S') srv_msg.client_does_include('Client', None, 'fqdn') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::100') srv_msg.response_check_include_option('Response', None, '25') srv_msg.response_check_option_content('Response', '25', None, 'sub-option', '26') srv_msg.response_check_suboption_content('Response', '26', '25', None, 'prefix', '3001::') srv_msg.response_check_include_option('Response', None, '39') srv_msg.response_check_option_content('Response', '39', None, 'fqdn', 'reserved-hostname.my.domain.com.')
def test_v4_host_reservation_mysql_one_address_inside_pool_option(): misc.test_setup() # outside of the pool # TODO update names srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'ff:01:02:03:ff:04') srv_control.update_db_backend_reservation('next_server', '11.1.1.1', 'MySQL', '1') srv_control.update_db_backend_reservation('server_hostname', 'hostname-server.com', 'MySQL', '1') srv_control.update_db_backend_reservation('boot_file_name', 'file-name', 'MySQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'MySQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'MySQL', '1') srv_control.option_db_record_reservation('11', '10.0.0.1', 'dhcp4', '1', '$(EMPTY)', '1', 'subnet', 'MySQL', '1') srv_control.config_srv_opt('resource-location-servers', '199.199.199.1,150.150.150.1') srv_control.upload_db_reservation('MySQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_requests_option('11') 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', None, 'OFFER') srv_msg.response_check_include_option('Response', None, '11') srv_msg.response_check_option_content('Response', '11', None, 'value', '10.0.0.1') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_v6_host_reservation_pgsql_hwaddrr_matching_option(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'PostgreSQL', '1') srv_control.option_db_record_reservation('7', '10', 'dhcp6', '1', '$(EMPTY)', '1', 'subnet', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.config_srv_opt('preference', '12') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_requests_option('7') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') # Response sub-option 5 from option 3 MUST contain address 3000::100. srv_msg.response_check_include_option('Response', None, '7') srv_msg.response_check_option_content('Response', '7', None, 'value', '10') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:22') srv_msg.client_requests_option('7') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') # Response sub-option 5 from option 3 MUST contain address 3000::100. srv_msg.response_check_include_option('Response', None, '7') srv_msg.response_check_option_content('Response', '7', None, 'value', '12')
def test_v4_hosts_cmds_libreload(): misc.test_setup() srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel() srv_control.enable_db_backend_reservation('MySQL') srv_control.build_and_send_config_files('SSH', 'config-file') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.50') srv_msg.send_ctrl_cmd_via_socket('{"command":"reservation-add","arguments":{"reservation":{"subnet-id":1,"hw-address":"ff:01:02:03:ff:04","ip-address":"192.168.50.100"}}}') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.100') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.100') 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', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.100') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0') srv_msg.send_ctrl_cmd_via_socket('{"command": "libreload","arguments": {}}') srv_msg.send_ctrl_cmd_via_socket('{"command":"reservation-del","arguments":{"subnet-id":1,"ip-address":"192.168.50.100"}}') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.50')
def _create_pgsql_dump(): # dump for postrgesql is bit different because we do not have config backend for postgres # but we will still use kea 1.6.3 to generate this. In future we will have to create new dump with # config backend data srv_msg.remove_file_from_server('$(SOFTWARE_INSTALL_PATH)/pg_db_v4.sql') world.f_cfg.multi_threading_enabled = False misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.10-192.168.50.10') srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.add_hooks('libdhcp_cb_cmds.so') srv_control.add_hooks('libdhcp_mysql_cb.so') srv_control.open_control_channel() srv_control.agent_control_channel('$(MGMT_ADDRESS)') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.define_temporary_lease_db_backend('postgresql') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') hr = {"reservation": {"subnet-id": 1, "hw-address": "01:0a:0b:0c:0d:0e:0f", "ip-address": "192.168.50.205", "next-server": "192.0.2.1", "server-hostname": "hal9000", "boot-file-name": "/dev/null", "option-data": [{"name": "domain-name-servers", "data": "10.1.1.202,10.1.1.203"}], "client-classes": ["special_snowflake", "office"]}} _send_cmd("reservation-add", hr) 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.10') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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') # wanted to do this with fabric_sudo_command(cmd, sudo_user='******' but it failed cmd = "sudo -S -u postgres pg_dump %s >%s/pg_db_v4.sql" % (world.f_cfg.db_name, world.f_cfg.software_install_path) fabric_run_command(cmd, ignore_errors=False, destination_host=world.f_cfg.mgmt_address) srv_msg.execute_shell_cmd("sed -i 's/$(DB_USER)/!db_user!/g' %s/pg_db_v4.sql" % world.f_cfg.software_install_path)
def test_v6_host_reservation_mysql_duid_ll_matching_option_no_address_1(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'MySQL', 1) srv_control.option_db_record_reservation(7, 10, 'dhcp6', 1, '$(EMPTY)', 1, 'subnet', 'MySQL', 1) srv_control.upload_db_reservation('MySQL') srv_control.config_srv('preference', 0, '123') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_requests_option(7) srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::100', expect_include=False) srv_msg.response_check_include_option(7) srv_msg.response_check_option_content(7, 'value', 10) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:21') srv_msg.client_requests_option(7) srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_include_option(7) srv_msg.response_check_option_content(7, 'value', 123)
def test_v4_hosts_cmds_add_reservation_complex_mysql(): misc.test_setup() srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel() srv_control.enable_db_backend_reservation('MySQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', '01:0a:0b:0c:0d:0e:0f') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.50') result = srv_msg.send_ctrl_cmd_via_socket('{"command":"reservation-add","arguments":{"reservation":{"subnet-id":1,"client-id":"01:0a:0b:0c:0d:0e:0f","ip-address":"192.0.2.205","next-server":"192.0.2.1","server-hostname":"hal9000","boot-file-name":"/dev/null","option-data":[{"name":"domain-name-servers","data":"10.1.1.202,10.1.1.203"}],"client-classes":["special_snowflake","office"]}}}') assert result['result'] == 0 # TODO: it fails with: "specified reservation '192.0.2.205' is not matching the IPv4 subnet prefix '192.168.50.0/24'", how should Kea behave actually? misc.test_procedure() srv_msg.client_does_include_with_value('client_id', '01:0a:0b:0c:0d:0e:0f') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.0.2.205') srv_msg.response_check_include_option('Response', None, '6') srv_msg.response_check_option_content('Response', '6', None, 'value', '10.1.1.203') srv_msg.response_check_option_content('Response', '6', None, 'value', '10.1.1.202') srv_msg.response_check_content('Response', None, 'sname', 'hal9000') srv_msg.response_check_content('Response', None, 'file', '/dev/null') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.0.2.205') srv_msg.client_does_include_with_value('client_id', '01:0a:0b:0c:0d:0e:0f') srv_msg.client_sets_value('Client', 'chaddr', '01:0a:0b:0c:0d:0e:0f') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.0.2.205') srv_msg.response_check_include_option('Response', None, '6') srv_msg.response_check_option_content('Response', '6', None, 'value', '10.1.1.203') srv_msg.response_check_option_content('Response', '6', None, 'value', '10.1.1.202') srv_msg.response_check_content('Response', None, 'sname', 'hal9000') srv_msg.response_check_content('Response', None, 'file', '/dev/null')
def test_v4_hosts_cmds_add_reservation_pgsql_flex_id(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cmds.so') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_flex_id.so') srv_control.add_parameter_to_hook('2', 'identifier-expression', 'option[60].hex') srv_control.add_line('"host-reservation-identifiers": [ "flex-id" ]') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.50') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command":"reservation-add","arguments":{"reservation":{"subnet-id":1,"flex-id":"\'docsis3.0\'","ip-address":"192.168.50.100"}}}') misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.100') misc.test_procedure() # Client adds to the message vendor_class_id with value docsis3.0. srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.100') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.100') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_v4_hooks_flexid_pgsql_1(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.5') srv_control.add_line( {"host-reservation-identifiers": ["hw-address", "flex-id"]}) srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook(1, 'identifier-expression', 'option[60].hex') srv_control.add_parameter_to_hook(1, 'replace-client-id', True) # enable matching client id srv_control.set_conf_parameter_global('match-client-id', True) srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'flex-id', '646f63736973332e30') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', 1) srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'PostgreSQL', 1) srv_control.update_db_backend_reservation('dhcp4_subnet_id', 1, 'PostgreSQL', 1) srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') # Pause the Test. misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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.10') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') srv_msg.client_sets_value('Client', 'chaddr', 'ff:01:02:03:ff:04') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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') srv_msg.response_check_include_option(1) srv_msg.response_check_option_content(1, 'value', '255.255.255.0')
def test_v4_hosts_cmds_add_reservation_pgsql_flex_id(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel() srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook('2', 'identifier-expression', 'option[60].hex') srv_control.add_line('"host-reservation-identifiers": [ "flex-id" ]') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.50') srv_msg.send_ctrl_cmd_via_socket('{"command":"reservation-add","arguments":{"reservation":{"subnet-id":1,"flex-id":"\'docsis3.0\'","ip-address":"192.168.50.100"}}}') misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.100') misc.test_procedure() # Client adds to the message vendor_class_id with value docsis3.0. srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.100') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.100') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_v4_hosts_cmds_add_reservation_complex_mysql(): misc.test_setup() srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_host_cmds.so') srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.50-192.168.50.50') srv_control.open_control_channel('unix', '$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket') srv_control.enable_db_backend_reservation('MySQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', '01:0a:0b:0c:0d:0e:0f') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.50') srv_msg.send_through_socket_server_site('$(SOFTWARE_INSTALL_DIR)/var/kea/control_socket', '{"command":"reservation-add","arguments":{"reservation":{"subnet-id":1,"client-id":"01:0a:0b:0c:0d:0e:0f","ip-address":"192.0.2.205","next-server":"192.0.2.1","server-hostname":"hal9000","boot-file-name":"/dev/null","option-data":[{"name":"domain-name-servers","data":"10.1.1.202,10.1.1.203"}],"client-classes":["special_snowflake","office"]}}}') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', '01:0a:0b:0c:0d:0e:0f') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.0.2.205') srv_msg.response_check_include_option('Response', None, '6') srv_msg.response_check_option_content('Response', '6', None, 'value', '10.1.1.203') srv_msg.response_check_option_content('Response', '6', None, 'value', '10.1.1.202') srv_msg.response_check_content('Response', None, 'sname', 'hal9000') srv_msg.response_check_content('Response', None, 'file', '/dev/null') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.0.2.205') srv_msg.client_does_include_with_value('client_id', '01:0a:0b:0c:0d:0e:0f') srv_msg.client_sets_value('Client', 'chaddr', '01:0a:0b:0c:0d:0e:0f') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.0.2.205') srv_msg.response_check_include_option('Response', None, '6') srv_msg.response_check_option_content('Response', '6', None, 'value', '10.1.1.203') srv_msg.response_check_option_content('Response', '6', None, 'value', '10.1.1.202') srv_msg.response_check_content('Response', None, 'sname', 'hal9000') srv_msg.response_check_content('Response', None, 'file', '/dev/null')
def test_v4_host_reservation_pgsql_client_id_one_address_inside_pool(): misc.test_setup() # outside of the pool # TODO update names srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'client-id', '00010203040577') srv_control.add_line( '"host-reservation-identifiers": [ "hw-address", "duid", "client-id" ]' ) srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files('SSH', 'config-file') 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_does_include_with_value('client_id', '00010203040577') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', '00010203040577') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_v6_host_reservation_duplicate_reservation_address(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::1', '$(EMPTY)', 'PostgreSQL', '1') srv_control.new_db_backend_reservation('PostgreSQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:11') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::1', '$(EMPTY)', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') # upload should failed! #TODO add step to failed upload srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started')
def test_v4_hooks_flexid_mysql_1(): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.5') srv_control.add_line('"host-reservation-identifiers": ["hw-address", "flex-id" ]') srv_control.add_hooks('$(SOFTWARE_INSTALL_DIR)/lib/kea/hooks/libdhcp_flex_id.so') srv_control.add_parameter_to_hook('1', 'identifier-expression', 'option[60].hex') srv_control.add_parameter_to_hook('1', 'replace-client-id', 'true') # enable matching client id srv_control.set_conf_parameter_global('match-client-id', 'true') srv_control.enable_db_backend_reservation('MySQL') # 646f63736973332e30 = docsis3.0 srv_control.new_db_backend_reservation('MySQL', 'flex-id', '646f63736973332e30') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'MySQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'MySQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'MySQL', '1') srv_control.upload_db_reservation('MySQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') # Pause the Test. misc.test_procedure() srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') 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', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') misc.test_procedure() srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('vendor_class_id', 'docsis3.0') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_v4_host_reservation_allowed_duplicate_mac_reservations_command_control( backend): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.set_conf_parameter_global('ip-reservations-unique', False) srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.open_control_channel() srv_control.agent_control_channel(world.f_cfg.mgmt_address) srv_control.enable_db_backend_reservation(backend) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') assert _add_reservation({ "hw-address": "ff:01:02:03:ff:77", "ip-address": "192.168.50.2" })["text"] == "Host added." assert _add_reservation({ "hw-address": "ff:01:02:03:ff:66", "ip-address": "192.168.50.2" })["text"] == "Host added."
def test_v4_host_reservation_conflicts_duplicate_mac_reservations_command_control( backend): misc.test_setup() srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.add_hooks('libdhcp_host_cmds.so') srv_control.open_control_channel() srv_control.agent_control_channel(world.f_cfg.mgmt_address) srv_control.enable_db_backend_reservation(backend) srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') assert _add_reservation({ "hw-address": "ff:01:02:03:ff:77", "ip-address": "192.168.50.2" })["text"] == "Host added." assert _add_reservation( { "hw-address": "ff:01:02:03:ff:66", "ip-address": "192.168.50.2" }, exp_result=1)["text"] == "Database duplicate entry error"
def test_v6_host_reservation_pgsql_hwaddrr_matching_option_inforequest(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'PostgreSQL', 1) srv_control.option_db_record_reservation(7, 10, 'dhcp6', 1, '$(EMPTY)', 1, 'subnet', 'PostgreSQL', 1) srv_control.upload_db_reservation('PostgreSQL') srv_control.config_srv_opt('preference', '12') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_requests_option(7) srv_msg.client_send_msg('INFOREQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(3, expect_include=False) srv_msg.response_check_include_option(7) srv_msg.response_check_option_content(7, 'value', 12) misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:01:00:01:52:7b:a8:f0:f6:f5:f4:f3:f2:01') srv_msg.client_requests_option(7) srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(3, expect_include=False) srv_msg.response_check_include_option(7) srv_msg.response_check_option_content(7, 'value', 10)
def test_v6_host_reservation_mysql_duplicate_reservation_duid(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'MySQL', 1) srv_control.ipv6_address_db_backend_reservation('3000::1', '$(EMPTY)', 'MySQL', 1) srv_control.new_db_backend_reservation('MySQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'MySQL', 2) srv_control.ipv6_address_db_backend_reservation('3000::2', '$(EMPTY)', 'MySQL', 2) srv_control.upload_db_reservation('MySQL', exp_failed=True) # upload should failed! # TODO add step to check failed upload srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started')
def test_v6_hooks_flexid_pgsql_1(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.add_line({"host-reservation-identifiers": ["duid", "flex-id"]}) srv_control.add_hooks('libdhcp_flex_id.so') srv_control.add_parameter_to_hook(1, 'identifier-expression', 'relay6[0].option[18].hex') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'flex-id', '706f727431323334') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', 1) srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'PostgreSQL', 1) srv_control.ipv6_address_db_backend_reservation('3000::f', '$(EMPTY)', 'PostgreSQL', 1) srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') # Pause the Test. misc.test_procedure() srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') srv_msg.client_sets_value('RelayAgent', 'ifaceid', 'port1234') srv_msg.client_does_include('RelayAgent', 'interface-id') srv_msg.create_relay_forward() misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'RELAYREPLY') srv_msg.response_check_include_option(18) srv_msg.response_check_include_option(9) srv_msg.response_check_option_content(9, 'Relayed', 'Message') srv_msg.response_check_include_option(1) srv_msg.response_check_include_option(2) srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::f')
def test_v4_host_reservation_pgsql_client_id_one_address_inside_pool(): misc.test_setup() # outside of the pool # TODO update names srv_control.config_srv_subnet('192.168.50.0/24', '192.168.50.1-192.168.50.50') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'client-id', '00010203040577') srv_control.add_line('"host-reservation-identifiers": [ "hw-address", "duid", "client-id" ]') srv_control.update_db_backend_reservation('hostname', 'reserved-hostname', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('ipv4_address', '192.168.50.10', 'PostgreSQL', '1') srv_control.update_db_backend_reservation('dhcp4_subnet_id', '1', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files('SSH', 'config-file') 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_does_include_with_value('client_id', '00010203040577') srv_msg.client_send_msg('DISCOVER') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'OFFER') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') misc.test_procedure() srv_msg.client_does_include_with_value('client_id', '00010203040577') srv_msg.client_copy_option('server_id') srv_msg.client_does_include_with_value('requested_addr', '192.168.50.10') 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', None, 'ACK') srv_msg.response_check_content('Response', None, 'yiaddr', '192.168.50.10') srv_msg.response_check_include_option('Response', None, '1') srv_msg.response_check_option_content('Response', '1', None, 'value', '255.255.255.0')
def test_v6_host_reservation_mysql_conflicts_reconfigure_server_with_reservation_of_used_address_2(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::2') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '13') srv_msg.response_check_suboption_content('Response', '13', '3', None, 'statuscode', '2') # bigger prefix pool + reservation misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'hw-address', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'MySQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::1', '$(EMPTY)', 'MySQL', '1') srv_control.upload_db_reservation('MySQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', 'NOT ', 'addr', '3000::1')
def test_v6_host_reservation_pgsql_option_multiple(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'PostgreSQL', 1) srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'PostgreSQL', 1) srv_control.option_db_record_reservation(7, 10, 'dhcp6', 1, '$(EMPTY)', 1, 'subnet', 'PostgreSQL', 1) srv_control.option_db_record_reservation(21, 'srv1.example.com,srv2.isc.org', 'dhcp6', 1, '$(EMPTY)', 1, 'subnet', 'PostgreSQL', 1) srv_control.option_db_record_reservation(23, '2001:db8::1,2001:db8::2', 'dhcp6', 1, '$(EMPTY)', 1, 'subnet', 'PostgreSQL', 1) srv_control.option_db_record_reservation( 59, 'http://www.kea-reserved.isc.org', 'dhcp6', 1, '$(EMPTY)', 1, 'subnet', 'PostgreSQL', 1) # Add option reservation code 60 value 10 space dhcp6 persistent 1 client class $(EMPTY) subnet id 1 and scope subnet to MySQL record id 1. srv_control.upload_db_reservation('PostgreSQL') srv_control.config_srv('preference', 0, '123') srv_control.config_srv_opt('sip-server-dns', 'srv4.example.com,srv5.isc.org') # 21 srv_control.config_srv_opt('dns-servers', '2001:db8::4,2001:db8::5') # 23 srv_control.config_srv_opt('bootfile-url', 'http://www.kea.isc.org') # 59 srv_control.config_srv_opt('new-tzdb-timezone', 'Europe/Zurich') # 60 and not reserved srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_requests_option(7) srv_msg.client_requests_option(21) srv_msg.client_requests_option(23) srv_msg.client_requests_option(42) srv_msg.client_requests_option(59) srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::100') srv_msg.response_check_include_option(7) srv_msg.response_check_option_content(7, 'value', 10) srv_msg.response_check_include_option(59) srv_msg.response_check_option_content(59, 'optdata', 'http://www.kea-reserved.isc.org') srv_msg.response_check_include_option(21) srv_msg.response_check_option_content(21, 'addr', 'srv1.example.com.,srv2.isc.org.') srv_msg.response_check_include_option(23) srv_msg.response_check_option_content(23, 'addr', '2001:db8::1,2001:db8::2') srv_msg.response_check_include_option(42) srv_msg.response_check_option_content(42, 'optdata', 'Europe/Zurich') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:21') srv_msg.client_requests_option(7) srv_msg.client_requests_option(21) srv_msg.client_requests_option(23) srv_msg.client_requests_option(59) srv_msg.client_requests_option(42) srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_include_option(7) srv_msg.response_check_option_content(7, 'value', 123) srv_msg.response_check_include_option(59) srv_msg.response_check_option_content(59, 'optdata', 'http://www.kea.isc.org') srv_msg.response_check_include_option(21) srv_msg.response_check_option_content(21, 'addr', 'srv4.example.com.,srv5.isc.org.') srv_msg.response_check_include_option(23) srv_msg.response_check_option_content(23, 'addr', '2001:db8::4,2001:db8::5') srv_msg.response_check_include_option(42) srv_msg.response_check_option_content(42, 'optdata', 'Europe/Zurich')
def test_v6_host_reservation_pgsql_option_multiple(): misc.test_setup() srv_control.config_srv_subnet('3000::/64', '3000::1-3000::ff') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::100', '$(EMPTY)', 'PostgreSQL', '1') srv_control.option_db_record_reservation('7', '10', 'dhcp6', '1', '$(EMPTY)', '1', 'subnet', 'PostgreSQL', '1') srv_control.option_db_record_reservation('21', 'srv1.example.com,srv2.isc.org', 'dhcp6', '1', '$(EMPTY)', '1', 'subnet', 'PostgreSQL', '1') srv_control.option_db_record_reservation('23', '2001:db8::1,2001:db8::2', 'dhcp6', '1', '$(EMPTY)', '1', 'subnet', 'PostgreSQL', '1') srv_control.option_db_record_reservation('59', 'http://www.kea-reserved.isc.org', 'dhcp6', '1', '$(EMPTY)', '1', 'subnet', 'PostgreSQL', '1') # Add option reservation code 60 value 10 space dhcp6 persistent 1 client class $(EMPTY) subnet id 1 and scope subnet to MySQL record id 1. srv_control.upload_db_reservation('PostgreSQL') srv_control.config_srv('preference', '0', '123') srv_control.config_srv_opt('sip-server-dns', 'srv4.example.com,srv5.isc.org') # 21 srv_control.config_srv_opt('dns-servers', '2001:db8::4,2001:db8::5') # 23 srv_control.config_srv_opt('bootfile-url', 'http://www.kea.isc.org') # 59 srv_control.config_srv_opt('new-tzdb-timezone', 'Europe/Zurich') # 60 and not reserved srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_requests_option('7') srv_msg.client_requests_option('21') srv_msg.client_requests_option('23') srv_msg.client_requests_option('42') srv_msg.client_requests_option('59') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::100') srv_msg.response_check_include_option('Response', None, '7') srv_msg.response_check_option_content('Response', '7', None, 'value', '10') srv_msg.response_check_include_option('Response', None, '59') srv_msg.response_check_option_content('Response', '59', None, 'optdata', 'http://www.kea-reserved.isc.org') srv_msg.response_check_include_option('Response', None, '21') srv_msg.response_check_option_content('Response', '21', None, 'addr', 'srv1.example.com.,srv2.isc.org.') srv_msg.response_check_include_option('Response', None, '23') srv_msg.response_check_option_content('Response', '23', None, 'addr', '2001:db8::1,2001:db8::2') srv_msg.response_check_include_option('Response', None, '42') srv_msg.response_check_option_content('Response', '42', None, 'optdata', 'Europe/Zurich') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:21') srv_msg.client_requests_option('7') srv_msg.client_requests_option('21') srv_msg.client_requests_option('23') srv_msg.client_requests_option('59') srv_msg.client_requests_option('42') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_include_option('Response', None, '7') srv_msg.response_check_option_content('Response', '7', None, 'value', '123') srv_msg.response_check_include_option('Response', None, '59') srv_msg.response_check_option_content('Response', '59', None, 'optdata', 'http://www.kea.isc.org') srv_msg.response_check_include_option('Response', None, '21') srv_msg.response_check_option_content('Response', '21', None, 'addr', 'srv4.example.com.,srv5.isc.org.') srv_msg.response_check_include_option('Response', None, '23') srv_msg.response_check_option_content('Response', '23', None, 'addr', '2001:db8::4,2001:db8::5') srv_msg.response_check_include_option('Response', None, '42') srv_msg.response_check_option_content('Response', '42', None, 'optdata', 'Europe/Zurich')
def test_v6_host_reservation_pgsql_conflicts_two_entries_for_one_host_different_subnets(): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::1', '$(EMPTY)', 'PostgreSQL', '1') srv_control.new_db_backend_reservation('PostgreSQL', 'hw-address', 'f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '2', 'PostgreSQL', '2') srv_control.ipv6_address_db_backend_reservation('3000::3', '$(EMPTY)', 'PostgreSQL', '2') srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', '666') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_sets_value('Client', 'ia_id', '666') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', '667') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'ia_id', '667') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', 'NOT ', 'addr', '3000::3')
def test_v6_host_reservation_pgsql_conflicts_reconfigure_server_with_reservation_of_used_address_renew_after_expire(): misc.test_setup() srv_control.set_time('renew-timer', '5') srv_control.set_time('rebind-timer', '6') srv_control.set_time('preferred-lifetime', '7') srv_control.set_time('valid-lifetime', '8') srv_control.config_srv_subnet('3000::/30', '3000::1-3000::2') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') # SAVE VALUES srv_msg.client_save_option('IA_NA') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '13') srv_msg.response_check_suboption_content('Response', '13', '3', None, 'statuscode', '2') # bigger prefix pool + reservation srv_msg.forge_sleep('5', 'seconds') misc.test_setup() srv_control.set_time('renew-timer', '5') srv_control.set_time('rebind-timer', '6') srv_control.set_time('preferred-lifetime', '7') srv_control.set_time('valid-lifetime', '8') srv_control.config_srv_subnet('3000::/30', '3000::1-3000::3') srv_control.enable_db_backend_reservation('PostgreSQL') srv_control.new_db_backend_reservation('PostgreSQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', '1', 'PostgreSQL', '1') srv_control.ipv6_address_db_backend_reservation('3000::2', '$(EMPTY)', 'PostgreSQL', '1') srv_control.upload_db_reservation('PostgreSQL') srv_control.build_and_send_config_files('SSH', 'config-file') srv_control.start_srv('DHCP', 'reconfigured') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') srv_msg.client_add_saved_option('DONT ') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('RENEW') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'validlft', '0') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::2') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'validlft', '8') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_does_include('Client', None, 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', None, 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', None, 'REPLY') srv_msg.response_check_include_option('Response', None, '3') srv_msg.response_check_option_content('Response', '3', None, 'sub-option', '5') srv_msg.response_check_suboption_content('Response', '5', '3', None, 'addr', '3000::2')
def test_v6_host_reservation_mysql_conflicts_reconfigure_server_with_reservation_of_used_address_renew_after_expire( ): misc.test_setup() srv_control.set_time('renew-timer', 5) srv_control.set_time('rebind-timer', 6) srv_control.set_time('preferred-lifetime', 7) srv_control.set_time('valid-lifetime', 8) srv_control.config_srv_subnet('3000::/30', '3000::1-3000::2') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', '6661') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:11') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', '6662') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') # SAVE VALUES srv_msg.client_save_option('IA_NA') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', '6663') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 13) srv_msg.response_check_suboption_content(13, 3, 'statuscode', 2) # bigger prefix pool + reservation srv_msg.forge_sleep(10, 'seconds') misc.test_setup() srv_control.set_time('renew-timer', 5) srv_control.set_time('rebind-timer', 6) srv_control.set_time('preferred-lifetime', 7) srv_control.set_time('valid-lifetime', 8) srv_control.config_srv_subnet('3000::/30', '3000::1-3000::2') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'MySQL', 1) srv_control.ipv6_address_db_backend_reservation('3000::2', '$(EMPTY)', 'MySQL', 1) srv_control.upload_db_reservation('MySQL') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'reconfigured') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', 666) srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:66:55:44:33:22:22') srv_msg.client_add_saved_option('DONT ') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('RENEW') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'validlft', 0) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::2') srv_msg.response_check_suboption_content(5, 3, 'validlft', 8) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::2')
def test_v6_host_reservation_mysql_conflicts_two_entries_for_one_host_different_subnets( ): misc.test_setup() srv_control.config_srv_subnet('3000::/30', '3000::1-3000::10') srv_control.enable_db_backend_reservation('MySQL') srv_control.new_db_backend_reservation('MySQL', 'duid', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', 1, 'MySQL', 1) srv_control.ipv6_address_db_backend_reservation('3000::1', '$(EMPTY)', 'MySQL', 1) srv_control.new_db_backend_reservation('MySQL', 'hw-address', 'f6:f5:f4:f3:f2:01') srv_control.update_db_backend_reservation('dhcp6_subnet_id', 2, 'MySQL', 2) srv_control.ipv6_address_db_backend_reservation('3000::3', '$(EMPTY)', 'MySQL', 2) srv_control.upload_db_reservation('MySQL') srv_control.build_and_send_config_files() srv_control.start_srv('DHCP', 'started') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', 666) srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) misc.test_procedure() srv_msg.client_copy_option('server-id') srv_msg.client_copy_option('IA_NA') srv_msg.client_sets_value('Client', 'ia_id', 666) srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::1') misc.test_procedure() srv_msg.client_sets_value('Client', 'ia_id', '667') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_does_include('Client', 'IA-NA') srv_msg.client_send_msg('SOLICIT') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'ADVERTISE') srv_msg.response_check_include_option(3) srv_msg.response_check_option_content(3, 'sub-option', 5) misc.test_procedure() srv_msg.client_copy_option('IA_NA') srv_msg.client_copy_option('server-id') srv_msg.client_sets_value('Client', 'ia_id', '667') srv_msg.client_sets_value('Client', 'DUID', '00:03:00:01:f6:f5:f4:f3:f2:01') srv_msg.client_does_include('Client', 'client-id') srv_msg.client_send_msg('REQUEST') misc.pass_criteria() srv_msg.send_wait_for_message('MUST', 'REPLY') srv_msg.response_check_option_content(3, 'sub-option', 5) srv_msg.response_check_suboption_content(5, 3, 'addr', '3000::3', expect_include=False)