public void doTestRegister(org.ovirt.engine.api.model.Cluster cluster, boolean importAsNewEntity) { setUriInfo(setUpActionExpectations(ActionType.ImportVmTemplateFromConfiguration, ImportVmTemplateFromConfParameters.class, new String[] { "ContainerId", "StorageDomainId", "ClusterId", "ImportAsNewEntity", "ImagesExistOnTargetStorageDomain" }, new Object[] { TEMPLATE_ID, GUIDS[3], GUIDS[1], importAsNewEntity, true })); Action action = new Action(); action.setCluster(cluster); action.setClone(importAsNewEntity); verifyActionResponse(resource.register(action)); }
public void doTestRegister(org.ovirt.engine.api.model.Cluster cluster, boolean importAsNewEntity) { setUriInfo(setUpActionExpectations(ActionType.ImportVmFromConfiguration, ImportVmFromConfParameters.class, new String[] { "ContainerId", "StorageDomainId", "ClusterId", "ImportAsNewEntity", "ImagesExistOnTargetStorageDomain" }, new Object[] { VM_ID, GUIDS[3], GUIDS[1], importAsNewEntity, true })); Action action = new Action(); action.setCluster(cluster); action.setClone(importAsNewEntity); verifyActionResponse(resource.register(action)); }
public void doTestImport(StorageDomain storageDomain, org.ovirt.engine.api.model.Cluster cluster, boolean importAsNewEntity) { setUpGetEntityExpectations(1, StorageDomainType.ImportExport, GUIDS[2]); setUriInfo(setUpActionExpectations(ActionType.ImportVmTemplate, ImportVmTemplateParameters.class, new String[] { "ContainerId", "StorageDomainId", "SourceDomainId", "DestDomainId", "StoragePoolId", "ClusterId", "ImportAsNewEntity" }, new Object[] { TEMPLATE_ID, GUIDS[2], STORAGE_DOMAIN_ID, GUIDS[2], DATA_CENTER_ID, GUIDS[1], importAsNewEntity })); Action action = new Action(); action.setStorageDomain(storageDomain); action.setCluster(cluster); action.setClone(importAsNewEntity); verifyActionResponse(resource.doImport(action)); }
public void doTestImport(StorageDomain storageDomain, org.ovirt.engine.api.model.Cluster cluster, boolean collapseSnapshots, boolean importAsNewEntity) { setUpGetEntityExpectations(1, StorageDomainType.ImportExport, GUIDS[2]); UriInfo uriInfo = setUpActionExpectations( ActionType.ImportVm, ImportVmParameters.class, new String[] { "ContainerId", "StorageDomainId", "SourceDomainId", "DestDomainId", "StoragePoolId", "ClusterId", "CopyCollapse", "ImportAsNewEntity" }, new Object[] { VM_ID, GUIDS[2], STORAGE_DOMAIN_ID, GUIDS[2], DATA_CENTER_ID, GUIDS[1], collapseSnapshots, importAsNewEntity }, true, // valid, true, // success null, // taskReturn null, // baseUri false //replay ); uriInfo = addMatrixParameterExpectations(uriInfo, BackendStorageDomainVmResource.COLLAPSE_SNAPSHOTS, Boolean.toString(collapseSnapshots)); setUriInfo(uriInfo); Action action = new Action(); action.setStorageDomain(storageDomain); action.setCluster(cluster); action.setClone(importAsNewEntity); verifyActionResponse(resource.doImport(action)); }
@Test public void testMigrateWithClusterId() { 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)); }
@Test public void testImportNotFound() { Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(GUIDS[2].toString()); action.setCluster(new org.ovirt.engine.api.model.Cluster()); action.getCluster().setId(GUIDS[1].toString()); setUpGetEntityExpectations(StorageDomainType.ImportExport, STORAGE_DOMAIN_ID, true); verifyNotFoundException(assertThrows(WebApplicationException.class, () -> resource.doImport(action))); }
@Test public void testImportNotFound() { Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(GUIDS[2].toString()); action.setCluster(new org.ovirt.engine.api.model.Cluster()); action.getCluster().setId(GUIDS[1].toString()); setUpGetEntityExpectations(StorageDomainType.ImportExport, GUIDS[2], true); setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID); verifyNotFoundException(assertThrows(WebApplicationException.class, () -> resource.doImport(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"); }
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()); }
@Test public void testApproveChangingCluster() { setUpGetEntityExpectations(4); setUriInfo(setUpActionExpectations(ActionType.ChangeVDSCluster, ChangeVDSClusterParameters.class, new String[] { "ClusterId", "VdsId" }, new Object[] { GUIDS[0], GUIDS[0]}, true, true, new ActionReturnValue(), false)); setUriInfo(setUpActionExpectations(ActionType.UpdateVds, UpdateVdsActionParameters.class, new String[] { }, new Object[] { }, true, true)); setUriInfo(setUpActionExpectations(ActionType.ApproveVds, ApproveVdsParameters.class, new String[] { "VdsId" }, new Object[] { GUIDS[0] })); org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster(); cluster.setId(GUIDS[0].toString()); Action action = new Action(); action.setCluster(cluster); verifyActionResponse(resource.approve(action)); }
to.setCluster(adaptIn(from.getCluster()));