cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Workflows CLI Activity: how to assign device per activity?

Workflows CLI Activity: how to assign device per activity?

htw
New Contributor III

Hi,

i want to automate a certain provisioning process with Workflow feature. The process requires to set several different CLI commands on some of our devices.

For example:

on device 1: CLI commands A and  on device 2: CLI commands B

The devices which I want to use in the workflow are static, they are always the same eight devices from our inventory. But I need to run different commands on them.

I figured out to create a workflow with several CLI activities (one CLI activity per device). How can I pre-assign a CLI Activity to a certain device? I tried to set the device variable per activity (deleted the workflow device variable, and created new device variable in each activity). I tried to enter Device Name of the switch and i tried to use the IP-Adress in this variable but I always get the "select device dialogue" when I start the workflow.

1 ACCEPTED SOLUTION

Markus_Nikulski
Extreme Employee

Hi,

don't overcomplicate this. Use an if-then expression to check the IP and apply the commands depending on the IP address.

Markus_Nikulski_0-1712151000162.png

 

View solution in original post

4 REPLIES 4

htw
New Contributor III

After looking for some phyton variable basics and some example workflows from github i tried adding the workflow variable in main:

def main():
mycustomport = emc_vars["mycustomport"]

and then using it with cmds.append f.e.:

elif emc_vars['deviceIP'] == "192.168.100.200":
cmds.append('enable port '+mycustomport)

This seem to work. šŸ™‚

htw
New Contributor III

 

Hi Markus,

using your code as Phyton script activity I managed to send two different commands to two different devices of a three device test group. How can I implement variables into the commands? ( I am not very familiar with phyton.)

In my test CLI activity example I had "disable port ${mycustomport}" which uses a defined variable  "mycustomport" which is defined as a custom workflow input. 

 

I cannot educate you about Python. Please use youtube / search engines / whatever.
If you are in Python using our Workflows you have a dictionary providing you access to the Workflow-wide variables.

Using placeholders (%s) to define the poison where the injecting should be. You can use ore than one variable. Here a example just with one:
cmds.append("show interface gigaeth %s" % emc_vars['mycustomport'])

 

Markus_Nikulski
Extreme Employee

Hi,

don't overcomplicate this. Use an if-then expression to check the IP and apply the commands depending on the IP address.

Markus_Nikulski_0-1712151000162.png

 

GTM-P2G8KFN