diff --git a/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java b/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java index 0b9f7bcb7db4..0327762798df 100644 --- a/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java +++ b/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java @@ -174,8 +174,8 @@ public interface StorageManager extends StorageService { "If set to true, the disk is created only when there is a suitable storage pool that supports the disk provisioning type specified by the service/disk offering. " + "If set to false, the disk is created with a disk provisioning type supported by the pool. Default value is false, and this is currently supported for VMware only.", true, ConfigKey.Scope.Zone); - ConfigKey PreferredStoragePool = new ConfigKey(String.class, "preferred.storage.pool", "Advanced", "", - "The UUID of preferred storage pool for allocation.", true, ConfigKey.Scope.Account, null); + ConfigKey PreferredStoragePool = new ConfigKey<>(String.class, "preferred.storage.pool", "Advanced", "", + "The UUID of preferred storage pool for allocation.", true, ConfigKey.Scope.Cluster, null); ConfigKey MountDisabledStoragePool = new ConfigKey<>(Boolean.class, "mount.disabled.storage.pool", diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index 060619088882..d18c7a01d4cc 100644 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -349,16 +349,20 @@ private Optional getMatchingStoragePool(String preferredPoolId, Lis } private Optional getPreferredStoragePool(List poolList, VirtualMachine vm) { - String accountStoragePoolUuid = null; + String clusterPreferredStoragePoolUuid = null; + Long clusterId = null; if (vm != null) { - accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId()); + HostVO host = _hostDao.findById(vm.getHostId()); + if (host != null) { + clusterId = host.getClusterId(); + clusterPreferredStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(clusterId); + } } - Optional storagePool = getMatchingStoragePool(accountStoragePoolUuid, poolList); + Optional storagePool = getMatchingStoragePool(clusterPreferredStoragePoolUuid, poolList); if (storagePool.isPresent()) { String storagePoolToString = getReflectOnlySelectedFields(storagePool.get()); - logger.debug("The storage pool [{}] was specified for this account [{}] and will be used for allocation.", storagePoolToString, vm.getAccountId()); - + logger.debug("The storage pool [{}] was specified for this cluster [{}] and will be used for allocation.", storagePoolToString, clusterId); } else { String globalStoragePoolUuid = StorageManager.PreferredStoragePool.value(); storagePool = getMatchingStoragePool(globalStoragePoolUuid, poolList); diff --git a/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java index a3c889cd0707..26a2ba9c2955 100644 --- a/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -1917,11 +1917,17 @@ private Optional getMatchingStoragePool(String preferredPoolId, Lis } private Optional getPreferredStoragePool(List poolList, VirtualMachine vm) { - String accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId()); - Optional storagePool = getMatchingStoragePool(accountStoragePoolUuid, poolList); + Optional storagePool = Optional.empty(); + if (vm.getHostId() != null) { + HostVO host = _hostDao.findById(vm.getHostId()); + if (host != null) { + String accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(host.getClusterId()); + storagePool = getMatchingStoragePool(accountStoragePoolUuid, poolList); + } + } if (storagePool.isPresent()) { - logger.debug("A storage pool is specified for this account, so we will use this storage pool for allocation: {}", storagePool.get()); + logger.debug("A storage pool is specified for this cluster, so we will use this storage pool for allocation: {}", storagePool.get()); } else { String globalStoragePoolUuid = StorageManager.PreferredStoragePool.value(); storagePool = getMatchingStoragePool(globalStoragePoolUuid, poolList);