cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: updated refs/heads/4.4-forward to 43e479d
Date Thu, 12 Jun 2014 23:33:10 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward 2d96ad987 -> 43e479d23


CLOUDSTACK-6907: lisVolumes - make a decision whether to set service or disk offering in the
response, based on the DiskOfferingVO type entry, not the volume Type


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

Branch: refs/heads/4.4-forward
Commit: 43e479d238649e3ab61259b6b57e56152f1ecb29
Parents: 2d96ad9
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Thu Jun 12 16:14:31 2014 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Thu Jun 12 16:16:04 2014 -0700

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiDBUtils.java        |  6 +++++-
 .../cloud/api/query/dao/VolumeJoinDaoImpl.java  | 20 ++++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43e479d2/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 153d998..90a09a0 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -900,7 +900,11 @@ public class ApiDBUtils {
     }
 
     public static DiskOfferingVO findDiskOfferingById(Long diskOfferingId) {
-        return s_diskOfferingDao.findByIdIncludingRemoved(diskOfferingId);
+        DiskOfferingVO off = s_diskOfferingDao.findByIdIncludingRemoved(diskOfferingId);
+        if (off.getType() == DiskOfferingVO.Type.Disk) {
+            return off;
+        }
+        return null;
     }
 
     public static DomainVO findDomainById(Long domainId) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43e479d2/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
index 9e1ee37..24d0922 100644
--- a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
@@ -22,13 +22,12 @@ import java.util.List;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.api.ApiDBUtils;
 import com.cloud.api.ApiResponseHelper;
@@ -152,19 +151,28 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO,
Long> implem
         // DiskOfferingVO diskOffering =
         // ApiDBUtils.findDiskOfferingById(volume.getDiskOfferingId());
         if (volume.getDiskOfferingId() > 0) {
+            boolean isServiceOffering = false;
             if (volume.getVolumeType().equals(Volume.Type.ROOT)) {
-                volResponse.setServiceOfferingId(volume.getDiskOfferingUuid());
+                isServiceOffering = true;
             } else {
-                volResponse.setDiskOfferingId(volume.getDiskOfferingUuid());
+                // can't rely on the fact that the volume is the datadisk as it might have
been created as a root, and
+                // then detached later
+                long offeringId = volume.getDiskOfferingId();
+                if (ApiDBUtils.findDiskOfferingById(offeringId) == null) {
+                    isServiceOffering = true;
+                }
             }
 
-            if (volume.getVolumeType().equals(Volume.Type.ROOT)) {
+            if (isServiceOffering) {
+                volResponse.setServiceOfferingId(volume.getDiskOfferingUuid());
                 volResponse.setServiceOfferingName(volume.getDiskOfferingName());
                 volResponse.setServiceOfferingDisplayText(volume.getDiskOfferingDisplayText());
             } else {
+                volResponse.setDiskOfferingId(volume.getDiskOfferingUuid());
                 volResponse.setDiskOfferingName(volume.getDiskOfferingName());
                 volResponse.setDiskOfferingDisplayText(volume.getDiskOfferingDisplayText());
             }
+
             volResponse.setStorageType(volume.isUseLocalStorage() ? ServiceOffering.StorageType.local.toString()
: ServiceOffering.StorageType.shared.toString());
             volResponse.setBytesReadRate(volume.getBytesReadRate());
             volResponse.setBytesWriteRate(volume.getBytesReadRate());


Mime
View raw message