VMware Cloud Community
qc4vmware
Virtuoso
Virtuoso

Change Owner with Request a catalog resource action fails with 400 Bad Request

We've just upgraded to 7.3 and I am trying to re-assign ownership as part of a workflow where a service account does the request then flips ownership at the end.  I am trying to use the "Request a catalog resource action" to do this but always get a 400 Bad Request.  I am running this on the Change Owner op of the Deployment passing in just one value provider-NewOwner set to the desired user.  I can reassign from the gui with no issues but am always hitting this error in vRO.  HELP!

0 Kudos
8 Replies
filosmith
Enthusiast
Enthusiast

Did it work with 7.2?

Can you change the owner when logged into the GUI as the service account? Maybe you have permission to change the owner but the service account doesn't.

Is it a new deployment you're changing? I have found that I have to wait several seconds for the IaaS and vCAC databases to sync up before I can change the owner.

0 Kudos
qc4vmware
Virtuoso
Virtuoso

We migrated from 6.2.5 to 7.3.  Worked fine in 6.2.5 but that was a resource operation on the VM.  Now it is on the Deployment.

Our workflow is flipping the owner on new deployments but I have checks in place to wait for all of the resource operations to be in place and make sure all assets are returned via the api.  My testing is being done on systems that have been around for days.  I can login to the gui with the same account that I am using in vRO and change the owner without issue.

0 Kudos
qc4vmware
Virtuoso
Virtuoso

Can you verify for me in your environment?  Just run the canned workflow for requesting a resource operation, select a deployment and the Change Owner op.  Blows up for me.

0 Kudos
filosmith
Enthusiast
Enthusiast

It seems to work for me. Library/vRealize Automation/Requests/Request a resource action, right?

[2017-08-02 07:33:54.947] [I] Getting resource action 'Change Owner' request form...

[2017-08-02 07:33:55.010] [I] Accepted inputs:

[2017-08-02 07:33:55.011] [I]  - provider-NewOwner

[2017-08-02 07:33:55.012] [I] Filling in resource action request...

[2017-08-02 07:33:55.013] [I] Sending resource action request...

[2017-08-02 07:33:55.172] [I] Resource action request 'f2e1a6db-7876-4808-aa7f-0db835d728c2' sent!

I should say that I'm on 7.2.

0 Kudos
qc4vmware
Virtuoso
Virtuoso

Thanks for testing on 7.2 but so much could have changed going to 7.3... Anyone on the vRO team willing to take a minute and just fire a test off?  I'd just love confirmation that it works for someone in 7.3.  I have two 7.3 environments to test in a lab and production and both fail the same way.iiliev​ can you help?

0 Kudos
qc4vmware
Virtuoso
Virtuoso

Just so everyone who may be dialed into this thread knows it sure looks like a bug.  Got a friend in professional services to test this for me and confirmed it blows up in a couple of other deployments.  I was able to work around the issue by creating my own workflow and directly making calls to the services... here is a snippet.  I snagged a good chunk of this code from other posts.  Sorry for not giving specific credit Smiley Happy

var operations = item.getOperations();

var tryCnt = 0;

while (!reconfigOp && tryCnt < 24) {

tryCnt++;

System.debug("trying " + tryCnt);

for each (var op in operations) {

System.log(op.name + "::" + op.id);

if (op.name === "Change Owner") {

reconfigOp = op;

break;

}

}

if (!reconfigOp) {

System.sleep(5000);

operations = item.getOperations();

}

}

if (!reconfigOp) {

System.error("No resource action for Change Owner could be located.  Could be an entitlement issue.");

}

else {

var requestTemplate = vCACCAFERequestsHelper.getRequestForResourceAction(reconfigOp)

var jsonData = vCACCAFERequestsHelper.getResourceActionRequestData(requestTemplate);

var json = JSON.parse(jsonData);

//Change provider-NewOwner

json["provider-NewOwner"] = {"type":"entityRef", "classId":"principal", "id":newOwner, "label":""};

//This puts everything back in the right format:

vCACCAFERequestsHelper.setResourceActionRequestData(requestTemplate, JSON.stringify(json));

//And this actually says go do the work:

var request = System.getModule("com.vmware.library.vcaccafe.request").requestResourceActionWithRequestTemplate(reconfigOp, requestTemplate);

var changeOwnerRequest = request;

var requestCompletion = null;

var loopCnt = 0

var completionState = null;

if (request) {

while (!requestCompletion) {

loopCnt++;

//System.log("Execution Status: " + request.getExecutionStatus().value());

//System.log("State: " + request.getState().value());

requestCompletion = request.getRequestCompletion();

if (requestCompletion) {

completionState = request.getRequestCompletion().getRequestCompletionState().value();

System.log("RequestCompletionState: " + completionState);

}

else {

System.sleep(5000);

}

if (loopCnt > 24) break; // should not take more than a couple of minutes to finish.

request = vCACCAFEEntitiesFinder.getResourceActionRequest(host , request.getId()) ;

changeOwnerRequest = request;

}

}

else {

throw "Failed to submit Change Owner";

}

if (completionState == null || completionState != "SUCCESSFUL") throw "Change Owner Failed.";

}

0 Kudos
kmarkov
VMware Employee
VMware Employee

The type which is expected by the API call has changed. Apparently, up to version 7.2 it was perfectly fine to specify the new owner in plain text. Now it is necessary to provide entity reference.

So, if for the inputs parameter of the 'Request a resource action' before it was possible to set it like this:

var newOwner = "configurationadmin@vsphere.local";

inputs = new Array();

inputs.push({ name: "provider-NewOwner", value: newOwner});

Now you need to do it like this:

var newOwner = "configurationadmin@vsphere.local";

var newOwnerLiteral = new vCACCAFEEntityReference("principal" , newOwner);

inputs = new Array();

inputs.push({ name: "provider-NewOwner", value: newOwnerLiteral.getValue()});

qc4vmware
Virtuoso
Virtuoso

Thanks for the info!  I don't have vRO available to me at the moment but I don't think this was obvious to me from the documentation.  I'll give this a whirl sometime this week.

Paul

0 Kudos