Skip to content

Commit 37cdb4e

Browse files
koushik-dasyadvr
authored andcommitted
CLOUDSTACK-8054: No event generated on host maintenance mode is completed
Added events for host maintenance start and completion (cherry picked from commit f6854bc) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent cc31571 commit 37cdb4e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import javax.naming.ConfigurationException;
3232

3333
import com.cloud.vm.VirtualMachine;
34+
3435
import org.apache.cloudstack.api.ApiConstants;
3536
import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
3637
import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
@@ -93,7 +94,9 @@
9394
import com.cloud.deploy.PlannerHostReservationVO;
9495
import com.cloud.deploy.dao.PlannerHostReservationDao;
9596
import com.cloud.event.ActionEvent;
97+
import com.cloud.event.ActionEventUtils;
9698
import com.cloud.event.EventTypes;
99+
import com.cloud.event.EventVO;
97100
import com.cloud.exception.AgentUnavailableException;
98101
import com.cloud.exception.DiscoveryException;
99102
import com.cloud.exception.InvalidParameterValueException;
@@ -1188,6 +1191,7 @@ private boolean doMaintain(final long hostId) {
11881191
throw new CloudRuntimeException(err + e.getMessage());
11891192
}
11901193

1194+
ActionEventUtils.onStartedActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(), EventTypes.EVENT_MAINTENANCE_PREPARE, "starting maintenance for host " + hostId, true, 0);
11911195
_agentMgr.pullAgentToMaintenance(hostId);
11921196

11931197
/* TODO: move below to listener */
@@ -1270,6 +1274,7 @@ public boolean checkAndMaintain(final long hostId) {
12701274
if (vos.isEmpty() && vosMigrating.isEmpty()) {
12711275
resourceStateTransitTo(host, ResourceState.Event.InternalEnterMaintenance, _nodeId);
12721276
hostInMaintenance = true;
1277+
ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_MAINTENANCE_PREPARE, "completed maintenance for host " + hostId, 0);
12731278
}
12741279
}
12751280
} catch (NoTransitionException e) {

0 commit comments

Comments
 (0)