@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 testUndoSnapshot() { setUriInfo(setUpActionExpectations(ActionType.RestoreAllSnapshots, RestoreAllSnapshotsParameters.class, new String[] { "VmId", "SnapshotAction" }, new Object[] { GUIDS[0], SnapshotActionEnum.UNDO })); Response response = resource.undoSnapshot(new Action()); verifyActionResponse(response); Action action = (Action)response.getEntity(); assertTrue(action.isSetStatus()); assertEquals(CreationStatus.COMPLETE.value(), action.getStatus()); }
@Test public void testCommitSnapshot() { setUriInfo(setUpActionExpectations(ActionType.RestoreAllSnapshots, RestoreAllSnapshotsParameters.class, new String[] { "VmId", "SnapshotAction" }, new Object[] { GUIDS[0], SnapshotActionEnum.COMMIT })); Response response = resource.commitSnapshot(new Action()); verifyActionResponse(response); Action action = (Action)response.getEntity(); assertTrue(action.isSetStatus()); assertEquals(CreationStatus.COMPLETE.value(), action.getStatus()); }
private void doTestSuspendAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) { 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()); }
private void doTestActivateAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) { setUriInfo(setUpActionExpectations(ActionType.ActivateVds, VdsActionParameters.class, new String[] { "VdsId" }, new Object[] { GUIDS[0] }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus)))); Response response = resource.activate(new Action()); verifyActionResponse(response, "hosts/" + GUIDS[0], true, null); Action action = (Action)response.getEntity(); assertTrue(action.isSetStatus()); assertEquals(actionStatus.value(), action.getStatus()); }
private void doTestActivateAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) { setUriInfo( setUpActionExpectations( ActionType.ActivateStorageDomain, StorageDomainPoolParametersBase.class, new String[] { "StorageDomainId", "StoragePoolId" }, new Object[] { STORAGE_DOMAIN_ID, DATA_CENTER_ID }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus)) ) ); Response response = resource.activate(new Action()); verifyActionResponse( response, "datacenters/" + DATA_CENTER_ID + "/storagedomains/" + STORAGE_DOMAIN_ID, true, null ); Action action = (Action) response.getEntity(); assertTrue(action.isSetStatus()); assertEquals(actionStatus.value(), action.getStatus()); }
@Test public void testPreviewSnapshot() { 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()); }
private void doTestExportAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) { setUriInfo(setUpActionExpectations(ActionType.ExportVmTemplate, MoveOrCopyParameters.class, new String[] { "ContainerId", "StorageDomainId", "ForceOverride" }, new Object[] { GUIDS[0], GUIDS[2], false }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus)))); Action action = new Action(); StorageDomain storageDomain = new StorageDomain(); storageDomain.setId(GUIDS[2].toString()); action.setStorageDomain(storageDomain); Response response = resource.export(action); verifyActionResponse(response, "templates/" + GUIDS[0], true, null); action = (Action)response.getEntity(); assertTrue(action.isSetStatus()); assertEquals(actionStatus.value(), action.getStatus()); }
private void doTestImportAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) { setUpGetEntityExpectations(1, StorageDomainType.ImportExport, GUIDS[2]); setUpGetDataCenterByStorageDomainExpectations(GUIDS[3]); setUriInfo(setUpActionExpectations( ActionType.ImportVm, ImportVmParameters.class, new String[] { "ContainerId", "StorageDomainId", "SourceDomainId", "DestDomainId", "StoragePoolId", "ClusterId" }, new Object[] { VM_ID, GUIDS[2], STORAGE_DOMAIN_ID, GUIDS[2], DATA_CENTER_ID, GUIDS[1] }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus)))); 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()); Action action = new Action(); action.setStorageDomain(storageDomain); action.setCluster(cluster); Response response = resource.doImport(action); verifyActionResponse(response, URL_BASE, true, null); action = (Action)response.getEntity(); assertTrue(action.isSetStatus()); assertEquals(actionStatus.value(), action.getStatus()); }
private void doTestImportAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) { setUpGetEntityExpectations(1, StorageDomainType.ImportExport, GUIDS[2]); setUpGetDataCenterByStorageDomainExpectations(GUIDS[3]); setUriInfo(setUpActionExpectations( ActionType.ImportVmTemplate, ImportVmTemplateParameters.class, new String[] { "ContainerId", "StorageDomainId", "SourceDomainId", "DestDomainId", "StoragePoolId", "ClusterId" }, new Object[] { TEMPLATE_ID, GUIDS[2], STORAGE_DOMAIN_ID, GUIDS[2], DATA_CENTER_ID, GUIDS[1] }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus)))); 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()); Action action = new Action(); action.setStorageDomain(storageDomain); action.setCluster(cluster); Response response = resource.doImport(action); verifyActionResponse(response, URL_BASE, true, null); action = (Action)response.getEntity(); assertTrue(action.isSetStatus()); assertEquals(actionStatus.value(), action.getStatus()); }
to.setSsh(adaptOut(from.getSsh())); if (from.isSetStatus()) { V3Status status = new V3Status(); status.setState(from.getStatus());