Search in sources :

Example 1 with AzureResource

use of com.vmware.photon.controller.model.adapters.azure.model.cost.AzureResource in project photon-model by vmware.

the class AzureCostStatsService method createStatsForAzureResources.

private void createStatsForAzureResources(Context context, AzureService service, List<ComputeStats> resourceCostStats) {
    // Now creating cost stats for VMs only
    if (service.meterCategory.equals(AzureCostConstants.METER_CATEGORY_VIRTUAL_MACHINES)) {
        // Check if there are resources under this subscription
        Map<String, List<String>> instanceIdToComputeLinks = context.subscriptionGuidToResources.getOrDefault(service.getSubscriptionId(), new ConcurrentHashMap<>());
        // Create compute stats for resources present
        service.resourceDetailsMap.keySet().forEach(instanceId -> {
            List<String> computeLinks = instanceIdToComputeLinks.getOrDefault(instanceId.toLowerCase(), new ArrayList<>());
            AzureResource azureResource = service.resourceDetailsMap.get(instanceId);
            // Create stats for each of the compute links
            computeLinks.forEach(computeLink -> {
                ComputeStats resourceComputeStat = createComputeStatsForResource(computeLink, azureResource);
                if (!resourceComputeStat.statValues.isEmpty()) {
                    resourceCostStats.add(resourceComputeStat);
                }
            });
        });
    }
}
Also used : AzureResource(com.vmware.photon.controller.model.adapters.azure.model.cost.AzureResource) ComputeStats(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ComputeStats (com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats)1 AzureResource (com.vmware.photon.controller.model.adapters.azure.model.cost.AzureResource)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1