Search in sources :

Example 1 with AwsServiceDetailDto

use of com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto in project photon-model by vmware.

the class AWSCostStatsService method insertEC2ServiceDetail.

private void insertEC2ServiceDetail(AwsAccountDetailDto awsAccountDetailDto) {
    AwsServiceDetailDto vm = awsAccountDetailDto.serviceDetailsMap.get(AwsServices.EC2_Instance_Usage.getName());
    AwsServiceDetailDto ebs = awsAccountDetailDto.serviceDetailsMap.get(AwsServices.EC2_EBS.getName());
    AwsServiceDetailDto others = awsAccountDetailDto.serviceDetailsMap.get(AwsServices.EC2_Others.getName());
    AwsServiceDetailDto ec2ServiceDetail = new AwsServiceDetailDto();
    ec2ServiceDetail.id = AwsServices.EC2.getName();
    ec2ServiceDetail.type = AwsServices.getTypeByName(AwsServices.EC2.getName()).toString();
    ec2ServiceDetail.directCosts = Stream.of(vm, ebs, others).filter(Objects::nonNull).map(dto -> dto.directCosts.entrySet()).flatMap(Set::stream).collect(Collectors.toMap(Entry::getKey, Entry::getValue, Double::sum));
    ec2ServiceDetail.otherCosts = Stream.of(vm, ebs, others).filter(Objects::nonNull).map(dto -> dto.otherCosts.entrySet()).flatMap(Set::stream).collect(Collectors.toMap(Entry::getKey, Entry::getValue, Double::sum));
    ec2ServiceDetail.remainingCosts = Stream.of(vm, ebs, others).filter(Objects::nonNull).map(dto -> dto.remainingCosts.entrySet()).flatMap(Set::stream).collect(Collectors.toMap(Entry::getKey, Entry::getValue, Double::sum));
    ec2ServiceDetail.reservedRecurringCosts = Stream.of(vm, ebs, others).filter(Objects::nonNull).map(dto -> dto.reservedRecurringCosts.entrySet()).flatMap(Set::stream).collect(Collectors.toMap(Entry::getKey, Entry::getValue, Double::sum));
    awsAccountDetailDto.serviceDetailsMap.put(AwsServices.EC2.getName(), ec2ServiceDetail);
}
Also used : AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) Arrays(java.util.Arrays) DateTimeZone(org.joda.time.DateTimeZone) AWS_ACCOUNT_BILL_PROCESSED_TIME_MILLIS(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_ACCOUNT_BILL_PROCESSED_TIME_MILLIS) AWSCsvBillParser(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSCsvBillParser) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) QueryTask(com.vmware.xenon.services.common.QueryTask) ServiceDocument(com.vmware.xenon.common.ServiceDocument) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) EndpointAllocationTaskService(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService) SingleResourceStatsCollectionTaskState(com.vmware.photon.controller.model.tasks.monitoring.SingleResourceStatsCollectionTaskService.SingleResourceStatsCollectionTaskState) ProgressListener(com.amazonaws.event.ProgressListener) STORAGE_TYPE_EBS(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.STORAGE_TYPE_EBS) Utils(com.vmware.xenon.common.Utils) STORAGE_TYPE_S3(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.STORAGE_TYPE_S3) ACCOUNT_IS_AUTO_DISCOVERED(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.ACCOUNT_IS_AUTO_DISCOVERED) Map(java.util.Map) URI(java.net.URI) ProgressEventType(com.amazonaws.event.ProgressEventType) AWSMissingResourcesEnumerationService(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSMissingResourcesEnumerationService) Path(java.nio.file.Path) AWSClientManager(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManager) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) PrintWriter(java.io.PrintWriter) ComputeStatsResponse(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse) ComputeStatsRequest(com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest) StatelessService(com.vmware.xenon.common.StatelessService) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TaskManager(com.vmware.photon.controller.model.adapters.util.TaskManager) Set(java.util.Set) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) Occurance(com.vmware.xenon.services.common.QueryTask.Query.Occurance) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) AwsServiceDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto) Objects(java.util.Objects) List(java.util.List) AWS_LINKED_ACCOUNT_IDS(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_LINKED_ACCOUNT_IDS) Stream(java.util.stream.Stream) UriUtils(com.vmware.xenon.common.UriUtils) Entry(java.util.Map.Entry) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) AwsServices(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSCsvBillParser.AwsServices) ResourceMetrics(com.vmware.photon.controller.model.monitoring.ResourceMetricsService.ResourceMetrics) SingleResourceTaskCollectionStage(com.vmware.photon.controller.model.tasks.monitoring.SingleResourceStatsCollectionTaskService.SingleResourceTaskCollectionStage) AwsAccountDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsAccountDetailDto) TransferManager(com.amazonaws.services.s3.transfer.TransferManager) QueryByPages(com.vmware.photon.controller.model.query.QueryUtils.QueryByPages) OperationContext(com.vmware.xenon.common.OperationContext) AWS_ACCOUNT_ID_KEY(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_ACCOUNT_ID_KEY) HashMap(java.util.HashMap) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) GetObjectRequest(com.amazonaws.services.s3.model.GetObjectRequest) ResourceMetricsService(com.vmware.photon.controller.model.monitoring.ResourceMetricsService) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) ProgressEvent(com.amazonaws.event.ProgressEvent) HashSet(java.util.HashSet) AuthCredentialsService(com.vmware.xenon.services.common.AuthCredentialsService) Query(com.vmware.xenon.services.common.QueryTask.Query) UriPaths(com.vmware.photon.controller.model.UriPaths) CollectionUtils(org.apache.commons.collections.CollectionUtils) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) BiConsumer(java.util.function.BiConsumer) ComputeStats(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats) AwsClientType(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AwsClientType) StatsUtil(com.vmware.photon.controller.model.tasks.monitoring.StatsUtil) ExecutorService(java.util.concurrent.ExecutorService) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) AmazonS3Exception(com.amazonaws.services.s3.model.AmazonS3Exception) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) Files(java.nio.file.Files) StringWriter(java.io.StringWriter) Operation(com.vmware.xenon.common.Operation) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) IOException(java.io.IOException) ServiceStat(com.vmware.xenon.common.ServiceStats.ServiceStat) AwsResourceDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsResourceDetailDto) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) LocalDate(org.joda.time.LocalDate) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) Paths(java.nio.file.Paths) ClusterUtil(com.vmware.photon.controller.model.util.ClusterUtil) AWSStatsNormalizer(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSStatsNormalizer) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) PhotonModelConstants(com.vmware.photon.controller.model.constants.PhotonModelConstants) AWSClientManagerFactory(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManagerFactory) ServiceDocumentDescription(com.vmware.xenon.common.ServiceDocumentDescription) Collections(java.util.Collections) OperationJoin(com.vmware.xenon.common.OperationJoin) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) AwsServiceDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto) Entry(java.util.Map.Entry) Set(java.util.Set) HashSet(java.util.HashSet) Objects(java.util.Objects)

Example 2 with AwsServiceDetailDto

use of com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto in project photon-model by vmware.

the class AWSCostStatsService method createServiceStatsForAccount.

protected void createServiceStatsForAccount(AWSCostStatsCreationContext statsData, LocalDate billMonth, AwsAccountDetailDto awsAccountDetailDto) {
    Consumer<ComputeState> serviceStatsProcessor = (accountComputeState) -> {
        ComputeStats awsServiceStats = new ComputeStats();
        awsServiceStats.statValues = new ConcurrentHashMap<>();
        awsServiceStats.computeLink = accountComputeState.documentSelfLink;
        awsServiceStats.addCustomProperty(PhotonModelConstants.DOES_CONTAIN_SERVICE_STATS, Boolean.TRUE.toString());
        for (AwsServiceDetailDto serviceDetailDto : awsAccountDetailDto.serviceDetailsMap.values()) {
            Map<String, List<ServiceStat>> statsForAwsService = createStatsForAwsService(serviceDetailDto);
            awsServiceStats.statValues.putAll(statsForAwsService);
        }
        if (!awsServiceStats.statValues.isEmpty()) {
            statsData.statsResponse.statsList.add(awsServiceStats);
        }
    };
    insertEC2ServiceDetail(awsAccountDetailDto);
    processAccountStats(statsData, billMonth, awsAccountDetailDto, serviceStatsProcessor);
}
Also used : AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) Arrays(java.util.Arrays) DateTimeZone(org.joda.time.DateTimeZone) AWS_ACCOUNT_BILL_PROCESSED_TIME_MILLIS(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_ACCOUNT_BILL_PROCESSED_TIME_MILLIS) AWSCsvBillParser(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSCsvBillParser) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) QueryTask(com.vmware.xenon.services.common.QueryTask) ServiceDocument(com.vmware.xenon.common.ServiceDocument) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) EndpointAllocationTaskService(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService) SingleResourceStatsCollectionTaskState(com.vmware.photon.controller.model.tasks.monitoring.SingleResourceStatsCollectionTaskService.SingleResourceStatsCollectionTaskState) ProgressListener(com.amazonaws.event.ProgressListener) STORAGE_TYPE_EBS(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.STORAGE_TYPE_EBS) Utils(com.vmware.xenon.common.Utils) STORAGE_TYPE_S3(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.STORAGE_TYPE_S3) ACCOUNT_IS_AUTO_DISCOVERED(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.ACCOUNT_IS_AUTO_DISCOVERED) Map(java.util.Map) URI(java.net.URI) ProgressEventType(com.amazonaws.event.ProgressEventType) AWSMissingResourcesEnumerationService(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSMissingResourcesEnumerationService) Path(java.nio.file.Path) AWSClientManager(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManager) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) PrintWriter(java.io.PrintWriter) ComputeStatsResponse(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse) ComputeStatsRequest(com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest) StatelessService(com.vmware.xenon.common.StatelessService) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TaskManager(com.vmware.photon.controller.model.adapters.util.TaskManager) Set(java.util.Set) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) Occurance(com.vmware.xenon.services.common.QueryTask.Query.Occurance) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) AwsServiceDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto) Objects(java.util.Objects) List(java.util.List) AWS_LINKED_ACCOUNT_IDS(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_LINKED_ACCOUNT_IDS) Stream(java.util.stream.Stream) UriUtils(com.vmware.xenon.common.UriUtils) Entry(java.util.Map.Entry) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) AwsServices(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSCsvBillParser.AwsServices) ResourceMetrics(com.vmware.photon.controller.model.monitoring.ResourceMetricsService.ResourceMetrics) SingleResourceTaskCollectionStage(com.vmware.photon.controller.model.tasks.monitoring.SingleResourceStatsCollectionTaskService.SingleResourceTaskCollectionStage) AwsAccountDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsAccountDetailDto) TransferManager(com.amazonaws.services.s3.transfer.TransferManager) QueryByPages(com.vmware.photon.controller.model.query.QueryUtils.QueryByPages) OperationContext(com.vmware.xenon.common.OperationContext) AWS_ACCOUNT_ID_KEY(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_ACCOUNT_ID_KEY) HashMap(java.util.HashMap) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) GetObjectRequest(com.amazonaws.services.s3.model.GetObjectRequest) ResourceMetricsService(com.vmware.photon.controller.model.monitoring.ResourceMetricsService) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) ProgressEvent(com.amazonaws.event.ProgressEvent) HashSet(java.util.HashSet) AuthCredentialsService(com.vmware.xenon.services.common.AuthCredentialsService) Query(com.vmware.xenon.services.common.QueryTask.Query) UriPaths(com.vmware.photon.controller.model.UriPaths) CollectionUtils(org.apache.commons.collections.CollectionUtils) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) BiConsumer(java.util.function.BiConsumer) ComputeStats(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats) AwsClientType(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AwsClientType) StatsUtil(com.vmware.photon.controller.model.tasks.monitoring.StatsUtil) ExecutorService(java.util.concurrent.ExecutorService) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) AmazonS3Exception(com.amazonaws.services.s3.model.AmazonS3Exception) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) Files(java.nio.file.Files) StringWriter(java.io.StringWriter) Operation(com.vmware.xenon.common.Operation) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) IOException(java.io.IOException) ServiceStat(com.vmware.xenon.common.ServiceStats.ServiceStat) AwsResourceDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsResourceDetailDto) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) LocalDate(org.joda.time.LocalDate) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) Paths(java.nio.file.Paths) ClusterUtil(com.vmware.photon.controller.model.util.ClusterUtil) AWSStatsNormalizer(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSStatsNormalizer) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) PhotonModelConstants(com.vmware.photon.controller.model.constants.PhotonModelConstants) AWSClientManagerFactory(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManagerFactory) ServiceDocumentDescription(com.vmware.xenon.common.ServiceDocumentDescription) Collections(java.util.Collections) OperationJoin(com.vmware.xenon.common.OperationJoin) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) ServiceStat(com.vmware.xenon.common.ServiceStats.ServiceStat) AwsServiceDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto) ComputeStats(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap)

Example 3 with AwsServiceDetailDto

use of com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto in project photon-model by vmware.

the class AWSCostStatsService method createResourceStatsForAccount.

protected void createResourceStatsForAccount(AWSCostStatsCreationContext statsData, AwsAccountDetailDto awsAccountDetailDto) {
    Map<String, AwsServiceDetailDto> serviceDetails = awsAccountDetailDto.serviceDetailsMap;
    List<AwsServices> supportedServices = Arrays.asList(AwsServices.EC2_Instance_Usage, AwsServices.EC2_EBS, AwsServices.S3);
    for (String service : serviceDetails.keySet()) {
        if (!supportedServices.contains(AwsServices.getByName(service))) {
            continue;
        }
        Map<String, AwsResourceDetailDto> resourceDetailsMap = serviceDetails.get(service).resourceDetailsMap;
        if (resourceDetailsMap == null) {
            continue;
        }
        for (Entry<String, AwsResourceDetailDto> entry : resourceDetailsMap.entrySet()) {
            String resourceId = entry.getKey();
            AwsResourceDetailDto resourceDetails = entry.getValue();
            if ((resourceDetails == null) || (resourceDetails.directCosts == null)) {
                continue;
            }
            Set<String> resourceLinks = statsData.awsResourceLinksById.getOrDefault(resourceId, Collections.emptySet());
            for (String resourceStateLink : resourceLinks) {
                ComputeStats resourceStats = createStatsForResource(resourceStateLink, resourceDetails);
                statsData.statsResponse.statsList.add(resourceStats);
            }
        }
    }
}
Also used : AwsResourceDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsResourceDetailDto) AwsServiceDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto) ComputeStats(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats) AwsServices(com.vmware.photon.controller.model.adapters.awsadapter.util.AWSCsvBillParser.AwsServices)

Example 4 with AwsServiceDetailDto

use of com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto in project photon-model by vmware.

the class AWSCsvBillParser method createOrGetServiceDetailObject.

private AwsServiceDetailDto createOrGetServiceDetailObject(AwsAccountDetailDto accountDetails, String serviceName, String resourceId) {
    if (serviceName != null && serviceName.contains(AwsServices.EC2.getName())) {
        if (resourceId != null && resourceId.startsWith(AWS_INSTANCE_ID_PREFIX)) {
            serviceName = AwsServices.EC2_Instance_Usage.getName();
        } else if (resourceId != null && resourceId.startsWith(AWS_VOLUME_ID_PREFIX)) {
            serviceName = AwsServices.EC2_EBS.getName();
        } else {
            serviceName = AwsServices.EC2_Others.getName();
        }
    }
    AwsServiceDetailDto serviceDetail = accountDetails.fetchServiceDetail(serviceName);
    /*
         * If the service is not present, add the service and its details from
         * the bill
         */
    if (serviceDetail == null && serviceName != null && !serviceName.isEmpty()) {
        serviceDetail = new AwsServiceDetailDto();
        serviceDetail.id = serviceName;
        serviceDetail.type = AwsServices.getTypeByName(serviceName).toString();
        accountDetails.addToServiceDetailsMap(serviceName, serviceDetail);
    }
    return serviceDetail;
}
Also used : AwsServiceDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto)

Example 5 with AwsServiceDetailDto

use of com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto in project photon-model by vmware.

the class AWSCsvBillParser method readSummaryRow.

private void readSummaryRow(Map<String, Object> rowMap, String linkedAccountId, String productName, Map<String, AwsAccountDetailDto> accountDetails, Collection<String> ignorableInvoiceCharge) {
    AwsAccountDetailDto awsAccountDetail;
    if (linkedAccountId == null || linkedAccountId.length() == 0) {
        // The AccountId is not obtained from LinkedAccountId in case of
        // non-consolidated bills and has to be fetched from PayerAccountId
        // column from the bill file
        awsAccountDetail = createOrGetAccountDetailObject(accountDetails, getStringFieldValue(rowMap, DetailedCsvHeaders.PAYER_ACCOUNT_ID));
    } else {
        awsAccountDetail = createOrGetAccountDetailObject(accountDetails, linkedAccountId);
    }
    String lineInvoiceId = getStringFieldValue(rowMap, DetailedCsvHeaders.INVOICE_ID);
    Double resourceCost = getResourceCost(rowMap);
    if (matchFieldValue(rowMap, DetailedCsvHeaders.RECORD_TYPE, DetailedCsvHeaders.LINE_ITEM)) {
        LocalDateTime usageStartTimeFromCsv = (LocalDateTime) rowMap.get(DetailedCsvHeaders.USAGE_START_DATE);
        Long millisForBillHour = getMillisForHour(usageStartTimeFromCsv);
        AwsServiceDetailDto serviceDetail = createOrGetServiceDetailObject(awsAccountDetail, productName, null);
        if (serviceDetail != null && millisForBillHour != null) {
            if (matchFieldValue(rowMap, DetailedCsvHeaders.OPERATION, RUN_INSTANCES)) {
                serviceDetail.addToReservedRecurringCosts(millisForBillHour, resourceCost);
                return;
            }
            serviceDetail.addToRemainingCosts(millisForBillHour, resourceCost);
            if (StringUtils.isNotEmpty(lineInvoiceId) && StringUtils.isNotEmpty(this.billInvoiceId) && !StringUtils.equals(lineInvoiceId, this.billInvoiceId)) {
                // service subscriptions/renewals
                awsAccountDetail.accountOneTimeCharges += resourceCost;
                ignorableInvoiceCharge.add(lineInvoiceId);
            }
            return;
        }
        awsAccountDetail.otherCharges += resourceCost;
    } else if (matchFieldValue(rowMap, DetailedCsvHeaders.RECORD_TYPE, ACCOUNT_TOTAL)) {
        // If the RecordType is AccountTotal, this is the account monthly cost for consolidated bills
        awsAccountDetail.cost = resourceCost;
    } else if (matchFieldValue(rowMap, DetailedCsvHeaders.RECORD_TYPE, INVOICE_TOTAL)) {
        // ie, for primary accounts with no linked accounts
        if (!ignorableInvoiceCharge.contains(lineInvoiceId)) {
            awsAccountDetail.cost = resourceCost;
        }
    }
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) AwsServiceDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto) AwsAccountDetailDto(com.vmware.photon.controller.model.adapters.aws.dto.AwsAccountDetailDto)

Aggregations

AwsServiceDetailDto (com.vmware.photon.controller.model.adapters.aws.dto.AwsServiceDetailDto)6 AwsAccountDetailDto (com.vmware.photon.controller.model.adapters.aws.dto.AwsAccountDetailDto)4 AwsResourceDetailDto (com.vmware.photon.controller.model.adapters.aws.dto.AwsResourceDetailDto)4 ComputeStats (com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats)3 AwsServices (com.vmware.photon.controller.model.adapters.awsadapter.util.AWSCsvBillParser.AwsServices)3 ProgressEvent (com.amazonaws.event.ProgressEvent)2 ProgressEventType (com.amazonaws.event.ProgressEventType)2 ProgressListener (com.amazonaws.event.ProgressListener)2 AmazonS3Exception (com.amazonaws.services.s3.model.AmazonS3Exception)2 GetObjectRequest (com.amazonaws.services.s3.model.GetObjectRequest)2 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)2 UriPaths (com.vmware.photon.controller.model.UriPaths)2 ComputeStatsRequest (com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest)2 ComputeStatsResponse (com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse)2 ACCOUNT_IS_AUTO_DISCOVERED (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.ACCOUNT_IS_AUTO_DISCOVERED)2 AWS_ACCOUNT_BILL_PROCESSED_TIME_MILLIS (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_ACCOUNT_BILL_PROCESSED_TIME_MILLIS)2 AWS_ACCOUNT_ID_KEY (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_ACCOUNT_ID_KEY)2 AWS_LINKED_ACCOUNT_IDS (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWS_LINKED_ACCOUNT_IDS)2 AwsClientType (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AwsClientType)2 STORAGE_TYPE_EBS (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.STORAGE_TYPE_EBS)2