Search in sources :

Example 56 with Operation

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);
}
Also used : TestRequestSender(com.vmware.xenon.common.test.TestRequestSender) Operation(com.vmware.xenon.common.Operation) ResourceOperation(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperation)

Example 57 with Operation

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;
    }
}
Also used : QueryTask(com.vmware.xenon.services.common.QueryTask) Operation(com.vmware.xenon.common.Operation) ImageService(com.vmware.photon.controller.model.resources.ImageService)

Example 58 with Operation

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;
    }
}
Also used : QueryTask(com.vmware.xenon.services.common.QueryTask) Operation(com.vmware.xenon.common.Operation) ImageService(com.vmware.photon.controller.model.resources.ImageService)

Example 59 with Operation

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);
}
Also used : Operation(com.vmware.xenon.common.Operation) BaseModelTest(com.vmware.photon.controller.model.helpers.BaseModelTest) Test(org.junit.Test)

Example 60 with Operation

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();
}
Also used : TestContext(com.vmware.xenon.common.test.TestContext) Operation(com.vmware.xenon.common.Operation)

Aggregations

Operation (com.vmware.xenon.common.Operation)391 URI (java.net.URI)142 ArrayList (java.util.ArrayList)132 QueryTask (com.vmware.xenon.services.common.QueryTask)118 List (java.util.List)118 Utils (com.vmware.xenon.common.Utils)111 StatelessService (com.vmware.xenon.common.StatelessService)108 UriUtils (com.vmware.xenon.common.UriUtils)106 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)98 Map (java.util.Map)92 HashMap (java.util.HashMap)90 OperationJoin (com.vmware.xenon.common.OperationJoin)86 Query (com.vmware.xenon.services.common.QueryTask.Query)86 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)82 Collectors (java.util.stream.Collectors)79 HashSet (java.util.HashSet)78 AuthCredentialsServiceState (com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState)73 AdapterUtils (com.vmware.photon.controller.model.adapters.util.AdapterUtils)70 DeferredResult (com.vmware.xenon.common.DeferredResult)69 Consumer (java.util.function.Consumer)69