One of the great things about cloud computing environments is the ability to shutdown workloads when they are not needed, and therefore not pay for the resources (except storage). Dev/Test is an excellent example of this, where whole development environments can be shutdown at night or at weekends, and then started up again just in time for the developers to use them.
This blog post will look at the concept of storing metadata against the vApps that details when they should be started up and then shut down again. This metadata can then be read by a Powershell script that is run every hour from a management server.
In VMware vCloud Director, metadata key/value pairs can be stored against most objects within the environment – for example, virtual data centers, vApps and VMs.
There are several ways that these tasks could be performed, but the metadata I have created as shown below seems to work quite well:
- Day of the week (Every, or MonTueWed, SatSun, etc)
- Start Time in 24 hour clock format (07, 09)
- Stop Time in 24 hour clock format (19, 22)
- AutoOnOff (Yes,No)
Create a spreadsheet in Excel similar to the one below. Save it in comma delimited format.
The following script can then be used to update the metadata on the named vApps. Firstly we’ll need to define a cmdlet to create the metadata called New-CIMetaData Main body of the script. Similarly, this short script will enable you to dump out all your metadata into a CSV. This assumes you are already connected to the cloud. Watch this space for more interesting ways to use Powershell to automate the iland cloud.