|
43 | 43 | import com.cloud.agent.manager.allocator.PodAllocator; |
44 | 44 | import com.cloud.agent.transport.Request; |
45 | 45 | import com.cloud.api.ApiConstants; |
| 46 | +import com.cloud.api.ApiDBUtils; |
46 | 47 | import com.cloud.api.commands.AddClusterCmd; |
47 | 48 | import com.cloud.api.commands.AddHostCmd; |
48 | 49 | import com.cloud.api.commands.AddSecondaryStorageCmd; |
|
60 | 61 | import com.cloud.cluster.ClusterManager; |
61 | 62 | import com.cloud.cluster.ManagementServerNode; |
62 | 63 | import com.cloud.configuration.Config; |
| 64 | +import com.cloud.configuration.ConfigurationManager; |
63 | 65 | import com.cloud.configuration.dao.ConfigurationDao; |
64 | 66 | import com.cloud.dc.ClusterDetailsDao; |
65 | 67 | import com.cloud.dc.ClusterVO; |
|
95 | 97 | import com.cloud.org.Cluster; |
96 | 98 | import com.cloud.org.Grouping; |
97 | 99 | import com.cloud.org.Managed; |
| 100 | +import com.cloud.org.Grouping.AllocationState; |
98 | 101 | import com.cloud.service.ServiceOfferingVO; |
99 | 102 | import com.cloud.storage.GuestOSCategoryVO; |
100 | 103 | import com.cloud.storage.StorageManager; |
@@ -196,6 +199,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma |
196 | 199 | @Inject |
197 | 200 | protected ClusterManager _clusterMgr; |
198 | 201 | @Inject |
| 202 | + ConfigurationManager _configMgr; |
| 203 | + @Inject |
199 | 204 | protected StoragePoolHostDao _storagePoolHostDao; |
200 | 205 | @Inject(adapter = PodAllocator.class) |
201 | 206 | protected Adapters<PodAllocator> _podAllocators = null; |
@@ -1064,7 +1069,11 @@ public boolean resourceStateTransitTo(Host host, ResourceState.Event event, long |
1064 | 1069 | } |
1065 | 1070 |
|
1066 | 1071 | // TO DO - Make it more granular and have better conversion into capacity type |
1067 | | - _capacityDao.updateCapacityState(null, null, null, host.getId(), nextState.toString()); |
| 1072 | + AllocationState capacityState = _configMgr.findClusterAllocationState(ApiDBUtils.findClusterById(host.getClusterId())); |
| 1073 | + if (capacityState == AllocationState.Enabled && nextState != ResourceState.Enabled){ |
| 1074 | + capacityState = AllocationState.Disabled; |
| 1075 | + } |
| 1076 | + _capacityDao.updateCapacityState(null, null, null, host.getId(), capacityState.toString()); |
1068 | 1077 | return _hostDao.updateResourceState(currentState, event, nextState, host); |
1069 | 1078 | } |
1070 | 1079 |
|
|
0 commit comments