VMware {code} Community
sahmed24
Contributor
Contributor

Create ResourcePool results in error

Hi

i am trying to create a resource pool in C#. Below is the code. 'crmor' is the MOB to computer resource. i get exception saying specified parameter is incorrect. i dont know how to fix it.

ManagedObjectReference resourcePool

= _connectVCenter.Cb.getServiceUtil().GetMoRefProp(crmor, "resourcePool");

SharesInfo sInfo = new SharesInfo();

sInfo.level = SharesLevel.normal;

sInfo.shares = 0;

ResourceAllocationInfo cInfo = new ResourceAllocationInfo();

cInfo.limit = -1;

cInfo.shares = sInfo;

cInfo.limitSpecified = true;

cInfo.reservation = 0;

cInfo.reservationSpecified = true;

cInfo.expandableReservation = true;

cInfo.expandableReservationSpecified = true;

ResourceAllocationInfo mInfo = new ResourceAllocationInfo();

mInfo.limit = -1;

mInfo.shares = sInfo;

mInfo.reservation = 0;

mInfo.reservationSpecified = true;

mInfo.expandableReservation = true;

mInfo.expandableReservationSpecified = true;

ResourceConfigSpec resourceSpec = new ResourceConfigSpec();

resourceSpec.cpuAllocation = cInfo;

resourceSpec.memoryAllocation = mInfo;

ManagedObjectReference newPool =

_service.CreateResourcePool(resourcePool, "NewPooool", resourceSpec);

A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll

System.Web.Services.Protocols.SoapException: A specified parameter was not correct.

at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

at Vim25Api.VimService.CreateResourcePool(ManagedObjectReference _this, String name, ResourceConfigSpec spec)

at Cryptzone.Automation.vCenter.VMCloneManager.CreateResourcePool(Dictionary`2 options) in C:\Automation\ConsoleApplication1\Cryptzone.Automation.vCenter\VMCloneManager.cs:line 124

Tags (1)
0 Kudos
1 Reply
sahmed24
Contributor
Contributor

ok, i found the issue, it was kind of stupid of me. i missed this line.

mInfo.limitSpecified = true;

0 Kudos