diff --git a/server/src/com/cloud/event/ActionEventUtils.java b/server/src/com/cloud/event/ActionEventUtils.java index d435381b69b..c332a8e32e4 100755 --- a/server/src/com/cloud/event/ActionEventUtils.java +++ b/server/src/com/cloud/event/ActionEventUtils.java @@ -41,6 +41,8 @@ import com.cloud.user.AccountVO; import com.cloud.user.User; import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.UserDao; +import com.cloud.projects.dao.ProjectDao; +import com.cloud.projects.Project; import com.cloud.utils.component.ComponentContext; public class ActionEventUtils { @@ -48,6 +50,7 @@ public class ActionEventUtils { private static EventDao s_eventDao; private static AccountDao s_accountDao; + private static ProjectDao s_projectDao; protected static UserDao s_userDao; protected static EventBus s_eventBus = null; @@ -63,6 +66,8 @@ public class ActionEventUtils { AccountDao accountDao; @Inject UserDao userDao; + @Inject + ProjectDao projectDao; public ActionEventUtils() { } @@ -72,6 +77,7 @@ public class ActionEventUtils { s_eventDao = eventDao; s_accountDao = accountDao; s_userDao = userDao; + s_projectDao = projectDao; } public static Long onActionEvent(Long userId, Long accountId, Long domainId, String type, String description) { @@ -185,6 +191,7 @@ public class ActionEventUtils { new org.apache.cloudstack.framework.events.Event(ManagementService.Name, eventCategory, eventType, EventTypes.getEntityForEvent(eventType), entityUuid); Map eventDescription = new HashMap(); + Project project = s_projectDao.findByProjectAccountId(accountId); Account account = s_accountDao.findById(accountId); User user = s_userDao.findById(userId); // if account has been deleted, this might be called during cleanup of resources and results in null pointer @@ -192,6 +199,8 @@ public class ActionEventUtils { return; if (user == null) return; + if (project != null) + eventDescription.put("project", project.getUuid()); eventDescription.put("user", user.getUuid()); eventDescription.put("account", account.getUuid()); eventDescription.put("event", eventType); diff --git a/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java b/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java index 061fd42ac6b..f891e70196d 100644 --- a/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java +++ b/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java @@ -78,6 +78,7 @@ import com.cloud.utils.component.ComponentContext; import com.cloud.vm.UserVmVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.dao.UserVmDao; +import com.cloud.projects.dao.ProjectDao; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(loader = AnnotationConfigContextLoader.class) @@ -110,6 +111,9 @@ public class AffinityApiUnitTest { @Inject AccountDao _accountDao; + @Inject + ProjectDao _projectDao; + @Inject EventDao _eventDao; @@ -217,6 +221,11 @@ public class AffinityApiUnitTest { return Mockito.mock(AccountDao.class); } + @Bean + public ProjectDao projectDao() { + return Mockito.mock(ProjectDao.class); + } + @Bean public AccountService accountService() { return Mockito.mock(AccountService.class);