cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow emc.cli question(s)

Workflow emc.cli question(s)

XTRMUser
Contributor

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.

1 ACCEPTED SOLUTION

Zdeněk_Pala
Extreme Employee

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

 

Regards Zdeněk Pala

View solution in original post

3 REPLIES 3

XTRMUser
Contributor

Yes, the emc_cli.close() was the secret for me. Thanks so much. 

Zdeněk_Pala
Extreme Employee

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

 

Regards Zdeněk Pala

Markus_Nikulski
Extreme Employee

if you like to change the device context you have to close the session first before establishing a new one.

 

Markus_Nikulski_0-1709127242265.png

 

 

GTM-P2G8KFN