VMware Cloud Community
Karoliner
Contributor
Contributor
Jump to solution

Define VC:<object> when calling workflows from Powershell?

Hello!

In our vRO we have a workflow that builds our standard 2012 servers, in this workflow the user can select which Datastore, Network, Host etc on which to place the resulting VM. Now i'd like to be able to start this workflow from Powershell using the vRO API, i've managed to get some parts of it working by using what i learned from reading this guide: http://www.vcoteam.info/articles/learn-vco/297-how-to-use-powershell-to-start-an-orchestrator-workfl... but since it only touches on using String properties i'm now stuck on how to define the inventory(?) properties like VC:HostSystem.

Is it possible to define attributes like VC:Datastore, VC:HostSystem etc via Powershell/XML/json and then start a workflow? If so i'd love some examples.

Thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

All plug-in objects (including those of type VC:Datastore, VC:HostSystem, etc) are passed to vRO REST API as sdk-object. Here are samples in JSON and XML format for REST request body for out-of-the-box workflow 'Rename datacenter' which has 2 input parameters: datacenter of type VC:Datacenter and newName of type string

// JSON format

{

  "parameters" : [

    {"value":{"sdk-object":{"type":"VC:Datacenter","id":"10.23.1.12/datacenter-35"}},"type":"VC:Datacenter","name":"datacenter"},

    {"value":{"string":{"value":"dc4"}},"type":"string","name":"newName","scope":"local"}

  ]

}

// XML format

<?xml version="1.0" encoding="UTF-8"?>

<execution-context xmlns="http://www.vmware.com/vco"> 

  <parameters> 

       <parameter name="datacenter" type="VC:Datacenter" scope="local"> 

            <sdk-object type="VC:Datacenter" id="10.23.1.12/datacenter-35" />

       </parameter> 

       <parameter name="newName" type="string" scope="local"> 

            <string>dc3</string>

       </parameter> 

  </parameters> 

</execution-context> 

View solution in original post

0 Kudos
1 Reply
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

All plug-in objects (including those of type VC:Datastore, VC:HostSystem, etc) are passed to vRO REST API as sdk-object. Here are samples in JSON and XML format for REST request body for out-of-the-box workflow 'Rename datacenter' which has 2 input parameters: datacenter of type VC:Datacenter and newName of type string

// JSON format

{

  "parameters" : [

    {"value":{"sdk-object":{"type":"VC:Datacenter","id":"10.23.1.12/datacenter-35"}},"type":"VC:Datacenter","name":"datacenter"},

    {"value":{"string":{"value":"dc4"}},"type":"string","name":"newName","scope":"local"}

  ]

}

// XML format

<?xml version="1.0" encoding="UTF-8"?>

<execution-context xmlns="http://www.vmware.com/vco"> 

  <parameters> 

       <parameter name="datacenter" type="VC:Datacenter" scope="local"> 

            <sdk-object type="VC:Datacenter" id="10.23.1.12/datacenter-35" />

       </parameter> 

       <parameter name="newName" type="string" scope="local"> 

            <string>dc3</string>

       </parameter> 

  </parameters> 

</execution-context> 

0 Kudos