use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.
the class VSphereAdapterImageEnumerationService method collectAllEndpointImages.
private DeferredResult<Set<String>> collectAllEndpointImages(ImageEnumerateRequest req) {
Builder builder = Query.Builder.create().addKindFieldClause(ImageState.class).addFieldClause(ImageState.FIELD_NAME_ENDPOINT_LINK, req.resourceLink());
QueryTask task = QueryTask.Builder.createDirectTask().setQuery(builder.build()).setResultLimit(QueryUtils.DEFAULT_RESULT_LIMIT).build();
DeferredResult<Set<String>> res = new DeferredResult<>();
Set<String> imageLinks = new ConcurrentSkipListSet<>();
QueryUtils.startInventoryQueryTask(this, task).whenComplete((result, e) -> {
if (e != null) {
res.complete(new HashSet<>());
return;
}
if (result.results.nextPageLink == null) {
res.complete(imageLinks);
return;
}
Operation.createGet(PhotonModelUriUtils.createInventoryUri(getHost(), result.results.nextPageLink)).setCompletion(makeCompletion(imageLinks, res)).sendWith(this);
});
return res;
}
use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.
the class VSphereHostSystemEnumerationHelper method queryForHostSystem.
/**
* Builds a query for finding a HostSystems by its manage object reference.
*/
private static QueryTask queryForHostSystem(EnumerationProgress ctx, String parentComputeLink, String moRefId) {
Builder builder = Builder.create().addKindFieldClause(ComputeState.class).addFieldClause(ComputeState.FIELD_NAME_ID, moRefId).addFieldClause(ComputeState.FIELD_NAME_PARENT_LINK, parentComputeLink);
QueryUtils.addEndpointLink(builder, ComputeState.class, ctx.getRequest().endpointLink);
QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
return QueryTask.Builder.createDirectTask().setQuery(builder.build()).addOption(QueryOption.EXPAND_CONTENT).build();
}
use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.
the class VsphereFolderEnumerationHelper method queryForFolder.
private static QueryTask queryForFolder(EnumerationProgress ctx, FolderOverlay folder) {
String moref = VimUtils.convertMoRefToString(folder.getId());
Builder builder = QueryTask.Query.Builder.create().addKindFieldClause(ResourceGroupState.class).addCompositeFieldClause(ResourceState.FIELD_NAME_CUSTOM_PROPERTIES, CustomProperties.MOREF, moref);
QueryUtils.addEndpointLink(builder, ResourceGroupService.ResourceGroupState.class, ctx.getRequest().endpointLink);
QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
return QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
}
use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.
the class VsphereStoragePolicyEnumerationHelper method queryForStoragePolicy.
static QueryTask queryForStoragePolicy(EnumerationProgress ctx, String id, String name) {
Builder builder = Builder.create().addFieldClause(ResourceState.FIELD_NAME_ID, id).addKindFieldClause(ResourceGroupState.class).addCaseInsensitiveFieldClause(ResourceState.FIELD_NAME_NAME, name, MatchType.TERM, Occurance.MUST_OCCUR);
QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
return QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
}
Aggregations