mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Upload volume format check with the supported hypervisor, fail if supported hypervisor not found on zone (#9224)
This commit is contained in:
parent
0f770194df
commit
503ae64a3d
@ -158,6 +158,7 @@ import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.ProjectManager;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.resource.ResourceState;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.server.ManagementService;
|
||||
@ -258,6 +259,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
@Inject
|
||||
private ConfigurationManager _configMgr;
|
||||
@Inject
|
||||
private ResourceManager _resourceMgr;
|
||||
@Inject
|
||||
private VolumeDao _volsDao;
|
||||
@Inject
|
||||
private VolumeDetailsDao _volsDetailsDao;
|
||||
@ -564,7 +567,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
_resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.secondary_storage);
|
||||
}
|
||||
|
||||
sanitizeFormat(format);
|
||||
checkFormatWithSupportedHypervisorsInZone(format, zoneId);
|
||||
|
||||
// Check that the disk offering specified is valid
|
||||
if (diskOfferingId != null) {
|
||||
@ -581,6 +584,15 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
return false;
|
||||
}
|
||||
|
||||
private void checkFormatWithSupportedHypervisorsInZone(String format, Long zoneId) {
|
||||
ImageFormat imageformat = ImageFormat.valueOf(format);
|
||||
final List<HypervisorType> supportedHypervisorTypesInZone = _resourceMgr.getSupportedHypervisorTypes(zoneId, false, null);
|
||||
final HypervisorType hypervisorTypeFromFormat = ApiDBUtils.getHypervisorTypeFromFormat(zoneId, imageformat);
|
||||
if (!(supportedHypervisorTypesInZone.contains(hypervisorTypeFromFormat))) {
|
||||
throw new InvalidParameterValueException(String.format("The %s hypervisor supported for %s file format, is not found on the zone", hypervisorTypeFromFormat.toString(), format));
|
||||
}
|
||||
}
|
||||
|
||||
public String getRandomVolumeName() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user