VMware Cloud Community
Glen_A
Contributor
Contributor
Jump to solution

Problem with setting resources.

I cant seem to get this to work..TO ME..it looks right, but I figured i would let the lords of ps look it over and let me know what they find out..

$vcs = Connect-VIServer "VC-25" -User "" -Password $Password

Get-VM "TESTDPLY-VT01" | Get-View | % {

$spec = new-object VMware.Vim.VirtualMachineConfigSpec

$spec.cpuAllocation = New-Object VMware.Vim.ResourceAllocationInfo

$spec.cpuAllocation.Shares = New-Object VMware.Vim.SharesInfo

$spec.cpuAllocation.Shares.Level = "normal"

$spec.CpuAllocation.Reservation = "20"

$spec.cpuAllocation.Limit = "5000"

$spec.MemoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo

$spec.MemoryAllocation.Shares = New-Object VMware.Vim.SharesInfo

$spec.MemoryAllocation.Shares.Level = "normal"

$spec.MemoryAllocation.Reservation = "512"

$spec.MemoryAllocation.Limit = -1

$_.ReconfigVM_Task($spec)

}

This is the error I am getting. The error doesnt show up in PG. It shows up in the VC server recent tasks:

Reconfigure Virtual Machine - A specified Parameter was not correct spec.memoryallocation.Reservation.

Thanks guys!!

Glen

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Could it be that you allocated less than 512Mb of memory to the guest ?

The reservation has to be between 0 and the amount of memory (in Mb) that you allocated to the guest.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
8 Replies
LucD
Leadership
Leadership
Jump to solution

The reservation property in the ResourceAllocationInfo object expects a long integer and in the script you pass a string ("512").

Change that line to


$spec.MemoryAllocation.Reservation = 512

and it will probably work.

Same for the other Limit and Reservation properties.

The script becomes

$vcs = Connect-VIServer "VC-25" -User "" -Password $Password

Get-VM "TESTDPLY-VT01" | Get-View | % {
$spec = new-object VMware.Vim.VirtualMachineConfigSpec
$spec.cpuAllocation = New-Object VMware.Vim.ResourceAllocationInfo
$spec.cpuAllocation.Shares = New-Object VMware.Vim.SharesInfo
$spec.cpuAllocation.Shares.Level = "normal"
$spec.CpuAllocation.Reservation = 20
$spec.cpuAllocation.Limit = 5000
$spec.MemoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo
$spec.MemoryAllocation.Shares = New-Object VMware.Vim.SharesInfo
$spec.MemoryAllocation.Shares.Level = "normal"
$spec.MemoryAllocation.Reservation = 512
$spec.MemoryAllocation.Limit = -1

$_.ReconfigVM_Task($spec)

}

Sorry, couldn't test it since I currently have no access to my test VI Smiley Sad


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Glen_A
Contributor
Contributor
Jump to solution

That didnt get it.. same error..its the only one in the script I cannot get to run..The rest of the script runs..

After this.. I need to figure out how to edit the custom annotation fields as well...I am finding it easier as I go..but finding each peice and what to call......MAN!!

I get the same error even if I run it in VItoolkit and not PG

thanks..

Glen

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Could it be that you allocated less than 512Mb of memory to the guest ?

The reservation has to be between 0 and the amount of memory (in Mb) that you allocated to the guest.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Glen_A
Contributor
Contributor
Jump to solution

DUH..

That got it..! It was too easy...

Works like a charm..

Thanks again..

Glen

0 Kudos
Glen_A
Contributor
Contributor
Jump to solution

Might I ask directly..

To edit the annotation fields in a specific vm, would I use this object:

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.Annotation = ""

If so.. how do I specify which to edit..we have the following annotation

fields:

Application

Disk Space

Maint. Window

Owner(s)

Owning Dept

Ranking

Notes

Not sure how to edit those...cant find a lot of information about it either..

Thanks...

glen

EDIT: I think I will need to use CustomFields.[0] =

but I cant find the root object that custom fields belongs in..I am still looking

Glen E. Adkins II

VMware Enterprise Admin

Server Support/Engineering

Phone:(614)-293-0731

Pager:(614)-346-4195

Glen.AdkinsII@osumc.edu

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The VITK contains cmdlets to manipulate the annotation fields.

These are: New-CustomField, Remove-CustomField and Set-CustomField.

For reading the annotation fields you can use the CustomFields property that Get-VM returns

Get-VM <VM-name> | select -ExpandProperty CustomFields

For manipulating the notes field have a look at .


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Glen_A
Contributor
Contributor
Jump to solution

They appear to be read only that way...

Glen

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Correct, to change them you use the Set-CustomField cmdlet.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos