use of com.vmware.xenon.common.Operation in project photon-model by vmware.
the class TestVSphereComputeDiskDay2Service method sendRequest.
private void sendRequest(ResourceOperationRequest request, DiskService.DiskType diskType, VerificationHost.WaitHandler handler) {
Operation attachDiskOp = Operation.createPatch(UriUtils.buildUri(this.host, VSphereComputeDiskManagementService.SELF_LINK)).setBody(request).setReferer(this.host.getReferer());
TestRequestSender sender = new TestRequestSender(this.host);
sender.sendRequest(attachDiskOp);
this.host.log(String.format("Waiting for %s disk attach to complete", diskType.name()));
this.host.waitFor(String.format("%s %s disk failed.", request.operation, diskType.name()), handler);
}
use of com.vmware.xenon.common.Operation 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;
}
}
use of com.vmware.xenon.common.Operation in project photon-model by vmware.
the class TestVSphereLinkedCloneProvisionTask 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;
}
}
use of com.vmware.xenon.common.Operation in project photon-model by vmware.
the class UriPrefixTest method testUriPrefix.
@Test
public void testUriPrefix() throws Throwable {
String factoryPath = PhotonModelServices.LINKS[0];
assertTrue(factoryPath.startsWith(UriUtils.normalizeUriPath(RESOURCES_URI_PREFIX)));
Operation returnOp = sendOperationSynchronously(Operation.createGet(this.host, factoryPath));
assertTrue(returnOp.getStatusCode() == Operation.STATUS_CODE_OK);
factoryPath = PhotonModelMetricServices.LINKS[0];
assertTrue(factoryPath.startsWith(UriUtils.normalizeUriPath(DEFAULT_URI_PREFIX)));
returnOp = sendOperationSynchronously(Operation.createGet(this.host, factoryPath));
assertTrue(returnOp.getStatusCode() == Operation.STATUS_CODE_OK);
}
use of com.vmware.xenon.common.Operation in project photon-model by vmware.
the class BaseModelTest method patchServiceSynchronously.
public <T extends ServiceDocument> int patchServiceSynchronously(String serviceUri, ComputeInstanceRequest patchBody) throws Throwable {
TestContext ctx = this.host.testCreate(1);
Operation patchOperation = Operation.createPatch(UriUtils.buildUri(this.host, serviceUri)).setBody(patchBody).setCompletion(ctx.getCompletion());
this.host.send(patchOperation);
this.testWait(ctx);
return patchOperation.getStatusCode();
}
Aggregations