02-27-2024 10:43 AM
I'm working on developing a workflow that will show where a mac address is in my network. I can't query XIQ, since a number of the mac addresses aren't there, and I don't have the IP address and use "show ip arp <ip address>" on the VOSS cores.
In my workflow, python script, I have the following (there is more, but this is the appropriate stuff, I think).
from xmclib import emc_vars
# Ask for a complete list of all my switches
my_query1 = '''{network{devices{ip,sysName,nosId}}}'''
my_result1 = emc_nbi.query(my_query1)['network']['devices']
# Now cycle through the switches
for my_switch in my_result1:
my_switch_ip = my_switch['ip']
my_switch_name = my_switch['sysName']
my_os = my_switch['nosId']
# I know that BOSS and VOSS (I don't have EXOS) syntax commands are different. I'm using BOSS in the example below
# I use the show mac-addr addr <mac-address>
client_command = 'show mac-addr addr ' + mac_address_ers
emc_cli.setIpAddress(my_switch_ip)
my_search_results = emc_cli.send(client_command).getOutput()
#more processing here
The first time through the loop, everything works correctly. The 2nd (and subsequent) time (it uses another IP address), the field "my_search_results" gives the first time through results.
Do I need to clear the emc_cli or the getOutput or something???
Thanks for any tips.
Solved! Go to Solution.
02-28-2024 06:05 AM
Hi,
try to do some cleanup before you open new session:
emc_cli.setIpAddress(varDevice)
sendConfigCmds(varCMDS)
emc_cli.close()
emc_cli.setCliRule(None)
this worked for me.
good luck
02-28-2024 09:37 AM
Yes, the emc_cli.close() was the secret for me. Thanks so much.
02-28-2024 06:05 AM
Hi,
try to do some cleanup before you open new session:
emc_cli.setIpAddress(varDevice)
sendConfigCmds(varCMDS)
emc_cli.close()
emc_cli.setCliRule(None)
this worked for me.
good luck
02-28-2024 05:34 AM
if you like to change the device context you have to close the session first before establishing a new one.