alert: Send alert for ha'ed vm's (#5664)

* alert: Send alert for ha'ed vm's

When ha is performed on vm's send the alert for it so that
its for admins to know which vm's got ha'ed else its time
consuming to get those details from logs

* feedback change

Co-authored-by: Rakesh Venkatesh <rakeshv@apache.org>
This commit is contained in:
Rakesh 2022-03-17 04:52:35 +01:00 committed by GitHub
parent 3fc31ca1e5
commit 6f3c18f3a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -608,7 +608,10 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements Configur
VMInstanceVO started = _instanceDao.findById(vm.getId()); VMInstanceVO started = _instanceDao.findById(vm.getId());
if (started != null && started.getState() == VirtualMachine.State.Running) { if (started != null && started.getState() == VirtualMachine.State.Running) {
s_logger.info("VM is now restarted: " + vmId + " on " + started.getHostId()); String message = String.format("HA starting VM: %s (%s)", started.getHostName(), started.getInstanceName());
HostVO hostVmHasStarted = _hostDao.findById(started.getHostId());
s_logger.info(String.format("HA is now restarting %s on %s", started, hostVmHasStarted));
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodIdToDeployIn(), message, message);
return null; return null;
} }