This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.19 by this push:
new 503ae64a3db Upload volume format check with the supported hypervisor,
fail if supported hypervisor not found on zone (#9224)
503ae64a3db is described below
commit 503ae64a3db711c8cffc5e41251f46706a83beb5
Author: Suresh Kumar Anaparti <[email protected]>
AuthorDate: Wed Jun 12 15:10:29 2024 +0530
Upload volume format check with the supported hypervisor, fail if supported
hypervisor not found on zone (#9224)
---
.../main/java/com/cloud/storage/VolumeApiServiceImpl.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
index 02add0db174..1cf069feae8 100644
--- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
@@ -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();
}