|
16 | 16 | // under the License. |
17 | 17 | package com.cloud.storage; |
18 | 18 |
|
| 19 | +import static com.cloud.configuration.ConfigurationManagerImpl.SystemVMUseLocalStorage; |
19 | 20 | import static com.cloud.utils.NumbersUtil.toHumanReadableSize; |
20 | 21 |
|
21 | 22 | import java.io.UnsupportedEncodingException; |
|
144 | 145 | import org.apache.commons.collections.CollectionUtils; |
145 | 146 | import org.apache.commons.collections.MapUtils; |
146 | 147 | import org.apache.commons.lang.time.DateUtils; |
| 148 | +import org.apache.commons.lang3.BooleanUtils; |
147 | 149 | import org.apache.commons.lang3.EnumUtils; |
148 | 150 | import org.springframework.stereotype.Component; |
149 | 151 |
|
|
176 | 178 | import com.cloud.cluster.ClusterManagerListener; |
177 | 179 | import com.cloud.configuration.Config; |
178 | 180 | import com.cloud.configuration.ConfigurationManager; |
179 | | -import com.cloud.configuration.ConfigurationManagerImpl; |
180 | 181 | import com.cloud.configuration.Resource.ResourceType; |
181 | 182 | import com.cloud.cpu.CPU; |
182 | 183 | import com.cloud.dc.ClusterVO; |
@@ -803,19 +804,18 @@ protected DataStore createLocalStorage(Map<String, Object> poolInfos) throws Con |
803 | 804 | return createLocalStorage(host, pInfo); |
804 | 805 | } |
805 | 806 |
|
| 807 | + private boolean isLocalStorageEnabledForZone(DataCenterVO zone) { |
| 808 | + return zone.isLocalStorageEnabled() || BooleanUtils.toBoolean(SystemVMUseLocalStorage.valueIn(zone.getId())); |
| 809 | + } |
| 810 | + |
806 | 811 | @DB |
807 | 812 | @Override |
808 | 813 | public DataStore createLocalStorage(Host host, StoragePoolInfo pInfo) throws ConnectionException { |
809 | 814 | DataCenterVO dc = _dcDao.findById(host.getDataCenterId()); |
810 | 815 | if (dc == null) { |
811 | 816 | return null; |
812 | 817 | } |
813 | | - boolean useLocalStorageForSystemVM = false; |
814 | | - Boolean isLocal = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dc.getId()); |
815 | | - if (isLocal != null) { |
816 | | - useLocalStorageForSystemVM = isLocal.booleanValue(); |
817 | | - } |
818 | | - if (!(dc.isLocalStorageEnabled() || useLocalStorageForSystemVM)) { |
| 818 | + if (!isLocalStorageEnabledForZone(dc)) { |
819 | 819 | return null; |
820 | 820 | } |
821 | 821 | DataStore store = null; |
@@ -1018,7 +1018,7 @@ public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws Resource |
1018 | 1018 | throw new PermissionDeniedException(String.format("Cannot perform this operation, Zone is currently disabled: %s", zone)); |
1019 | 1019 | } |
1020 | 1020 | // Check if it's local storage and if it's enabled on the zone |
1021 | | - if (isFileScheme && !zone.isLocalStorageEnabled()) { |
| 1021 | + if (isFileScheme && !isLocalStorageEnabledForZone(zone)) { |
1022 | 1022 | throw new InvalidParameterValueException("Local storage is not enabled for zone: " + zone); |
1023 | 1023 | } |
1024 | 1024 |
|
|
0 commit comments