Search in sources :

Example 76 with Action

use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.

the class BackendStorageDomainVmResourceTest method doTestRegister.

public void doTestRegister(org.ovirt.engine.api.model.Cluster cluster, boolean importAsNewEntity) throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.ImportVmFromConfiguration, ImportVmFromConfParameters.class, new String[] { "ContainerId", "StorageDomainId", "ClusterId", "ImportAsNewEntity", "ImagesExistOnTargetStorageDomain" }, new Object[] { VM_ID, GUIDS[3], GUIDS[1], importAsNewEntity, true }));
    Action action = new Action();
    action.setCluster(cluster);
    action.setClone(importAsNewEntity);
    verifyActionResponse(resource.register(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) ImportVmFromConfParameters(org.ovirt.engine.core.common.action.ImportVmFromConfParameters)

Example 77 with Action

use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.

the class BackendStorageDomainVmResourceTest method testImportWithDiskWithoutId.

@Test
public void testImportWithDiskWithoutId() throws Exception {
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(GUIDS[2].toString());
    org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster();
    cluster.setId(GUIDS[1].toString());
    setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID);
    setUpGetEntityExpectations(1, StorageDomainType.ImportExport, GUIDS[2]);
    UriInfo uriInfo = setUpBasicUriExpectations();
    uriInfo = addMatrixParameterExpectations(uriInfo, BackendStorageDomainVmResource.COLLAPSE_SNAPSHOTS, Boolean.toString(true));
    setUriInfo(uriInfo);
    Action action = new Action();
    action.setStorageDomain(storageDomain);
    action.setCluster(cluster);
    action.setClone(false);
    Vm vm = new Vm();
    DiskAttachments diskAttachments = new DiskAttachments();
    DiskAttachment diskAttachment = new DiskAttachment();
    diskAttachment.setDisk(new Disk());
    diskAttachments.getDiskAttachments().add(diskAttachment);
    vm.setDiskAttachments(diskAttachments);
    action.setVm(vm);
    try {
        resource.doImport(action);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Disk", "setVolumesTypeFormat", "id");
    }
}
Also used : Action(org.ovirt.engine.api.model.Action) WebApplicationException(javax.ws.rs.WebApplicationException) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) DiskAttachments(org.ovirt.engine.api.model.DiskAttachments) BackendStorageDomainVmsResourceTest.setUpStorageDomain(org.ovirt.engine.api.restapi.resource.BackendStorageDomainVmsResourceTest.setUpStorageDomain) StorageDomain(org.ovirt.engine.api.model.StorageDomain) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) Vm(org.ovirt.engine.api.model.Vm) Disk(org.ovirt.engine.api.model.Disk) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 78 with Action

use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.

the class BackendVmDiskResourceTest method setUpMoveParams.

private Action setUpMoveParams(boolean byName) {
    Action action = new Action();
    StorageDomain sd = new StorageDomain();
    if (byName) {
        sd.setName(NAMES[2]);
    } else {
        sd.setId(GUIDS[3].toString());
    }
    action.setStorageDomain(sd);
    return action;
}
Also used : Action(org.ovirt.engine.api.model.Action) StorageDomain(org.ovirt.engine.api.model.StorageDomain)

Example 79 with Action

use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.

the class BackendVmDiskResourceTest method testActivate.

@Test
public void testActivate() throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.HotPlugDiskToVm, VmDiskOperationParameterBase.class, new String[] { "DiskVmElement" }, new Object[] { new DiskVmElement(DISK_ID, VM_ID) }, true, true));
    Response response = resource.activate(new Action());
    assertEquals(200, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) Action(org.ovirt.engine.api.model.Action) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase) Test(org.junit.Test)

Example 80 with Action

use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.

the class BackendVmDiskResourceTest method testIncompleteExport.

@Test
public void testIncompleteExport() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    try {
        resource.export(new Action());
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Action", "export", "storageDomain.id|name");
    }
}
Also used : Action(org.ovirt.engine.api.model.Action) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Aggregations

Action (org.ovirt.engine.api.model.Action)100 Test (org.junit.Test)70 WebApplicationException (javax.ws.rs.WebApplicationException)17 Response (javax.ws.rs.core.Response)17 StorageDomain (org.ovirt.engine.api.model.StorageDomain)14 Vm (org.ovirt.engine.api.model.Vm)9 AbstractBackendSubResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)9 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)7 RunVmOnceParams (org.ovirt.engine.core.common.action.RunVmOnceParams)6 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)5 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)5 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)4 ExportRepoImageParameters (org.ovirt.engine.core.common.action.ExportRepoImageParameters)4 VmOperationParameterBase (org.ovirt.engine.core.common.action.VmOperationParameterBase)4 UpdateVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters)4 GlusterBricks (org.ovirt.engine.api.model.GlusterBricks)3 Option (org.ovirt.engine.api.model.Option)3 BackendStorageDomainVmsResourceTest.setUpStorageDomain (org.ovirt.engine.api.restapi.resource.BackendStorageDomainVmsResourceTest.setUpStorageDomain)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 ArrayList (java.util.ArrayList)2