VMware Cloud Community
befreeman
Enthusiast
Enthusiast

Trying to create a Resource Action and its target criteria with vRO (vCO) workflow

I can successfully create the resource action, however I am stumped on how to create target criteria.  Has anyone done this or have any suggestions on how to do this?

Here is what I have so far (import param in a vCACCAFE:ResourceAction) action:

// only want to be visible when vm status is On or Off

var statusLiteral = new vCACCAFEStringLiteral("Status");

var onLiteral = new vCACCAFEStringLiteral("On");

var offLiteral = new vCACCAFEStringLiteral("Off");

var statusEqualsOn = new vCACCAFEEqualsOperator().evaluate(statusLiteral, onLiteral);

var statusEqualsOff = new vCACCAFEEqualsOperator().evaluate(statusLiteral, offLiteral);

var orClause = new vCACCAFEOrClause([statusEqualsOn, statusEqualsOff]);

action.setTargetCriteria(orClause);

But this throws the following error:

Unable to create object : vCACCAFEEqualsOperator : Class ch.dunes.vso.sdk.DynamicWrapper can not access a member of class com.vmware.vcac.platform.content.operators.EqualsOperator with modifiers "protected"

I tried just as a static method vCACCAFEEqualsOperator.evaluate(...   and received this error:

TypeError: Cannot find function evaluate in object DynamicWrapper (Class) : [vCACCAFEEqualsOperator]-[class com.vmware.vcac.platform.content.operators.EqualsOperator] -- VALUE : null. (Workflow:TestUpdateResourceAction / Scriptable task (item1)#4)

I also very skeptical that the statusLiteral will actually do what I want above.

Any help would be greatly appreciated!

Tags (4)
Reply
0 Kudos
2 Replies
gmuleshkov
VMware Employee
VMware Employee

There is a way to do it but I am not sure that this is the best solution.

You can create the resource action with target criteria using the vCAC UI and see the request using firebug or something similar. Like this you will be able to see the JSON message.

After that you can create a scripting that will create resource action from the plugin. The script should be something like this:

// The JSON that you get from firebug

var resourceAction= {

"workflowId": ".....",
"name": "......",
"description": "..............",
"catalogRequestInfoHidden": false,

"forms": .......

"tenant": "...",

    "status": "....",

    "inputParameter": ......

"disposal": false,

    "targetCriteria": {

        "type": "expression",

        "operator": {

            "type": "contains"

        },

        "leftOperand": {

            "type": "path",

            "path": "name"

        },

        "rightOperand": {

            "type": "constant",

            "value": {

                "type": "string",

                "value": "test"

            }

        }

    }

}

Then you can use something like this:

var service = host.createAdvancedDesignerClient();

service.post("resourceOperations", resourceAction);

In this case I tried with a target criteria "name contains test"

Hope this helps.

Regards,

Georgi

befreeman
Enthusiast
Enthusiast

Thanks, I'll give this a try!

Reply
0 Kudos