PowerCLI 5.0.1 goes Cloud

As a belated Christmas present the new PowerCLI version 5.0.1 is available. This new build brings us the Cloud snapin. The availability of vCD cmdlets was already announced during VMworld 2011 and now the vCD cmdlets make their public appearance.

The first release of the Cloud snapin brings us primarily Get type cmdlets. But there is more, just as the Get-View cmdlet opened up access to the vSphere API, the new Get-CIView cmdlet, and the ExtensionData property, opens up access  to all the vCD APIs.

First a quick list of all the cmdlets that are available in the Cloud snapin.

PS: the list above has been created with the script from my PowerCLI cmdlet XRef – Another look post.

The PowerCLI help pages are available online.

Btw the CI noun prefix that you will see as a prefix to most of the Cloud cmdlets nouns, stands for Cloud Infrastructure.

To start a session you use the Connect-CIServer cmdlet, similar to what you do with the Connect-VIServer cmdlet. The difference is that you will have to specify a vCloud Director server instead of a vSphere Server.

And you’ll immediately notice a first change, the Certificate warning message has changed. You are prompted to answer with one of the listed options.

Does this mean you will have to do this every time (provided you don’t update the Certificate) ?
No, the Set-PowerCLIConfiguration cmdlet has been extended with a new parameter, called InvalidCertificateAction. You can provide the parameter with one of the values of the BadCertificateAction enumeration, and PowerCLI will take that as the default action for future connects.

Notice that we didn’t specify an Organization name, through the Org parameter, to the Connect-CIServer cmdlet. That means your session will get connected to the System organization.

Once you are connected, you can start having a look around with the help of all the Get type cmdlets. The VMs in the Cloud

returns something like

The Roles that are present

which gives

And the available vApps in this cloud

This tells us there currently 4 vApps present

But is this all we can do ? Only produce reports of what is available in our cloud ?

No, luckily there are already a couple of other cmdlets that will allow you to populate your cloud.

Let’s take the case where we want to import a VM from our vCenter into our Cloud.

First connect to the vCenter server, then get the VM you want to import and pass the VM to the Import-CIVApp cmdlet. Note that for the creation of this new vApp you will have to provide an Organization VDC. The organization VDCs can be listed with the Get-OrgVdc cmdlet.

You will first see that VM, called TestVM2, is cloned in your vCenter, followed by an import of the clone into your Cloud. This import will display a progress bar.

The VM will be part of the new Cloud vApp called TestVapp.

And the imported VM is in the new vApp called TestVapp.

Adding additional VMs to this vApp is done this way.

That’s all there is to it.

Now what if you want to do something that is not (yet) covered by the Cloud snapin cmdlets ?

With the Get-CIView cmdlet and the ExtensionData property on the Cloud objects, you can have access to all the vCloud object properties and methods.

If you intend to use these vCloud .Net object, I advise to have the reference guide available. Download the VMware vCloud SDK for .Net file, extract the files from the ZIP archive and then open .\VMware-vCloudDirector-.NetSDK-1.5.0.2\Docs\ndoc3_msdn_temp\index.html from the folder where you unzipped the archive.

A quick sample, where we list the  methods accessible through the ExtensionData of a VM.

The other way to get there is through the Get-CIView cmdlet. This gives access to the same methods (and properties).

The access to these methods comes in handy when we need to perform some action that is not available through the cmdlets.

As an example, we want to delete the VM called TestVM3 from the TestVapp vApp. With the access to the vCD API this is now a piece of cake.

That was my short tour of the Cloud snapin, but it only scratched the surface. There’s tons more of good stuff to be discovered.

Before I forget, make sure to select the Cloud snapin when you install/upgrade PowerCLI 5.0.1. By default the Cloud snapin is not installed !

Needless to say that there are other improvements in PowerCLI 5.0.1. One that I will definitely have a closer look at is the new XML feature that is provided with the Get-EsxCli cmdlet.

And btw, the mixup of the FreeSpaceGB and CapacityGB properties, both in the objects returned by the Get-Datastore cmdlet, is fixed 🙂

Enjoy PowerCLI 5.0.1 !

9 Comments

    Alan Renouf

    @Joel B

    Joel,

    Just a note, you are using Get-vApp and not Get-CIvApp, there is a difference as Get-vApp gets a vSphere vApp and get-CIvApp will get you the details for the Cloud Infrastructure vApp.

      LucD

      Nice catch Alan.
      I still have to get used to this CI prefix 😉

    Joel B

    Seems i cannot get the vapp info for a specified VM.

    Connect-Ciserver -Server VcloudServer -User USER -Password Password

    $report = @()

    $VM = “*”

    foreach($VM in Get-CiVM -Name $vm){
    $vapp = $vm | get-vapp
    $row = “” | Select Name, VApp, Org, Status, “Operating System”, CpuCount, “Memory (GB)”, “Owner”
    $row.Name = $vm.Name
    $row.Vapp = $vm.vapp
    $row.Org = $vm.Org
    $row.Status = $vm.Status
    $row.”Operating System” = $vm.GuestOSFullName
    $row.CpuCount = $vm.CpuCount
    $row.”Memory (GB)” = ($VM | Measure-Object -Property MemoryMB -Sum).Sum/1024
    $row.”Owner” = $vapp.Owner
    $report += $row
    }
    $report | export-csv “C:\VcloudVMsNEW.csv” -NoTypeInformation -UseCulture

    Any ideas to get the owner? any tips for efficiency? -I would also like to make this export to an HTML file.

    Thanks!

      LucD

      @Joel, could this be a permission problem ?
      Can you display the Owner through the ExtensionData property ?

      $vapp.ExtensionData.Owner.User.Name

      Can you see the Owner in the web interface ?

    Joel

    @LucD
    Here is a little something I just wrote.

    Connect-Ciserver -Server VCDserver -User Username -Password Password

    $report = @()

    $Vm = “*”

    foreach($VM in Get-CiVM -Name $vm){
    $vapp = $vm | get-vapp
    $row = “” | Select Name, VApp, Org, Status, “Operating System”, CpuCount, “Memory (GB)”, “Owner”
    $row.Name = $vm.Name
    $row.Vapp = $vm.vapp
    $row.Org = $vm.Org
    $row.Status = $vm.Status
    $row.”Operating System” = $vm.GuestOSFullName
    $row.CpuCount = $vm.CpuCount
    $row.”MemoryGB” = ($VM | Measure-Object -Property MemoryMB -Sum).Sum/1024
    $row.”Owner” = $vapp.Owner
    $report += $row
    }
    $report | export-csv “C:\VcloudVMsNEW.csv” -NoTypeInformation -UseCulture

    Anyway to improve on efficiency? Also looking to make it an HTML file.

      LucD

      Nice one Joel.
      I don’t see any immediate improvements

    Conrad

    Didn’t they just release this like 5 minutes ago. You work Fast Luc!

      LucD

      @Conrad, thanks, but it was already released at 6 PM PST. Several hours ago 😉

Leave a Reply

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

*
*

seventeen + seventeen =

This site uses Akismet to reduce spam. Learn how your comment data is processed.