public static void validateCopy(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if ( (action.getStorageDomain()==null || action.getStorageDomain().getId()==null) && (action.getStorageDomain()==null || action.getStorageDomain().getName()==null) ) { throw new ValidationException("Parameters 'storage_domain.id' or 'storage_domain.name' are mandatory but both were not provided."); } }
to.setStorageDomain(adaptOut(from.getStorageDomain()));
public static void validateExport(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if ( (action.getStorageDomain()==null || action.getStorageDomain().getId()==null) && (action.getStorageDomain()==null || action.getStorageDomain().getName()==null) ) { throw new ValidationException("Parameters 'storage_domain.id' or 'storage_domain.name' are mandatory but both were not provided."); } }
public static void validateCopy(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if ( (action.getStorageDomain()==null || action.getStorageDomain().getId()==null) && (action.getStorageDomain()==null || action.getStorageDomain().getName()==null) ) { throw new ValidationException("Parameters 'storage_domain.id' or 'storage_domain.name' are mandatory but both were not provided."); } }
public static void validateImport(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if ( (action.getStorageDomain()==null || action.getStorageDomain().getId()==null) && (action.getStorageDomain()==null || action.getStorageDomain().getName()==null) ) { throw new ValidationException("Parameters 'storage_domain.id' or 'storage_domain.name' are mandatory but both were not provided."); } }
public static void validateImport(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if ( (action.getStorageDomain()==null || action.getStorageDomain().getId()==null) && (action.getStorageDomain()==null || action.getStorageDomain().getName()==null) ) { throw new ValidationException("Parameters 'storage_domain.id' or 'storage_domain.name' are mandatory but both were not provided."); } }
public static void validateExport(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if ( (action.getStorageDomain()==null || action.getStorageDomain().getId()==null) && (action.getStorageDomain()==null || action.getStorageDomain().getName()==null) ) { throw new ValidationException("Parameters 'storage_domain.id' or 'storage_domain.name' are mandatory but both were not provided."); } }
public static void validateMove(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if ( (action.getStorageDomain()==null || action.getStorageDomain().getId()==null) && (action.getStorageDomain()==null || action.getStorageDomain().getName()==null) ) { throw new ValidationException("Parameters 'storage_domain.id' or 'storage_domain.name' are mandatory but both were not provided."); } }
protected Guid getDestStorageDomainId(Action action) { if (action.getStorageDomain().isSetId()) { return asGuid(action.getStorageDomain().getId()); } else { return parent.lookupStorageDomainIdByName(action.getStorageDomain().getName()); } }
protected Guid getStorageDomainId(Action action) { if (action.getStorageDomain().isSetId()) { return asGuid(action.getStorageDomain().getId()); } else { return lookupStorageDomainIdByName(action.getStorageDomain().getName()); } }
public Guid getStoragePoolId(Action action) { if(action.getStorageDomain().isSetId()){ return getDataCenterId(Guid.createGuidFromStringDefaultEmpty(action.getStorageDomain().getId())); } else { return getDataCenterId(lookupStorageDomainIdByName(action.getStorageDomain().getName())); } }
public static Method getExportSignature(Action action) throws NoSuchMethodException, SecurityException { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } /** * to_path_on_host */ if (action!=null && (action.getHost()!=null && action.getHost().getId()!=null || action.getHost()!=null && action.getHost().getName()!=null) && action.getDirectory()!=null ) { return TemplateResource.class.getMethod("exportToPathOnHost", Action.class); } /** * to_export_domain */ if (action!=null && (action.getStorageDomain()!=null && action.getStorageDomain().getId()!=null || action.getStorageDomain()!=null && action.getStorageDomain().getName()!=null) ) { return TemplateResource.class.getMethod("exportToExportDomain", Action.class); } throw new ValidationException("No matching signature found, make sure that mandatory attributes are provided."); }
public static Method getExportSignature(Action action) throws NoSuchMethodException, SecurityException { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } /** * to_path_on_host */ if (action!=null && (action.getHost()!=null && action.getHost().getId()!=null || action.getHost()!=null && action.getHost().getName()!=null) && action.getDirectory()!=null ) { return VmResource.class.getMethod("exportToPathOnHost", Action.class); } /** * to_export_domain */ if (action!=null && (action.getStorageDomain()!=null && action.getStorageDomain().getId()!=null || action.getStorageDomain()!=null && action.getStorageDomain().getName()!=null) ) { return VmResource.class.getMethod("exportToExportDomain", Action.class); } throw new ValidationException("No matching signature found, make sure that mandatory attributes are provided."); }
@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)); }
@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 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))); }