Search in sources :

Example 1 with AzureSubscriptionsEnumerationRequest

use of com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService.AzureSubscriptionsEnumerationRequest in project photon-model by vmware.

the class AzureSubscriptionsEnumerationServiceTest method createAzureCostComputesForSubscriptions.

private void createAzureCostComputesForSubscriptions(Collection<AzureSubscription> subscriptions) {
    AzureSubscriptionsEnumerationRequest request = getAzureCostComputeEnumRequestForSubscriptions(subscriptions);
    TestRequestSender sender = new TestRequestSender(this.host);
    Operation op = Operation.createPatch(this.host, AzureSubscriptionsEnumerationService.SELF_LINK).setBody(request);
    sender.sendAndWait(op);
}
Also used : TestRequestSender(com.vmware.xenon.common.test.TestRequestSender) Operation(com.vmware.xenon.common.Operation) AzureSubscriptionsEnumerationRequest(com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService.AzureSubscriptionsEnumerationRequest)

Example 2 with AzureSubscriptionsEnumerationRequest

use of com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService.AzureSubscriptionsEnumerationRequest in project photon-model by vmware.

the class AzureSubscriptionsEnumerationServiceTest method getAzureCostComputeEnumRequestForSubscriptions.

private AzureSubscriptionsEnumerationRequest getAzureCostComputeEnumRequestForSubscriptions(Collection<AzureSubscription> azureSubscriptions) {
    AzureSubscriptionsEnumerationRequest request = new AzureSubscriptionsEnumerationRequest();
    request.resourceReference = UriUtils.buildUri(this.host, this.computeLink);
    request.azureSubscriptions = azureSubscriptions;
    return request;
}
Also used : AzureSubscriptionsEnumerationRequest(com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService.AzureSubscriptionsEnumerationRequest)

Example 3 with AzureSubscriptionsEnumerationRequest

use of com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService.AzureSubscriptionsEnumerationRequest in project photon-model by vmware.

the class AzureCostStatsService method createMissingComputeStates.

/**
 * The user adds the EA account as the end-point. By parsing the bill, we understand there are
 * one or more subscriptions, resources whose compute states need to be created in order
 * to store cost information for those entities.
 */
private void createMissingComputeStates(Context context, Stages next, List<AzureSubscription> newSubscriptions) {
    logInfo(() -> String.format("Creating compute states for the following subscriptions: %s for " + "endpoint %s ", newSubscriptions.toString(), context.computeHostDesc.endpointLink));
    AzureSubscriptionsEnumerationRequest request = new AzureSubscriptionsEnumerationRequest();
    request.resourceReference = UriUtils.extendUri(getInventoryServiceUri(), context.computeHostDesc.documentSelfLink);
    request.azureSubscriptions = newSubscriptions;
    Operation.createPatch(getHost(), AzureSubscriptionsEnumerationService.SELF_LINK).setBody(request).setCompletion((operation, exception) -> {
        logInfo(() -> String.format("Finished creating compute states for " + "subscriptions under endpoint %s.", context.computeHostDesc.documentSelfLink));
        context.stage = next;
        handleRequest(context);
    }).sendWith(this);
}
Also used : AzureCostConstants(com.vmware.photon.controller.model.adapters.azure.constants.AzureCostConstants) AzureStatsNormalizer(com.vmware.photon.controller.model.adapters.azure.utils.AzureStatsNormalizer) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) Arrays(java.util.Arrays) DateTimeZone(org.joda.time.DateTimeZone) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) QueryTask(com.vmware.xenon.services.common.QueryTask) ServiceDocument(com.vmware.xenon.common.ServiceDocument) AzureUriPaths(com.vmware.photon.controller.model.adapters.azure.AzureUriPaths) StringUtils(org.apache.commons.lang3.StringUtils) 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) Utils(com.vmware.xenon.common.Utils) BufferedSink(okio.BufferedSink) Map(java.util.Map) AzureService(com.vmware.photon.controller.model.adapters.azure.model.cost.AzureService) URI(java.net.URI) AzureSubscriptionsEnumerationRequest(com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService.AzureSubscriptionsEnumerationRequest) Builder(com.vmware.xenon.services.common.QueryTask.Builder) Path(java.nio.file.Path) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) Interceptor(okhttp3.Interceptor) ComputeStatsResponse(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse) AzureDetailedBillHandler(com.vmware.photon.controller.model.adapters.azure.ea.utils.AzureDetailedBillHandler) Request(okhttp3.Request) ComputeStatsRequest(com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest) StatelessService(com.vmware.xenon.common.StatelessService) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) OldEaSummarizedBillElement(com.vmware.photon.controller.model.adapters.azure.model.cost.OldEaSummarizedBillElement) TaskManager(com.vmware.photon.controller.model.adapters.util.TaskManager) Set(java.util.Set) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) AzureSubscriptionsEnumerationService(com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService) AzureCostHelper(com.vmware.photon.controller.model.adapters.azure.ea.utils.AzureCostHelper) List(java.util.List) 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) INTERNAL_REQUEST_TIMEOUT_SECONDS(com.vmware.photon.controller.model.adapters.azure.constants.AzureCostConstants.INTERNAL_REQUEST_TIMEOUT_SECONDS) ResourceMetrics(com.vmware.photon.controller.model.monitoring.ResourceMetricsService.ResourceMetrics) SingleResourceTaskCollectionStage(com.vmware.photon.controller.model.tasks.monitoring.SingleResourceStatsCollectionTaskService.SingleResourceTaskCollectionStage) Okio(okio.Okio) QueryByPages(com.vmware.photon.controller.model.query.QueryUtils.QueryByPages) OperationContext(com.vmware.xenon.common.OperationContext) AtomicDouble(com.google.common.util.concurrent.AtomicDouble) HashMap(java.util.HashMap) Function(java.util.function.Function) AzureResource(com.vmware.photon.controller.model.adapters.azure.model.cost.AzureResource) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) EndpointConfigRequest(com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest) Query(com.vmware.xenon.services.common.QueryTask.Query) CollectionUtils(org.apache.commons.collections.CollectionUtils) EaBillLinkElement(com.vmware.photon.controller.model.adapters.azure.model.cost.EaBillLinkElement) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) AUTO_DISCOVERED_ENTITY(com.vmware.photon.controller.model.constants.PhotonModelConstants.AUTO_DISCOVERED_ENTITY) EaBillLinks(com.vmware.photon.controller.model.adapters.azure.model.cost.EaBillLinks) BiConsumer(java.util.function.BiConsumer) Response(okhttp3.Response) EndpointType(com.vmware.photon.controller.model.constants.PhotonModelConstants.EndpointType) Call(okhttp3.Call) Callback(okhttp3.Callback) AzureSubscription(com.vmware.photon.controller.model.adapters.azure.model.cost.AzureSubscription) ComputeStats(com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats) ExecutorService(java.util.concurrent.ExecutorService) OldApi(com.vmware.photon.controller.model.adapters.azure.model.cost.OldApi) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) ServiceErrorResponse(com.vmware.xenon.common.ServiceErrorResponse) Files(java.nio.file.Files) Operation(com.vmware.xenon.common.Operation) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) TypeName(com.vmware.xenon.common.ServiceDocumentDescription.TypeName) ServiceStat(com.vmware.xenon.common.ServiceStats.ServiceStat) File(java.io.File) QueryTop(com.vmware.photon.controller.model.query.QueryUtils.QueryTop) BillParsingStatus(com.vmware.photon.controller.model.adapters.azure.model.cost.BillParsingStatus) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) LocalDate(org.joda.time.LocalDate) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) OkHttpClient(okhttp3.OkHttpClient) Paths(java.nio.file.Paths) ClusterUtil(com.vmware.photon.controller.model.util.ClusterUtil) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) PhotonModelConstants(com.vmware.photon.controller.model.constants.PhotonModelConstants) ServiceDocumentDescription(com.vmware.xenon.common.ServiceDocumentDescription) Comparator(java.util.Comparator) QuerySpecification(com.vmware.xenon.services.common.QueryTask.QuerySpecification) OperationJoin(com.vmware.xenon.common.OperationJoin) AzureSubscriptionsEnumerationRequest(com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService.AzureSubscriptionsEnumerationRequest)

Aggregations

AzureSubscriptionsEnumerationRequest (com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService.AzureSubscriptionsEnumerationRequest)3 Sets (com.google.common.collect.Sets)1 AtomicDouble (com.google.common.util.concurrent.AtomicDouble)1 ComputeStatsRequest (com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest)1 ComputeStatsResponse (com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse)1 ComputeStats (com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats)1 EndpointConfigRequest (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest)1 AzureUriPaths (com.vmware.photon.controller.model.adapters.azure.AzureUriPaths)1 AzureCostConstants (com.vmware.photon.controller.model.adapters.azure.constants.AzureCostConstants)1 INTERNAL_REQUEST_TIMEOUT_SECONDS (com.vmware.photon.controller.model.adapters.azure.constants.AzureCostConstants.INTERNAL_REQUEST_TIMEOUT_SECONDS)1 AzureSubscriptionsEnumerationService (com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService)1 AzureCostHelper (com.vmware.photon.controller.model.adapters.azure.ea.utils.AzureCostHelper)1 AzureDetailedBillHandler (com.vmware.photon.controller.model.adapters.azure.ea.utils.AzureDetailedBillHandler)1 AzureResource (com.vmware.photon.controller.model.adapters.azure.model.cost.AzureResource)1 AzureService (com.vmware.photon.controller.model.adapters.azure.model.cost.AzureService)1 AzureSubscription (com.vmware.photon.controller.model.adapters.azure.model.cost.AzureSubscription)1 BillParsingStatus (com.vmware.photon.controller.model.adapters.azure.model.cost.BillParsingStatus)1 EaBillLinkElement (com.vmware.photon.controller.model.adapters.azure.model.cost.EaBillLinkElement)1 EaBillLinks (com.vmware.photon.controller.model.adapters.azure.model.cost.EaBillLinks)1 OldApi (com.vmware.photon.controller.model.adapters.azure.model.cost.OldApi)1