ā04-03-2024 02:25 AM
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.
Solved! Go to Solution.
ā04-03-2024 06:30 AM
Hi,
don't overcomplicate this. Use an if-then expression to check the IP and apply the commands depending on the IP address.
ā04-03-2024 10:38 AM
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. š
ā04-03-2024 08:20 AM
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.
ā04-04-2024 05:38 AM
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'])
ā04-03-2024 06:30 AM
Hi,
don't overcomplicate this. Use an if-then expression to check the IP and apply the commands depending on the IP address.