jmoody5824
Contributor
Contributor

Change owner of vApp

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee

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 Smiley Happy

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
3 Replies
Burke-
VMware Employee
VMware Employee

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

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
Burke-
VMware Employee
VMware Employee

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 Smiley Happy

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
jmoody5824
Contributor
Contributor

Thank you this works, I have marked your answer as Correct.

0 Kudos