use of com.vmware.xenon.services.common.QueryTask in project photon-model by vmware.
the class TestVSphereProvisionFromImageLink method findImage.
private String findImage() {
Query q = Query.Builder.create().addKindFieldClause(ImageState.class).addFieldClause(ImageState.FIELD_NAME_NAME, "*" + this.libraryItemName, 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;
}
}
use of com.vmware.xenon.services.common.QueryTask in project photon-model by vmware.
the class TestVSphereProvisionWithCloudConfigTask method findTemplate.
private ComputeState findTemplate() throws InterruptedException, ExecutionException, TimeoutException {
String templateVmName = System.getProperty("vc.templateVmName");
Query q = Query.Builder.create().addFieldClause(ComputeState.FIELD_NAME_NAME, templateVmName).addKindFieldClause(ComputeState.class).build();
QueryTask task = QueryTask.Builder.createDirectTask().addOption(QueryOption.EXPAND_CONTENT).setQuery(q).build();
Operation op = QueryUtils.createQueryTaskOperation(this.host, task, ServiceTypeCluster.INVENTORY_SERVICE);
QueryTask result = this.host.waitForResponse(op).getBody(QueryTask.class);
Object firstResult = result.results.documents.values().iterator().next();
return Utils.fromJson(firstResult, ComputeState.class);
}
use of com.vmware.xenon.services.common.QueryTask in project photon-model by vmware.
the class TestVSphereProvisionWithStaticIpTask method findPortGroup.
protected String findPortGroup(String name) throws Throwable {
Query q = Query.Builder.create().addKindFieldClause(SubnetState.class).addFieldClause(NetworkState.FIELD_NAME_NAME, name).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;
}
}
use of com.vmware.xenon.services.common.QueryTask in project photon-model by vmware.
the class TestVSphereOvfImport method importOvfAsDescriptions.
@Test
public void importOvfAsDescriptions() throws Throwable {
this.resourcePool = createResourcePool();
this.auth = createAuth();
this.computeHostDescription = createComputeDescription();
createComputeHost();
ComputeDescription computeDesc = new ComputeDescription();
computeDesc.supportedChildren = new ArrayList<>();
computeDesc.instanceAdapterReference = UriUtils.buildUri(this.host, VSphereUriPaths.INSTANCE_SERVICE);
computeDesc.authCredentialsLink = this.auth.documentSelfLink;
computeDesc.name = computeDesc.id;
computeDesc.dataStoreId = this.dataStoreId;
ImportOvfRequest req = new ImportOvfRequest();
req.ovfUri = new File("src/test/resources/vcenter.ovf").toURI();
req.template = computeDesc;
Operation op = Operation.createPatch(this.host, OvfImporterService.SELF_LINK).setBody(req).setReferer(this.host.getPublicUri());
op = this.host.waitForResponse(op);
assertEquals(Operation.STATUS_CODE_OK, op.getStatusCode());
Query q = Query.Builder.create().addFieldClause(ComputeState.FIELD_NAME_ID, "ovf-", MatchType.PREFIX).build();
QueryTask task = QueryTask.Builder.createDirectTask().setQuery(q).build();
QueryUtils.createQueryTaskOperation(this.host, task, ServiceTypeCluster.INVENTORY_SERVICE);
task = this.host.waitForResponse(op).getBody(QueryTask.class);
assertTrue(task.results.documentLinks.size() > 5);
snapshotFactoryState("ovf", ComputeDescriptionService.class);
}
use of com.vmware.xenon.services.common.QueryTask in project photon-model by vmware.
the class TestVSphereEnumerationTask method findRandomHost.
private ComputeState findRandomHost() throws InterruptedException, TimeoutException, ExecutionException {
Query q = Query.Builder.create().addCompositeFieldClause(ComputeState.FIELD_NAME_CUSTOM_PROPERTIES, CustomProperties.TYPE, VimNames.TYPE_HOST).addKindFieldClause(ComputeState.class).build();
QueryTask qt = QueryTask.Builder.createDirectTask().setQuery(q).addOption(QueryOption.EXPAND_CONTENT).build();
Operation op = QueryUtils.createQueryTaskOperation(this.host, qt, ServiceTypeCluster.INVENTORY_SERVICE);
QueryTask result = this.host.waitForResponse(op).getBody(QueryTask.class);
Object firstResult = result.results.documents.values().iterator().next();
return Utils.fromJson(firstResult, ComputeState.class);
}
Aggregations