cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sate...@apache.org
Subject [14/50] [abbrv] git commit: updated refs/heads/vmware-datamodel to 6a8c2bd
Date Fri, 31 May 2013 07:49:12 GMT
update volume API needs to respect the account and domain


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

Branch: refs/heads/vmware-datamodel
Commit: 3ae00f4b2fbbb305b783cff880ac92c3caf74871
Parents: 83c13fc
Author: Anthony Xu <anthony.xu@citrix.com>
Authored: Wed May 29 14:44:47 2013 -0700
Committer: Anthony Xu <anthony.xu@citrix.com>
Committed: Wed May 29 14:45:15 2013 -0700

----------------------------------------------------------------------
 .../src/com/cloud/storage/VolumeManagerImpl.java   |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ae00f4b/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index 4b654eb..aedb68e 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -358,6 +358,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
             throws ResourceAllocationException {
         Account caller = UserContext.current().getCaller();
         long ownerId = cmd.getEntityOwnerId();
+        Account owner = _accountDao.findById(ownerId);
         Long zoneId = cmd.getZoneId();
         String volumeName = cmd.getVolumeName();
         String url = cmd.getUrl();
@@ -367,7 +368,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
 
         validateVolume(caller, ownerId, zoneId, volumeName, url, format);
         
-        VolumeVO volume = persistVolume(caller, ownerId, zoneId, volumeName,
+        VolumeVO volume = persistVolume(owner, zoneId, volumeName,
                 url, cmd.getFormat());
         
         VolumeInfo vol = this.volFactory.getVolume(volume.getId());
@@ -700,7 +701,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         return UUID.randomUUID().toString();
     }
     
-    private VolumeVO persistVolume(Account caller, long ownerId, Long zoneId,
+    private VolumeVO persistVolume(Account owner, Long zoneId,
             String volumeName, String url, String format) {
 
         Transaction txn = Transaction.currentTxn();
@@ -708,20 +709,17 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
 
         VolumeVO volume = new VolumeVO(volumeName, zoneId, -1, -1, -1,
                 new Long(-1), null, null, 0, Volume.Type.DATADISK);
-        Account owner = (caller.getId() == ownerId) ? caller : _accountMgr
-                          .getActiveAccountById(ownerId);
         volume.setPoolId(null);
         volume.setDataCenterId(zoneId);
         volume.setPodId(null);
-        volume.setAccountId(ownerId);
+        volume.setAccountId(owner.getAccountId());
+        volume.setDomainId(owner.getDomainId());
         long diskOfferingId = _diskOfferingDao.findByUniqueName(
                 "Cloud.com-Custom").getId();
         volume.setDiskOfferingId(diskOfferingId);
         // volume.setSize(size);
         volume.setInstanceId(null);
         volume.setUpdated(new Date());
-        volume.setDomainId((owner == null) ? Domain.ROOT_DOMAIN : owner
-                .getDomainId());
 
         volume = _volsDao.persist(volume);
         try {


Mime
View raw message