VMware Cloud Community
BillSkulley
Contributor
Contributor
Jump to solution

vCO REST and vCD

I'm trying to extend from the excellent information in http://communities.vmware.com/message/2119680 and drive vCO vCD workflows from curl, however I'm again getting the "syntactically incorrect" error return.

Specifically I'm attempting to call the "Power on a vApp" workflow in the vCloud Director library.  I'm using the following curl command line:

curl -i - k -H "content-type: text/html" -d @reqbody.xml --user <username>:<password>  https://<vCO server>:8281/api/workflows/88808080808080808080808080808080C18080800126658240472157fdafc0fce/executions/

The content of reqbody.xml:

<?xml version="1.0" encoding="UTF-8"?>
<vco:execution-context xmlns:vco="http://www.vmware.com/vco" xmlns="vco">
  <vco:parameters>
    <vco:parameter name="vApp" type="vCloud:VApp">
      <vco:vCloud:VApp>b5cd68fc-a50f-4cac-9b3e-45679bcd2ce7</vco:vCloud:VApp>
    </vco:parameter>
  </vco:parameters>
</vco:execution-context>

I've also attempted to validate via the presentation and presentation/instances with the same "Bad Request" syntax return.  I'm certain I'm somehow mishandling the "vCloud:VApp" type but am at a loss as to how to correct it.

Thanks!

Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Bill,

There are a few problems:

  • You've specified content type of the request to be text/html but the actual content you pass is of type application/xml (content of your reqbody.xml)
  • You haven't specified request command (-X POST)
  • The xml fragment where you specify input parameter is incorrect. Instead of

    <vco:parameter name="vApp" type="vCloud:VApp">
      <vco:vCloud:VApp>b5cd68fc-a50f-4cac-9b3e-45679bcd2ce7</vco:vCloud:VApp>
    </vco:parameter>

          it should be something like

    <vco:parameter name="vApp" type="vCloud:VApp">
      <vco:sdk-object type="vCloud:VApp" id="b5cd68fc-a50f-4cac-9b3e-45679bcd2ce7" />
    </vco:parameter>

I don't have vCloud plug-in installed at hand so I haven't tested it, but I expect it to work just fine.

Hope this helps,

Ilian

View solution in original post

Reply
0 Kudos
7 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Why would you use the REST plug-in when you can use the vCloud plug-in ?

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
BillSkulley
Contributor
Contributor
Jump to solution

I have the vCD plugin in vCO, but I am taking "baby steps" in building a larger workflow which can be driven externally by another automation engine (politics).  I'm just working with the vApp power on workflow as a proof of concept for an eventual workflow which might include approvals, deploying a new vApp, CMDB updates, etc etc.  Since much of the subject matter is (obviously) new to me I thought starting with a simple workflow and building up would be the best approach.

Thanks!

Reply
0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

sneaking in just to clarify a misunderstanding:

I think Bill wants to use the vCO REST API to trigger a workflow from an external system (northbound integration).

I don't have an answer for this specific one, but:

start simpler:

create a hello world workflow with no inputs, and try to call that one.

then: create a hello something workflow that has one string input (or anohter plain data type) and call that one.

then finally try to call a workflow with a complex inventory object as input.

(and keep us updated about the results :smileygrin: )

Cheers,

Joerg

cdecanini_
VMware Employee
VMware Employee
Jump to solution

Yep, I noticed that. I replied after reading this from my blackberry and getting confused between the vCD & REST API.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Bill,

There are a few problems:

  • You've specified content type of the request to be text/html but the actual content you pass is of type application/xml (content of your reqbody.xml)
  • You haven't specified request command (-X POST)
  • The xml fragment where you specify input parameter is incorrect. Instead of

    <vco:parameter name="vApp" type="vCloud:VApp">
      <vco:vCloud:VApp>b5cd68fc-a50f-4cac-9b3e-45679bcd2ce7</vco:vCloud:VApp>
    </vco:parameter>

          it should be something like

    <vco:parameter name="vApp" type="vCloud:VApp">
      <vco:sdk-object type="vCloud:VApp" id="b5cd68fc-a50f-4cac-9b3e-45679bcd2ce7" />
    </vco:parameter>

I don't have vCloud plug-in installed at hand so I haven't tested it, but I expect it to work just fine.

Hope this helps,

Ilian

Reply
0 Kudos
BillSkulley
Contributor
Contributor
Jump to solution

Thanks for all the good ideas.

I have been able to successfully call the sample "Hello World" from the information in http://communities.vmware.com/message/2119680 via REST using curl.  Extending from that I've been able to call "simple" workflows such as "Export Logs and app settings".  So I at least know (or think I know) I'm on the right track Smiley Happy  Its the "x:y" parameter types that have me lost at the moment (I imagine, and will test next, that I'll have similar issues with vCenter workflows for example).

I've modified the curl command line as suggested, and also updated the xml file:

<?xml version="1.0" encoding="UTF-8"?>
<vco:execution-context xmlns:vco="
http://www.vmware.com/vco" xmlns="vco">
  <vco:parameters>
    <vco:parameter name="vApp" type="vCloud:VApp">
      <vco:sdk-object type="vCloud:VApp" id="b5cd68fc-a50f-4cac-9b3e-45679bcd2ce7" />
    </vco:parameter>
  </vco:parameters>
</vco:execution-context>

This causes a slightly different behavior in that now the returned error contains slightly more useful information:

The request sent by the client was syntactically incorrect (1 error(s) found: [ { vApp - This field is required. } ]) 

I've played a bit with the xml, like including name="vApp" and different vApp ID formats but with no difference in result.

I don't know if this is helpful, but the server.log contains the following information as well:

2012-10-12 11:34:33.682+0000 WARN  [TypeQualifierToDecoratorConverter] Can't find mapping for:class ch.dunes.model.type.qualifier.TQCallerParameter,[kind:null,name:contextualParameter,value:]
2012-10-12 11:34:33.682+0000 INFO  [Attribute] Cannot convert strong to object dunes://service.dunes.ch/CustomSDKObject?id='b5cd68fc-a50f-4cac-9b3e-45679bcd2ce7'&dunesName='vCloud:VApp'
ch.dunes.model.type.ConvertorException: Cannot convert to object , reason : Unable to perform operation 'find('VApp', 'b5cd68fc-a50f-4cac-9b3e-45679bcd2ce7')' on plugin 'vCloud' reason : 'null'

I have double-checked and can run this workflow directly from the Orchestrator client GUI successfully against the target vApp.  So the problem definitely appears to be in my REST request. :smileyconfused: 

Reply
0 Kudos
BillSkulley
Contributor
Contributor
Jump to solution

Actually wandering off into vCenter workflows helped.  As well as additional log trolling.

So, the remaining issue was the ID itself, it is much more complex than I thought:

<vco:sdk-object type="vCloud:VApp" id="a8d5ae9e1c4a828c499a6154e392a3016298eed7e4cd3a9abc9da78925////https://_your_vcloud_server_/api/vApp/vapp-b5cd68fc-a50f-4cac-9b3e-45679bcd2ce7" />

I've not yet figured out what the first part of that ID is, and then how to find the whole thing programatically but I'm pretty sure I'll be able to figure this out with more reading/digging.

The XML format was my real stumbling block, though, so I consider my question answered!

Thanks!

Reply
0 Kudos