Skip to content

Commit 210e776

Browse files
OleksandrKozodoivmittal-msft
authored andcommitted
Added changes for updating TestbedProcessing module (sonic-net#4221)
Summary: * Fixed incorrect name of num_asics value. * Added extra approach for getting os value from testbed-new.yaml. * Added extra approach for getting dev value from testbed dictionary. What is the motivation for this PR? Sometimes the device configuration is located in testbed dictionary of testbed-new.yaml module. The fanouthosts fixture gets 'os' type from host_vars. How did you do it? Added the possibility for getting dev value from testbed dictionary. Added the possibility for defining os type by the extra parameter os in testbed-new.yaml. Example: testbed-new.yaml: devices: str-msn2700-01: os: sonic device_type: DevSonic # source: sonic-mgmt/ansible/files/sonic_lab_devices-github.csv Signed-off-by: Oleksandr Kozodoi <oleksandrx.kozodoi@intel.com>
1 parent 08ef0a6 commit 210e776

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

ansible/TestbedProcessing.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,13 @@ def makeLab(data, devices, testbed, outfile):
388388
toWrite.write("[" + key + "]\n")
389389
for host in value.get("host"):
390390
entry = host
391-
dev = devices.get(host.lower())
391+
392+
if host.lower() in devices:
393+
dev = devices.get(host.lower())
394+
elif host.lower() in testbed:
395+
dev = testbed.get(host.lower())
396+
else:
397+
dev = None
392398

393399
if "ptf" in key:
394400
try: #get ansible host
@@ -458,8 +464,8 @@ def makeLab(data, devices, testbed, outfile):
458464

459465
if card_type != 'supervisor':
460466
entry += "\tstart_switchid=" + str( start_switchid )
461-
if num_asic is not None:
462-
start_switchid += int( num_asic )
467+
if num_asics is not None:
468+
start_switchid += int( num_asics )
463469
else:
464470
start_switchid += 1
465471

@@ -526,6 +532,13 @@ def makeLab(data, devices, testbed, outfile):
526532
except AttributeError:
527533
print("\t\t" + host + " max_cores not found")
528534

535+
try: #get os
536+
os = dev.get("os")
537+
if os is not None:
538+
entry += "\tos=" + str( os )
539+
except AttributeError:
540+
print("\t\t" + host + " os not found")
541+
529542
toWrite.write(entry + "\n")
530543
toWrite.write("\n")
531544

0 commit comments

Comments
 (0)