Search in sources :

Example 91 with Action

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

the class BackendVmResourceTest method testStartWithBootMenu.

@Test
public void testStartWithBootMenu() throws Exception {
    setUpWindowsGetEntityExpectations(1, false);
    setUriInfo(setUpActionExpectations(ActionType.RunVmOnce, RunVmOnceParams.class, new String[] { "VmId", "BootMenuEnabled" }, new Object[] { GUIDS[0], true }));
    Action action = new Action();
    action.setVm(new Vm());
    action.getVm().setBios(new Bios());
    action.getVm().getBios().setBootMenu(new BootMenu());
    action.getVm().getBios().getBootMenu().setEnabled(true);
    verifyActionResponse(resource.start(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) RunVmOnceParams(org.ovirt.engine.core.common.action.RunVmOnceParams) BootMenu(org.ovirt.engine.api.model.BootMenu) Bios(org.ovirt.engine.api.model.Bios) Vm(org.ovirt.engine.api.model.Vm) Test(org.junit.Test)

Example 92 with Action

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

the class BackendVmResourceTest method testStartWithCdRomAndFloppy.

@Test
public void testStartWithCdRomAndFloppy() throws Exception {
    setUpWindowsGetEntityExpectations(1, false);
    setUriInfo(setUpActionExpectations(ActionType.RunVmOnce, RunVmOnceParams.class, new String[] { "VmId", "DiskPath", "FloppyPath" }, new Object[] { GUIDS[0], ISO_ID, FLOPPY_ID }));
    Action action = new Action();
    action.setVm(new Vm());
    action.getVm().setCdroms(new Cdroms());
    action.getVm().getCdroms().getCdroms().add(new Cdrom());
    action.getVm().getCdroms().getCdroms().get(0).setFile(new File());
    action.getVm().getCdroms().getCdroms().get(0).getFile().setId(ISO_ID);
    action.getVm().setFloppies(new Floppies());
    action.getVm().getFloppies().getFloppies().add(new Floppy());
    action.getVm().getFloppies().getFloppies().get(0).setFile(new File());
    action.getVm().getFloppies().getFloppies().get(0).getFile().setId(FLOPPY_ID);
    verifyActionResponse(resource.start(action));
}
Also used : Cdrom(org.ovirt.engine.api.model.Cdrom) Action(org.ovirt.engine.api.model.Action) RunVmOnceParams(org.ovirt.engine.core.common.action.RunVmOnceParams) Floppies(org.ovirt.engine.api.model.Floppies) Vm(org.ovirt.engine.api.model.Vm) Floppy(org.ovirt.engine.api.model.Floppy) File(org.ovirt.engine.api.model.File) Cdroms(org.ovirt.engine.api.model.Cdroms) Test(org.junit.Test)

Example 93 with Action

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

the class BackendVmResourceTest method testStartWithHost.

protected void testStartWithHost(Host host, Guid hostId) throws Exception {
    setUpWindowsGetEntityExpectations(1, false);
    setUriInfo(setUpActionExpectations(ActionType.RunVmOnce, RunVmOnceParams.class, new String[] { "VmId", "DestinationVdsId" }, new Object[] { GUIDS[0], hostId }));
    Action action = new Action();
    action.setVm(new Vm());
    VmPlacementPolicy placementPolicy = new VmPlacementPolicy();
    placementPolicy.setHosts(new Hosts());
    placementPolicy.getHosts().getHosts().add(host);
    action.getVm().setPlacementPolicy(placementPolicy);
    verifyActionResponse(resource.start(action));
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) Action(org.ovirt.engine.api.model.Action) RunVmOnceParams(org.ovirt.engine.core.common.action.RunVmOnceParams) Vm(org.ovirt.engine.api.model.Vm) VmPlacementPolicy(org.ovirt.engine.api.model.VmPlacementPolicy)

Example 94 with Action

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

the class BackendVmResourceTest method testStartWithPauseAndStateless.

@Test
public void testStartWithPauseAndStateless() throws Exception {
    setUpWindowsGetEntityExpectations(1, false);
    setUriInfo(setUpActionExpectations(ActionType.RunVmOnce, RunVmOnceParams.class, new String[] { "VmId", "RunAndPause", "RunAsStateless" }, new Object[] { GUIDS[0], true, Boolean.TRUE }));
    Action action = new Action();
    action.setPause(true);
    action.setVm(new Vm());
    action.getVm().setStateless(true);
    verifyActionResponse(resource.start(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) RunVmOnceParams(org.ovirt.engine.core.common.action.RunVmOnceParams) Vm(org.ovirt.engine.api.model.Vm) Test(org.junit.Test)

Example 95 with Action

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

the class ActionMapper method map.

@Mapping(from = List.class, to = Action.class)
public static Action map(List<AsyncTaskStatus> entity, Action template) {
    Action model = template != null ? template : new Action();
    CreationStatus asyncStatus = null;
    for (AsyncTaskStatus task : entity) {
        asyncStatus = AsyncTaskMapper.map(task, asyncStatus);
    }
    model.setStatus(asyncStatus.value());
    if (asyncStatus == CreationStatus.FAILED) {
        model.setFault(new Fault());
        for (AsyncTaskStatus task : entity) {
            if (task.getException() != null) {
                model.getFault().setDetail(task.getException().toString());
                break;
            }
        }
    }
    return model;
}
Also used : Action(org.ovirt.engine.api.model.Action) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Fault(org.ovirt.engine.api.model.Fault) CreationStatus(org.ovirt.engine.api.model.CreationStatus)

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