コード例 #1
0
def test_ft_lldp_docker_restart():
    """
     Author : Karthikeya Kumar CH<*****@*****.**>
     Verify the LLDP functionality after docker restart.
     Reference Test Bed : D1 <--2--> D2
     """
    st.log("Checking the LLDP functionality with docker restart")
    service_name = "lldp"
    basic_obj.service_operations_by_systemctl(vars.D1, service_name, 'stop')
    basic_obj.service_operations_by_systemctl(vars.D1, service_name, 'restart')
    if not basic_obj.poll_for_system_status(vars.D1, service_name, 30, 1):
        st.report_fail("service_not_running", service_name)
    if not basic_obj.verify_service_status(vars.D1, service_name):
        st.report_fail("lldp_service_not_up")
    if not intf_obj.poll_for_interfaces(vars.D1, iteration_count=30, delay=1):
        st.report_fail("interfaces_not_up_after_poll")
    if not lldp_obj.poll_lldp_neighbors(
            vars.D1, iteration_count=30, delay=1, interface=vars.D1D2P1):
        st.report_fail("lldp_neighbors_info_not_found_after_poll")
    lldp_info = lldp_obj.get_lldp_neighbors(vars.D1, interface=vars.D1D2P1)
    if not lldp_info:
        st.error("No lldp entries are available")
        st.report_fail("operation_failed")
    lldp_value_dut1 = lldp_info[0]
    lldp_output_dut1 = lldp_value_dut1['chassis_name']
    hostname_cli_output = basic_obj.get_hostname(vars.D2)
    if lldp_output_dut1 != hostname_cli_output:
        st.report_fail("lldp_cli_not_matching")
    st.log("LLDP and CLI output values are : LLDP:{} , CLI:{} ".format(
        lldp_output_dut1, hostname_cli_output))
    st.report_pass("test_case_passed")
コード例 #2
0
def test_ft_snmp_sysName():
    """
    Author : Karthikeya Kumar CH<*****@*****.**>
    Verify that the sysName MIB object functions properly.
    Reference Test Bed : D1 --- Mgmt Network
    """
    st.log("Ensuring minimum topology")
    hostname = basic_obj.get_hostname(vars.D1)
    get_snmp_output = snmp_obj.get_snmp_operation(
        ipaddress=ipaddress,
        oid=data.oid_sysName,
        community_name=data.ro_community)
    st.log("hostname Device('{}') and SNMP('{}')".format(
        hostname, get_snmp_output[0]))
    if not get_snmp_output[0] == hostname:
        st.report_fail("sysName_verification_fail")
    st.report_pass("test_case_passed")
コード例 #3
0
def test_ft_snmp_docker_restart():
    """
    Author : Karthikeya Kumar CH<*****@*****.**>
    Verify that the sysName MIB object functions properly after docker restart
    Reference Test Bed : D1--- Mgmt Network
    """
    basic_obj.service_operations_by_systemctl(vars.D1, 'snmp', 'restart')
    if not basic_obj.poll_for_system_status(vars.D1, 'snmp', 30, 1):
        st.report_fail("service_not_running".format('snmp'))
    if not basic_obj.verify_service_status(vars.D1, 'snmp'):
        st.report_fail("snmp_service_not_up")
    hostname = basic_obj.get_hostname(vars.D1)
    get_snmp_output = snmp_obj.get_snmp_operation(
        ipaddress=ipaddress,
        oid=data.oid_sysName,
        community_name=data.ro_community)
    st.log("hostname Device('{}') and SNMP('{}')".format(
        hostname, get_snmp_output[0]))
    if not get_snmp_output[0] == hostname:
        st.report_fail("sysName_verification_fail_after_docker_restart")
    st.report_pass("test_case_passed")
コード例 #4
0
def ansible_st_module_hooks(request):
    global dut_dict, dut_ip_dict, host_name_dict, host_name_dict1
    dut_dict, dut_ip_dict, host_name_dict, host_name_dict1 = {}, {}, {}, {}

    st.ensure_min_topology("D1T1:2")
    dut_list = st.get_dut_names()
    for index in range(len(dut_list)):
        dut_name = "dut" + str(index)
        dut_dict[dut_name] = dut_list[index]
        dut = dut_list[index]
        st.log("get host name from DUTs")
        host_name = basic.get_hostname(dut)
        host_name_dict[dut_name] = host_name
        dut_ip_dict[dut_name] =  st.get_mgmt_ip(dut)
        new_host_name = "dut" + str(index) + str(index) + str(index)
        host_name_dict1[dut_name] = new_host_name
        st.log("create new host name in DUTs")
        basic.set_hostname(dut,host_name_dict1[dut_name])
    yield
    st.log("revert host name in DUTs")
    for key in dut_dict.keys():
        basic.set_hostname(dut_dict[key], host_name_dict[key])
コード例 #5
0
ファイル: test_ssh.py プロジェクト: zero804/sonic-mgmt
def test_ft_ssh_add_user_verify():
    """
    Author : Prudvi Mangadu ([email protected])
    """
    user_ssh = 0
    acl_sshv4 = 0
    acl_sshv6 = 0
    acl_snmp = 0

    if not snmp_config(config='add'): acl_snmp = +1

    ipaddress = st.get_mgmt_ip(vars.D1)
    if not ipaddress:
        st.report_env_fail("ip_verification_fail")

    snmp_cmd = "snmpget -Oqv -v 2c -c {} {} {}".format(ssh_data.ro_community,
                                                       ipaddress,
                                                       ssh_data.oid_sysName)

    out = config_nondefault_user()
    if not out: user_ssh = +1

    st.log("connecting to device with username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    if not st.exec_ssh(vars.D1, ssh_data.usr_default, ssh_data.pwd_final,
                       ssh_data.commands_to_verify):
        st.error('Cannot SSH into Device with default credentials')
        user_ssh = +1

    st.log('connecting to device with username={},password={}'.format(
        ssh_data.usr_non_default, ssh_data.pwd_non_default))
    if not st.exec_ssh(vars.D1, ssh_data.usr_non_default,
                       ssh_data.pwd_non_default, ssh_data.commands_to_verify):
        st.error('Cannot SSH into Device with non-default credentials')
        user_ssh = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output:
        user_ssh = +1

    IPAddr = ensure_service_params(vars.D1, "snmptrap", "ip") + "/32"
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_1",
                     "SRC_IP", IPAddr)
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_2",
                     "SRC_IP", IPAddr)
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_3",
                     "SRC_IP", ssh_data.ipv4_network)
    change_acl_rules(acl_data.acl_json_config_control_plane,
                     "V6_SSH_ONLY|RULE_1", "SRC_IPV6",
                     ssh_data.ipv6_network_D1)
    acl_config = acl_data.acl_json_config_control_plane
    st.log("ACL_DATA: {}".format(acl_config))
    acl_obj.apply_acl_config(vars.D1, acl_config)
    acl_obj.show_acl_table(vars.D1)
    acl_obj.show_acl_rule(vars.D1)

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_1"):
        st.error("Failed to create ACL rule '{}' ".format("SNMP_SSH"))
        acl_snmp = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_2"):
        st.error("Failed to create ACL rule '{}' ".format("SNMP_SSH"))
        acl_sshv4 = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "V6_SSH_ONLY",
                     "RULE_1"):
        st.error("Failed to create ACL rule '{}' ".format("V6_SSH_ONLY"))
        acl_sshv6 = +1

    hostname = get_hostname(vars.D1)
    st.log("HOSTNAME: {}".format(hostname))
    snmp_out = execute_command(ssh_conn_obj, snmp_cmd)
    if hostname not in snmp_out:
        st.error("SNMP walk operation is failed")
        acl_snmp = +1

    st.log("connecting to device with default username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv6 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv6 = +1

    st.log(
        "connecting to device with non default username={},password={}".format(
            ssh_data.usr_non_default, ssh_data.pwd_non_default))
    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P1,
                                   ssh_data.usr_non_default,
                                   ssh_data.pwd_non_default)
    if not output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P1,
                                   ssh_data.usr_non_default,
                                   ssh_data.pwd_non_default)
    if not output: acl_sshv6 = +1

    config_save(vars.D1)
    st.log('rebooting the device.')
    st.reboot(vars.D1, 'fast')

    acl_obj.show_acl_table(vars.D1)
    acl_obj.show_acl_rule(vars.D1)

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_2"):
        st.log("Failed to create ACL rule '{}' ".format("SSH_SSH"))
        acl_sshv4 = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "V6_SSH_ONLY",
                     "RULE_1"):
        st.log("Failed to create ACL rule '{}' ".format("V6_SSH_ONLY"))
        acl_sshv4 = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_1"):
        st.error("Failed to create ACL rule '{}' ".format("SNMP_SSH"))
        acl_snmp = +1

    ipaddress = st.get_mgmt_ip(vars.D1)
    if not ipaddress or not ip_obj.ping(vars.D1, IPAddr.strip('/32')):
        st.error(
            "Ping to SNMP server or getting ip address to the dut is failed after reload"
        )
        acl_obj.acl_delete(vars.D1)
        config_nondefault_user(config='remove')
        st.report_fail("ip_verification_fail")

    snmp_cmd = "snmpget -Oqv -v 2c -c {} {} {}".format(ssh_data.ro_community,
                                                       ipaddress,
                                                       ssh_data.oid_sysName)

    hostname = get_hostname(vars.D1)
    snmp_out = execute_command(ssh_conn_obj, snmp_cmd)
    if hostname not in snmp_out:
        st.error("SNMP walk operation is failed after reload")
        acl_snmp = +1

    st.log('Verifying SNMP ACL with invalid source address')
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_1",
                     "SRC_IP", "2.2.2.0/24")
    acl_config = acl_data.acl_json_config_control_plane
    acl_obj.acl_delete(vars.D1)
    acl_obj.apply_acl_config(vars.D1, acl_config)
    st.wait(3, "Waiting to apply acl rules")
    snmp_out = execute_command(ssh_conn_obj, snmp_cmd)
    if "Timeout" not in snmp_out: acl_snmp = +1

    st.log("connecting to device with default username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv6 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv6 = +1

    if acl_sshv4:
        st.report_tc_fail("test_ft_controlplane_acl_service_sshv4",
                          "ssh_failed",
                          "with control plane ACL service SSHv4 after reboot")
    else:
        st.report_tc_pass("test_ft_controlplane_acl_service_sshv4",
                          "ssh_failed",
                          "with control plane ACL service SSHv4 after reboot")

    if acl_sshv6:
        st.report_tc_fail("test_ft_controlplane_acl_service_sshv6",
                          "ssh_failed",
                          "with control plane ACL service SSHv6 after reboot")
    else:
        st.report_tc_pass("test_ft_controlplane_acl_service_sshv6",
                          "ssh_failed",
                          "with control plane ACL service SSHv6 after reboot")

    if acl_snmp:
        st.report_tc_fail("test_ft_controlplane_acl_service_snmp",
                          "snmp_output_failed",
                          "with control plane ACL service SNMP after reboot")
    else:
        st.report_tc_pass("test_ft_controlplane_acl_service_snmp",
                          "snmp_output_failed",
                          "with control plane ACL service SNMP after reboot")

    acl_obj.acl_delete(vars.D1)

    if acl_sshv4 or acl_sshv6 or acl_snmp:
        st.generate_tech_support(vars.D1,
                                 "controlplane_acl_services_after_reboot")

    st.log('Verifying SSH connection after removing control plane ACLs')
    st.log("connecting to device with username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    if not st.exec_ssh(vars.D1, ssh_data.usr_default, ssh_data.pwd_final,
                       ssh_data.commands_to_verify):
        st.error(
            'Cannot SSH into Device with default credentials after reboot')
        user_ssh = +1

    st.log('connecting to device with username={},password={}'.format(
        ssh_data.usr_non_default, ssh_data.pwd_non_default))
    if not st.exec_ssh(vars.D1, ssh_data.usr_non_default,
                       ssh_data.pwd_non_default, ssh_data.commands_to_verify):
        st.error(
            'Cannot SSH into Device with non-default credentials after reboot')
        user_ssh = +1

    config_nondefault_user(config='remove')

    if (user_ssh or acl_snmp or acl_sshv4 or acl_sshv6):
        st.report_fail("test_case_failed")
    st.report_pass("test_case_passed")
コード例 #6
0
def chef_func_hooks(request):
    global hostname
    global_vars()
    chef_obj.reset_cookbook_json()
    hostname = basic_obj.get_hostname(vars.D1)
    yield
コード例 #7
0
def test_ft_ztp_config_section_check_with_option_67(ztp_func_hooks):
    # ################ Author Details ################
    # Name: Chaitanya Vella
    # Email: [email protected]
    # ################################################
    # ############## Test bed details ################
    #  D1 ---- DHCP Server
    #  ft_ztp_config_section_check_with_option_67	: This test function cover over 18 scenarios using option 67
    # #################################################
    vars = st.ensure_min_topology("D1")
    hostname = basic_obj.get_hostname(vars.D1)
    config_params.config_file = "ztp_plugin_conf.json"
    config_params.static_ip = ztp_params.dhcp.static_ip
    config_params.config_path = ztp_params.config_path
    config_params.dhcp_config_file = ztp_params.dhcp.config_file
    config_params.type = "http"
    config_params.dhcp_service_name = data.dhcp_service_name
    config_params.action = 'restart'
    config_params.device = 'server'
    config_params.device_action = "run"
    config_params.reboot_type = "normal"
    config_params.ztp_log_path = data.ztp_log_path
    config_params.file_names = [
        "02-configdb-json", "03-provisioning-script", "04-connectivity-tests",
        "05-test-plugin"
    ]
    config_params.json_content = data.json_content
    config_params.log_msg = "Checking configuration section {} result: SUCCESS"
    config_params.ztp_log_string = "ZTP successfully completed"
    config_params.option_type = "67"
    config_params.result = ""
    config_params.service = "disable"
    config_params.config_db_path = data.config_db_path
    config_params.config_db_temp = data.config_db_temp
    config_params.config_file = "ztp_plugin_conf.json"
    config_params.config_db_file_name = "{}_config_db.json".format(hostname)
    config_params.featureconfig_file_name = "invalid_config.json"
    config_params.json_config_path = "http://{}{}/".format(
        ztp_params.dhcp.static_ip, ztp_params.config_path)
    config_params.provision_script_path = "https://{}{}/{} -k".format(
        ztp_params.dhcp.static_ip, ztp_params.provision_script_path,
        data.option_239_sh_file)
    config_params.ping_script_path = "http://{}{}/{}".format(
        ztp_params.dhcp.static_ip, ztp_params.provision_script_path,
        data.ping_script_file)
    config_params.config_db_url = "http://{}{}/{}".format(
        ztp_params.dhcp.static_ip, ztp_params.config_path,
        config_params.config_db_file_name)
    data.feature_config_url = "http://{}{}/{}".format(
        ztp_params.dhcp.static_ip, ztp_params.config_path,
        config_params.featureconfig_file_name)
    config_params.json_content = {
        "ztp": {
            "02-configdb-json": {
                "dynamic-url": {
                    "source": {
                        "prefix": config_params.json_config_path,
                        "identifier": "hostname",
                        "suffix": "_config_db.json"
                    },
                    "destination": "/etc/sonic/config_db.json"
                }
            },
            "03-provisioning-script": {
                "plugin": {
                    "url": config_params.provision_script_path
                }
            },
            "04-connectivity-tests": {
                "plugin": {
                    "url": config_params.ping_script_path
                }
            },
            "05-test-plugin": {
                "message": "Test-Plugin-Test",
                "message-file": "/home/admin/test-file1",
                "reboot-on-success": True
            },
            "06-snmp": {
                "community-ro": "sonic",
                "snmp-location": "Hyderabad",
                "snmp-syscontact": "admin",
                "ignore-result": "true",
                "restart-agent": True
            },
            "07-configdb-json": {
                "url": {
                    "source": data.feature_config_url,
                    "timeout": 300
                },
                "clear-config": "false",
                "save-config": "true",
                "ignore-result": True
            }
        }
    }
    ztp_obj.config_ztp_backdoor_options(vars.D1,
                                        ztp_cfg={
                                            "admin-mode":
                                            True,
                                            "restart-ztp-interval":
                                            30,
                                            "log-level":
                                            "DEBUG",
                                            "feat-console-logging":
                                            feat_logging_console
                                        })
    source_path = "{}{}".format(data.local_provision_scripts_folder,
                                data.option_239_sh_file)
    destination_path = "{}{}/{}".format(ztp_params.home_path,
                                        ztp_params.provision_script_path,
                                        data.option_239_sh_file)
    basic_obj.copy_file_from_client_to_server(ssh_conn_obj,
                                              src_path=source_path,
                                              dst_path=destination_path,
                                              persist=True)
    options = SpyTestDict()
    options.dhcp_config_file = ztp_params.dhcp.config_file
    options.server_ip = config_params.static_ip
    options.config_path = ztp_params.provision_script_path
    options.provision_script = data.option_239_sh_file
    options.search_pattern = r'\s*option\s+provision-url\s*\S*\s*"\S+";'
    options.option_string = 'option provision-url '
    options.option_url = "http://{}{}/{}".format(
        ztp_params.dhcp.static_ip, ztp_params.provision_script_path,
        data.option_239_sh_file)
    ztp_obj.write_option_to_dhcp_server(ssh_conn_obj, options)
    shell_scripts = [data.ping_script_file, data.option_239_sh_file]
    for shell_script in shell_scripts:
        source_path = "{}{}".format(data.local_provision_scripts_folder,
                                    shell_script)
        destination_path = "{}{}/{}".format(ztp_params.home_path,
                                            ztp_params.provision_script_path,
                                            shell_script)
        basic_obj.copy_file_from_client_to_server(ssh_conn_obj,
                                                  src_path=source_path,
                                                  dst_path=destination_path,
                                                  persist=True)
    st.log(
        "Preparing invalid config JSON to check the gracefull handling of ZTP ..."
    )
    interface_name = random.choice(st.get_free_ports(vars.D1))
    vlan_list = vlan_obj.get_non_existing_vlan(vars.D1, 1)
    data.config_db_content = {
        "VLAN": {
            "Vlan{}".format(vlan_list[0]): {
                "members": [interface_name],
                "vlanid": vlan_list[0]
            }
        },
        "VLAN_MEMBER": {
            "Vlan{}|{}".format(vlan_list[0], interface_name): {
                "tagging_mode": "tagged"
            }
        }
    }
    file_path = basic_obj.write_to_json_file(data.config_db_content)
    destination_path = "{}{}/{}".format(ztp_params.home_path,
                                        ztp_params.config_path,
                                        config_params.featureconfig_file_name)
    basic_obj.copy_file_from_client_to_server(ssh_conn_obj,
                                              src_path=file_path,
                                              dst_path=destination_path)
    ztp_obj.config_and_verify_dhcp_option(ssh_conn_obj,
                                          vars.D1,
                                          ztp_params,
                                          config_params,
                                          expect_reboot=True,
                                          reboot_on_success=["05-test-plugin"])
    # if ztp_params.cli_type == "click":
    #     st.log("Verifying the ZTP DEBUG logs ..")
    #     ztp_log_string = "DEBUG sonic-ztp"
    #     st.log(st.log(ztp_log_string))
    #     if not basic_obj.poll_for_error_logs(vars.D1, data.ztp_log_path, ztp_log_string):
    #         if not basic_obj.poll_for_error_logs(vars.D1, data.syslog_path, ztp_log_string):
    #             st.log("ZTP log {} verification failed for message {}".format(data.ztp_log_path, ztp_log_string))
    #             st.report_fail("ztp_log_verification_failed", data.ztp_log_path, ztp_log_string)
    ztp_status = ztp_obj.show_ztp_status(vars.D1)
    if "dhcp-opt67" not in ztp_status["source"]:
        st.log(
            "ZTP source verification failed with {} against dhcp-opt67".format(
                ztp_status["source"]))
        st.report_fail("ztp_source_verification_failed", "dhcp-opt67",
                       ztp_status["source"])
    st.log("Verifying the ZTP plugin chronological order ..")
    if not ztp_obj.verify_plugin_chronological_order(vars.D1):
        st.report_fail("ztp_chronoloigical_verification_failed")
    st.log("Verifying ZTP admin disable operation ..")
    if not ztp_obj.verify_dhclient_on_interface(vars.D1, "/sbin/dhclient",
                                                ztp_params.oob_port):
        st.report_fail("ztp_dhclient_error")
    ztp_status = ztp_obj.show_ztp_status(vars.D1)
    ztp_obj.ztp_operations(vars.D1, "disable")
    if not ztp_obj.verify_ztp_attributes(vars.D1, "adminmode", "False"):
        st.log("ZTP status verification failed")
        st.report_fail("ztp_status_verification_failed")
    ztp_status_after_disable = ztp_obj.show_ztp_status(vars.D1)
    if ztp_status["status"] != ztp_status_after_disable["status"]:
        st.log("ZTP status verification failed")
        st.report_fail("ztp_status_verification_failed")
    snmp_params = {"rocommunityv6": "sonic", "rocommunity": "sonic"}
    if not verify_snmp_details_using_docker(vars.D1, **snmp_params):
        st.report_fail("snmp_params_verification_failed")
    snmp_params = {"syslocation": "Hyderabad"}
    if not verify_snmp_details_using_docker(vars.D1, **snmp_params):
        st.report_fail("snmp_params_verification_failed")
    snmp_params = {"syscontact": "admin"}
    if not verify_snmp_details_using_docker(vars.D1, **snmp_params):
        st.report_fail("snmp_params_verification_failed")
    st.report_pass("test_case_passed")
コード例 #8
0
def test_ft_ztp_restart_no_config(ztp_func_hooks):
    # ################ Author Details ################
    # Name: Chaitanya Vella
    # Email: [email protected]
    # ################################################
    # ############## Test bed details ################
    #  D1 ---- DHCP Server
    #  ft_ztp_restart_no_config	: Verify that SONiC ZTP is successful even though we have not pushed config db json
    #  with and without ""restart-ztp-no-config": false" attribute in ztp.json
    #  YET TO BE DONE #
    # #################################################
    vars = st.ensure_min_topology("D1")
    hostname = basic_obj.get_hostname(vars.D1)
    config_params.config_file = "ztp_restart_no_config.json"
    config_params.static_ip = ztp_params.dhcp.static_ip
    config_params.config_path = ztp_params.config_path
    config_params.dhcp_config_file = ztp_params.dhcp.config_file
    config_params.type = "http"
    config_params.dhcp_service_name = data.dhcp_service_name
    config_params.action = 'restart'
    config_params.device = 'server'
    config_params.device_action = "reboot"
    config_params.reboot_type = "normal"
    config_params.ztp_log_path = data.ztp_log_path
    config_params.file_names = [
        "03-provisioning-script", "04-connectivity-tests"
    ]
    config_params.json_content = data.json_content
    config_params.log_msg = "Checking configuration section {} result: SUCCESS"
    config_params.ztp_log_string = "ZTP successfully completed"
    config_params.option_type = "67"
    config_params.config_db_path = data.config_db_path
    config_params.config_db_temp = data.config_db_temp
    config_params.config_db_file_name = "{}_config_db.json".format(hostname)
    config_params.json_config_path = "http://{}{}/".format(
        ztp_params.dhcp.static_ip, ztp_params.config_path)
    config_params.provision_script_path = "http://{}{}/{}".format(
        ztp_params.dhcp.static_ip, ztp_params.provision_script_path,
        data.option_239_sh_file)
    config_params.ping_script_path = "http://{}{}/{}".format(
        ztp_params.dhcp.static_ip, ztp_params.provision_script_path,
        data.ping_script_file)
    config_params.config_db_url = "http://{}{}/{}".format(
        ztp_params.dhcp.static_ip, ztp_params.config_path,
        config_params.config_db_file_name)
    config_params.json_content = {
        "ztp": {
            "03-provisioning-script": {
                "plugin": {
                    "url": config_params.provision_script_path
                }
            },
            "04-connectivity-tests": {
                "plugin": {
                    "url": config_params.ping_script_path
                }
            },
            "restart-ztp-no-config": False
        }
    }
    ztp_obj.ztp_operations(vars.D1, "disable")
    if not ztp_obj.verify_ztp_attributes(vars.D1, "adminmode", "False"):
        st.log("ZTP status verification failed")
        st.report_fail("ztp_status_verification_failed")
    st.reboot(vars.D1)
    if not ztp_obj.verify_ztp_attributes(vars.D1, "adminmode", "False"):
        st.log("ZTP status verification failed")
        st.report_fail("ztp_status_verification_failed")
    ztp_obj.enable_ztp_if_disabled(vars.D1)
    if ztp_obj.verify_ztp_attributes(vars.D1, "adminmode", "False"):
        st.log("ZTP status verification failed")
        st.report_fail("ztp_status_verification_failed")
    shell_scripts = [data.ping_script_file, data.option_239_sh_file]
    for shell_script in shell_scripts:
        source_path = "{}{}".format(data.local_provision_scripts_folder,
                                    shell_script)
        destination_path = "{}{}/{}".format(ztp_params.home_path,
                                            ztp_params.provision_script_path,
                                            shell_script)
        basic_obj.copy_file_from_client_to_server(ssh_conn_obj,
                                                  src_path=source_path,
                                                  dst_path=destination_path,
                                                  persist=True)
    ztp_obj.config_and_verify_dhcp_option(ssh_conn_obj, vars.D1, ztp_params,
                                          config_params)