Skip to content

Commit b385569

Browse files
committed
Address comments
1 parent 96c9494 commit b385569

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

server/src/main/java/com/cloud/storage/StorageManagerImpl.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717
package com.cloud.storage;
1818

19+
import static com.cloud.configuration.ConfigurationManagerImpl.SystemVMUseLocalStorage;
1920
import static com.cloud.utils.NumbersUtil.toHumanReadableSize;
2021

2122
import java.io.UnsupportedEncodingException;
@@ -144,6 +145,7 @@
144145
import org.apache.commons.collections.CollectionUtils;
145146
import org.apache.commons.collections.MapUtils;
146147
import org.apache.commons.lang.time.DateUtils;
148+
import org.apache.commons.lang3.BooleanUtils;
147149
import org.apache.commons.lang3.EnumUtils;
148150
import org.springframework.stereotype.Component;
149151

@@ -803,19 +805,18 @@ protected DataStore createLocalStorage(Map<String, Object> poolInfos) throws Con
803805
return createLocalStorage(host, pInfo);
804806
}
805807

808+
private boolean isLocalStorageEnabledForZone(DataCenterVO zone) {
809+
return zone.isLocalStorageEnabled() || BooleanUtils.toBoolean(SystemVMUseLocalStorage.valueIn(zone.getId()));
810+
}
811+
806812
@DB
807813
@Override
808814
public DataStore createLocalStorage(Host host, StoragePoolInfo pInfo) throws ConnectionException {
809815
DataCenterVO dc = _dcDao.findById(host.getDataCenterId());
810816
if (dc == null) {
811817
return null;
812818
}
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)) {
819+
if (!isLocalStorageEnabledForZone(dc)) {
819820
return null;
820821
}
821822
DataStore store = null;
@@ -1018,7 +1019,7 @@ public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws Resource
10181019
throw new PermissionDeniedException(String.format("Cannot perform this operation, Zone is currently disabled: %s", zone));
10191020
}
10201021
// Check if it's local storage and if it's enabled on the zone
1021-
if (isFileScheme && !zone.isLocalStorageEnabled()) {
1022+
if (isFileScheme && !isLocalStorageEnabledForZone(zone)) {
10221023
throw new InvalidParameterValueException("Local storage is not enabled for zone: " + zone);
10231024
}
10241025

0 commit comments

Comments
 (0)