Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> PreferredStoragePool = new ConfigKey<String>(String.class, "preferred.storage.pool", "Advanced", "",
"The UUID of preferred storage pool for allocation.", true, ConfigKey.Scope.Account, null);
ConfigKey<String> PreferredStoragePool = new ConfigKey<>(String.class, "preferred.storage.pool", "Advanced", "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can have two configurations with same key

  • 1 for global/zone/cluster
  • 2 for global/domain/account

changing from Account to Cluster may be disliked by some users (maybe)

"The UUID of preferred storage pool for allocation.", true, ConfigKey.Scope.Cluster, null);

ConfigKey<Boolean> MountDisabledStoragePool = new ConfigKey<>(Boolean.class,
"mount.disabled.storage.pool",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,20 @@ private Optional<StoragePool> getMatchingStoragePool(String preferredPoolId, Lis
}

private Optional<StoragePool> getPreferredStoragePool(List<StoragePool> 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> storagePool = getMatchingStoragePool(accountStoragePoolUuid, poolList);
Optional<StoragePool> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1903,11 +1903,17 @@ private Optional<StoragePool> getMatchingStoragePool(String preferredPoolId, Lis
}

private Optional<StoragePool> getPreferredStoragePool(List<StoragePool> poolList, VirtualMachine vm) {
String accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());
Optional<StoragePool> storagePool = getMatchingStoragePool(accountStoragePoolUuid, poolList);
Optional<StoragePool> 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: "
logger.debug("A storage pool is specified for this cluster, so we will use this storage pool for allocation: "
+ storagePool.get().getUuid());
} else {
String globalStoragePoolUuid = StorageManager.PreferredStoragePool.value();
Expand Down