cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [22/50] [abbrv] git commit: updated refs/heads/rbac to 9e92197
Date Tue, 04 Feb 2014 23:39:06 GMT
CLOUDSTACK-5496 : Account included in ActionEvents is Project Account ID

When Action Events are generated and placed on the Event Bus, an
"account" parameter is included with the event. When these events are
generated for resources within projects, this "account" parameter is not
useful as it's the UUID of the project account, instead of the project.

To solve this, I updated ActionEventsUtil class to include a "project"
parameter in the generated events when the resource is being
changed/add/deleted in a project.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5de9ae0b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5de9ae0b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5de9ae0b

Branch: refs/heads/rbac
Commit: 5de9ae0bceddd751ae7f59fa4b7aec1d13f8bf59
Parents: 85d0f8f
Author: David Grizzanti <david.grizzanti@sungard.com>
Authored: Thu Jan 30 17:30:42 2014 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Thu Jan 30 17:35:01 2014 +0530

----------------------------------------------------------------------
 server/src/com/cloud/event/ActionEventUtils.java            | 9 +++++++++
 .../org/apache/cloudstack/affinity/AffinityApiUnitTest.java | 9 +++++++++
 2 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5de9ae0b/server/src/com/cloud/event/ActionEventUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/ActionEventUtils.java b/server/src/com/cloud/event/ActionEventUtils.java
index d435381..c332a8e 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<String, String> eventDescription = new HashMap<String, String>();
+        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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5de9ae0b/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java b/server/test/org/apache/cloudstack/affinity/AffinityApiUnitTest.java
index 061fd42..f891e70 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)
@@ -111,6 +112,9 @@ public class AffinityApiUnitTest {
     AccountDao _accountDao;
 
     @Inject
+    ProjectDao _projectDao;
+
+    @Inject
     EventDao _eventDao;
 
     @Inject
@@ -218,6 +222,11 @@ public class AffinityApiUnitTest {
         }
 
         @Bean
+        public ProjectDao projectDao() {
+            return Mockito.mock(ProjectDao.class);
+        }
+
+        @Bean
         public AccountService accountService() {
             return Mockito.mock(AccountService.class);
         }


Mime
View raw message