Publish event for VM.STOP when out of band stop is detected

Signed-off-by: Marcus Sorensen <mls@apple.com>
(cherry picked from commit 72a3d54db0a0bb0afbcbee35abc1e98ef102aa49)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Marcus Sorensen 2023-08-24 10:39:22 -06:00 committed by Rohit Yadav
parent 0d9aa70edd
commit d8db09ac58
1 changed files with 5 additions and 0 deletions

View File

@ -47,6 +47,7 @@ import javax.inject.Inject;
import javax.naming.ConfigurationException;
import javax.persistence.EntityExistsException;
import com.cloud.event.ActionEventUtils;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.annotation.AnnotationService;
import org.apache.cloudstack.annotation.dao.AnnotationDao;
@ -4822,6 +4823,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (" + vm.getState()
+ " -> Running) from out-of-context transition. VM network environment may need to be reset");
ActionEventUtils.onActionEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, vm.getDomainId(),
EventTypes.EVENT_VM_START, "Out of band VM power on", vm.getId(), ApiCommandResourceType.VirtualMachine.toString());
s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Running state according to power-on report from hypervisor");
break;
@ -4855,6 +4858,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
case Stopping:
case Running:
case Stopped:
ActionEventUtils.onActionEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM,vm.getDomainId(),
EventTypes.EVENT_VM_STOP, "Out of band VM power off", vm.getId(), ApiCommandResourceType.VirtualMachine.toString());
case Migrating:
if (s_logger.isInfoEnabled()) {
s_logger.info(