Last active
September 27, 2016 15:34
-
-
Save chelnak/863c61425685e87ca060f27295c3dafa to your computer and use it in GitHub Desktop.
Creating reservations with PowervRA - This gist contains examples for creating vSphere and vCloud Air reservations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --- Create a vCloud Air Reservation | |
# --- Get the compute resource id | |
$ComputeResource = Get-vRAReservationComputeResource -Type "vCloud Air" -Name "uk-slough-1-6 - VDC1 (vCloud Air)" | |
# --- Get the network definition | |
$NetworkDefinitionArray = @() | |
$Network1 = New-vRAReservationNetworkDefinition -Type "vCloud Air" -ComputeResourceId $ComputeResource.Id -NetworkPath "isolated-network" | |
$NetworkDefinitionArray += $Network1 | |
# --- Get the storage definition | |
$StorageDefinitionArray = @() | |
$Storage1 = New-vRAReservationStorageDefinition -Type "vCloud Air" -ComputeResourceId $ComputeResource.Id -Path "Standard" -ReservedSizeGB 500 -Priority 0 | |
$StorageDefinitionArray += $Storage1 | |
$Param = @{ | |
Type = "vCloud Air" | |
Name = "vCA-Reservation-GB" | |
Tenant = "Tenant01" | |
BusinessGroup = "Default Business Group[Tenant01]" | |
ReservationPolicy = "ReservationPolicy01" | |
Priority = 0 | |
ComputeResourceId = $ComputeResource.Id | |
Quota = 0 | |
MemoryGB = 50 | |
Storage = $StorageDefinitionArray | |
Network = $NetworkDefinitionArray | |
EnableAlerts = $False | |
EmailBusinessGroupManager = $False | |
AlertRecipients = "user1@vsphere.local", "user2@vsphere.local" | |
} | |
New-vRAReservation @Param |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --- Create a vSphere Reservation | |
# --- Get the compute resource id | |
$ComputeResource = Get-vRAReservationComputeResource -Type vSphere -Name "Cluster01 (vCenter)" | |
# --- Get the network definition | |
$NetworkDefinitionArray = @() | |
$Network1 = New-vRAReservationNetworkDefinition -Type vSphere -ComputeResourceId $ComputeResource.Id -NetworkPath "VM Network" -NetworkProfile "TestProfile" | |
$NetworkDefinitionArray += $Network1 | |
# --- Get the storage definition | |
$StorageDefinitionArray = @() | |
$Storage1 = New-vRAReservationStorageDefinition -Type vSphere -ComputeResourceId $ComputeResource.Id -Path "Datastore01" -ReservedSizeGB 10 -Priority 0 | |
$StorageDefinitionArray += $Storage1 | |
$Param = @{ | |
Type = "vSphere" | |
Name = "Reservation20" | |
Tenant = "Tenant01" | |
BusinessGroup = "Default Business Group[Tenant01]" | |
ReservationPolicy = "ReservationPolicy01" | |
Priority = 0 | |
ComputeResourceId = $ComputeResource.Id | |
Quota = 0 | |
MemoryGB = 20 | |
Storage = $StorageDefinitionArray | |
Resourcepool = "Resources" | |
Network = $NetworkDefinitionArray | |
EnableAlerts = $true | |
StorageAlertPercentageLevel = 20 | |
EmailBusinessGroupManager = $true | |
AlertRecipients = "user1@vsphere.local", "user2@vsphere.local" | |
} | |
New-vRAReservation @Param |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --- Create Multiple vCloud Air Reservations | |
1..10 | % { | |
# --- Set the reservation name | |
$ReservationName = "PowervRA-vCA-Reservation$($_)" | |
Write-Output "Creating $($ReservationName)" | |
# --- Get the compute resource id | |
$ComputeResource = Get-vRAReservationComputeResource -Type "vCloud Air" -Name "uk-slough-1-6 - VDC1 (vCloud Air)" | |
# --- Get the network definition | |
$NetworkDefinitionArray = @() | |
$Network1 = New-vRAReservationNetworkDefinition -Type "vCloud Air" -ComputeResourceId $ComputeResource.Id -NetworkPath "isolated-network" | |
$NetworkDefinitionArray += $Network1 | |
# --- Get the storage definition | |
$StorageDefinitionArray = @() | |
$Storage1 = New-vRAReservationStorageDefinition -Type "vCloud Air" -ComputeResourceId $ComputeResource.Id -Path "Standard" -ReservedSizeGB 500 -Priority 0 | |
$StorageDefinitionArray += $Storage1 | |
$Param = @{ | |
Type = "vCloud Air" | |
Name = $ReservationName | |
Tenant = "Tenant01" | |
BusinessGroup = "Default Business Group[Tenant01]" | |
ReservationPolicy = "Test01" | |
Priority = 0 | |
ComputeResourceId = $ComputeResource.Id | |
Quota = 0 | |
MemoryGB = 50 | |
Storage = $StorageDefinitionArray | |
Network = $NetworkDefinitionArray | |
EnableAlerts = $False | |
EmailBusinessGroupManager = $False | |
AlertRecipients = "cgumbley@vsphere.local", "jmedd@vsphere.local" | |
} | |
New-vRAReservation @Param | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --- Create Multiple vSphere Reservations | |
1..10 | % { | |
# --- Set the reservation name | |
$ReservationName = "PowervRA-vSphere-Reservation$($_)" | |
Write-Output "Creating $($ReservationName)" | |
# --- Get the compute resource id | |
$ComputeResource = Get-vRAReservationComputeResource -Type vSphere -Name "Cluster01 (vCenter)" | |
# --- Get the network definition | |
$NetworkDefinitionArray = @() | |
$Network1 = New-vRAReservationNetworkDefinition -Type vSphere -ComputeResourceId $ComputeResource.Id -NetworkPath "VM Network" -NetworkProfile "TestProfile" | |
$NetworkDefinitionArray += $Network1 | |
# --- Get the storage definition | |
$StorageDefinitionArray = @() | |
$Storage1 = New-vRAReservationStorageDefinition -Type vSphere -ComputeResourceId $ComputeResource.Id -Path "Datastore01" -ReservedSizeGB 10 -Priority 0 | |
$StorageDefinitionArray += $Storage1 | |
$Param = @{ | |
Type = "vSphere" | |
Name = $ReservationName | |
Tenant = "Tenant01" | |
BusinessGroup = "Default Business Group[Tenant01]" | |
ReservationPolicy = "ReservationPolicy01" | |
Priority = 0 | |
ComputeResourceId = $ComputeResource.Id | |
Quota = 0 | |
MemoryGB = 20 | |
Storage = $StorageDefinitionArray | |
Resourcepool = "Resources" | |
Network = $NetworkDefinitionArray | |
EnableAlerts = $true | |
StorageAlertPercentageLevel = 20 | |
EmailBusinessGroupManager = $true | |
AlertRecipients = "user1@vsphere.local", "user2@vsphere.local" | |
} | |
New-vRAReservation @Param | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried this code for creating a reservation for a vsphere object on my vRA 7.0.1 environment, but got the following error. It's worth noting that I ran this from a workstation on a different network, not sure if that matters.
Invoke-RestMethod : {"errors":[{"code":10101,"message":"Invalid argument.","systemMessage":"Illegal GUID format null","moreInfoUrl":null}]}
At C:\Program Files\Microsoft Application Virtualization\Client\PowervRA\Functions\Public\Invoke-vRARestMethod.psm1:109 char:25
Any thoughts??
Here's the code I attempted to run.
--- Get the compute resource id
$ComputeResource = Get-vRAReservationComputeResource -Type vSphere -Name "vccls1 (vcenter1.nebe.local)" -verbose
--- Get the network definition
$NetworkDefinitionArray = @()
$Network1 = New-vRAReservationNetworkDefinition -Type vSphere -ComputeResourceId $ComputeResource.Id -NetworkPath "NetPath1" -NetworkProfile "192.168.0.1" -verbose
$NetworkDefinitionArray += $Network1
--- Get the storage definition
$StorageDefinitionArray = @()
$Storage1 = New-vRAReservationStorageDefinition -Type vSphere -ComputeResourceId $ComputeResource.Id -Path "Storage01" -ReservedSizeGB 10 -Priority 0 -verbose
$StorageDefinitionArray += $Storage1
$Param = @{
}
New-vRAReservation @param -verbose