hdo0917
Enthusiast
Enthusiast

How to get the cost of CPU, memory, storage using vRO

Hi,

I have couple of XaaS blueprints and I want to display the cost of provisioning similar to the ASD's blueprint. I was able to get the blueprint's cost by day and total cost, but I could not find any vRO classes to get the cost of each component such as CPU/memory/storage. The reason for that is I want to update on the fly the daily cost and total cost when the user change the number of CPU, memory...

Here is my code to get the daily and total cost:

// Input: vCACCAFE:CatalogItem

var host = vCACCAFEEntitiesFinder.getHostForEntity(catalogItem);

var items = vCACCAFEEntitiesFinder.findCatalogResources(host, catalogItem.name);

       System.log('Number items: ' + items.length);

for each (var i in items) {

    System.log("Id: " + i.id);   

    System.log("Name: " + i.name);

    var resource = vCACCAFEEntitiesFinder.getCatalogResource(host, i.id);

    var resourceType = resource.getResourceTypeRef().getLabel();

    System.log("resource type: " + resourceType);

    System.log("resource Data: " + resource.getResourceData());

    System.log("resource lease: " + resource.getLeaseForDisplay().getAmount());

    var cost = resource.getCosts().getLeaseRate().getCost();

    System.log("resource cost: " + cost.amount + cost.currencyCode);

    var totalCost = resource.getTotalCost();

    System.log("resource total cost: " + totalCost.amount);

}

Does anybody know which vCACCAFE class I should use to get those info?

Thanks,

  - Huy

0 Kudos
1 Reply
hdo0917
Enthusiast
Enthusiast

Hi,

I guess nobody run into the same problem so same topic, different approach:

The vRA 7.2 Programming Guide (p68) has this example using curl:

curl -- insecure -H “Content Type: application/json” -H "Authorization: Bearer $token" https://$host/composition-service/api/blueprints/$BlueprintId/costs/upfront"

{

"blueprintId": "myblueprintId",

"requestedFor": "fritz@coke.sqa-horizon.local",

"subTenantId": "7a961949-13c4-4f3d-9010-66db8da6c51e",

"requestData": {

"entries": [

{

"key": "vSphere_Machine_1",

"value": {

"type": "complex",

"componentTypeId": "com.vmware.csp.iaas.blueprint.service",

"classId": "Blueprint.Node",

"typeFilter": "phanisimple*vSphere_Machine_1",

"values": {

"entries": [

{

"key": "_cluster",

"value": {

"type": "integer",

"value": 3

}

},

{

"key": "cpu",

"value": {

"type": "integer",

"value": 2

}

},

{

"key": "memory",

"value": {

"type": "integer",

"value": 2048

}

}

]

}

}

}

]

}

}

My question is where do I get the highlight data?

Thanks

0 Kudos