@Test public void testCloneVm() { 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()); }
@Test public void testStartWithVm() { 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); }
protected void testStartWithHost(Host host, Guid hostId) { 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)); }
private void testStartWithModifiedGraphics(GraphicsType graphicsType) { setUpWindowsGetEntityExpectations(1, false); setUriInfo(setUpActionExpectations(ActionType.RunVmOnce, RunVmOnceParams.class, new String[] { "VmId", "RunOnceGraphics" }, new Object[] { GUIDS[0], Collections.singleton(graphicsType) })); Action action = new Action(); action.setVm(new Vm()); action.getVm().setDisplay(new Display()); DisplayType display = (graphicsType == GraphicsType.VNC) ? DisplayType.VNC : DisplayType.SPICE; action.getVm().getDisplay().setType(display); verifyActionResponse(resource.start(action)); }
@Test public void testStartWithPauseAndStateless() { 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)); }
@Test public void testStartWithCdRomAndFloppy() { 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)); }
@Test public void testStartWithBootDev() { setUpWindowsGetEntityExpectations(1, false); setUriInfo(setUpActionExpectations(ActionType.RunVmOnce, RunVmOnceParams.class, new String[] { "VmId", "BootSequence" }, new Object[] { GUIDS[0], BootSequence.N })); Action action = new Action(); action.setVm(new Vm()); action.getVm().setOs(new OperatingSystem()); action.getVm().getOs().setBoot(new Boot()); action.getVm().getOs().getBoot().setDevices(new Boot.DevicesList()); action.getVm().getOs().getBoot().getDevices().getDevices().add(BootDevice.NETWORK); verifyActionResponse(resource.start(action)); }
@Test public void testImportWithDiskWithoutId() { 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); verifyIncompleteException( assertThrows(WebApplicationException.class, () -> resource.doImport(action)), "Disk", "setVolumesTypeFormat", "id"); }
@Test public void testStartWithBootMenu() { 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)); }
to.setVm(adaptIn(from.getVm()));