VMware Cloud Community
Subnet88
Enthusiast
Enthusiast
Jump to solution

Retrieve available storage for a VclVDC

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.

Capacity = vdc.storageCapacity;
System.log("Used VDC Storage Capacity: "+Math.round(Capacity.used/1024)+"GB")
Reply
0 Kudos
1 Solution

Accepted Solutions
cdecanini_
VMware Employee
VMware Employee
Jump to solution

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.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter

View solution in original post

Reply
0 Kudos
12 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Have you tried Capacity.allocated, Capacity.limit, Capacity.overhead ?

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

Yes I have. They all come back as 0

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

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.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Try this:

var adminVdc = vdc.toAdminObject();
var providerVdcReference = adminVdc.providerVdcReference;
var vclHost = vdc.parent.parent;

return vclHost.getEntityByReference(VclEntityType.PROVIDER_VDC , providerVdcReference);

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

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.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

With setting as unlimited:

[2012-05-23 18:26:11.044] [I] Storage Capacity:
[2012-05-23 18:26:11.045] [I] Storage allocated: 0
[2012-05-23 18:26:11.046] [I] Storage limit: 0
[2012-05-23 18:26:11.047] [I] Storage overhead: 0
[2012-05-23 18:26:11.047] [I] Storage used: 613414
[2012-05-23 18:26:11.048] [I] Units: MB
[2012-05-23 18:26:11.081] [I] Parent: vCODemo

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);

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

Thank you. I will set the storage limit properties from now on.

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

Did you try it? If so and you confirm that resolved your issue, please mark appropriate reply(s) as Correct.

Thank you

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

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?

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

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.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

That did it!

Thank you Christophe.

Reply
0 Kudos