Does anybody on here know off hoand how to retrieve the valable storage for a VclVDC backed by an NFS datastore? I can retrieve the used storage of a vdc, using the below code, but cant seem to find the available capacity.
Try this:
var datastoreMoRefs = new Array();
var queryService = providerVdc.getHost().getQueryService();
var expression = new VclExpression(VclQueryProviderVdcResourcePoolRelationField.PROVIDERVDC, providerVdc.href, VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);
var resultSet = queryService.queryRecords(VclQueryRecordType.DATSTOREPROVIDERVDCRELATION, params);
while (resultSet != null) {
var records = resultSet.getRecords(new VclQueryResultDatastoreProviderVdcRelationRecord());
System.log(records.length + " records found");
for each (var record in records) {
datastoreMoRefs.push(record.moref);
System.log(record.moref);
}
resultSet = resultSet.getNextPage();
}
return datastoreMoRefs;
Christophe.
Have you tried Capacity.allocated, Capacity.limit, Capacity.overhead ?
Christophe.
Yes I have. They all come back as 0
Have you tried to get these from the AdminVDC or even the providerVdc ?
I wonder if this is because of NFS or because VDC is not exposing these. I cannot test ATM
Maybe there is something that can be done with the query service as well.
Christophe.
I have tried from the Adminvdc
Do you know of hand how to convert the vdc or adminvdc to a provider vdc? .parent odd both returns the org
Try this:
var adminVdc = vdc.toAdminObject();
var providerVdcReference = adminVdc.providerVdcReference;
var vclHost = vdc.parent.parent;
return vclHost.getEntityByReference(VclEntityType.PROVIDER_VDC , providerVdcReference);
What it's backed by shouldn't have anything to do with it... this symptom generally indicates that you have set the "Storage limit" value uder Administration - Organization vDCs - <your org vdc> properties - Storage tab to "Unlimited"
You must specify an actual limit in order for the api calls to return anything to you.
With setting as unlimited:
After assigning a limit:
[2012-05-23 18:26:47.525] [I] Storage Capacity:
[2012-05-23 18:26:47.526] [I] Storage allocated: 613416
[2012-05-23 18:26:47.527] [I] Storage limit: 613416
[2012-05-23 18:26:47.527] [I] Storage overhead: 0
[2012-05-23 18:26:47.529] [I] Storage used: 613414
[2012-05-23 18:26:47.529] [I] Units: MB
[2012-05-23 18:26:47.534] [I] Parent: vCODemo
My Test code (takes a vCloud:VDC named "vdc" as input):
vdc.updateInternalState(); System.log("--------- " +vdc.name+ "-----------"); System.log("Allocation Model: "+vdc.allocationModel); System.log("Compute Capacity: "); var cpuCapacity = vdc.computeCapacity.cpu; System.log("CPU allocated: "+cpuCapacity.allocated); System.log("CPU limit: "+cpuCapacity.limit); System.log("CPU overhead: "+cpuCapacity.overhead); System.log("CPU used: "+cpuCapacity.used); System.log("Units: "+cpuCapacity.units); System.log("Description: "+vdc.description); System.log("ID: "+vdc.id); System.log("isEnabled: "+vdc.isEnabled); System.log("Network Quota: "+vdc.networkQuota); System.log("NIC Quota: "+vdc.nicQuota); System.log("VM Quota: "+vdc.vmQuota); System.log("Storage Capacity: "); var storageCapacity = vdc.storageCapacity; System.log("Storage allocated: "+storageCapacity.allocated); System.log("Storage limit: "+storageCapacity.limit); System.log("Storage overhead: "+storageCapacity.overhead); System.log("Storage used: "+storageCapacity.used); System.log("Units: "+storageCapacity.units); System.log("Parent: "+vdc.parent.name);
Thank you. I will set the storage limit properties from now on.
Did you try it? If so and you confirm that resolved your issue, please mark appropriate reply(s) as Correct.
Thank you
That works. However, I am sharing the same storage between multiple provider VDC's. Could you think of a way I could get the datastore moref(s) from the VclVDC?
Try this:
var datastoreMoRefs = new Array();
var queryService = providerVdc.getHost().getQueryService();
var expression = new VclExpression(VclQueryProviderVdcResourcePoolRelationField.PROVIDERVDC, providerVdc.href, VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);
var resultSet = queryService.queryRecords(VclQueryRecordType.DATSTOREPROVIDERVDCRELATION, params);
while (resultSet != null) {
var records = resultSet.getRecords(new VclQueryResultDatastoreProviderVdcRelationRecord());
System.log(records.length + " records found");
for each (var record in records) {
datastoreMoRefs.push(record.moref);
System.log(record.moref);
}
resultSet = resultSet.getNextPage();
}
return datastoreMoRefs;
Christophe.
That did it!
Thank you Christophe.