Carmageddon
Contributor
Contributor

Creating vCloud org with custom policy - vApp template Lease - Maximum storage lease

Jump to solution

Hello guys!

I am working on utilizing the Orchestrator to enable auto provision and customization of the vCloud.

My (hopefully) last problem, remains the organization's policy setting which is:

vApp template Lease:

Maximum storage lease (30 days)

This is the default, and apparently, the example workflow for creating an organization, has no way to change this!

I am talking about this bit:

var leaseSettings = System.getModule("com.vmware.library.vCloud.Admin.Organization").createOrgLeaseSettings(
storageLeaseHours,
deploymentLeaseHours,
deleteOnStorageLeaseExpiration);

Apparently, the deleteOnStorageLeaseExpiration only affects the Storage cleanup: (Move to Expired Items or Permanently Delete) - but not the Maximum storage lease setting Smiley Sad

Searching the API library, I found this and tried to do something:

var myVclOrgVAppTemplateLeaseSettings = new VclOrgVAppTemplateLeaseSettings();

myVclOrgVAppTemplateLeaseSettings.storageLeaseSeconds = 0;

myVclOrgVAppTemplateLeaseSettings.deleteOnStorageLeaseExpiration = deleteOnStorageLeaseExpiration;

However, on attempt of using it in createOrgSettings, I get exception:
Cannot convert com.vmware.vmo.plugin.vcloud.model.schema.objects.OrgVAppTemplateLeaseSettings@731305e9 to com.vmware.vmo.plugin.vcloud.model.schema.objects.OrgEmailSettings (Dynamic Script Module name : createOrgSettings#17)
How do I utilize this, to customize the Maximum storage lease attribute for the organization policy? this is not very clear...
Thanks!
0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee

Screenshot helps SOOO much Smiley Happy I understand now...

Okay, working with the Org object alone won't get you where you need to go, you also need to get the Admin Organization object

var adminOrg = myOrgObject.toAdminObject();

now, with the adminOrg, you can call the "updateSetings" method with a "VclOrgSettings" object passed as the parameter...

var orgSettings = new VclOrgSettings();

// Look at the VclOrgSettings object in the api explorer to find the available properties - one of them is the one you need: "vAppTemplateLeaseSettings" - so the code you created will go in here....

Given the above...

Create the Org as you are... once you have the org created, get the admin object for that org and update the vAppTemplateLeaseSettings as desired :smileygrin:

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
7 Replies
Burke-
VMware Employee
VMware Employee

Please  move this post to the Orchestrator community.

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
Carmageddon
Contributor
Contributor

hmmm I thought I posted this in Orchestrator community :smileyshocked:

How to move it?

0 Kudos
Burke-
VMware Employee
VMware Employee

It's in the right place now Smiley Wink When it was first posted, it was in the vCenter Orchestrator Plug-in SDK community - that community is for people developing plug-ins for vCO 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
0 Kudos
Burke-
VMware Employee
VMware Employee

In looking at the library workflow "Add an organization", I see an input for storageLeaseHours ... are you saying that this disregards your input and defaults to 30 days? If you want it permanent, you just set the storage lease to 0 with deleteOnStorageLeaseExpiration to false... does this not work?

... I haven't looked too deeply into this myself, but it "looks" like things are in place for creating an org with all the appropriate settings.

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
Carmageddon
Contributor
Contributor

Yes, I used exactly the settings like you said - deleteOnStorageLeaseExpiration is false (No in vco) and storageLeaseHours is 0.

The result is attached in screenshot.

Note that if deleteOnStorageLeaseExpiration is set to true, it only changes the Storage Cleanup: "Move to..." to "Permanently delete" - tahts all.

0 Kudos
Burke-
VMware Employee
VMware Employee

Screenshot helps SOOO much Smiley Happy I understand now...

Okay, working with the Org object alone won't get you where you need to go, you also need to get the Admin Organization object

var adminOrg = myOrgObject.toAdminObject();

now, with the adminOrg, you can call the "updateSetings" method with a "VclOrgSettings" object passed as the parameter...

var orgSettings = new VclOrgSettings();

// Look at the VclOrgSettings object in the api explorer to find the available properties - one of them is the one you need: "vAppTemplateLeaseSettings" - so the code you created will go in here....

Given the above...

Create the Org as you are... once you have the org created, get the admin object for that org and update the vAppTemplateLeaseSettings as desired :smileygrin:

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
Carmageddon
Contributor
Contributor

Thank you so much!

It works Smiley Happy

Final block of code, for anyone else encountering the same issues:

// Create object with VApp lease settings.
var myVclOrgVAppTemplateLeaseSettings = new VclOrgVAppTemplateLeaseSettings();
myVclOrgVAppTemplateLeaseSettings.storageLeaseSeconds = 0;
myVclOrgVAppTemplateLeaseSettings.deleteOnStorageLeaseExpiration = deleteOnStorageLeaseExpiration;
//Create org Settings object, and attach the VAppLeaseSettings object to it.
var orgSettingsExtra = new VclOrgSettings();
orgSettingsExtra.vAppTemplateLeaseSettings = myVclOrgVAppTemplateLeaseSettings;
adminOrg.updateSettings(orgSettingsExtra);

I think this is a minor "bug" that tweaking this setting is not possible without custom code in Orchestrator.

The key was of course knowing the adminOrg has an updateSettings method, and that this method takes VclOrgSettings object, and that this object has an attribute, which takes exactly the object which controls what was lacking Smiley Happy

Just for my understanding - how did you figure out how to build this object?

0 Kudos