VMware Cloud Community
NNilss
Contributor
Contributor

Storage Profiles

Hello

I am doing some testing with powercli and vCloud director.

PowerCLI C:\> $storage = Get-OrgVdc -name Orgvdc

PowerCLI C:\> $storage.StorageLimitGB

200

Untitled.png

200 is actually the combined storage from 2 storage profiles.

Is there any way to get the output from what storage profile the disk is from?

Regards 

/Niclas

0 Kudos
1 Reply
jake_robinson_b
Hot Shot
Hot Shot

Hi Niclas,

I put some code together to get the info you want:

# This function does a HTTP GET against the vCloud 5.1 API using our current API session.

# It accepts any vCloud HREF.

function Get-vCloud51($href)

{

    $request = [System.Net.HttpWebRequest]::Create($href)

    $request.Accept = "application/*+xml;version=5.1"

    $request.Headers.add("x-vcloud-authorization",$global:DefaultCIServers[0].SessionId)

    $response = $request.GetResponse()

    $streamReader = new-object System.IO.StreamReader($response.getResponseStream())

    [xml]$xmldata = $streamreader.ReadToEnd()

    $streamReader.close()

    $response.close()

    return $xmldata

}

# The following gets an OrgVdc via 1.5 API, then 5.1 API.

# It then gets the storage profiles associated with the OrgVdc

# and displays them on the screen

$orgVdc = Get-OrgVdc "MyOrgVDC" # Change this to the OrgVdc you want

$orgVdc51 = Get-vCloud51 $orgVdc.Href

$storageLimits = @()

foreach ($storageProfile in $orgVdc51.adminvdc.VdcStorageProfiles.VdcStorageProfile)

{

    $storageProfile51 = Get-vCloud51 $storageprofile.href

    $storageLimits += $storageProfile51.adminVdcStorageProfile | select name, Limit

}

$storageLimits

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
0 Kudos