Skip to content

Commit 0b18117

Browse files
committed
bug CS-14530: Whwnever creating an agent for the host put in enabled and disabled according to the hierarchy.
Reviewed By: Kishan
1 parent e04822e commit 0b18117

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

server/src/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.cloud.agent.manager.allocator.PodAllocator;
4444
import com.cloud.agent.transport.Request;
4545
import com.cloud.api.ApiConstants;
46+
import com.cloud.api.ApiDBUtils;
4647
import com.cloud.api.commands.AddClusterCmd;
4748
import com.cloud.api.commands.AddHostCmd;
4849
import com.cloud.api.commands.AddSecondaryStorageCmd;
@@ -60,6 +61,7 @@
6061
import com.cloud.cluster.ClusterManager;
6162
import com.cloud.cluster.ManagementServerNode;
6263
import com.cloud.configuration.Config;
64+
import com.cloud.configuration.ConfigurationManager;
6365
import com.cloud.configuration.dao.ConfigurationDao;
6466
import com.cloud.dc.ClusterDetailsDao;
6567
import com.cloud.dc.ClusterVO;
@@ -95,6 +97,7 @@
9597
import com.cloud.org.Cluster;
9698
import com.cloud.org.Grouping;
9799
import com.cloud.org.Managed;
100+
import com.cloud.org.Grouping.AllocationState;
98101
import com.cloud.service.ServiceOfferingVO;
99102
import com.cloud.storage.GuestOSCategoryVO;
100103
import com.cloud.storage.StorageManager;
@@ -196,6 +199,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
196199
@Inject
197200
protected ClusterManager _clusterMgr;
198201
@Inject
202+
ConfigurationManager _configMgr;
203+
@Inject
199204
protected StoragePoolHostDao _storagePoolHostDao;
200205
@Inject(adapter = PodAllocator.class)
201206
protected Adapters<PodAllocator> _podAllocators = null;
@@ -1064,7 +1069,11 @@ public boolean resourceStateTransitTo(Host host, ResourceState.Event event, long
10641069
}
10651070

10661071
// 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());
10681077
return _hostDao.updateResourceState(currentState, event, nextState, host);
10691078
}
10701079

0 commit comments

Comments
 (0)