use of com.vmware.xenon.services.common.QueryTask in project photon-model by vmware.
the class TestVSphereDiskService method getStoragePolicyLink.
private String getStoragePolicyLink() {
QueryTask.Query.Builder builder = QueryTask.Query.Builder.create().addKindFieldClause(ResourceGroupState.class);
builder.addFieldClause(ResourceGroupState.FIELD_NAME_ID, this.spId);
builder.addCaseInsensitiveFieldClause(StorageDescriptionService.StorageDescription.FIELD_NAME_NAME, this.spName, QueryTask.QueryTerm.MatchType.TERM, QueryTask.Query.Occurance.MUST_OCCUR);
QueryTask task = QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
Operation op = QueryUtils.createQueryTaskOperation(this.host, task, ServiceTypeCluster.INVENTORY_SERVICE);
QueryTask result = this.host.waitForResponse(op).getBody(QueryTask.class);
return result.results.documentLinks.get(0);
}
use of com.vmware.xenon.services.common.QueryTask in project photon-model by vmware.
the class TestVSphereEnumerationTask method verifyCIGapForDatacenterOrFolder.
private void verifyCIGapForDatacenterOrFolder(String type) {
Query.Builder builder = Query.Builder.create().addKindFieldClause(ResourceGroupService.ResourceGroupState.class).addCompositeFieldClause(ResourceGroupService.ResourceGroupState.FIELD_NAME_CUSTOM_PROPERTIES, CustomProperties.TYPE, type);
QueryTask task = QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
withTaskResults(task, result -> assertTrue(result.documentCount != 0));
}
use of com.vmware.xenon.services.common.QueryTask in project photon-model by vmware.
the class TestVSphereEnumerationTask method withTaskResults.
private void withTaskResults(QueryTask task, Consumer<ServiceDocumentQueryResult> handler) {
task.querySpec.options = EnumSet.of(QueryOption.EXPAND_CONTENT);
task.documentExpirationTimeMicros = Utils.fromNowMicrosUtc(QUERY_TASK_EXPIRY_MICROS);
Operation op = QueryUtils.createQueryTaskOperation(this.host, task, ServiceTypeCluster.INVENTORY_SERVICE);
QueryTask result = this.host.waitForResponse(op).getBody(QueryTask.class);
handler.accept(result.results);
}
use of com.vmware.xenon.services.common.QueryTask in project photon-model by vmware.
the class TestVSphereCloneTaskBase method findFirstNetwork.
private String findFirstNetwork() {
QueryTask.Query q = QueryTask.Query.Builder.create().addFieldClause(ServiceDocument.FIELD_NAME_KIND, Utils.buildKind(NetworkService.NetworkState.class)).addCompositeFieldClause(NetworkService.NetworkState.FIELD_NAME_CUSTOM_PROPERTIES, CustomProperties.TYPE, VimNames.TYPE_NETWORK).build();
QueryTask task = QueryTask.Builder.createDirectTask().setQuery(q).build();
Operation op = QueryUtils.createQueryTaskOperation(this.host, task, ServiceTypeCluster.INVENTORY_SERVICE);
Operation result = this.host.waitForResponse(op);
try {
return result.getBody(QueryTask.class).results.documentLinks.get(0);
} catch (Exception e) {
result.fail(e);
Assert.fail(e.getMessage());
// never gets here
return null;
}
}
use of com.vmware.xenon.services.common.QueryTask in project photon-model by vmware.
the class TestVSphereLibraryProvisionTaskBase method findImage.
private String findImage() {
QueryTask.Query q = QueryTask.Query.Builder.create().addKindFieldClause(ImageService.ImageState.class).addFieldClause(ImageService.ImageState.FIELD_NAME_NAME, "*" + this.libraryItemName, QueryTask.QueryTerm.MatchType.WILDCARD).build();
QueryTask task = QueryTask.Builder.createDirectTask().setQuery(q).build();
Operation op = QueryUtils.createQueryTaskOperation(this.host, task, ServiceTypeCluster.INVENTORY_SERVICE);
Operation result = this.host.waitForResponse(op);
try {
return result.getBody(QueryTask.class).results.documentLinks.get(0);
} catch (Exception e) {
Assert.fail(e.getMessage());
return null;
}
}
Aggregations