In vCloud Director (vCD), vApp leases are defined at the organization level and can’t be overridden at the vApp level. In our dev/test cloud we set leases so that vApps will expire after a certain amount of time. We do this so that unused vApps will expire and users can continue to deploy new vApps without the need for further increasing their vApp quota. Users receive emails that their vApps are about to expire and they can renew them at any time, but I thought I’d look into a way of creating an exception list for vApps that should never expire.
I decided on using vCenter Ochestrator (vCO) to accomplish this for the following reasons:
- We already use heavily in our vCD environment.
- A vCO workflow has a graphical interface for adding/deleting vApps from the exception list.
- The workflow will reside on the vCO server and not on some other server where it’s more likely to be forgotten.
- I can use the built-in vCO scheduler to run the workflow.
- If needed, I can make an API call to run the workflow externally.
I’m not going to document each step of creating the workflow, but I’ll list what each workflow component looks like so you can see the inputs, outputs and code.
Get current vApp
leaseSettingsSection = currentVapp.getLeaseSettingsSection() System.log("Updating runtime lease for vApp: " + currentVapp.name + ". Current lease is: " + leaseSettingsSection.deploymentLeaseInSeconds) System.log("Updating storage lease for vApp: " + currentVapp.name + ". Current lease is: " + leaseSettingsSection.storageLeaseInSeconds) newDeploymentLeaseInSeconds = currentVapp.parent.parent.toAdminObject().settings.vAppLeaseSettings.deploymentLeaseSeconds newStorageLeaseInSeconds = currentVapp.parent.parent.toAdminObject().settings.vAppLeaseSettings.storageLeaseSeconds leaseSettingsSection.deploymentLeaseInSeconds = newDeploymentLeaseInSeconds leaseSettingsSection.storageLeaseInSeconds = newStorageLeaseInSeconds var task = currentVapp.updateSection(leaseSettingsSection)
Adding vApp(s) to the workflow
Edit the workflow:
Select the vApp attribute’s value:
Browse to vCloud Director > vCD instance > Organizations > Org that your vApp(s) are in > vDCs > vDC your vApp(s) are in > vApps
Add each of the vApps that you want to renew the leases on.
Once you’re done, you’ll see the list of vApps in the vApps attribute array:
Example of a successful run:
Scheduling the workflow
Select your workflow:
Set the scheduling times for whatever makes sense in your environment: