Creating a vRealize Service Blueprint to create Infoblox DNS records

In my last post I described how to create Infoblox DNS host records using the vRealize Orchestartor (vRO) HTTP-REST plug-in.  One of the use cases I presented at the end of this post was to create a vRealize Automation (vRA) advanced service to provide creating Infoblox DNS records as a vRA catalog item.  A day after that post I was asked to present on vRA and since we’ve been working with Infoblox a lot lately, I thought that this is something I could show.

Modifying the original workflow

Since I’ve already detailed how to create the workflow, I’m not going to cover it again, but we will have to modify the inputs of the workflow so that it makes more sense when calling it from vRA.  We can start off at section Modifying the workflow in the previous post.  Instead of having a single input named content with the full payload of our REST request, let’s go ahead and change it so that we have two inputs: hostname & ipaddress.  I’m not going to cover in detail how to add/modify attributes and other changes to the workflow.  It’s pretty tedious, I’m in a hurry, you probably already know how or can find the info in one of the previous posts or online.

Right-click the workflow and select Edit.

Select the Inputs tab, highlight the content attribute and click delete.

2015-07-14_14-56-53

Select Add Parameter, select arg_in_0 and give the attribute a name of hostname.

2015-07-14_15-00-28

Enter Hostname in the description field.  Repeat this step for the ipaddress parameter so that it looks like:

2015-07-14_15-00-51

Now we need to bind these inputs to our Scripting workflow element.  Select the

  1. Schema tab
  2. Scripting workflow element
  3. In tab
  4. Check hostname and ipaddress and press Select.

2015-07-14_15-07-53

With the Scripting workflow element still active, select the Scripting tab and add the following line of code:

var content = ‘{“ipv4addrs”:[{“ipv4addr”:”‘ + ipaddress + ‘”}],”name”:”‘ + hostname + ‘”}’

The content variable is the REST payload we will be sending to the Infoblox server.  Previously this was passed in as an input in its entirety.  Now we are building the content variable up via the ipaddress and hostname inputs.   The rest of the code is the same as in the previous post.

Now you can save and close the workflow.

Creating the vRA Advanced Service

Access the vRA portal and select the Advanced Services tab.  If you don’t see this tab, perform the following:

  1. Select Administration
  2. Identity Store and Users & Groups
  3. Enter your user id.
  4. Select your user id.
  5. Select View Details

2015-07-14_15-20-56

On the next screen check Service Architect and press update.  If you reload the browser, you should see the Advanced Services tab.  I don’t know vRA permissions too well so if you still don’t see it, try to give yourself more permissions.

Select

  1. Advanced Services
  2. Service Blueprints
  3. Add

2015-07-14_15-26-11

From here we can browse to the vRO workflow we previously created and select next.

2015-07-14_15-31-26

Name the service and press next.

2015-07-14_15-29-14

You don’t have to do anything on the next screen, but notice how it created fields for the Hostname and IP Address that it pulled from the workflow’s inputs.

2015-07-14_15-32-14

On the next screen press Add.

Creating a Catalog Item

We need to publish the service blueprint so that it becomes visible as a catalog item.  Highlight the new blueprint and select Publish.

2015-07-14_15-34-48Select

  1. Administration
  2. Catalog Management
  3. Catalog Items

2015-07-14_15-35-452015-07-14_15-36-30

Now our service blueprint is available as a catalog item and has a source of Advanced Designer Service.  Select Configure.

Here I’ve added an Infoblox icon and added the catalog item to the Infrastructure service.

2015-07-14_15-40-09

You can manage services by clicking the Services menu item under the Administration tab.

Add an entitlement to the service/catalog item

If your user account doesn’t already have access to the service where you placed the catalog item or you did not place the catalog item into a service, you’ll need to add an entitlement.

Select.

  1. Administration
  2. Catalog Management
  3. Entitlements
  4. The business group your in
  5. Edit

2015-07-14_15-42-57

Either add the service where you placed the catalog item or add the catalog item individually:

2015-07-14_15-46-30

Requesting the catalog item

Now we are ready to request the catalog item from the Catalog tab.  Simply select Request on the Create DNS Record item.

2015-07-14_15-47-58

Give the request a description. Fill in the details and press submit.

2015-07-14_15-50-06

You can see the status of your request on the Requests tab.

2015-07-14_15-51-43

You will also see the workflow run in vRO:

2015-07-14_15-52-39

The new DNS record should now be in Infoblox.

Advertisements

Creating Infoblox host records with vRealize Orchestrator’s HTTP-REST Plug-in

In a previous post I described how to resolve an Infoblox managed IP address.  In this post I’m going to show how to create an Infoblox host record.  In the past we used the Infoblox plug-in to perform DNS management, but lately we’ve been replacing the functionality provided by the Infoblox plug-in with the HTTP-REST plug-in.  We did this for the following reasons:

  • The Infoblox plug-in comes with workflows that have specific requirements that we couldn’t always meet.
  • The workflows also have additional functionality, but it wasn’t needed in our environment.
  • The Infoblox plug-in has to be compatible with the version of the Infoblox NIOS and vRO/vCO that you’re using. We currently have a compatibility issue that would only be resolved by upgrading the Infoblox NIOS, but our team doesn’t manage it and it’s not scheduled to be upgraded for months. By using the HTTP-REST plug-in we eliminate this issue completely.
  • The HTTP-REST plug-in comes with vRO/vCO so there is nothing additional to install.
  • It gives our team more exposure to consuming services via REST APIs.
  • It gives our team more control in the way we consume Infoblox services.  We were using an older version of the Infolbox plug-in so they may have added additional functionality, but now we can perform name resolution and create various types of name records.

I’m not going into as much detail as I did in Resolving an Infoblox IP Address with vRealize Orchestrator’s HTTP-REST Plug-in so if you get stuck, please see that post.

Add a REST host

In the vRO client, go to Library > HTTP-REST > Configuration and run the “Add a REST host” workflow

2015-06-29_12-05-22

2015-06-29_11-19-57

2015-06-29_11-20-08

If successful, you will now see a green check next to the workflow run:

2015-06-29_11-53-46

Add a REST Operation

In the vRO client, go to Library > HTTP-REST > Configuration and run the “Add a REST Operation” workflow.

2015-06-29_12-05-22

If we were to use the curl command to make the API call to create the host record, it would look like this:

curl -k -u vco_user:superpass -H “Content-Type: application/json” \

-X POST https://10.62.1.10/wapi/v1.2.1/record:host -d \

‘{“ipv4addrs”:[{“ipv4addr”:”10.62.1.20″}],”name”:”test.vmware.local”}’

To do this in vRO, we need to specify the following:

  • Template URL: /record:host
  • HTTP method: POST
  • Content type: application/json

Notice how the template URL value is what is appended to the HTTP-REST host of https://10.62.1.10/wapi/v1.2.1

2015-06-29_11-20-37

If successful, you will now see a green check next to the workflow run and under the variables tab you can see the specified values:

2015-07-07_18-35-40

Generate a new workflow based on the newly created REST operation

Now that we have our REST operation defined, we need to create a vRO workflow that we can use.

In the vRO client, go to Library > HTTP-REST and run the “Generate a new workflow from a REST operation” worfklow.

Under Operation select “Not set” and choose the “Create Host Record” operation:

2015-07-07_18-54-20

2015-07-07_18-56-02

2015-06-29_11-21-09

Again, make you sure you see the green check next to the workflow run so that you know it was sucessful:

2015-06-29_11-52-01

Modifying the workflow

Now we have a workflow that we can run manually or call from other systems such as vCloud Director or vRealize Automation, but first we need to modify the workflow slightly so that we can add some additional functionality such as error handling.

When using the curl command the string that comes after -d is the data that we are sending to the Infoblox server.  In this case it’s the string ‘{“ipv4addrs”:[{“ipv4addr”:”10.62.1.20″}],”name”:”test.vmware.local”}’:

curl -k -u vco_user:superpass -H “Content-Type: application/json” \

-X POST https://10.62.1.10/wapi/v1.2.1/record:host -d \

‘{“ipv4addrs”:[{“ipv4addr”:”10.62.1.20″}],”name”:”test.vmware.local”}’

If we look at the Inputs tab of our workflow we will see that it takes a single variable named content:

2015-07-07_19-03-53

If we were to run the workflow manually, it would need to look like this:

2015-07-07_19-04-43

In our environment this workflow is actually called from another workflow that builds the content string from values extracted out of a vCloud Director VM.  Depending on your use case, you may need to modify this workflow so that it takes a hostname/IP address and then builds the content string.

Let’s take a look at the scripting section of the workflow.  Edit the workflow and go to:

  1. Schema tab
  2. Scripting object
  3. Scripting tab
  4. Code we added

2015-07-07_19-09-10

In section 4 I do the following:

Convert the value that the Infoblox sends back after creating the host record into a JSON string.

var jsonContent = JSON.parse(contentAsString)

If the value of statusCode 201, log a message stating that DNS record was created successfully. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for the definition of the HTML code 201.

If the value of statusCode does not equal 201, extract the returned text from the JSON value jsonContent and log a message stating that there was an error creating the DNS record.

contentAsString = jsonContent.text;
System.log(“Failed to create DNS host record: ” + statusCode + ” : ” + contentAsString);

The variables statusCode and contentAsString are stored in the scripting elements output:

2015-07-07_19-23-52

as well as the workflows output:

2015-07-07_19-21-48

The calling workflow then says that if the statusCode is 201, everything is okay.  If not, it uses the value of contentAsString to inform the user what went wrong.

The input, outputs and scripting sections can differ in your situation.  What I’ve done is just what was requested of me.  When you work as part of a team that develops vRO workflows, someone else may be developing a workflow that calls your workflow and they say, “I want to send you x, y & z and I want you to return a, b, & c to me.”

Use cases

I’d like to cover some of these use cases in future posts, but here are some ways that I think this workflow could be used:

  1. Running the workflow manually.  If this was done, I’d probably edit the inputs so that it would take a hostname and IP address instead of the content string.
  2. Take advantage of the vCenter/vRO integration where you could right-click a VM in vCenter and run a workflow that would extract the hostname/IP from the VM and create a DNS entry.  You could also have a similar workflow to create other types of DNS records such as CNAMEs (aliases).
  3. Add a custom action to a vRealize Automation VM so that you could manage the VM’s DNS records.
  4. Use vRealize Automation’s Advanced Services to create a service that would allow the management of DNS records.