sonic-net / sonic-mgmt

Configuration management examples for SONiC
Other
175 stars 699 forks source link

[Question]: How to tell run run_tests.sh when you are using Cisco or other vendor preconfigured fanouts #13168

Open mrkcmo opened 2 months ago

mrkcmo commented 2 months ago

Issue Description

I am running into an issue where on a physical T2 test bed using Cisco Nexus switch as a fanout (could be any vendor pre-configured) the tests are trying to connect to the fanout as it thinks they are EOS and trying to configure them. I have set the OS in the inventory file to not be EOS by setting this under the fanout vars: "os = nxos". But this doesn't seem to work and the test still tries to connect to the fanout using the EOS credentials which obviously doesn't work. How do you setup the test bed to not touch pre-configured fanouts?

Results you see

The deploy-mg and add-topo work just fine but when running the tests we get errors trying to connect to the fanout's with EOS credentials.

Results you expected to see

That since the "os" is not set to EOS that it either not try and connect and configure the fanouts or a settings that needs to be configured that tells the run_tests.sh script to not try and setup pre-configured fanouts.

Is it platform specific

generic

Relevant log output

==================================== ERRORS ====================================
______ ERROR at setup of test_features_state[LL56-Sonic-Auto-c8808-1-LC0] ______

enhance_inventory = None
ansible_adhoc = <function ansible_adhoc.<locals>.init_host_mgr at 0x7f54a00a2ee0>
conn_graph_facts = {'device_bmc_info': {'LL56-Sonic-Auto-c8808-1-LC0': {}}, 'device_bmc_link': {'LL56-Sonic-Auto-c8808-1-LC0': {}}, 'devi...'peerport': 'Ethernet1/16', 'speed': '400000'}, ...}}, 'device_console_info': {'LL56-Sonic-Auto-c8808-1-LC0': {}}, ...}
creds = {'ansible_altpasswords': [], 'ansible_become_pass': 'password', 'ansible_ssh_pass': 'password', 'ansible_ssh_user': 'user', ...}
duthosts = [<MultiAsicSonicHost LL56-Sonic-Auto-c8808-1-LC0>]

    @pytest.fixture(scope="module")
    def fanouthosts(enhance_inventory, ansible_adhoc, conn_graph_facts, creds, duthosts):      # noqa F811
        """
        Shortcut fixture for getting Fanout hosts
        """

        dev_conn = conn_graph_facts.get('device_conn', {})
        fanout_hosts = {}
        # WA for virtual testbed which has no fanout
        for dut_host, value in list(dev_conn.items()):
            duthost = duthosts[dut_host]
            if duthost.facts['platform'] == 'x86_64-kvm_x86_64-r0':
                continue  # skip for kvm platform which has no fanout
            mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
            for dut_port in list(value.keys()):
                fanout_rec = value[dut_port]
                fanout_host = str(fanout_rec['peerdevice'])
                fanout_port = str(fanout_rec['peerport'])

                if fanout_host in list(fanout_hosts.keys()):
                    fanout = fanout_hosts[fanout_host]
                else:
                    host_vars = ansible_adhoc().options[
                        'inventory_manager'].get_host(fanout_host).vars
                    os_type = host_vars.get('os', 'eos')
                    if 'fanout_tacacs_user' in creds:
                        fanout_user = creds['fanout_tacacs_user']
                        fanout_password = creds['fanout_tacacs_password']
                    elif 'fanout_tacacs_{}_user'.format(os_type) in creds:
                        fanout_user = creds['fanout_tacacs_{}_user'.format(os_type)]
                        fanout_password = creds['fanout_tacacs_{}_password'.format(os_type)]
                    elif os_type == 'sonic':
                        fanout_user = creds.get('fanout_sonic_user', None)
                        fanout_password = creds.get('fanout_sonic_password', None)
                    elif os_type == 'eos':
                        fanout_user = creds.get('fanout_network_user', None)
                        fanout_password = creds.get('fanout_network_password', None)
                    elif os_type == 'snappi':
                        fanout_user = creds.get('fanout_network_user', None)
                        fanout_password = creds.get('fanout_network_password', None)
                    else:
                        # when os is mellanox, not supported
                        pytest.fail("os other than sonic and eos not supported")

                    eos_shell_user = None
                    eos_shell_password = None
                    if os_type == "eos":
                        admin_user = creds['fanout_admin_user']
                        admin_password = creds['fanout_admin_password']
                        eos_shell_user = creds.get('fanout_shell_user', admin_user)
                        eos_shell_password = creds.get('fanout_shell_password', admin_password)

>                   fanout = FanoutHost(ansible_adhoc,
                                        os_type,
                                        fanout_host,
                                        'FanoutLeaf',
                                        fanout_user,
                                        fanout_password,
                                        eos_shell_user=eos_shell_user,
                                        eos_shell_passwd=eos_shell_password)

Output of show version

Not needed

Attach files (if any)

No response

mrkcmo commented 2 months ago

@wangxin can you assist with this? I saw you tagged in other fanout questions and issues.