VMware Cloud Community
Shaha
Enthusiast
Enthusiast
Jump to solution

How can i set the system resource reservation using VI toolkit?

Hi, does anyone know how i can set the CPU and memory reservation for the service console?

Thanks.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Yes, with the same method.

You just need to know that what you see in the Simple view corresponds with host/system in the Advanced view.

I have added a few child indexes so you see the logic behind the Child -tree

The script then becomes

$esx = Get-View -Id (Get-VMHost <ESX-hostname>).Id
 
# The host/system object 
$sysresinfo = $esx.SystemResources.Child[1]
 
# Not the children of host/system  
$sysresinfo.Child = $null

# The new values (just an example)
$sysresinfo.Config.cpuAllocation.reservation = 300
$sysresinfo.Config.memoryAllocation.reservation = 1
 
$esx.UpdateSystemResources($sysresinfo) 

Again, be very careful what you are doing with this !!


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

View solution in original post

0 Kudos
14 Replies
LucD
Leadership
Leadership
Jump to solution

I don't know of any CPU reservation for the service console.

For the memory reservation you can have a look at


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

0 Kudos
Shaha
Enthusiast
Enthusiast
Jump to solution

I may not have explained myself well...

I am referring to system resource allocation as we would like to set the shares and minimum reservation etc.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

So you are talking about resource pools ?

That can be done via the Set-ResourcePool cmdlet.


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

0 Kudos
Shaha
Enthusiast
Enthusiast
Jump to solution

Nope, if you are on the VI client and go to the host, configuration tab and then select System Resource Allocation - those are the settings we would like to configure using the vi toolkit.

Thanks.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok ,I finally understood what you want to do.

And no, there is no cmdlet in the VITK to do that.

But the SDK can do it.

Some info:

- we use the UpdateSystemResources method of the HostSystem object

- this method requires a HostSystemResourceInfo object as parameter

- in that object you can give the new settings for a system resource object (optionally with all it's child objects).

- the tree structure of these children is luckily always the same. The host/vim/console child is the one that has the settings you want to change.

- for other objects in the tree look at the key property of HostSystemResourceInfo object. In this case it contains host/vim/console.

- instead of defining all the properties I just copy the child object that I obtain from HostSystem object

- the resource parameters are found in the ResourceAllocationInfo object (1 for the CPU resources and 1 for the memory resources)

The script:

$esx = Get-View -Id (Get-VMHost <ESX-host>).Id

# The host/vim/console object 
$sysresinfo = $esx.SystemResources.Child[2].Child[0]

# The new values (just an example)
$sysresinfo.Config.cpuAllocation.reservation = 268 
$sysresinfo.Config.memoryAllocation.expandableReservation = $false

$esx.UpdateSystemResources($sysresinfo) 

Be careful changing the system resource allocation parameters !

Understand what you are doing !


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

Shaha
Enthusiast
Enthusiast
Jump to solution

Hi,

I tried to run this code but i do not see any change although there is a task "Update System Resources".

Thanks for helping, i appreciate it.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Are you at the correct screen ?

In the VI Client, select the ESX server and go to Configuration - System Resource Allocation.

Click the button and select host/vim/console.

In the Details pane you should see the new values.


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

Shaha
Enthusiast
Enthusiast
Jump to solution

But we want to set the following:

0 Kudos
LucD
Leadership
Leadership
Jump to solution

There seems to be something missing from your last post.


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

0 Kudos
Shaha
Enthusiast
Enthusiast
Jump to solution

But we want to adjust the settings in the simple screen, is that possible?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, with the same method.

You just need to know that what you see in the Simple view corresponds with host/system in the Advanced view.

I have added a few child indexes so you see the logic behind the Child -tree

The script then becomes

$esx = Get-View -Id (Get-VMHost <ESX-hostname>).Id
 
# The host/system object 
$sysresinfo = $esx.SystemResources.Child[1]
 
# Not the children of host/system  
$sysresinfo.Child = $null

# The new values (just an example)
$sysresinfo.Config.cpuAllocation.reservation = 300
$sysresinfo.Config.memoryAllocation.reservation = 1
 
$esx.UpdateSystemResources($sysresinfo) 

Again, be very careful what you are doing with this !!


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

0 Kudos
Shaha
Enthusiast
Enthusiast
Jump to solution

thanks for persevering and helping me out.

0 Kudos
sochry
Enthusiast
Enthusiast
Jump to solution

Any ideas what is causing this?

Exception calling "UpdateSystemResources" with "1" argument(s): "A specified parameter was not correct.

"

At :line:16 char:26

+ $esx.UpdateSystemResources &lt;&lt;&lt;&lt; ($sysresinfo)

0 Kudos
sochry
Enthusiast
Enthusiast
Jump to solution

The error is from the first scirpt Luc provided. It works fine on the second script. Just looking to see what the differences are between the two....

Steve

0 Kudos