VMware {code} Community
v_potnis2001
Contributor
Contributor
Jump to solution

vsphere sdk api to get total memory available for virtual machine reservation

Which vsphere sdk api should I use to get the total memory available for making reservations for virtual machines?

Here is what I see in the VI client,

Click on hos->Configuration:

Memory

Physical

Total xx

System xx

Virtual Machines 3512.0 MB

Service Console xx

Now, when I click on the resource allocation tab I see

Memory reservation 3348 MB

Memorey Reservation Used: 0 MB

Memory unreserved:3348 MB

The question is which value is correct and what are programming apis for obtaining all these values (even if incorrect)?

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

If you're familiar with the vSphere API, the easiest way is to browse the API reference docs: and/or using the MOB (Managed Object Browser), once you explore a bit, you'll start to figure out where to locate certain properties from what you see on the vSphere Client

For Host memory configuration, take a look at:

For Host VM avaialble memory, take a look at:

To obtain the "Resource Allocation" information, you need to get a reference to the local resource pool for your host:

Even if you don't have a "Resource Pool", there is a default one that always exists. This should get your started

If you're using the VI Java, you may want to take a look at the VI Java Browser: http://www.doublecloud.org/2010/02/22/vijava-browser-a-great-tool-to-recommend/

You should also follow Steve Jin's blog (Author/Creator of open source VI Java vSphere bindings)

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
5 Replies
lamw
Community Manager
Community Manager
Jump to solution

All this information is available via the vSphere APIs:

There are various SDK bindings (vSphere SDK for Perl, PowerCLI,etc) It really depends on what language you're most familiar and comfortable with.

If you're new to VMware vSphere API/SDKs, you should take some time and go over this document:

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
v_potnis2001
Contributor
Contributor
Jump to solution

Can you point me to the sample code snippets (java will do fine) where we can get the available memory for VM reservations programmatically.

I don't find the required snippets in the vmware sdk api.

Based on my understanding the available memory for VM reservations decreases by the VM reservation + VM memory overhead.

Is it possible to get this available memory via the API

Btw, I'm not new to vmware sdk api but your help is much appreciated.

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

If you're familiar with the vSphere API, the easiest way is to browse the API reference docs: and/or using the MOB (Managed Object Browser), once you explore a bit, you'll start to figure out where to locate certain properties from what you see on the vSphere Client

For Host memory configuration, take a look at:

For Host VM avaialble memory, take a look at:

To obtain the "Resource Allocation" information, you need to get a reference to the local resource pool for your host:

Even if you don't have a "Resource Pool", there is a default one that always exists. This should get your started

If you're using the VI Java, you may want to take a look at the VI Java Browser: http://www.doublecloud.org/2010/02/22/vijava-browser-a-great-tool-to-recommend/

You should also follow Steve Jin's blog (Author/Creator of open source VI Java vSphere bindings)

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
v_potnis2001
Contributor
Contributor
Jump to solution

I used the following for the ESX host root resource pool:

http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.ResourceAllocationInf...

as you have also pointed out. Thanks.

Is there a way you can use this when the ESX host is part of cluster? I found that when a user does reservations using direct VI connection to host, vpxuser undoes them automatically.

Is this documented behavior?

0 Kudos
MartinWi
Contributor
Contributor
Jump to solution

FWIW I'm also interested in getting the configured resource allocations from vcenter, so that I can plot it on my own graphs and make reports for management out of it. I'm not much of developer but perhaps I could hack something up if I'm lucky.

0 Kudos