Home > Blogs > VMware PowerCLI Blog


Using PowerCLI to export vCloud Director policy settings

AlanFeb2012_thumb_thumb1
Posted by
Alan Renouf
Technical Marketing

Each Organization in vCloud Director has its own policy settings, these are defined when setting up the organization and can be altered through the  vCloud GUI, these define both the vApp lease periods and quotas of VMs which can be running or stored in the Organization.

This can be viewed by right clicking the Organization and selecting Properties and then selecting the Policies tab as below.

image

Recently I was asked by a customer if there was any way to retrieve this information for each Organization in his very populated vCloud Environment, understandably he did not want to right click each Organization and note the information, this could take a long time.

Luckily with PowerCLI 5.0.1 and the vCloud Director Snapin we can use the Get-Org and some custom selections to gain this information with a quick and easy script:

Get-Org | Foreach {
    $_ | Select Name,
    @{N="vAppMaxRuntimeLeaseDays";E={(New-Timespan -Seconds $_.ExtensionData.Settings.vAppLeaseSettings.DeploymentLeaseSeconds).TotalDays}},

    @{N="vAppMaxStorageLeaseDays";E={(New-Timespan -Seconds $_.ExtensionData.Settings.vAppLeaseSettings.StorageLeaseSeconds).TotalDays}},
    @{N="vAppStorageCleanup";E={If ($_.ExtensionData.Settings.vAppLeaseSettings.DeleteOnStorageLeaseExpiration) { "Delete" } Else { "Move"}}},

    @{N="TemplateMaxStorageLeaseDays";E={(New-Timespan -Seconds $_.ExtensionData.Settings.vAppTemplateLeaseSettings.StorageLeaseSeconds).TotalDays}},
    @{N="TemplateStorageCleanup";E={If ($_.ExtensionData.Settings.vAppTemplateLeaseSettings.DeleteOnStorageLeaseExpiration) { "Delete" } Else { "Move"}}},

    @{N="RunningVMQuota";E={$_.DeployedVMQuota}},
    @{N="StoredVMQuota";E={$_.StoredVMQuota}}

}

When run this we will see the results of each Organization within the vCD environment, this is easily exportable using PowerShells built in cmdlets such as Export-CSV or Export-CLiXml or ConvertTo-Html.

Name                        : Tenant01
vAppMaxRuntimeLeaseDays     : 7
vAppMaxStorageLeaseDays     : 30
vAppStorageCleanup          : Move
TemplateMaxStorageLeaseDays : 90
TemplateStorageCleanup      : Move
RunningVMQuota              : 9
StoredVMQuota               : 11

Name                        : Tenant02
vAppMaxRuntimeLeaseDays     : 1
vAppMaxStorageLeaseDays     : 1
vAppStorageCleanup          : Delete
TemplateMaxStorageLeaseDays : 7
TemplateStorageCleanup      : Delete
RunningVMQuota              : 3
StoredVMQuota               : 5

Name                        : Tenant03
vAppMaxRuntimeLeaseDays     : 365
vAppMaxStorageLeaseDays     : 365
vAppStorageCleanup          : Move
TemplateMaxStorageLeaseDays : 365
TemplateStorageCleanup      : Move
RunningVMQuota              : 950
StoredVMQuota               : 1000

This entry was posted in Reporting on by .
Alan Renouf

About Alan Renouf

Alan Renouf is a Product Line Manager at VMware focusing on API's, SDK's and CLI's, He is responsible for providing the architects and operators of private and public cloud infrastructure with the toolkits/frameworks and command-line interfaces they require to build a fully automated software-defined datacenter. Alan is a frequent blogger at http://blogs.vmware.com/PowerCLI a book author and has a personal blog at http://virtu-al.net. You can follow Alan on twitter as @alanrenouf.

Leave a Reply

Your email address will not be published. Required fields are marked *

*