Search in sources :

Example 31 with Vm

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

the class BackendVmResourceTest method testUpdateVmPolicySingleHostName.

@Test
public void testUpdateVmPolicySingleHostName() throws Exception {
    setUpUdpateVm();
    setUpGetHostByNameExpectations(1);
    setUriInfo(setUpActionExpectations(ActionType.UpdateVm, VmManagementParametersBase.class, new String[] {}, new Object[] {}, true, true));
    Vm model = getModel(0);
    model.setPlacementPolicy(new VmPlacementPolicy());
    model.getPlacementPolicy().setHosts(new Hosts());
    model.getPlacementPolicy().getHosts().getHosts().add(new Host());
    model.getPlacementPolicy().getHosts().getHosts().get(0).setName(NAMES[1]);
    verifyModel(resource.update(model), 0);
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) Vm(org.ovirt.engine.api.model.Vm) Host(org.ovirt.engine.api.model.Host) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VmPlacementPolicy(org.ovirt.engine.api.model.VmPlacementPolicy) Test(org.junit.Test)

Example 32 with Vm

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

the class BackendVmResourceTest method testGet.

@Test
public void testGet() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpGetEntityExpectations(1);
    setUpGetPayloadExpectations(0, 1);
    setUpGetBallooningExpectations();
    setUpGetGraphicsExpectations(1);
    setUpGetCertuficateExpectations();
    Vm response = resource.get();
    verifyModel(response, 0);
    verifyCertificate(response);
}
Also used : Vm(org.ovirt.engine.api.model.Vm) Test(org.junit.Test)

Example 33 with Vm

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

the class BackendVmResourceTest method testUpdateVmPolicyHostsNames.

@Test
public void testUpdateVmPolicyHostsNames() throws Exception {
    setUpUdpateVm();
    for (int i = 0; i < NAMES.length; i++) {
        setUpGetHostByNameExpectations(i);
    }
    setUriInfo(setUpActionExpectations(ActionType.UpdateVm, VmManagementParametersBase.class, new String[] {}, new Object[] {}, true, true));
    Vm model = getModel(0);
    model.setPlacementPolicy(new VmPlacementPolicy());
    Hosts hosts = new Hosts();
    for (int i = 0; i < NAMES.length; i++) {
        Host newHost = new Host();
        newHost.setName(NAMES[i]);
        hosts.getHosts().add(newHost);
    }
    model.getPlacementPolicy().setHosts(hosts);
    verifyModel(resource.update(model), 0);
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) Vm(org.ovirt.engine.api.model.Vm) Host(org.ovirt.engine.api.model.Host) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VmPlacementPolicy(org.ovirt.engine.api.model.VmPlacementPolicy) Test(org.junit.Test)

Example 34 with Vm

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

the class BackendVmResourceTest method testStartWithVm.

@Test
public void testStartWithVm() throws Exception {
    setUpWindowsGetEntityExpectations(1, false);
    setUriInfo(setUpActionExpectations(ActionType.RunVmOnce, RunVmOnceParams.class, new String[] { "VmId" }, new Object[] { GUIDS[0] }));
    Action action = new Action();
    action.setVm(new Vm());
    Response response = resource.start(action);
    verifyActionResponse(response);
    verifyActionModel(((Action) response.getEntity()).getVm(), 0);
}
Also used : Response(javax.ws.rs.core.Response) 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 35 with Vm

use of org.ovirt.engine.api.model.Vm 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)

Aggregations

Vm (org.ovirt.engine.api.model.Vm)145 Test (org.junit.Test)80 Response (javax.ws.rs.core.Response)26 Host (org.ovirt.engine.api.model.Host)21 WebApplicationException (javax.ws.rs.WebApplicationException)19 Guid (org.ovirt.engine.core.compat.Guid)15 Template (org.ovirt.engine.api.model.Template)11 Hosts (org.ovirt.engine.api.model.Hosts)10 Action (org.ovirt.engine.api.model.Action)9 VmPlacementPolicy (org.ovirt.engine.api.model.VmPlacementPolicy)9 Vms (org.ovirt.engine.api.model.Vms)8 RunVmOnceParams (org.ovirt.engine.core.common.action.RunVmOnceParams)8 VM (org.ovirt.engine.core.common.businessentities.VM)8 Disk (org.ovirt.engine.api.model.Disk)7 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)7 ArrayList (java.util.ArrayList)6 Nic (org.ovirt.engine.api.model.Nic)6 VmManagementParametersBase (org.ovirt.engine.core.common.action.VmManagementParametersBase)6 Configuration (org.ovirt.engine.api.model.Configuration)5 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)5