From 19dcbb8d8e9f5c43bbb902e403252ddc5dab931e Mon Sep 17 00:00:00 2001 From: kishan Date: Wed, 24 Nov 2010 17:48:19 +0530 Subject: [PATCH 1/2] bug 7246: changed event name to TEMPLATE.CLEANUP when cleaning up templates on sec storage. Usage won't track this event status 7246: resolved fixed --- api/src/com/cloud/event/EventTypes.java | 3 ++- .../src/com/cloud/storage/download/DownloadMonitorImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index eb7d601cfdd..c69439bd471 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -84,7 +84,8 @@ public class EventTypes { public static final String EVENT_TEMPLATE_DOWNLOAD_FAILED = "TEMPLATE.DOWNLOAD.FAILED"; public static final String EVENT_TEMPLATE_COPY = "TEMPLATE.COPY"; public static final String EVENT_TEMPLATE_EXTRACT = "TEMPLATE.EXTRACT"; - public static final String EVENT_TEMPLATE_UPLOAD = "TEMPLATE.UPLOAD"; + public static final String EVENT_TEMPLATE_UPLOAD = "TEMPLATE.UPLOAD"; + public static final String EVENT_TEMPLATE_CLEANUP = "TEMPLATE.CLEANUP"; // Volume Events public static final String EVENT_VOLUME_CREATE = "VOLUME.CREATE"; diff --git a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java index 0b77284bc01..d2c267ad80e 100755 --- a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java +++ b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java @@ -513,12 +513,12 @@ public class DownloadMonitorImpl implements DownloadMonitor { long result = send(sserverId, dtCommand, null); if (result == -1 ){ String description = "Failed to delete " + tInfo.getTemplateName() + " on secondary storage " + sserverId + " which isn't in the database"; - logEvent(1L, EventTypes.EVENT_TEMPLATE_DELETE, description , EventVO.LEVEL_ERROR); + logEvent(1L, EventTypes.EVENT_TEMPLATE_CLEANUP, description , EventVO.LEVEL_ERROR); s_logger.error(description); return; } String description = "Deleted template " + tInfo.getTemplateName() + " on secondary storage " + sserverId + " since it isn't in the database, result=" + result; - logEvent(1L, EventTypes.EVENT_TEMPLATE_DELETE, description, EventVO.LEVEL_INFO); + logEvent(1L, EventTypes.EVENT_TEMPLATE_CLEANUP, description, EventVO.LEVEL_INFO); s_logger.info(description); } From f70071dc98e439dc01bb966ffff302c839177c09 Mon Sep 17 00:00:00 2001 From: kishan Date: Wed, 24 Nov 2010 18:36:35 +0530 Subject: [PATCH 2/2] bug 6309: Added event VM.UPDATE along with changed fields status 6309: resolved fixed --- api/src/com/cloud/event/EventTypes.java | 3 +- .../src/com/cloud/vm/UserVmManagerImpl.java | 38 +++++++++++-------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index c69439bd471..8adf074e265 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -25,8 +25,7 @@ public class EventTypes { public static final String EVENT_VM_START = "VM.START"; public static final String EVENT_VM_STOP = "VM.STOP"; public static final String EVENT_VM_REBOOT = "VM.REBOOT"; - public static final String EVENT_VM_DISABLE_HA = "VM.DISABLEHA"; - public static final String EVENT_VM_ENABLE_HA = "VM.ENABLEHA"; + public static final String EVENT_VM_UPDATE = "VM.UPDATE"; public static final String EVENT_VM_UPGRADE = "VM.UPGRADE"; public static final String EVENT_VM_RESETPASSWORD = "VM.RESETPASSWORD"; diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 838df1b1e33..e5e9ce5b5f4 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -3125,7 +3125,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM } userId = accountAndUserValidation(id, account, userId,vmInstance); - + if (displayName == null) { displayName = vmInstance.getDisplayName(); } @@ -3140,25 +3140,31 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM throw new CloudRuntimeException("Unable to find virual machine with id " + id); } - if (group != null) { - addInstanceToGroup(id, group); + String description = ""; + + if(displayName != vmInstance.getDisplayName()){ + description += "New display name: "+displayName+". "; + } + + if(ha != vmInstance.isHaEnabled()){ + if(ha){ + description += "Enabled HA. "; + } else { + description += "Disabled HA. "; + } } - boolean haEnabled = vm.isHaEnabled(); - _vmDao.updateVM(id, displayName, ha); - if (haEnabled != ha) { - String description = null; - String type = null; - if (ha) { - description = "Successfully enabled HA for virtual machine " + vm.getHostName(); - type = EventTypes.EVENT_VM_ENABLE_HA; - } else { - description = "Successfully disabled HA for virtual machine " + vm.getHostName(); - type = EventTypes.EVENT_VM_DISABLE_HA; + + if (group != null) { + if(addInstanceToGroup(id, group)){ + description += "Added to group: "+group+"."; } - // create a event for the change in HA Enabled flag - EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, type, description, null); } + + _vmDao.updateVM(id, displayName, ha); + + // create a event for the change in HA Enabled flag + EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_VM_UPDATE, "Successfully updated virtual machine: "+vm.getHostName()+". "+description, null); return _vmDao.findById(id); }