VMware Cloud Community
Skyxcube
Contributor
Contributor

Set up System Resource Allocation via vCo or PowerCLI

Hi guys,

I'm been trying for a few days to automate some ESXi 5.5 post-install settings. Among several subject I want to set up system resource allocation for a HOST (not for a VM).

So I made some research through the API, finding this :

Method > updateSystemResource() documented here http://www.vmware.com/support/orchestrator/doc/vco_vsphere50_api/html/VcHostSystem.html

resourceInfo argument type VcHostSystemResourceInfo

VcHostSystemResourceInfo doc : http://www.vmware.com/support/orchestrator/doc/vco_vsphere50_api/html/VcHostSystemResourceInfo.html

config argument type VcResourceConfigSpec

vCResourceConfigSpec doc : http://www.vmware.com/support/orchestrator/doc/vco_vsphere50_api/html/VcResourceConfigSpec.html

argument cpuAllocation argument type VcResourceAllocationInfo

memoryAllocation argument type VcResourceAllocationInfo

VcResourceAllocationInfo doc : http://www.vmware.com/support/orchestrator/doc/vco_vsphere41_api/html/VcResourceAllocationInfo.html

limit and reservation arguments

From here I wrote this script into a simple workflow to update the settings with my custom parameters, :

var hostSystemResourceInfo = esxHost.systemResources;

var config = hostSystemResourceInfo.config;


config.cpuAllocation.reservation = "500";

config.cpuAllocation.limit = "1000";

config.cpuAllocation.expandableReservation = true;

config.memoryAllocation.reservation = "500";

config.memoryAllocation.limit = "1000";

config.memoryAllocation.expandableReservation = true;

esxHost.updateSystemResources(hostSystemResourceInfo);

esxHost is the host, which I select when I launch the workflow.

But all I get is an exception : A general system error occurred: Invalid fault (Workflow:Resource Allocation / RA conf (item1)#12)

A little help would be appreciated. Smiley Happy

I put an alert on this topic, so any question or script testing, I can do that. Smiley Happy

Thanks by advance !

Tags (1)
Reply
0 Kudos
2 Replies
Dan_Linsley
VMware Employee
VMware Employee

I used Onyx to help debug this.  I noticed with Onyx that the vCenter client will call updateSystemResources with an object that has a key of "host/system" when I try to update the System Resource Allocation in simple mode.  Switch to the Advanced mode (as shown below) and you'll notice that the root System Resource Pool is not editable.  Your current script was trying to update that root System Resource Pool.

systemResource.png

Try this update to your script:

var hostSystemResourceInfo = esxHost.systemResources;

System.log(hostSystemResourceInfo.key);

for (var i in hostSystemResourceInfo.child) {

    System.log(hostSystemResourceInfo.child[i].key);

    if (hostSystemResourceInfo.child[i].key == "host/system") {

        hostSystemResourceInfo = hostSystemResourceInfo.child[i];

        break;

    }

}

var config = hostSystemResourceInfo.config;

config.cpuAllocation.reservation = "500";

config.cpuAllocation.limit = "1000";

config.cpuAllocation.expandableReservation = true;

config.memoryAllocation.reservation = "500";

config.memoryAllocation.limit = "1000";

config.memoryAllocation.expandableReservation = true;

esxHost.updateSystemResources(hostSystemResourceInfo);

You may get different exceptions if the memory or cpu limits are too low.

Reply
0 Kudos
EMILY32
Contributor
Contributor

Hi

Welcome to the communities.

Hope below link will give you more idea to accomplish this testing work.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=200458...

" Fear defeats more people than any other one thing in the world. .
Reply
0 Kudos