VMware Cloud Community
spride
Enthusiast
Enthusiast
Jump to solution

vRA 6.2 REST API: Resource Action with VRO-mapped object

I created a Resource Action (Advanced Services - Resource Actions) that calls an orchestrator (VRO) workflow to do a few things.  The VRO workflow takes three objects as inputs: 2 string's and a VC:VirtualMachine.  Logging into the web GUI, when a user selects the action for the specific VM, they are presented with a form prompting for the content of the 2 strings.  The VC:VirtualMachine object is transparant and (I believe) is automatically mapped internally to the VM selected.  This action works great when launched through the web GUI.  Now I need to create the same scenario using the REST API.  I have created the JSON "ResourceActionRequest" object and included the 2 strings as entries in the request data, but I have no idea how to add in the VC:VirtualMachine object to the request.  I thought maybe it was also transparant, but I get an error if I try sending the JSON without the 3rd piece of data.  For example, here is my JSON "ResourceActionRequest" object:

{

    "@type": "ResourceActionRequest",

    "resourceRef": {

        "id": "<resourceRef-id>"

    },

    "resourceActionRef": {

        "id": "<resourceActionRef-id>"

    },

    "organization": {

        "tenantRef": "<label>",

        "tenantLabel": "<label>",

        "subtenantRef": "<subtenantRef>",

        "subtenantLabel": "<subtenantLabel>"

    },

    "state": "SUBMITTED",

    "requestNumber": 0,

    "requestData": {

        "entries": [{

            "key": "provider-MyFirstCustomProperty",

            "value": {

                "type": "string",

                "value": "blah,blah,blah"

            }

        },

        {

            "key": "provider-MySecondCustomProperty",

            "value": {

                "type": "string",

                "value": "blah,blah,blah"

            }

        }]

    }

}

I'm just not sure how to provide the VC:VirtualMachine into the request.  Any help would be appreciated.  Thanks!

-- Stephen

0 Kudos
1 Solution

Accepted Solutions
GrantOrchardVMw
Commander
Commander
Jump to solution

Hey Stephen,

I'm not seeing the following bits that I would expect:

{

  "key" : "provider-MachineName",

  "value" : {

    "type" : "string",

    "value" : "vra045"

  }

}

This is the vRA Machine Identity which should map back.

Grant

Grant http://grantorchard.com

View solution in original post

0 Kudos
3 Replies
GrantOrchardVMw
Commander
Commander
Jump to solution

Hey Stephen,

I'm not seeing the following bits that I would expect:

{

  "key" : "provider-MachineName",

  "value" : {

    "type" : "string",

    "value" : "vra045"

  }

}

This is the vRA Machine Identity which should map back.

Grant

Grant http://grantorchard.com
0 Kudos
spride
Enthusiast
Enthusiast
Jump to solution

Hey Grant - Many thanks for your input.  I actually jumped the gun a little bit because I didn't have access to our VRO server earlier.  It turns out I was using the wrong names for the 2 strings in my JSON.  I have a build profile and a resource action that basically call the same workflow.  The blueprint actually calls a stub wrapper and uses it's own names. while the resource action calls the workflow directly.  I was using the names in the blueprint instead of the resource action for those two strings.  Ugh.  As soon as I changed the names, it worked like a charm.

Lesson #1: Don't use different names for the same thing.  :smileysilly:

First thing tomorrow morning when I get into work I'm going to set all the names the same - haha.

I added your suggestion as well as it makes sense, too.  I really appreciate the feedback as it set my brain thinking and once I could get into our VRO server again, I was able to pinpoint the issue. Thanks for all your quick help!

BTW, is there another good resource for this API stuff besides the programmers guide that VMware hosts?  They have some good examples, but they are very limited.  Searching the net doesn't bring up a whole lot, either.  thanks.

0 Kudos
GrantOrchardVMw
Commander
Commander
Jump to solution

In a word - no 😕

I've been trying to write my way through some of this stuff on my blog but I haven't made massive inroads. Need more hours in the day Smiley Happy

For now just shout out here, I'm checking for questions when I'm not onsite with customers.

Grant

Grant http://grantorchard.com
0 Kudos