|
45 | 45 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; |
46 | 46 | import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; |
47 | 47 | import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
| 48 | +import org.apache.cloudstack.framework.config.ConfigKey; |
| 49 | +import org.apache.cloudstack.framework.config.Configurable; |
48 | 50 | import org.apache.cloudstack.framework.messagebus.MessageBus; |
49 | 51 | import org.apache.cloudstack.framework.messagebus.MessageSubscriber; |
50 | 52 | import org.apache.cloudstack.managed.context.ManagedContextTimerTask; |
|
132 | 134 |
|
133 | 135 | @Local(value = {DeploymentPlanningManager.class}) |
134 | 136 | public class DeploymentPlanningManagerImpl extends ManagerBase implements DeploymentPlanningManager, Manager, Listener, |
135 | | -StateListener<State, VirtualMachine.Event, VirtualMachine> { |
| 137 | +StateListener<State, VirtualMachine.Event, VirtualMachine>, Configurable { |
136 | 138 |
|
137 | 139 | private static final Logger s_logger = Logger.getLogger(DeploymentPlanningManagerImpl.class); |
138 | 140 | @Inject |
@@ -199,8 +201,6 @@ public void setHostAllocators(List<HostAllocator> hostAllocators) { |
199 | 201 | @Inject |
200 | 202 | protected StoragePoolHostDao _poolHostDao; |
201 | 203 |
|
202 | | - @Inject |
203 | | - protected DataCenterDao _zoneDao; |
204 | 204 | @Inject |
205 | 205 | protected VolumeDao _volsDao; |
206 | 206 | @Inject |
@@ -762,6 +762,16 @@ public Boolean doInTransaction(TransactionStatus status) { |
762 | 762 | return false; |
763 | 763 | } |
764 | 764 |
|
| 765 | + @Override |
| 766 | + public String getConfigComponentName() { |
| 767 | + return DeploymentPlanningManagerImpl.class.getSimpleName(); |
| 768 | + } |
| 769 | + |
| 770 | + @Override |
| 771 | + public ConfigKey<?>[] getConfigKeys() { |
| 772 | + return new ConfigKey<?>[] {DataCenter.UseSystemVMLocalStorage}; |
| 773 | + } |
| 774 | + |
765 | 775 | class HostReservationReleaseChecker extends ManagedContextTimerTask { |
766 | 776 | @Override |
767 | 777 | protected void runInContext() { |
@@ -1290,20 +1300,21 @@ protected Pair<Map<Volume, List<StoragePool>>, List<Volume>> findSuitablePoolsFo |
1290 | 1300 | DiskProfile diskProfile = new DiskProfile(toBeCreated, diskOffering, vmProfile.getHypervisorType()); |
1291 | 1301 | boolean useLocalStorage = false; |
1292 | 1302 | if (vmProfile.getType() != VirtualMachine.Type.User) { |
1293 | | - String ssvmUseLocalStorage = _configDao.getValue(Config.SystemVMUseLocalStorage.key()); |
1294 | | - |
1295 | | - DataCenterVO zone = _zoneDao.findById(plan.getDataCenterId()); |
1296 | | - |
| 1303 | + DataCenterVO zone = _dcDao.findById(plan.getDataCenterId()); |
1297 | 1304 | // It should not happen to have a "null" zone here. There can be NO instance if there is NO zone, |
1298 | 1305 | // so this part of the code would never be reached if no zone has been created. |
1299 | | - // |
1300 | 1306 | // Added the check and the comment just to make it clear. |
1301 | 1307 | boolean zoneUsesLocalStorage = zone != null ? zone.isLocalStorageEnabled() : false; |
1302 | | - |
| 1308 | + boolean ssvmUseLocalStorage = DataCenter.UseSystemVMLocalStorage.value(); |
| 1309 | + if (zone != null) { |
| 1310 | + ssvmUseLocalStorage = DataCenter.UseSystemVMLocalStorage.valueIn(plan.getDataCenterId()); |
| 1311 | + } |
| 1312 | + s_logger.debug("Checking if we need local storage for systemvms is needed for zone id=" + plan.getDataCenterId() + " with system.vm.use.local.storage=" + ssvmUseLocalStorage); |
1303 | 1313 | // Local storage is used for the NON User VMs if, and only if, the Zone is marked to use local storage AND |
1304 | 1314 | // the global settings (ssvmUseLocalStorage) is set to true. Otherwise, the global settings won't be applied. |
1305 | | - if (ssvmUseLocalStorage.equalsIgnoreCase("true") && zoneUsesLocalStorage) { |
| 1315 | + if (ssvmUseLocalStorage && zoneUsesLocalStorage) { |
1306 | 1316 | useLocalStorage = true; |
| 1317 | + s_logger.debug("SystemVMs will use local storage for zone id=" + plan.getDataCenterId()); |
1307 | 1318 | } |
1308 | 1319 | } else { |
1309 | 1320 | useLocalStorage = diskOffering.getUseLocalStorage(); |
|
0 commit comments