05-09-2024 04:30 PM
Hi Team,
In the n9k yaml file, I have devices section like this:
devices:
device_1:
device_2:
In the script, I call this object as :
self.parameters['uut'] = self.parameters['testbed'].devices['device_1']
I need to hardcode the hostname of the device in the script. Is there anyway, I can skip the hardcoding?
I tried :
self.parameters['uut'] = self.parameters['testbed'].devices - (only had one device in yaml)
OR
self.parameters['uut'] = self.parameters['testbed'].devices[0]. - first device from devices block.
But both of these given error.
Solved! Go to Solution.
05-10-2024 03:05 AM
device_keys = list(self.parameters['testbed'].devices.keys())
first_device_name = device_keys[0]
self.parameters['uut'] = self.parameters['testbed'].devices[first_device_name]
hostname = self.parameters['uut'].hostname # assuming there is a 'hostname' attribute in your device object
Hope this helps.
05-10-2024 03:05 AM
device_keys = list(self.parameters['testbed'].devices.keys())
first_device_name = device_keys[0]
self.parameters['uut'] = self.parameters['testbed'].devices[first_device_name]
hostname = self.parameters['uut'].hostname # assuming there is a 'hostname' attribute in your device object
Hope this helps.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide