Repository: cloudstack
Updated Branches:
  refs/heads/master 8ac7784db -> 4e674ffad


CLOUDSTACK-6568:API:createVolume: Volume gets created with wrong domain
ID.


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

Branch: refs/heads/master
Commit: 4e674ffad1abac139bbb4782b428b7179bfdd0d6
Parents: 8ac7784
Author: Min Chen <[email protected]>
Authored: Fri May 2 17:36:06 2014 -0700
Committer: Min Chen <[email protected]>
Committed: Fri May 2 17:47:06 2014 -0700

----------------------------------------------------------------------
 .../src/com/cloud/storage/VolumeApiServiceImpl.java | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e674ffa/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java 
b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index d23fc09..da204f3 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -371,10 +371,11 @@ public class VolumeApiServiceImpl extends ManagerBase 
implements VolumeApiServic
         Account caller = CallContext.current().getCallingAccount();
 
         long ownerId = cmd.getEntityOwnerId();
+        Account owner = _accountMgr.getActiveAccountById(ownerId);
         Boolean displayVolume = cmd.getDisplayVolume();
 
         // permission check
-        _accountMgr.checkAccess(caller, null, 
_accountMgr.getActiveAccountById(ownerId));
+        _accountMgr.checkAccess(caller, null, owner);
 
         if (displayVolume == null) {
             displayVolume = true;
@@ -386,7 +387,7 @@ public class VolumeApiServiceImpl extends ManagerBase 
implements VolumeApiServic
         }
 
         // Check that the resource limit for volumes won't be exceeded
-        _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), 
ResourceType.volume, displayVolume);
+        _resourceLimitMgr.checkResourceLimit(owner, ResourceType.volume, 
displayVolume);
 
         Long zoneId = cmd.getZoneId();
         Long diskOfferingId = null;
@@ -526,7 +527,7 @@ public class VolumeApiServiceImpl extends ManagerBase 
implements VolumeApiServic
         }
 
         // Check that the resource limit for primary storage won't be exceeded
-        _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), 
ResourceType.primary_storage, displayVolume, new Long(size));
+        _resourceLimitMgr.checkResourceLimit(owner, 
ResourceType.primary_storage, displayVolume, new Long(size));
 
         // Verify that zone exists
         DataCenterVO zone = _dcDao.findById(zoneId);
@@ -550,13 +551,13 @@ public class VolumeApiServiceImpl extends ManagerBase 
implements VolumeApiServic
             userSpecifiedName = getRandomVolumeName();
         }
 
-        VolumeVO volume = commitVolume(cmd, caller, ownerId, displayVolume, 
zoneId, diskOfferingId, provisioningType, size,
+        VolumeVO volume = commitVolume(cmd, caller, owner, displayVolume, 
zoneId, diskOfferingId, provisioningType, size,
                 minIops, maxIops, parentVolume, userSpecifiedName, 
_uuidMgr.generateUuid(Volume.class, cmd.getCustomId()));
 
         return volume;
     }
 
-    private VolumeVO commitVolume(final CreateVolumeCmd cmd, final Account 
caller, final long ownerId, final Boolean displayVolume,
+    private VolumeVO commitVolume(final CreateVolumeCmd cmd, final Account 
caller, final Account owner, final Boolean displayVolume,
             final Long zoneId, final Long diskOfferingId, final 
Storage.ProvisioningType provisioningType, final Long size, final Long minIops, 
final Long maxIops, final VolumeVO parentVolume,
             final String userSpecifiedName, final String uuid) {
         return Transaction.execute(new TransactionCallback<VolumeVO>() {
@@ -567,15 +568,14 @@ public class VolumeApiServiceImpl extends ManagerBase 
implements VolumeApiServic
                 volume.setUuid(uuid);
                 volume.setDataCenterId(zoneId);
                 volume.setPodId(null);
-                volume.setAccountId(ownerId);
-                volume.setDomainId(((caller == null) ? Domain.ROOT_DOMAIN : 
caller.getDomainId()));
+                volume.setAccountId(owner.getId());
+                volume.setDomainId(owner.getDomainId());
                 volume.setDiskOfferingId(diskOfferingId);
                 volume.setSize(size);
                 volume.setMinIops(minIops);
                 volume.setMaxIops(maxIops);
                 volume.setInstanceId(null);
                 volume.setUpdated(new Date());
-                volume.setDomainId((caller == null) ? Domain.ROOT_DOMAIN : 
caller.getDomainId());
                 volume.setDisplayVolume(displayVolume);
                 if (parentVolume != null) {
                     volume.setTemplateId(parentVolume.getTemplateId());

Reply via email to