cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject git commit: updated refs/heads/rbac to 91317dc
Date Tue, 28 Jan 2014 17:51:00 GMT
Updated Branches:
  refs/heads/rbac d40e52776 -> 91317dc49


Changes for createDomain - create new group AND createAccount - add account to domain group


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

Branch: refs/heads/rbac
Commit: 91317dc4977773358fc48b6ef125ec2e58094206
Parents: d40e527
Author: Prachi Damle <prachi@cloud.com>
Authored: Tue Jan 28 00:42:03 2014 -0800
Committer: Prachi Damle <prachi@cloud.com>
Committed: Tue Jan 28 09:48:19 2014 -0800

----------------------------------------------------------------------
 server/src/com/cloud/user/DomainManager.java    |  3 +++
 .../src/com/cloud/user/DomainManagerImpl.java   |  8 ++++++
 .../cloudstack/acl/api/AclApiServiceImpl.java   | 26 ++++++++++++++++++++
 3 files changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/91317dc4/server/src/com/cloud/user/DomainManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/DomainManager.java b/server/src/com/cloud/user/DomainManager.java
index 41d9d34..27c837d 100644
--- a/server/src/com/cloud/user/DomainManager.java
+++ b/server/src/com/cloud/user/DomainManager.java
@@ -47,4 +47,7 @@ public interface DomainManager extends DomainService {
      * @return Domain object if the command succeeded
      */
     Domain updateDomain(UpdateDomainCmd cmd);
+
+    public static final String MESSAGE_ADD_DOMAIN_EVENT = "Message.AddDomain.Event";
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/91317dc4/server/src/com/cloud/user/DomainManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/DomainManagerImpl.java b/server/src/com/cloud/user/DomainManagerImpl.java
index 59772ff..fbbe0c2 100644
--- a/server/src/com/cloud/user/DomainManagerImpl.java
+++ b/server/src/com/cloud/user/DomainManagerImpl.java
@@ -32,6 +32,8 @@ import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd;
 import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+import org.apache.cloudstack.framework.messagebus.MessageBus;
+import org.apache.cloudstack.framework.messagebus.PublishScope;
 import org.apache.cloudstack.region.RegionManager;
 
 import com.cloud.configuration.Resource.ResourceOwnerType;
@@ -105,6 +107,9 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager,
Dom
     @Inject
     private NetworkDomainDao _networkDomainDao;
 
+    @Inject
+    MessageBus _messageBus;
+
     @Override
     public Domain getDomain(long domainId) {
         return _domainDao.findById(domainId);
@@ -204,6 +209,9 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager,
Dom
         });
 
         CallContext.current().putContextParameter(Domain.class, domain.getUuid());
+
+        _messageBus.publish(_name, MESSAGE_ADD_DOMAIN_EVENT, PublishScope.LOCAL, domain.getId());
+
         return domain;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/91317dc4/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiServiceImpl.java
b/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiServiceImpl.java
index 7651548..12e3748 100644
--- a/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiServiceImpl.java
+++ b/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiServiceImpl.java
@@ -66,6 +66,7 @@ import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.AccountVO;
+import com.cloud.user.DomainManager;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.Manager;
@@ -107,6 +108,18 @@ public class AclApiServiceImpl extends ManagerBase implements AclApiService,
Man
                     s_logger.debug("MessageBus message: new Account Added: " + accountId
+ ", adding it to groupId :"
                             + groupId);
                     addAccountToAclGroup(accountId, groupId);
+                    // add it to domain group too
+                    AccountVO account = _accountDao.findById(accountId);
+                    Domain domain = _domainDao.findById(account.getDomainId());
+                    if (domain != null) {
+                        ListResponse<AclGroupResponse> domainGroups = listAclGroups(null,
+                                "DomainGrp-" + domain.getUuid(), domain.getId(), null, null);
+                        if (domainGroups.getResponses() != null) {
+                            for (AclGroupResponse group : domainGroups.getResponses()) {
+                                addAccountToAclGroup(accountId, new Long(group.getId()));
+                            }
+                        }
+                    }
                 }
             }
         });
@@ -123,6 +136,18 @@ public class AclApiServiceImpl extends ManagerBase implements AclApiService,
Man
             }
         });
 
+        _messageBus.subscribe(DomainManager.MESSAGE_ADD_DOMAIN_EVENT, new MessageSubscriber()
{
+            @Override
+            public void onPublishMessage(String senderAddress, String subject, Object obj)
{
+                Long domainId = ((Long) obj);
+                if (domainId != null) {
+                    s_logger.debug("MessageBus message: new Domain created: " + domainId
+ ", creating a new group");
+                    Domain domain = _domainDao.findById(domainId);
+                    _iamSrv.createAclGroup("DomainGrp-" + domain.getUuid(), "Domain group",
domain.getPath());
+                }
+            }
+        });
+
         return super.configure(name, params);
     }
 
@@ -158,6 +183,7 @@ public class AclApiServiceImpl extends ManagerBase implements AclApiService,
Man
         return _iamSrv.addAccountsToGroup(acctIds, groupId);
     }
 
+
     private void removeAccountFromAclGroups(long accountId) {
         List<AclGroup> groups = listAclGroups(accountId);
         List<Long> accts = new ArrayList<Long>();


Mime
View raw message