Skip to content

Commit e9872b1

Browse files
committed
Address comments
1 parent 96c9494 commit e9872b1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 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

@@ -176,7 +178,6 @@
176178
import com.cloud.cluster.ClusterManagerListener;
177179
import com.cloud.configuration.Config;
178180
import com.cloud.configuration.ConfigurationManager;
179-
import com.cloud.configuration.ConfigurationManagerImpl;
180181
import com.cloud.configuration.Resource.ResourceType;
181182
import com.cloud.cpu.CPU;
182183
import com.cloud.dc.ClusterVO;
@@ -803,19 +804,18 @@ protected DataStore createLocalStorage(Map<String, Object> poolInfos) throws Con
803804
return createLocalStorage(host, pInfo);
804805
}
805806

807+
private boolean isLocalStorageEnabledForZone(DataCenterVO zone) {
808+
return zone.isLocalStorageEnabled() || BooleanUtils.toBoolean(SystemVMUseLocalStorage.valueIn(zone.getId()));
809+
}
810+
806811
@DB
807812
@Override
808813
public DataStore createLocalStorage(Host host, StoragePoolInfo pInfo) throws ConnectionException {
809814
DataCenterVO dc = _dcDao.findById(host.getDataCenterId());
810815
if (dc == null) {
811816
return null;
812817
}
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)) {
819819
return null;
820820
}
821821
DataStore store = null;
@@ -1018,7 +1018,7 @@ public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws Resource
10181018
throw new PermissionDeniedException(String.format("Cannot perform this operation, Zone is currently disabled: %s", zone));
10191019
}
10201020
// Check if it's local storage and if it's enabled on the zone
1021-
if (isFileScheme && !zone.isLocalStorageEnabled()) {
1021+
if (isFileScheme && !isLocalStorageEnabledForZone(zone)) {
10221022
throw new InvalidParameterValueException("Local storage is not enabled for zone: " + zone);
10231023
}
10241024

0 commit comments

Comments
 (0)