private Action setUpParams(boolean byName) { Action action = new Action(); StorageDomain sd = new StorageDomain(); if (byName) { sd.setName(NAMES[2]); } else { sd.setId(GUIDS[3].toString()); } action.setStorageDomain(sd); return action; } }
to.setStorageDomain(adaptIn(from.getStorageDomain()));
private Action setUpCopyParams(boolean byName) { Action action = new Action(); StorageDomain sd = new StorageDomain(); if (byName) { sd.setName(NAMES[2]); } else { sd.setId(GUIDS[3].toString()); } action.setStorageDomain(sd); return action; }
private Action setUpMoveParams(boolean byName) { Action action = new Action(); StorageDomain sd = new StorageDomain(); if (byName) { sd.setName(NAMES[2]); } else { sd.setId(GUIDS[3].toString()); } action.setStorageDomain(sd); return action; }
protected void doTestExport(StorageDomain storageDomain, boolean exclusive) { setUriInfo(setUpActionExpectations(ActionType.ExportVmTemplate, MoveOrCopyParameters.class, new String[]{"ContainerId", "StorageDomainId", "ForceOverride"}, new Object[]{GUIDS[0], GUIDS[2], exclusive})); Action action = new Action(); action.setStorageDomain(storageDomain); if (exclusive) { action.setExclusive(exclusive); } verifyActionResponse(resource.export(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)); }
protected void doTestExport(StorageDomain storageDomain, boolean exclusive, boolean discardSnapshots) { setUriInfo(setUpActionExpectations(ActionType.ExportVm, MoveOrCopyParameters.class, new String[] { "ContainerId", "StorageDomainId", "ForceOverride", "CopyCollapse" }, new Object[] { GUIDS[0], GUIDS[2], exclusive, discardSnapshots })); Action action = new Action(); action.setStorageDomain(storageDomain); if (exclusive) { action.setExclusive(exclusive); } if (discardSnapshots) { action.setDiscardSnapshots(discardSnapshots); } verifyActionResponse(resource.exportToExportDomain(action)); }
@Test public void testExport() { setUriInfo(setUpActionExpectations(ActionType.ExportRepoImage, ExportRepoImageParameters.class, new String[]{"ImageGroupID", "DestinationDomainId"}, new Object[]{DISK_ID, GUIDS[3]}, true, true, null, null, true)); Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(GUIDS[3].toString()); verifyActionResponse(resource.export(action)); }
@Test public void testExport() { setUriInfo(setUpActionExpectations(ActionType.ExportRepoImage, ExportRepoImageParameters.class, new String[]{"ImageGroupID", "DestinationDomainId"}, new Object[]{DISK_ID, GUIDS[3]}, true, true, null, null, true)); Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(GUIDS[3].toString()); verifyActionResponse(resource.export(action)); }
@Test public void testExport() { setUriInfo(setUpActionExpectations(ActionType.ExportRepoImage, ExportRepoImageParameters.class, new String[]{"ImageGroupID", "DestinationDomainId"}, new Object[]{GUIDS[1], GUIDS[3]}, true, true, null, null, true)); Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(GUIDS[3].toString()); verifyActionResponse(resource.export(action)); }
@Test public void testExport() { setUriInfo( setUpActionExpectations( ActionType.ExportRepoImage, ExportRepoImageParameters.class, new String[] { "ImageGroupID", "DestinationDomainId" }, new Object[] { DISK_ID, GUIDS[3]}, true, true, null, null, true ) ); Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(GUIDS[3].toString()); verifyActionResponse(resource.export(action)); }
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()); }
@Test public void testImport() { setUpEntityQueryExpectations(QueryType.GetStoragePoolsByStorageDomainId, IdQueryParameters.class, new String[]{"Id"}, new Object[]{DESTINATION_DOMAIN_ID}, getStoragePoolList()); setUriInfo(setUpActionExpectations(ActionType.ImportRepoImage, ImportRepoImageParameters.class, new String[]{"SourceRepoImageId", "SourceStorageDomainId", "StoragePoolId", "StorageDomainId"}, new Object[]{IMAGE_ID.toString(), DOMAIN_ID, STORAGE_POOL_ID, DESTINATION_DOMAIN_ID}, true, true, null, null, true)); Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(DESTINATION_DOMAIN_ID.toString()); verifyActionResponse(resource.doImport(action), "storagedomains/" + DOMAIN_ID + "/images/" + IMAGE_ID, false); }
@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()); }