def ztp_module_hooks(request):
    st.add_prevent("ztp")
    initialize_variables()
    pre_config_ztp()
    path_list = [ztp_params.home_path+ztp_params.config_path, ztp_params.home_path+ztp_params.provision_script_path]
    ztp_obj.create_required_folders(ssh_conn_obj, path_list)
    basic_obj.move_file_to_local_path(vars.D1, "/etc/sonic/snmp.yml", "/etc/sonic/snmp.yml.bkp")
    source_path = "{}{}".format(config_params.local_provision_scripts_folder, config_params.snmp_filename)
    st.upload_file_to_dut(vars.D1, source_path, "/home/admin/snmp.yml")
    basic_obj.copy_file_to_local_path(vars.D1, "/home/admin/snmp.yml", "/etc/sonic/snmp.yml")
    if ztp_params.breakout:
        if breakout(vars.D1, ztp_params.breakout, cli_type="klish", skip_error=True):
            intf_details = get_interface_details_by_alt_name(vars.D1, ztp_params.inband_port)
            if isinstance(intf_details, dict):
                inband_port = intf_details["interface"]
            else:
                inband_port = intf_details
            interface_noshutdown(vars.D1, inband_port)
            config_ip_addr_interface(vars.D1, inband_port, ztp_params.dhcp6.client_ip_inband, ztp_params.dhcp6.inband_v6_subnet, family="ipv6")
            # enable_dhcp_on_interface(vars.D1, ztp_params.inband_port)
            if not ping(vars.D1, ztp_params.dhcp6.inband_static_ip, family="ipv6"):
                st.log("Pinging to DHCP server failed from DUT, issue either with DUT or server")
    # config_save(vars.D1)
    yield
    ztp_cfg = {"admin-mode": True, "restart-ztp-interval": 30, "feat-console-logging": feat_logging_console}
    ztp_obj.config_ztp_backdoor_options(vars.D1, ztp_cfg)
    reset_module_config()
    basic_obj.move_file_to_local_path(vars.D1, "/etc/sonic/snmp.yml.bkp", "/etc/sonic/snmp.yml")
Esempio n. 2
0
def ztp_module_hooks(request):
    st.add_prevent("ztp")
    initialize_config_params()
    pre_config_ztp()
    initialize_data_variables()
    path_list = [ztp_params.home_path+ztp_params.config_path, ztp_params.home_path+ztp_params.firmware_path,
                 ztp_params.home_path+ztp_params.provision_script_path, ztp_params.home_path+ztp_params.xml_path]
    ztp_obj.create_required_folders(ssh_conn_obj, path_list)
    basic_obj.move_file_to_local_path(vars.D1, "/etc/sonic/snmp.yml", "/etc/sonic/snmp.yml.bkp")
    source_path = "{}{}".format(config_params.local_provision_scripts_folder, config_params.snmp_filename)
    st.upload_file_to_dut(vars.D1, source_path, "/home/admin/snmp.yml")
    basic_obj.copy_file_to_local_path(vars.D1, "/home/admin/snmp.yml", "/etc/sonic/snmp.yml")
    if ztp_params.breakout:
        if breakout(vars.D1, ztp_params.breakout, cli_type="klish", skip_error=True):
            intf_details = get_interface_details_by_alt_name(vars.D1, ztp_params.inband_port)
            if isinstance(intf_details, dict):
                inband_port = intf_details["interface"]
            else:
                inband_port = intf_details
            interface_noshutdown(vars.D1, inband_port)
            config_ip_addr_interface(vars.D1, inband_port, ztp_params.dhcp.client_ip_inband, ztp_params.dhcp.inband_v4_subnet)
            # enable_dhcp_on_interface(vars.D1, ztp_params.inband_port)
            if not ping(vars.D1, ztp_params.dhcp.inband_static_ip):
                st.log("Pinging to DHCP server failed from DUT, issue either with DUT or server")
    # config_save(vars.D1)

    # write_config_db(vars.D1, interface_data)
    yield
    reset_module_config()
    basic_obj.move_file_to_local_path(vars.D1, "/etc/sonic/snmp.yml.bkp", "/etc/sonic/snmp.yml")
Esempio n. 3
0
 def set_port_defaults(self, dut, breakout, speed):
     rv1, rv2 = True, True
     if breakout:
         cli_type = st.getenv("SPYTEST_HOOKS_BREAKOUT_UITYPE", "klish")
         rv1 = port.breakout(dut, breakout, cli_type=cli_type)
     if speed:
         cli_type = st.getenv("SPYTEST_HOOKS_SPEED_UITYPE", "")
         rv2 = port.set_speed(dut, speed, cli_type=cli_type)
     return bool(rv1 and rv2)