From 32ac5d0ceafaf5885448fe41b639dacdc129b48f Mon Sep 17 00:00:00 2001 From: nvazquez Date: Fri, 11 Feb 2022 10:46:56 -0300 Subject: [PATCH 1/2] [Simulator] Add zone wide storage --- server/src/main/java/com/cloud/storage/StorageManagerImpl.java | 2 +- ui/src/views/infra/AddPrimaryStorage.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java index 3522bb093dfd..af7007c051d5 100644 --- a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java @@ -776,7 +776,7 @@ public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws Resource throw new InvalidParameterValueException("Missing parameter hypervisor. Hypervisor type is required to create zone wide primary storage."); } if (hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.Hyperv && hypervisorType != HypervisorType.LXC - && hypervisorType != HypervisorType.Any) { + && hypervisorType != HypervisorType.Any && hypervisorType != HypervisorType.Simulator) { throw new InvalidParameterValueException("zone wide storage pool is not supported for hypervisor type " + hypervisor); } } else { diff --git a/ui/src/views/infra/AddPrimaryStorage.vue b/ui/src/views/infra/AddPrimaryStorage.vue index dbab19ea9e20..3a38975393e9 100644 --- a/ui/src/views/infra/AddPrimaryStorage.vue +++ b/ui/src/views/infra/AddPrimaryStorage.vue @@ -313,7 +313,7 @@ export default { inject: ['parentFetchData'], data () { return { - hypervisors: ['KVM', 'VMware', 'Hyperv', 'Any'], + hypervisors: ['KVM', 'VMware', 'Hyperv', 'Any', 'Simulator'], protocols: [], providers: [], scope: 'cluster', From 10ee9c2a019d9529dec26f886cde208dee99e867 Mon Sep 17 00:00:00 2001 From: nvazquez Date: Tue, 15 Feb 2022 01:11:16 -0300 Subject: [PATCH 2/2] Refactor --- .../main/java/com/cloud/storage/StorageManagerImpl.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java index af7007c051d5..b1a33c0d31cd 100644 --- a/server/src/main/java/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/main/java/com/cloud/storage/StorageManagerImpl.java @@ -50,6 +50,7 @@ import com.cloud.network.router.VirtualNetworkApplianceManager; import com.cloud.server.StatsCollector; import com.cloud.upgrade.SystemVmTemplateRegistration; +import com.google.common.collect.Sets; import org.apache.cloudstack.annotation.AnnotationService; import org.apache.cloudstack.annotation.dao.AnnotationDao; import org.apache.cloudstack.api.ApiConstants; @@ -775,9 +776,11 @@ public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws Resource } else { throw new InvalidParameterValueException("Missing parameter hypervisor. Hypervisor type is required to create zone wide primary storage."); } - if (hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.Hyperv && hypervisorType != HypervisorType.LXC - && hypervisorType != HypervisorType.Any && hypervisorType != HypervisorType.Simulator) { - throw new InvalidParameterValueException("zone wide storage pool is not supported for hypervisor type " + hypervisor); + + Set supportedHypervisorTypes = Sets.newHashSet(HypervisorType.KVM, HypervisorType.VMware, + HypervisorType.Hyperv, HypervisorType.LXC, HypervisorType.Any, HypervisorType.Simulator); + if (!supportedHypervisorTypes.contains(hypervisorType)) { + throw new InvalidParameterValueException("Zone wide storage pool is not supported for hypervisor type " + hypervisor); } } else { ClusterVO clusterVO = _clusterDao.findById(clusterId);