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)?
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:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
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:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
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.
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:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
I used the following for the ESX host root resource pool:
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?
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.