Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pytest/creds]: load groups vars into creds for the dut #1575

Merged
merged 2 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ def pytest_addoption(parser):
############################
# test_techsupport options #
############################

parser.addoption("--loop_num", action="store", default=10, type=int,
help="Change default loop range for show techsupport command")
parser.addoption("--loop_delay", action="store", default=10, type=int,
help="Change default loops delay")
parser.addoption("--logs_since", action="store", type=int,
parser.addoption("--logs_since", action="store", type=int,
help="number of minutes for show techsupport command")


Expand Down Expand Up @@ -234,8 +234,11 @@ def eos():
@pytest.fixture(scope="module")
def creds(duthost):
""" read credential information according to the dut inventory """
inv = duthost.host.options['inventory'].split('/')[-1]
files = glob.glob("../ansible/group_vars/{}/*.yml".format(inv))
groups = duthost.host.options['inventory_manager'].get_host(duthost.hostname).get_vars()['group_names']
logger.info("dut {} belongs to groups {}".format(duthost.hostname, groups))
files = []
for group in groups:
files += glob.glob("../ansible/group_vars/{}/*.yml".format(group))
files += glob.glob("../ansible/group_vars/all/*.yml")
creds = {}
for f in files:
Expand Down
5 changes: 5 additions & 0 deletions tests/veos.vtb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ server_1
[servers:vars]
topologies=['t1', 't1-lag', 't1-64-lag', 't1-64-lag-clet', 't0', 't0-16', 't0-56', 't0-52', 'ptf32', 'ptf64', 't0-64', 't0-64-32', 't0-116']

[lab]
vlab-01
vlab-02
vlab-03

[sonic]
vlab-01 ansible_host=10.250.0.101 type=kvm hwsku=Force10-S6000 ansible_password=password ansible_user=admin
vlab-02 ansible_host=10.250.0.102 type=kvm hwsku=Force10-S6100 ansible_password=password
Expand Down