Well, first said I would. Then I said I didn’t have time. Then I woke up 5.30 in the morning. So I thought I would anyway. What’s that? Well, I thought I would check out the new cmdlets added in PowerCLI 5.1 that allow for the management of vCloud Director. The main reason for doing this is with 4 Organizations with 2 Organization vDC’s each that’s quite a bit of work to do via the UI of vCD, and I wanted to see how much I could achieve by just using the PowerCLI cmdlets. There’s two types of “scope” here by the way – there cmdlets that would be used by the SysAdmin say for creating a new Organization vDC and there are cmdlets for “Tenants” who’s scope it limited by the Organization, and rights within them.

First lets start with the basics. The vCloud Director cmdlets are installed when you setup PowerCLI 5.1 for the first time. If you opted not to install these, you may need to re-run the installer to enabled them. Typically, when faced with these sorts of options, I just install the whole darn thang. The PowerCLI for Tenants is seperate download/installation as its assumed that your tenants do not need access to the full vSphere/vCloud Director set – the “Tenant” download is available here:

http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview

Note: If you install the core vSphere/vCD PowerCLI you good to go. The “tenant” edition does not install along side the core. The tenant version is intended to just give a smaller subset of PowerCLI commands to those who merely manage the Organization in vCD. To check if you have the cmdlets available you can run:

get-command -Module vmware.vimautomation.cloud | select name

This will give you a full listing of the cmdlets available (you can click on the image to get a bigger view!)

Screen Shot 2012-12-13 at 07.18.25.png

and if you want help on a particular cmdlet get-help followed by the cmdlet name will give you plenty of detail such as get-help connect-ciserver. Connect-ciserver is a pretty important cmdlet as it allows you to connect to the vCD “cell” with either SysAdmin rights or rights to specific Organization within the vCD instance. So for example,

If I was the SysAdmin I would use:

connect-ciserver -server mycloud.corp.com user admin password Password1

and to disconnect, just as with equivalent cmdlet with vSphere/vCenter we can do that with:

disconnect-ciserver * -confirm:$false

If I was the OrgAdmin I would use:

connect-ciserver -server mycloud.corp.com -userrmoorcroft@corp.com-password Password1 -Org CorpHQ

So really the difference between the two logins is the -Org parameter.

As a SysAdmin there are some reporting cmdlets to get you going, that will pull back information such as get-providervdc, get-org, get-orgvdc

Screen Shot 2012-12-13 at 07.41.02.pngScreen Shot 2012-12-13 at 07.41.29.png

So… (drumroll) what I want to do is create a new Organization Virtual Datacenter for COIG (Corp Oversea Investment Group). First I need to connect to the Organization COIG as the SysAdmin – remember only SysAdmins can create new Organization vDCs.

connect-ciserver -server mycloud.corp.com -user admin -password Password1

Next I need to specify the parameters for new Organization Virtual Datacenter. In my case I used the PAYG resource model for a new “Test/Dev” Virtual Datacenter using the New-OrgVdc cmdlet.

new-orgvdc -ProviderVdc “Bronze Provider Virtual Datacenter”  -Org “COIG” –Name “COIG – Test & Dev Virtual Datacenter”  –Description “Test & Dev Virtual DataCenter” -AllocationModelPayAsYouGo -NetworkPool “COIG-VLAN Network Pool (42-50)” -VMCpuCoreMHz 1000 -StorageAllocationGB 800
The first part of this (-ProviderVdc, -Org, -Name and -Description) are quite straight forward they control what Provider Virtual DataCenter and Organization will back the Organization vDC, followed by its name and description. Next -AllocationModelPayAsYouGo controls the resource model used – its worth mentioning that because the allocation models differ in the way resources are divyed up there are some specific settings for each of them. Next we allocate which Network Pool to use and the default amount CPU set for the vCPU Speed. Finally, the -StorageAllocationGB allows you to set how much storage the Organization Virtual Datacenter is allowed. I noticed for this to work the Provider Virtual Datacenter must support the *ANY Storage Profile. If you don’t have this storage profile included then you will receive an error message in PowerCLI. Sadly, I didn’t include ANY in my Gold or Silver Provider vDC so to carry on experimenting with the cmdlets, I created a “Bronze Cluster” and Bronze Provider vDC where it had been included.
Once the Organization Virtual Datacenter has been created some extended parameters can be modified using the Set-OrgVdc cmdlet – so for instance I could enable on the CIOG Test & Dev Virtual Datacenter that I wanted to enable Fast and Thin Provisioning:
Get-OrgVdc -Name “COIG – Test & Dev Virtual Datacenter” | Set-OrgVdc  -ThinProvisioned $true -UseFastProvisioning $true
By default when you select a network pool the vCloud PowerCLI uses the vCD defaults – that’s 1024 networks from the pool. If you pool size is smaller than this – then result is all the networks will be allocated. In my lab I have quite small number of VLANs per Organization so I like to change this with:
$myNetworkPool = Get-NetworkPool -Name “COIG-VLAN Network Pool (42-50)”
Get-OrgVdc -Name “COIG – Test & Dev Virtual Datacenter” | Set-OrgVdc  -NetworkPool $myNetworkPool –NetworkMaxCount 3
Running the basic get-commands will give you a good idea for how my lab environment is shaping up:
Screen Shot 2012-12-13 at 15.17.57.png
You might noticed I cleaned up the Organization Networks somewhat by using the 172.168 range consistently between each OrgNetwork type.