CLOUDSTACK-8054: No event generated on host maintenance mode is completed

Added events for host maintenance start and completion
This commit is contained in:
Koushik Das 2014-12-10 10:18:34 +05:30
parent f00a62879b
commit f6854bc984
1 changed files with 5 additions and 0 deletions

View File

@ -32,6 +32,7 @@ import javax.naming.ConfigurationException;
import com.cloud.capacity.CapacityState;
import com.cloud.vm.VirtualMachine;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
@ -93,7 +94,9 @@ import com.cloud.dc.dao.HostPodDao;
import com.cloud.deploy.PlannerHostReservationVO;
import com.cloud.deploy.dao.PlannerHostReservationDao;
import com.cloud.event.ActionEvent;
import com.cloud.event.ActionEventUtils;
import com.cloud.event.EventTypes;
import com.cloud.event.EventVO;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.DiscoveryException;
import com.cloud.exception.InvalidParameterValueException;
@ -1181,6 +1184,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
throw new CloudRuntimeException(err + e.getMessage());
}
ActionEventUtils.onStartedActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(), EventTypes.EVENT_MAINTENANCE_PREPARE, "starting maintenance for host " + hostId, true, 0);
_agentMgr.pullAgentToMaintenance(hostId);
/* TODO: move below to listener */
@ -1263,6 +1267,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
if (vos.isEmpty() && vosMigrating.isEmpty()) {
resourceStateTransitTo(host, ResourceState.Event.InternalEnterMaintenance, _nodeId);
hostInMaintenance = true;
ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_MAINTENANCE_PREPARE, "completed maintenance for host " + hostId, 0);
}
}
} catch (NoTransitionException e) {