Exemplo n.º 1
0
def global_vars_and_constants_init():
    global vars
    global tf_data
    vars = st.ensure_min_topology('D1T1:4')
    tf_data = SpyTestDict()
    hw_constants = st.get_datastore(vars.D1, "constants")
    scapi.get_running_config(vars.D1)
    # Global Vars
    tf_data.tg_port_list = [vars.T1D1P1, vars.T1D1P2, vars.T1D1P3, vars.T1D1P4]
    tf_data.port_list = [vars.D1T1P1, vars.D1T1P2, vars.D1T1P3, vars.D1T1P4]
    tf_data.platform = bcapi.get_hwsku(vars.D1).lower()
    tf_data.unicast = 'unicast'
    tf_data.multicast = 'multicast'
    tf_data.tg_current_mode = tf_data.unicast
    tf_data.queues_to_check = [
        'COUNTERS_PG_NAME_MAP', 'COUNTERS_QUEUE_NAME_MAP'
    ]
    tf_data.max_time_to_check_sys_maps = [150, 2]  # Seconds
    tf_data.traffic_duration = 3  # Seconds
    tf_data.test_max_retries_count = 3
    tf_data.need_debug_prints = True
    # Common Constants
    tf_data.pg_headroom_un_supported_platforms = hw_constants[
        'THRESHOLD_FEATURE_PG_HEADROOM_UN_SUPPORTED_PLATFORMS']
    tf_data.th3_platforms = hw_constants['TH3_PLATFORMS']
    return tf_data
Exemplo n.º 2
0
def ztp_push_full_config(dut, cli_type=""):
    """
    NOT USED ANYWHERE
    Author: Chaitanya Vella ([email protected])
    APU to push full config
    :param dut:
    :return:
    """
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    config_dbjson = "config_db.json"
    config_file = "ztp_data_local.json"
    plugin_file_path = "/etc/sonic/ztp/{}".format(config_file)
    source = "/tmp/{}".format(config_dbjson)
    plugin_json = {config_dbjson: {"url": {"source": "file://{}".format(source),
                                           "timeout": 300}, "save-config": "true"}}
    file_path = basic_obj.write_to_json_file(plugin_json)
    st.upload_file_to_dut(dut, file_path, plugin_file_path)
    running_config = switch_conf_obj.get_running_config(dut)
    file_path = basic_obj.write_to_json_file(running_config)
    st.upload_file_to_dut(dut, file_path, source)
    st.wait(wait_5)
    ztp_operations(dut, "run")
    st.wait(wait_60)
    show_ztp_status(dut, cli_type=cli_type)
    st.wait(wait_10)
    show_ztp_status(dut, cli_type=cli_type)
Exemplo n.º 3
0
def get_syslog_server(dut):
    """
    Get syslog servers.
    Author: Prudvi Mangadu ([email protected])

    :param dut:
    :return:
    """

    output = sc_obj.get_running_config(dut, 'SYSLOG_SERVER')
    return output
Exemplo n.º 4
0
def config_spanning_tree_rpvst_intf(dut, skip_verify=True, **kwargs):
   """
   :param dut:
   :param kwargs:
   :param skip_verify: True(Default) / False
   :return:

   Ex: config_spanning_tree_rpvst(1, ifname, field='edge_port', cfg_value='true')
   """

   st.log("Configuring RPVST interface parameters...")
   rpvst_data = kwargs
   stp_cfg = dict()

   # if STP is already configured on the DUT, just update the given field
   # rest of the fields should not be affected
   current_stp = sconf_obj.get_running_config(dut, "STP_PORT")
   stp_cfg['STP_PORT'] = current_stp

   if current_stp:
      if rpvst_data['ifname'] in current_stp:
         #if rpvst_data['field'] in current_stp[rpvst_data['ifname']]:
         #any existing field is updated. New field will get added to the config_db
         stp_cfg['STP_PORT'][rpvst_data['ifname']][rpvst_data['field']] = rpvst_data['cfg_value']
         #else:
         #   st.error("field {} does not exist".format(rpvst_data['field']))
         #   return False
      else:
         st.error("interface {} does not exist".format(rpvst_data['ifname']))
         return False
   else:
      st.error("STP interface configuration does not exist")
      return False

   json_cfg = json.dumps(stp_cfg)
   json.loads(json_cfg)

   st.apply_json2(dut, json_cfg)
   return True
Exemplo n.º 5
0
def config_spanning_tree_rpvst(dut, skip_verify=True, **kwargs):
   """
   :param dut:
   :param kwargs:
   :param skip_verify: True(Default) / False
   :return:

   Ex: config_spanning_tree_rpvst(1, field='mode', cfg_value='rpvst')
   """

   st.log("Configuring RPVST...")
   rpvst_data = kwargs

   # if STP is already configured on the DUT, just update the given field
   # rest of the fields should not be affected
   current_stp = sconf_obj.get_running_config(dut, "STP")

   if current_stp:
      stp_cfg = default_stp_global_cfg
      # current_value = sconf_obj.get_running_config(dut,"STP","GLOBAL",rpvst_data['field'])

      if rpvst_data['field'] in current_stp['GLOBAL']:
         stp_cfg['STP']['GLOBAL'][rpvst_data['field']] = rpvst_data['cfg_value']

      excluded_keys = rpvst_data['field']
      for key, _ in current_stp['GLOBAL'].items():
         if key not in excluded_keys:
            stp_cfg['STP']['GLOBAL'][key] = current_stp['GLOBAL'][key]

   else:
      stp_cfg = default_stp_global_cfg

   json_cfg = json.dumps(stp_cfg)
   json.loads(json_cfg)

   st.apply_json2(dut, json_cfg)
   return True
Exemplo n.º 6
0
def error_handling_func_hooks():
    if eh_data.debug:
        get_running_config(vars.D1)
    yield
    if eh_data.clear_logs:
        clear_logging(eh_data.dut_list, thread=True)