vCenter Orchestrator workflow to renew vCloud Director vApp leases

Posted by

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.

The workflow

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.

Workflow overview

2015-08-26_10-45-35


Workflow attributes

2015-08-26_10-46-18


vApps Left?

Inputs

2015-08-26_10-47-10

Scripting

2015-08-26_10-47-43


Get current vApp

Inputs

2015-08-26_10-48-33

Outputs

2015-08-26_10-49-11

Scripting

2015-08-26_11-11-24


vApp exist?

Inputs

2015-08-26_10-51-02

Scripting

2015-08-26_11-07-41


Update Leases

Inputs

2015-08-26_11-12-21

Outputs

2015-08-26_10-52-15

Scripting

2015-08-26_10-52-42

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)


VclWaitTaskEnd

Inputs

2015-08-26_10-53-17

Adding vApp(s) to the workflow

Edit the workflow:

2015-08-12_10-40-52

Select the vApp attribute’s value:

2015-08-12_10-42-53

2015-08-12_10-43-28

Browse to vCloud Director > vCD instance > Organizations > Org that your vApp(s) are in > vDCs > vDC your vApp(s) are in > vApps

2015-08-12_11-49-42

Add each of the vApps that you want to renew the leases on.

2015-08-12_11-53-47

Once you’re done, you’ll see the list of vApps in the vApps attribute array:

2015-08-12_11-54-51

Example of a successful run:

2015-08-26_10-54-48

Scheduling the workflow

2015-08-26_11-33-35

Select your workflow:

2015-08-12_11-58-41

Set the scheduling times for whatever makes sense in your environment:

2015-08-12_11-59-37

Finished schedule:

2015-08-12_12-00-05

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s