Hello everyone, relatively new to Orchestrator. Using Orchestrator 5.5 and vCloud Director 5.5 and trying to use the vCloud Director Plugin to create and mange vApps. I am trying to change the ownership of the vApp but cannot seem to find reference to how to make this change within Orchestrator. Anyone have code or document they can point me to on how to add this capability into Orchestrator to change the owner of a vApp.
Thank you
Yes, code works as expected with vCO 5.5.1 and vCD 5.5.. I've actually just simplified it as well.. I tested with a SYSTEM level account:
var org = vApp.parent.parent;
System.log("vApp Parent: "+org.name);
// First we need to get the adminObject for the Organization:
var adminOrg = org.toAdminObject();
// Now we can use the getUserByName method that takes a string input
var vCloudUser = adminOrg.getUserByName(newOwner);
// Finally, if the user was found, we set the ownership
if (vCloudUser != null){
vApp.changeOwner(vCloudUser.getReference());
}
vApp.updateInternalState();
In the above, there are two inputs:
vApp (vCloud:VApp) -- vApp object to set new owner on
newOwner (string) -- username of the new owner
UPDATE: I also tested this same code as an Organization (non SYSTEM ADMIN) user and found it to work there too
I haven't tried this with newer versions yet, but the code in the comment here may work -- scroll to bottom of page for the code I placed in the comment for changing the owner of a vApp:
Custom Deploy vApp Workflow for vCloud Director 1.5
Yes, code works as expected with vCO 5.5.1 and vCD 5.5.. I've actually just simplified it as well.. I tested with a SYSTEM level account:
var org = vApp.parent.parent;
System.log("vApp Parent: "+org.name);
// First we need to get the adminObject for the Organization:
var adminOrg = org.toAdminObject();
// Now we can use the getUserByName method that takes a string input
var vCloudUser = adminOrg.getUserByName(newOwner);
// Finally, if the user was found, we set the ownership
if (vCloudUser != null){
vApp.changeOwner(vCloudUser.getReference());
}
vApp.updateInternalState();
In the above, there are two inputs:
vApp (vCloud:VApp) -- vApp object to set new owner on
newOwner (string) -- username of the new owner
UPDATE: I also tested this same code as an Organization (non SYSTEM ADMIN) user and found it to work there too
Thank you this works, I have marked your answer as Correct.