Skip to content

Commit

Permalink
[pytest/creds]: load groups vars into creds for the dut (#1575)
Browse files Browse the repository at this point in the history
Signed-off-by: Guohan Lu <[email protected]>
  • Loading branch information
lguohan authored Apr 16, 2020
1 parent f7ec8f9 commit 1d3f69a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 7 additions & 5 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,9 +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))
files += glob.glob("../ansible/group_vars/all/*.yml")
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 = glob.glob("../ansible/group_vars/all/*.yml")
for group in groups:
files += glob.glob("../ansible/group_vars/{}/*.yml".format(group))
creds = {}
for f in files:
with open(f) as stream:
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

0 comments on commit 1d3f69a

Please sign in to comment.