use of com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.STORAGE_TYPE_S3 in project photon-model by vmware.
the class AWSCostStatsService method queryVolumes.
protected void queryVolumes(AWSCostStatsCreationContext statsData, AWSCostStatsCreationStages nextStage, AWSCostStatsCreationSubStage nextSubStage) {
Set<String> endpointLinks = statsData.awsAccountIdToComputeStates.values().stream().flatMap(// flatten collection of lists to single list
List::stream).flatMap(e -> e.endpointLinks.stream()).collect(// extract endpointLinks of all accounts
Collectors.toSet());
List<String> supportedStorageTypes = Arrays.asList(STORAGE_TYPE_EBS, STORAGE_TYPE_S3);
Query query = Query.Builder.create().addKindFieldClause(DiskState.class).addInCollectionItemClause(DiskState.FIELD_NAME_ENDPOINT_LINKS, endpointLinks, Occurance.MUST_OCCUR).addInClause(DiskState.FIELD_NAME_STORAGE_TYPE, supportedStorageTypes).build();
populateAwsResources(query, statsData, nextStage, nextSubStage);
}
use of com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.STORAGE_TYPE_S3 in project photon-model by vmware.
the class AWSS3StorageEnumerationAdapterService method getLocalResources.
/**
* Query and get list of S3 buckets present locally in disk states in current context.
*/
private void getLocalResources(S3StorageEnumerationContext aws, S3StorageEnumerationSubStage next) {
// instance Ids. the filtering is performed on the selected resource pool.
if (aws.localResourcesNextPageLink == null) {
Query.Builder qBuilder = Query.Builder.create().addKindFieldClause(DiskState.class).addFieldClause(DiskState.FIELD_NAME_STORAGE_TYPE, STORAGE_TYPE_S3).addInClause(DiskState.FIELD_NAME_ID, aws.remoteBucketsByBucketName.keySet());
addScopeCriteria(qBuilder, aws);
QueryTask queryTask = QueryTask.Builder.createDirectTask().setQuery(qBuilder.build()).addOption(QueryOption.EXPAND_CONTENT).setResultLimit(getQueryResultLimit()).build();
queryTask.tenantLinks = aws.parentCompute.tenantLinks;
QueryUtils.startInventoryQueryTask(this, queryTask).whenComplete((qrt, e) -> {
if (e != null) {
this.logSevere(() -> String.format("Failure retrieving query" + " results: %s", e.toString()));
signalErrorToEnumerationAdapter(aws, e);
return;
}
qrt.results.documents.values().forEach(documentJson -> {
DiskState localDisk = Utils.fromJson(documentJson, DiskState.class);
aws.localDiskStatesByBucketName.put(localDisk.name, localDisk);
});
this.logFine(() -> String.format("%d S3 disk states found.", qrt.results.documentCount));
if (qrt.results.nextPageLink != null) {
this.logFine("Processing next page for local disk states.");
aws.localResourcesNextPageLink = qrt.results.nextPageLink;
handleReceivedEnumerationData(aws);
} else {
aws.subStage = next;
handleReceivedEnumerationData(aws);
}
});
} else {
Operation.createGet(createInventoryUri(this.getHost(), aws.localResourcesNextPageLink)).setReferer(this.getUri()).setCompletion((o, e) -> {
if (e != null) {
this.logSevere(() -> String.format("Failure retrieving query" + " results: %s", e.toString()));
signalErrorToEnumerationAdapter(aws, e);
return;
}
QueryTask qrt = o.getBody(QueryTask.class);
qrt.results.documents.values().forEach(documentJson -> {
DiskState localDisk = Utils.fromJson(documentJson, DiskState.class);
aws.localDiskStatesByBucketName.put(localDisk.name, localDisk);
});
this.logFine(() -> String.format("%d S3 disk states found.", qrt.results.documentCount));
if (qrt.results.nextPageLink != null) {
this.logFine("Processing next page for local disk states.");
aws.localResourcesNextPageLink = qrt.results.nextPageLink;
handleReceivedEnumerationData(aws);
} else {
aws.subStage = next;
handleReceivedEnumerationData(aws);
}
}).sendWith(this);
}
}
Aggregations