Search in sources :

Example 1 with EaAccountCost

use of com.vmware.photon.controller.model.adapters.azure.ea.stats.AzureCostStatsService.EaAccountCost in project photon-model by vmware.

the class AzureCostHelper method createMonthlyEaAccountCostStats.

static List<ComputeStats> createMonthlyEaAccountCostStats(Map<LocalDate, EaAccountCost> monthlyEaAccountCosts, Map<LocalDate, Double> monthlyTotalCosts, ComputeStateWithDescription computeHostDesc) {
    List<ComputeStats> accountStats = new ArrayList<>();
    String usageCostStatName = AzureCostConstants.USAGE_COST;
    String marketplaceCostStatName = AzureCostConstants.MARKETPLACE_COST;
    String separatelyBilledCostStatName = AzureCostConstants.SEPARATELY_BILLED_COST;
    String costUnit = AzureStatsNormalizer.getNormalizedUnitValue(AzureCostConstants.DEFAULT_CURRENCY_VALUE);
    for (Entry<LocalDate, Double> monthlyTotalCost : monthlyTotalCosts.entrySet()) {
        ComputeStats accountStat = new ComputeStats();
        accountStat.computeLink = computeHostDesc.documentSelfLink;
        accountStat.statValues = new ConcurrentSkipListMap<>();
        LocalDate month = monthlyTotalCost.getKey();
        long timeStamp = adaptMonthToCostTimeStamp(month);
        EaAccountCost eaAccountCost = monthlyEaAccountCosts.get(month);
        ServiceStat usageCostServiceStat = AzureCostHelper.createServiceStat(usageCostStatName, eaAccountCost.monthlyEaAccountUsageCost, costUnit, timeStamp);
        ServiceStat marketplaceCostServiceStat = AzureCostHelper.createServiceStat(marketplaceCostStatName, eaAccountCost.monthlyEaAccountMarketplaceCost, costUnit, timeStamp);
        ServiceStat separatelyBilledCostServiceStat = AzureCostHelper.createServiceStat(separatelyBilledCostStatName, eaAccountCost.monthlyEaAccountSeparatelyBilledCost, costUnit, timeStamp);
        accountStat.statValues.put(usageCostStatName, Collections.singletonList(usageCostServiceStat));
        accountStat.statValues.put(marketplaceCostStatName, Collections.singletonList(marketplaceCostServiceStat));
        accountStat.statValues.put(separatelyBilledCostStatName, Collections.singletonList(separatelyBilledCostServiceStat));
        accountStats.add(accountStat);
    }
    return accountStats;
}
Also used : ServiceStat(com.vmware.xenon.common.ServiceStats.ServiceStat) ComputeStats(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats) ArrayList(java.util.ArrayList) EaAccountCost(com.vmware.photon.controller.model.adapters.azure.ea.stats.AzureCostStatsService.EaAccountCost) LocalDate(org.joda.time.LocalDate)

Example 2 with EaAccountCost

use of com.vmware.photon.controller.model.adapters.azure.ea.stats.AzureCostStatsService.EaAccountCost in project photon-model by vmware.

the class AzureCostHelper method getEaAccountTotalCost.

/**
 * Computes the total account cost incurred for a month for an EA account.
 * Total cost = usage cost + marketplace cost + separately billed cost
 * @param monthlyEaAccountCost map of monthly EA usage, marketplace and separately billed cost.
 * @return the map of monthly total cost for an EA account.
 */
static Map<LocalDate, Double> getEaAccountTotalCost(Map<LocalDate, EaAccountCost> monthlyEaAccountCost) {
    Map<LocalDate, Double> monthlyTotalCost = new HashMap<>();
    for (Entry<LocalDate, EaAccountCost> accountCostEntry : monthlyEaAccountCost.entrySet()) {
        LocalDate month = accountCostEntry.getKey();
        EaAccountCost accountCost = accountCostEntry.getValue();
        monthlyTotalCost.put(month, accountCost.getTotalCost());
    }
    return monthlyTotalCost;
}
Also used : HashMap(java.util.HashMap) EaAccountCost(com.vmware.photon.controller.model.adapters.azure.ea.stats.AzureCostStatsService.EaAccountCost) LocalDate(org.joda.time.LocalDate)

Aggregations

EaAccountCost (com.vmware.photon.controller.model.adapters.azure.ea.stats.AzureCostStatsService.EaAccountCost)2 LocalDate (org.joda.time.LocalDate)2 ComputeStats (com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats)1 ServiceStat (com.vmware.xenon.common.ServiceStats.ServiceStat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1