Search in sources :

Example 36 with Action

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

the class BackendVmResourceTest method testPreviewSnapshot.

@Test
public void testPreviewSnapshot() throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.TryBackToAllSnapshotsOfVm, TryBackToAllSnapshotsOfVmParameters.class, new String[] { "VmId", "DstSnapshotId" }, new Object[] { GUIDS[0], GUIDS[1] }));
    Action action = new Action();
    Snapshot snapshot = new Snapshot();
    snapshot.setId(GUIDS[1].toString());
    action.setSnapshot(snapshot);
    Response response = resource.previewSnapshot(action);
    verifyActionResponse(response);
    Action actionResponse = (Action) response.getEntity();
    assertTrue(actionResponse.isSetStatus());
    assertEquals(CreationStatus.COMPLETE.value(), actionResponse.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) Snapshot(org.ovirt.engine.api.model.Snapshot) Action(org.ovirt.engine.api.model.Action) TryBackToAllSnapshotsOfVmParameters(org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters) Test(org.junit.Test)

Example 37 with Action

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

the class BackendVmResourceTest method testCloneVm.

@Test
public void testCloneVm() throws Exception {
    org.ovirt.engine.core.common.businessentities.VM mockedVm = mock(org.ovirt.engine.core.common.businessentities.VM.class);
    VmStatic vmStatic = mock(VmStatic.class);
    when(mockedVm.getStaticData()).thenReturn(vmStatic);
    setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, mockedVm);
    setUriInfo(setUpActionExpectations(ActionType.CloneVm, CloneVmParameters.class, new String[] { "VmStaticData", "NewName" }, new Object[] { vmStatic, "someNewName" }));
    Action action = new Action();
    Vm vm = new Vm();
    vm.setName("someNewName");
    action.setVm(vm);
    Response response = resource.doClone(action);
    verifyActionResponse(response);
    Action actionResponse = (Action) response.getEntity();
    assertTrue(actionResponse.isSetStatus());
}
Also used : Response(javax.ws.rs.core.Response) Action(org.ovirt.engine.api.model.Action) Vm(org.ovirt.engine.api.model.Vm) CloneVmParameters(org.ovirt.engine.core.common.action.CloneVmParameters) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 38 with Action

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

the class BackendVmResourceTest method doTestSuspendAsync.

private void doTestSuspendAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.HibernateVm, VmOperationParameterBase.class, new String[] { "VmId" }, new Object[] { GUIDS[0] }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus))));
    Response response = resource.suspend(new Action());
    verifyActionResponse(response, "vms/" + GUIDS[0], true, null);
    Action action = (Action) response.getEntity();
    assertTrue(action.isSetStatus());
    assertEquals(actionStatus.value(), action.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) Action(org.ovirt.engine.api.model.Action) VmOperationParameterBase(org.ovirt.engine.core.common.action.VmOperationParameterBase) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)

Example 39 with Action

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

the class BackendVmResourceTest method testMaintenance.

@Test
public void testMaintenance() throws Exception {
    setUpGetEntityExpectations(1);
    setUriInfo(setUpActionExpectations(ActionType.SetHaMaintenance, SetHaMaintenanceParameters.class, new String[] { "IsEnabled" }, new Object[] { true }));
    Action action = new Action();
    action.setMaintenanceEnabled(true);
    verifyActionResponse(resource.maintenance(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) SetHaMaintenanceParameters(org.ovirt.engine.core.common.action.SetHaMaintenanceParameters) Test(org.junit.Test)

Example 40 with Action

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

the class BackendVmResourceTest method testMigrateWithClusterId.

@Test
public void testMigrateWithClusterId() throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.MigrateVm, MigrateVmParameters.class, new String[] { "VmId", "ForceMigrationForNonMigratableVm", "TargetClusterId" }, new Object[] { GUIDS[0], Boolean.FALSE, GUIDS[1] }));
    Action action = new Action();
    org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster();
    cluster.setId(GUIDS[1].toString());
    action.setCluster(cluster);
    verifyActionResponse(resource.migrate(action));
}
Also used : MigrateVmParameters(org.ovirt.engine.core.common.action.MigrateVmParameters) Action(org.ovirt.engine.api.model.Action) 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