Solved

Run a workflow on multiple devices, one after the other

  • 15 August 2019
  • 7 replies
  • 256 views

Userlevel 1
Hello,

I have a workflow that finds a given VLAN (with a prompted variable), and duplicates it with another ID if it exists. However, I have two things that I would love to implement, but haven't found anything that shows me it's possible.

1 - Is there a way to start the workflow on multiple devices, but it does them one by one, and not at the same time ?
As I have multiple python scripts or signals, the workflow is executed steps by steps on all the devices. So when storing information in a variable, it mixes between the devices and I don't have the correct result at the end.
Maybe it's possible to create workflow variable from script, but don't know how to play with variable outside of emc_vars.get() and emc_results.put().

I guess I could make a GateWay to make a loop, while checking the list of all the selected devices, and increasing an index until it's out of the devices_list's length. But maybe there is a more practical way.


2 - Is it possible to add a variable (like the Device name) in an Event's message ?
It would be to say "VLAN 3 was correctly added on the device : Device3", or messages like that.


Thanks a lot already for the answers.
Would happily discuss about it more in details.
icon

Best answer by Zdenek Pala 16 August 2019, 21:45

here is example for the device name/nickname NBI call

code:
varDeviceIP = "10.8.255.15"
varQuery = '''query{network{device(ip:"%s"){name,nickName}}}''' %varDeviceIP
varResult = emc_nbi.query(varQuery)
varName = varResult['network']['device']['name']
varNickName = varResult['network']['device']['nickName']
View original

7 replies

Userlevel 7
Number one: store variables from one activity to other activity = the information is not overwritten.
This can be done if you define variable scope as activity instead of workflow.

Number two: using device name.
You can use NBI to get information from XMC database to workflow.

Let me know if you need some examples. Next week I should be able to give you hints.
Userlevel 1
Number one: store variables from one activity to other activity = the information is not overwritten.
This can be done if you define variable scope as activity instead of workflow.

Number two: using device name.
You can use NBI to get information from XMC database to workflow.

Let me know if you need some examples. Next week I should be able to give you hints.


Thanks for those infos. I have to look into it.
Would love some examples though, so I can have a better idea on how it works.
Userlevel 7
here is example for the device name/nickname NBI call

code:
varDeviceIP = "10.8.255.15"
varQuery = '''query{network{device(ip:"%s"){name,nickName}}}''' %varDeviceIP
varResult = emc_nbi.query(varQuery)
varName = varResult['network']['device']['name']
varNickName = varResult['network']['device']['nickName']
Userlevel 1
here is example for the device name/nickname NBI call

code:
varDeviceIP = "10.8.255.15"
varQuery = '''query{network{device(ip:"%s"){name,nickName}}}''' %varDeviceIP
varResult = emc_nbi.query(varQuery)
varName = varResult['network']['device']['name']
varNickName = varResult['network']['device']['nickName']





I'm not sure I understand correctly where to insert that.

In the example figure bollow, should I insert your code in the script Activity Create VLAN 111, or in the signals VLAN created / VLAN not created after that ?



I guess it's in the script Activity. But it means it prints those informations in the Output of every device that ran the script. Or maybe I'm missing something.

What I'm trying to do is keeping logs of the successes/failures of the script.
Is there a way to affect the signal message from the script directly ? Like :
code:
emc_signal("ID_vlanCreated").put("message", "The VLAN " + id_vlan + " was created successfully.")



I tried looking in the API that was given to me in a previous post, but couldn't find any hint.

Thanks for helping me.
Userlevel 7
Yes you can add it to the python activity or you can create new python activity. In the activity you can resolv the nickname/name and store it to other variable (scope workflow). This new variable can be used in your signal...
Userlevel 1
I looked at the System workflows' examples to see how to use them in signals.
It's the ${CreatedVarName} that needs to be in the message, isn't it ?

Thank you very much for the help.
Userlevel 7
See two example workflows.
4Nealo = you can see how we can handle variables in Signals.
4Mealo-ConcurrentExecution = you can see how we can pass variables between activities with concurrent execution.

I have not found nice way how to generate more signals in concurrent execution.

Reply