VMware Cloud Community
tjurgens
Enthusiast
Enthusiast

Create New ORG VDC with specific storage profile

Environment: vCloud Director 5.6.4.  PowerCLI 6.0 R1

I have been working on a script for a little while now to create an Org, with an Org VDC and deploy an edge gateway in that org vdc.

I can manage to get the Org deployed without much issue, despite the New-Org command not including all options possible.  I can use $org.ExtensionData to set any of those options after I create my Org.  Not ideal, but it works.

However, the challenge I am having is creating a new OrgVDC (using the New-OrgVDC command) with the storage profiles we have in place.  The New-OrgVDC requires the -StorageAllocationGB parameter, but it doesn't allow me to select which storage policy to use.  When I attempt to just provide any value (aka, 100), the command fails "New-OrgVdc : 20/08/2015 4:25:09 PM    New-OrgVdc        The provider vdc does not contain the any storage policy." See screenshot of storage policies:

StorageProfiles.PNG

I found this post: Re: vCloud Director Storage Profiles where this value can be set *after* the Org VDC has been created, but not during the initial creation. Not to mention the inability of doing something wild and crazy like adding storage for both those storage profiles.

I am running this command (The ORG and ProviderVDC are correct):

New-OrgVdc -AllocationModelAllocationPool -CpuAllocationGHz 2 -MemoryAllocationGB 4 -Name "VDC-01-ON" -Org Tyler -ProviderVdc Reservation

When I run that I get prompted for StorageAllocationGB.

Interestingly enough, the userguide: https://www.vmware.com/support/developer/PowerCLI/PowerCLI60R1/doc/vsp_powercli_60r1_usg.pdf does not show this parameter is required.

Now, I am ok with setting it after the fact if I could create the ORG VDC initially, but I keep getting stuck on that initial storage profile issue.  Has this command simply not been updated for newer versions of vCD?  Is there anyway I can work around this situation and get my OrgVDC created using PowerCLI?

0 Kudos
4 Replies
tjurgens
Enthusiast
Enthusiast

I have attempted to recreate the New-OrgVdc command to allow me to set my own storage profile instead of it trying to use the "* (Any)" profile, but I am getting stumped.

I attempt to run this command with the following line:

New-TOrgVDC -Name "VPC-01-ON (Tyler)" -Org "Test" -AllocationModel "AllocationPool" -Enabled -CPUAllocated 2 -MEMAllocated 4096 -ProviderVDC "Reservation" -StorageAlloc 100

However, it gives an error, I don't believe I am passing the proper values into the ProviderVdcStorageProfile object, but I am getting stuck on what values I should be passing into it to get it to work.  Any advice?  I am just trying to hard code in my StorageProfile for now to get this working, I'll adjust that later.

$StorageProfile = "FAST"

Function New-TOrgVDC {

    Param (

        $Name,

        [Switch]$Enabled,

        $Org,

        $ProviderVDC,

        $AllocationModel,

        $CPUAllocated,

        $MEMAllocated,

        $StoraqeAlloc

    )

    Process {

        $adminVdc = New-Object VMware.VimAutomation.Cloud.Views.AdminVdc

        $adminVdc.Name = $name

        $adminVdc.IsEnabled = $Enabled

        $providerVdc = Get-ProviderVdc $ProviderVDC

        $id = $providerVdc.Id

        $PvDC = search-cloud -QueryType ProviderVdcStorageProfile -Name $StorageProfile

        Foreach ($pdc in $PvDC) {

            If ($pdc.ProviderVdc -eq $id) {

                $PvDCProfile = $pdc

                Write-Host $PvDCProfile

            }

        }  

        $providerVdcRef = New-Object VMware.VimAutomation.Cloud.Views.Reference

        $providerVdcRef.Href = $providerVdc.Href

        $adminVdc.ProviderVdcReference = $providerVdcRef

        $adminVdc.AllocationModel = $AllocationModel

        $adminVdc.ComputeCapacity = New-Object VMware.VimAutomation.Cloud.Views.ComputeCapacity

        $adminVdc.ComputeCapacity.Cpu = New-Object VMware.VimAutomation.Cloud.Views.CapacityWithUsage

        $adminVdc.ComputeCapacity.Cpu.Units = "MHz"

        $adminVdc.ComputeCapacity.Cpu.Allocated = $CPUAllocated

        $adminVdc.ComputeCapacity.Memory = New-Object VMware.VimAutomation.Cloud.Views.CapacityWithUsage

        $adminVdc.ComputeCapacity.Memory.Units = "MB"

        $adminVdc.ComputeCapacity.Memory.Allocated = $MEMAllocated

        $spParams = new-object VMware.VimAutomation.Cloud.Views.VdcStorageProfileParams

        $spParams.Limit = $StoraqeAlloc 

        $spParams.Units = "MB" 

        $spParams.ProviderVdcStorageProfile = $PvDCProfile.href 

        $spParams.Enabled = $true 

        $spParams.Default = $true 

        $adminVdc.VdcStorageProfiles = $spParams

       

        $OrgED = (Get-Org $Org).ExtensionData

        $orgVdc = $orgED.CreateVdc($adminVdc)

        Get-OrgVdc $name

    }

}

0 Kudos
AlexSmithNZ
Enthusiast
Enthusiast

I have a similar issue with vCloud 8.20.0 and PowerCLI 6.5.1. The 'New-OrgVDC' cmdlet does not appear to work as described. Hopefully one to the PowerCLI team can assist.

0 Kudos
AlexSmithNZ
Enthusiast
Enthusiast

I think I get this now. There should be a * (Any) Storage profile in vCD. This is some kind of special object in vCD, though it appears to have been deleted in my test environment. The workflow is to create the vORG then set the storage profile.

0 Kudos
BastiaanvanH
Contributor
Contributor

Not true. It's not there by default, you can create it by going to the PVDC and add a new Storage Policy.

There's defenetely a bug with New-orgVdc. You should be able to target a Storage Policy.

0 Kudos