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;
}
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;
}
Aggregations