VMware Cloud Community
radwareMichael
Contributor
Contributor

Running workflows using REST api

Hi experts,

I use vRO 7.0.1 with Radware's AdcVCOPlugin installed.

I'm trying to run one of  a workflows imported by plugin using REST api.

I used following article to get familiar with this process - How to use the REST API to Start a Workflow

I run the workflow manually once and it's terminated properly, then read its execution entity via REST , here it is ( Sorry for huge amount of text, I've marked red the point I've had problem with !)

{

  "href": "https://10.205.102.57:8281/vco/api/workflows/A5808080808080808080808080808080DB808080012940692841403...",

  "relations": {

    "link": [

      {

        "href": "https://10.205.102.57:8281/vco/api/workflows/A5808080808080808080808080808080DB808080012940692841403...",

        "rel": "up"

      },

      {

        "href": "https://10.205.102.57:8281/vco/api/workflows/A5808080808080808080808080808080DB808080012940692841403...",

        "rel": "remove"

      },

      {

        "href": "https://10.205.102.57:8281/vco/api/workflows/A5808080808080808080808080808080DB808080012940692841403...",

        "rel": "logs"

      },

      {

        "href": "https://10.205.102.57:8281/vco/api/workflows/A5808080808080808080808080808080DB808080012940692841403...",

        "rel": "state"

      }

    ]

  },

  "id": "8a4de6b954ed46c301552b9cdc8d038f",

  "state": "completed",

  "start-date": 1465315548301,

  "end-date": 1465315634838,

  "started-by": "vcoadmin",

  "name": "createADC",

  "input-parameters": [

   {

      "value": {

        "sdk-object": {

          "type": "AdcVCOPlugin:AdcContainer",

          "href": "https://10.205.102.57:8281/vco/api/catalog/AdcVCOPlugin/AdcContainer/vmc-01/",

          "id": "vmc-01"

        }

      },

      "type": "AdcVCOPlugin:AdcContainer",

      "name": "container",

      "scope": "local"

    },

    {

      "value": {

        "sdk-object": {

          "type": "VC:VirtualMachine",

          "href": "https://10.205.102.57:8281/vco/api/catalog/VC/VirtualMachine/10.205.122.41%252Fvm-3779/",

          "id": "10.205.122.41/vm-3779"

        }

      },

      "type": "VC:VirtualMachine",

      "name": "adcTemplateVM",

      "scope": "local"

    },

    {

      "value": {

        "sdk-object": {

          "type": "VC:VmFolder",

          "href": "https://10.205.102.57:8281/vco/api/catalog/VC/VmFolder/10.205.122.41%252Fgroup-v270/",

          "id": "10.205.122.41/group-v270"

        }

      },

      "type": "VC:VmFolder",

      "name": "adcTargetFolder",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "vmc-01-inst-01"

        }

      },

      "type": "string",

      "name": "adcInstanceName",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "Network"

        }

      },

      "type": "string",

      "name": "managementNetworkType",

      "scope": "local"

    },

    {

      "value": {

        "sdk-object": {

          "type": "VC:Network",

          "href": "https://10.205.102.57:8281/vco/api/catalog/VC/Network/10.205.122.41%252Fnetwork-12/",

          "id": "10.205.122.41/network-12"

        }

      },

      "type": "VC:Network",

      "name": "managementNetwork",

      "scope": "local"

    },

    {

      "type": "VC:DistributedVirtualPortgroup",

      "name": "managementPortgroup",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "vDS"

        }

      },

      "type": "string",

      "name": "clientNetworkType",

      "scope": "local"

    },

    {

      "type": "VC:Network",

      "name": "clientNetwork",

      "scope": "local"

    },

    {

      "value": {

        "sdk-object": {

          "type": "VC:DistributedVirtualPortgroup",

          "href": "https://10.205.102.57:8281/vco/api/catalog/VC/DistributedVirtualPortgroup/10.205.122.41%252Fdvportgr...",

          "id": "10.205.122.41/dvportgroup-315"

        }

      },

      "type": "VC:DistributedVirtualPortgroup",

      "name": "clientPortgroup",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "vDS"

        }

      },

      "type": "string",

      "name": "serverNetworkType",

      "scope": "local"

    },

    {

      "type": "VC:Network",

      "name": "serverNetwork",

      "scope": "local"

    },

    {

      "value": {

        "sdk-object": {

          "type": "VC:DistributedVirtualPortgroup",

          "href": "https://10.205.102.57:8281/vco/api/catalog/VC/DistributedVirtualPortgroup/10.205.122.41%252Fdvportgr...",

          "id": "10.205.122.41/dvportgroup-314"

        }

      },

      "type": "VC:DistributedVirtualPortgroup",

      "name": "serverPortgroup",

      "scope": "local"

    },

    {

      "value": {

        "number": {

          "value": 516

        }

      },

      "type": "number",

      "name": "clientsVlan",

      "scope": "local"

    },

    {

      "value": {

        "number": {

          "value": 515

        }

      },

      "type": "number",

      "name": "serversVlan",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "192.168.13.130"

        }

      },

      "type": "string",

      "name": "adcClientIfAddress",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "255.255.255.0"

        }

      },

      "type": "string",

      "name": "adcClientIfMask",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "192.168.12.1"

        }

      },

      "type": "string",

      "name": "adcServerIfAddress",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "255.255.255.0"

        }

      },

      "type": "string",

      "name": "adcServerIfMask",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "192.168.13.1"

        }

      },

      "type": "string",

      "name": "adcGWAdress",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "Version 3"

        }

      },

      "type": "string",

      "name": "snmpVersion",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "public"

        }

      },

      "type": "string",

      "name": "readCommunity",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "private"

        }

      },

      "type": "string",

      "name": "writeCommunity",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "adminsha"

        }

      },

      "type": "string",

      "name": "authenticationPassword",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "adminsha"

        }

      },

      "type": "string",

      "name": "privacyPassword",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "admin"

        }

      },

      "type": "string",

      "name": "cliPassword",

      "scope": "local"

    },

    {

      "value": {

        "boolean": {

          "value": true

        }

      },

      "type": "boolean",

      "name": "useSSH",

      "scope": "local"

    },

    {

      "value": {

        "number": {

          "value": 161

        }

      },

      "type": "number",

      "name": "port",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "adminsha"

        }

      },

      "type": "string",

      "name": "userName",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "DES"

        }

      },

      "type": "string",

      "name": "privProtocol",

      "scope": "local"

    },

    {

      "value": {

        "string": {

          "value": "SHA"

        }

      },

      "type": "string",

      "name": "authProtocol",

      "scope": "local"

    }

  ],

  "output-parameters": [

    {

      "value": {

        "sdk-object": {

          "type": "AdcVCOPlugin:AdcInstance",

          "href": "https://10.205.102.57:8281/vco/api/catalog/AdcVCOPlugin/AdcInstance/vmc-01-inst-01/",

          "id": "vmc-01-inst-01"

        }

      },

      "type": "AdcVCOPlugin:AdcInstance",

      "name": "newAdcInstance",

      "scope": "local"

    }

  ]

}

Now to run this workflow using REST api this time I've built following execution-context xml :

I've tried to run it without scope attribute and different variations of scope attribute as well  {local, AdcVCOPlugin, AdcVCOPlugin:AdcContainer}.

I thougt I's a problem and plugin objects should refer to plugin scope, now I see It's not.

But workflow execution always failed because of returned status 400 , here is original exception :

java.lang.RuntimeException: Workflow execution failed. Reason - {"status":400,"message":"2 error(s) found: [ { ADC-VA Container - Unable to convert object, no sdk type defined for class : VMWare vmc-01 (https://10.205.122.41:443/sdk) }  { ADC-VA Container - This field is required. } ]"}


So using this example from manual run

{

      "value": {

        "sdk-object": {

          "type": "AdcVCOPlugin:AdcContainer",

          "href": "https://10.205.102.57:8281/vco/api/catalog/AdcVCOPlugin/AdcContainer/vmc-01/",

          "id": "vmc-01"

        }

      },

      "type": "AdcVCOPlugin:AdcContainer",

      "name": "container",

      "scope": "local"

    }

What is wrong with input parameter i use to build ? How can I build it properly ?

<parameter name="container" type="AdcVCOPlugin:AdcContainer" scope="AdcVCOPlugin">

            <sdk-object type="AdcVCOPlugin:AdcContainer" href="https://10.205.102.57:8281/vco/api/catalog/AdcVCOPlugin/AdcContainer/vmc-01/" id="vmc-01"/>

        </parameter>

<execution-context

    xmlns="http://www.vmware.com/vco">

    <parameters>

       <parameter name="container" type="AdcVCOPlugin:AdcContainer" scope="AdcVCOPlugin">

            <sdk-object type="AdcVCOPlugin:AdcContainer" href="https://10.205.102.57:8281/vco/api/catalog/AdcVCOPlugin/AdcContainer/vmc-01/" id="vmc-01"/>

        </parameter>

        <parameter name="adcTemplateVM" type="VC:VirtualMachine" scope="local">

            <sdk-object type="VC:VirtualMachine" href="https://10.205.102.57:8281/vco/api/catalog/VC/VirtualMachine/10.205.122.41%252Fvm-3782/" id="10.205.122.41/vm-3782"/>

        </parameter>

        <parameter name="adcTargetFolder" type="VC:VmFolder" scope="local">

            <sdk-object type="VC:VmFolder" href="https://10.205.102.57:8281/vco/api/catalog/VC/VmFolder/10.205.122.41%252Fgroup-v270/" id="10.205.122.41/group-v270"/>

        </parameter>

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

            <string>vmc-01-inst-01</string>

        </parameter>

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

            <string>Network</string>

        </parameter>

        <parameter name="managementNetwork" type="VC:Network" scope="local">

            <sdk-object type="VC:Network" href="https://10.205.102.57:8281/vco/api/catalog/VC/Network/10.205.122.41%252Fnetwork-12/" id="10.205.122.41/network-12"/>

        </parameter>

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

            <string>vDS</string>

        </parameter>

        <parameter name="clientPortgroup" type="VC:DistributedVirtualPortgroup" scope="local">

            <sdk-object type="VC:DistributedVirtualPortgroup" href="https://10.205.102.57:8281/vco/api/catalog/VC/DistributedVirtualPortgroup/10.205.122.41%252Fdvportgr..." id="10.205.122.41/dvportgroup-315"/>

        </parameter>

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

            <string>vDS</string>

        </parameter>

        <parameter name="serverPortgroup" type="VC:DistributedVirtualPortgroup" scope="local">

            <sdk-object type="VC:DistributedVirtualPortgroup" href="https://10.205.102.57:8281/vco/api/catalog/VC/DistributedVirtualPortgroup/10.205.122.41%252Fdvportgr..." id="10.205.122.41/dvportgroup-314"/>

        </parameter>

        <parameter name="clientsVlan" type="number" scope="local">

            <number>516</number>

        </parameter>

        <parameter name="serversVlan" type="number" scope="local">

            <number>515</number>

        </parameter>

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

            <string>192.168.13.130</string>

        </parameter>

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

            <string>255.255.255.0</string>

        </parameter>

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

            <string>192.168.12.1</string>

        </parameter>

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

            <string>255.255.255.0</string>

        </parameter>

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

            <string>192.168.13.1</string>

        </parameter>

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

            <string>Version 3</string>

        </parameter>

        <parameter name="port" type="number" scope="local">

            <number>161</number>

        </parameter>

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

            <string>adminsha</string>

        </parameter>

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

            <string>SHA</string>

        </parameter>

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

            <string>adminsha</string>

        </parameter>

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

            <string>DES</string>

        </parameter>

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

            <string>adminsha</string>

        </parameter>

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

            <string>admin</string>

        </parameter>

    </parameters>

</execution-context>

Thanks

Reply
0 Kudos
5 Replies
iiliev
VMware Employee
VMware Employee

Hi,

Here is how a request body might look like in XML format:

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

  <parameters>

    <parameter type="AdcVCOPlugin:AdcContainer" name="container" scope="local">

      <sdk-object type="AdcVCOPlugin:AdcContainer" id="vmc-01"/>

    </parameter>

  </parameters>

</execution-context>

and in JSON format:

{

"parameters":[

  { "value":

    { "sdk-object" :

      { "type":"AdcVCOPlugin:AdcContainer",

        "id":"vmc-01"

      }

    },

    "type":"AdcVCOPlugin:AdcContainer",

    "name":"container",

    "scope":"local"

  }

]

}

Reply
0 Kudos
radwareMichael
Contributor
Contributor

Thanks Ilian,

I've changed request body as suggested, it doesn't solved problem, other suggestions ?

<execution-context  xmlns="http://www.vmware.com/vco"><parameters><parameter type="AdcVCOPlugin:AdcContainer" name="container" scope="local"><sdk-object type="AdcVCOPlugin:AdcContainer" id="vmc-01"/></parameter><parameter type="VC:VirtualMachine" name="adcTemplateVM" scope="local"><sdk-object type="VC:VirtualMachine" id="10.205.122.41/vm-3782"/></parameter><parameter type="VC:VmFolder" name="adcTargetFolder" scope="local"><sdk-object type="VC:VmFolder" id="10.205.122.41/group-v270"/></parameter><parameter type="string" name="adcInstanceName" scope="local"><string>vmc-01-inst-01</string></parameter><parameter type="string" name="managementNetworkType" scope="local"><string>Network</string></parameter><parameter type="VC:Network" name="managementNetwork" scope="local"><sdk-object type="VC:Network" id="10.205.122.41/network-12"/></parameter><parameter type="string" name="clientNetworkType" scope="local"><string>vDS</string></parameter><parameter type="VC:DistributedVirtualPortgroup" name="clientPortgroup" scope="local"><sdk-object type="VC:DistributedVirtualPortgroup" id="10.205.122.41/dvportgroup-315"/></parameter><parameter type="string" name="serverNetworkType" scope="local"><string>vDS</string></parameter><parameter type="VC:DistributedVirtualPortgroup" name="serverPortgroup" scope="local"><sdk-object type="VC:DistributedVirtualPortgroup" id="10.205.122.41/dvportgroup-314"/></parameter><parameter type="number" name="clientsVlan" scope="local"><number>516</number></parameter><parameter type="number" name="serversVlan" scope="local"><number>515</number></parameter><parameter type="string" name="adcClientIfAddress" scope="local"><string>192.168.13.130</string></parameter><parameter type="string" name="adcClientIfMask" scope="local"><string>255.255.255.0</string></parameter><parameter type="string" name="adcServerIfAddress" scope="local"><string>192.168.12.1</string></parameter><parameter type="string" name="adcServerIfMask" scope="local"><string>255.255.255.0</string></parameter><parameter type="string" name="adcGWAdress" scope="local"><string>192.168.13.1</string></parameter><parameter type="string" name="snmpVersion" scope="local"><string>Version 3</string></parameter><parameter type="number" name="port" scope="local"><number>161</number></parameter><parameter type="string" name="userName" scope="local"><string>adminsha</string></parameter><parameter type="string" name="authProtocol" scope="local"><string>SHA</string></parameter><parameter type="string" name="authenticationPassword" scope="local"><string>adminsha</string></parameter><parameter type="string" name="privProtocol" scope="local"><string>DES</string></parameter><parameter type="string" name="privacyPassword" scope="local"><string>adminsha</string></parameter><parameter type="string" name="cliPassword" scope="local"><string>admin</string></parameter></parameters></execution-context>

java.lang.RuntimeException: Workflow execution failed. Reason - {"status":400,"message":"2 error(s) found: [ { ADC-VA Container - Unable to convert object, no sdk type defined for class : VMWare vmc-01 (https://10.205.122.41:443/sdk) }  { ADC-VA Container - This field is required. } ]"}

    at com.radware.vdirect.qa.integrations.vro.utils.VroWebControl.executeWorkflow(VroWebControl.java:51)

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

This error is thrown if the server cannot find a suitable plug-in type to convert. I'm quite confident that the input format is correct (I'm using it successfully with other plug-ins like vCenter), so this could be an indication of bugs or incomplete implementation of some parts of the plug-in.

Is this plug-in's binary/source code available somewhere to take a look?

BTW, is the same workflow working if you start it using vRO Java client?

Reply
0 Kudos
radwareMichael
Contributor
Contributor

Via vRO Java client running same workflow completes successfully.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

To troubleshoot effectively, please try to simplify the test scenario as much as possible:

  1. Do not use a workflow with 20+ input parameters; create a sample workflow with single input and single output of the given type, that simply prints its input using System.log(...) and assigns it to the output.
  2. From the error output in update# 2, it seems you are using some custom code to start the workflow (VroWebControl.java). It's OK if you are confident that this code is bug free, but for other people that do not have access to the custom code it it is extremely hard to understand what is going on. It is recommended to use standard tools during troubleshooting; eg. start the workflow using REST client like curl.

Here is some sample command to start the workflow with curl (assuming the request body with the execution context XML is stored in file request.xml😞

curl -ikv -u {username}:{password} -H "Content-Type: application/xml" -X POST https://{vrohost}:8281/vco/api/workflows/{workflowid}/executions/ -d @request.xml

(replace the parameters enclosed in {} with their actual values valid for your environment)

Reply
0 Kudos