Getting started with vCenter Orchestrator Part 2 – Inputs & Attributes

In this post, I’ll show how to use Inputs and Attributes within a workflow.  I was going to make this post more involved, but WordPress doesn’t want to display half of the images that I’ve uploaded and since it’s a getting started series I’ll keep it simple.

Create Attributes

Create a new workflow named “Inputs & Attributes”.

Select “Add parameter’.  When the attribute is first created it has a name of att0 and is of type string.

2014-03-25_21-51-17

Click on att0 to change its name.

2014-03-25_21-51-27

Rename it to “repeatCount”.

2014-03-25_21-49-15

Click on “string” to change the type to number.

2014-03-25_21-49-26

Repeat this process and create another attribute with the name of “repeatDelay”.  Give both of the attributes a description.  You should have something similar to.

2014-03-25_21-51-01

Create input

Select the Input tab and then select “Add a parameter”.

2014-03-25_21-51-17

The input variable will intially be named arg_in_0.  Click on the name to change it.

2014-03-25_21-51-27

2014-03-25_21-51-51

Leave the type as string and fill in a description.  You should have.

2014-03-25_21-55-12

Create scriptable task element

Select the Schema tab, drag a scriptable task element onto the arrow between the Start and Stop elements.

2014-03-25_21-52-50

Now we need to bind our input/attribute variables to the scriptable task so that you’ll be able to access the values of the input/attributes in the scripting section of the scriptable task.

Select “Bind to workflow parameter/attribute”.

2014-03-25_21-53-03

Select all three entries.

2014-03-25_21-53-35

Select the Scripting tab and you will see the input and both attributes listed as inputs (They are listed to the right of “IN”).

2014-03-25_21-53-48

Type the following into the Scriptable task input field.

for (var i = 0; i < repeatCount; i++) {
System.log(repeatText)
System.sleep(repeatDelay * 1000)
}

2014-03-25_21-54-26

Notice that the input parameters are displayed as pink.

Run workflow

Start your workfow and enter the text you wish to repeat and submit.

2014-03-25_21-55-45

Select the Logs tab of the workflow run and you should see the following:

2014-03-25_21-56-15

The main takeaway from this post is that workflow elements such as scriptable tasks can access both inputs and attributes that are defined in the workflow.  Inputs are variables that users supply or are passed in from another workflow.  Attributes are variables that aren’t inputted into your workflow but are variables that your workflow can access.  For example, a vCenter/VM name.  When you bind an input/attribute to a workflow element like the scriptable task, it is similar to passing the input/attribute to the workflow element and the workflow element  acts like a function.

 

 

Advertisements

Getting started with vCenter Orchestrator Part 1

In this post I’m going to show how to create a basic vCenter Orchestrator (vCO) workflow.  vCO can look intimidating at first, but it only takes learning a few things to get you on your way.  I’m quite new to vCO so if anyone has any helpful suggestions, please leave a comment.  I’ll try to build on this workflow in later posts to provide more complex examples.

Launch the vCO client

Open a web browser and go to your vCO server.  For example, mine is at http://vco5c.vmware.local (no https).  You can choose to either start the vCO client from the webpage or download it to your client.  In this example I’m going to start it from the webpage.  If you haven’t configured vCO yet, there are a lot of blog postings on how to do it or you could see my post here that covers it.

2014-03-04_15-01-02

Creating the workflow

I created a folder named ‘Blog’, which you can do by right-clicking on the vCO server and choosing to create a new folder.

Next I’m going to create a new workflow under the Blog folder by right-clicking on Blog and selecting ‘New workflow’.  Make sure to actually right-click on the word Blog and not just anywhere in the area that’s highlighted dark blue or the context menu will not come up.

2014-03-04_14-46-51

Give your workflow a name.

2014-03-04_14-48-15

After naming your workflow you are dropped into edit mode for the workflow.  There are a lot of options but here are a few highlights.

2014-03-04_14-48-36

Selecting Schema will take you to the workflow editor page.

2014-03-04_15-10-23

A schema with only the start and end items.

2014-03-04_14-58-34

Drag the ‘Scriptable task’ item into the blue line.

2014-03-04_15-12-27

You should now see the Scriptable task on your workflow schema.  Give it a descriptive name.

2014-03-04_15-13-58

Now we will write one line of code to produce some output, validate the workflow, save and then close.

2014-03-04_15-15-58

Run the workflow

2014-03-04_15-23-13

2014-03-04_15-23-29

In the the next post I’ll show how to use variables within workflows.