Start XMC scripts or workflows via NAC Notifications" or NetSight "Alarms Manager"

  • 30 October 2018
  • 14 replies
  • 722 views

Userlevel 5
  • Contributor
  • 270 replies
Hello,

is there a way to start scripts (Python!) or workflows created via XMC triggered by NAC "Notifications" or Netsight "Alarms manager"?

I know I can start every script/executable in the file system and the python scripts are stored in the file system. But if I start these files directly I have to handle myself the "Device Selection" for the correct device the script should run against.
I hope there is a smoother way to do that because that's a normal scenario:

  • Something happens on a device (like port goes down)
  • Alarms manager detects this issue
  • Alarms manager starts a script to fix it
In Workflows there is a "Signal" element in the Events category. But It's not clear for me whether the signal is something from outside or a event within the workflow.
For me the event is from outside (example port down on an arbitrary switch in XMC).

Best regards
Stephan

14 replies

Userlevel 5
Hmmmmm,

there is an "Action" in the Notification manager pointing in the right direction.



But I can't select select anything in the dropdown even I created an Workflow as "Saved Task" in XMC. Maybe this windows is further on than the code behind it, because I still use the 8.1.4.40.
Userlevel 7
Three steps:
1. configure your workflow to be executable from menu "Access Control Events"
2. configure Notification to use your workflow
3. you need XMC 8.2.1.

Userlevel 5
Hello Pala,

works great (with 8.2.x), thanks for the good pictures.

Regards
Stephan
Three steps:
1. configure your workflow to be executable from menu "Access Control Events"
2. configure Notification to use your workflow
3. you need XMC 8.2.1.


Hi Zdenek,

I tried this and it doesn't work.

If I run the workflow by selecting my device (from the Tasks > Workflow menu itself) the workflow "works" (so no wrong cli command or so).

If I setup my notification, I get the following error: "no compatible devices found.".

Any Idea on how to solve this? It seems that XMC/control doesn't recognize the switch as an EXOS or something like that?

kind regards,

Jasper
Userlevel 7
Hi,

the workflow can be executed for non-exos switch the same way as on exos switch. what is the workflow you are trying to execute/start by notification?

have you tried to check why the workflow does fail?

Z.
Hi,

the workflow can be executed for non-exos switch the same way as on exos switch. what is the workflow you are trying to execute/start by notification?

have you tried to check why the workflow does fail?

Z.

Hi Zdenek,

just adding NSI's to some VLAN's using CLI commands on an EXOS (x450-g2, running 22.6.x).
The worklof/script works if you run it, using notifitcation it doesn't.

What kind of debug logging do I need to enable to view the actual error? Because in the 'events' I only see this "error": no compatible devices found.

Kind regards,

Jasper
Userlevel 7
If you run the workflow by executing it against the switch then the workflow does have access to emc_variable deviceIP.
If you run it from notification engine then the workflow does have emc_variable switchIP.

Check the list of variables here. if the workflow was executed you can see variables available for the workflow in the results window...
Hi Zdenek,

could you elaborate on that answer?
Our specific situation is that we try to get a workflow going after plugging in an AP which generates a notification.
This works when we run it in XMC but fails when we test it by plugging in an AP. The workflow runs but fails.

The big difference between the 2 variable results (XCM test vs real) is the fact that our devices variable stays empty whereas the devices variable in the test shows the switchIP.

I tried forcing the switchIP into the devices variable, but no difference, this looks like it's enforced (because it is system-defined?).

Any idea why this would be happening? Or do you have a way to get some debug level logging?

Thanks in advance,

Lennert
Userlevel 7
When I execute the workflow by notification engine I can use variables in the workflow.

Example of Notification:


Example of variables:



Example of python code to check those variables:

if emc_vars["oldstate"] != emc_vars["state"]:


Hope it helps.

Z.
Thanks for your answer. I think I get that.

Our notification looks just like yours and works.
But the problem lies with the fact that our workflow doesn't find the compatible devices.


In this instance our devices variable is empty.


This comes from a workflow with only a CLI activity in it.



Do you have an idea why our "devices" variable doesn't automatically get our Summit switch, or how we could enforce that?

Thanks in advance,

Lennert
Userlevel 7
I see now the issue... the device is not automatically populated from notification engine = it is function as designed = imagine you just want to do API call somewhere, you do not want to establish the session to the switch, may be you want establish the session to the engine...

What you can do = change the activity from CLI to Python.

here is python code example:

code:
#############CLI - FUNCTION DEFINITIONS
def sendConfigCmds(cmds):
for cmd in cmds:
cli_results = emc_cli.send( cmd )
if cli_results.isSuccess() is False:
print 'CLI-ERROR: ' + cli_results.getError()
exit
cli_lines = cli_results.getOutput()
return cli_lines

#############Establish the session and send commands
emc_cli.setIpAddress(emc_vars["switchIP"])
varCMDS = []
varCMDS.append('config terminal')
varCMDS.append('hosname I-Was-Here')
varCli_result = sendConfigCmds(varCMDS)
emc_cli.close()
Thanks for your quick responses. This helps a lot.

There's still the issue that no compatible devices are found, even though we change the emc_cli ip address to switchIP.
If i run your script through XMC, I get the error: no viable alternative for "switchIP"

So I put in variable switchIP manually and referenced it to global variable switchIP. But now I get error: device not found and switchIP stays empty so this would indicate that there's nothing in global variable switchIP which I can confirm in the variable results window.




So why would this occur? Any alternatives?

Thanks in advance,

Lennert
Userlevel 7
Does it work if you replace emc_vars["switchIP"] with the IP of your switch? and let it be executed by Notification engine?

What XMC version are you using?
Yes, the test works when I replace it with the IP of my switch. But not when I let it be executed by the Notification engine, it still says it has 0 devices to work with.

XMC version 8.2.6.5

Reply