You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/07/26 01:35:25 UTC

git commit: updated refs/heads/4.2 to 7ee655f

Updated Branches:
  refs/heads/4.2 3b39fb044 -> 7ee655f5c


CLOUDSTACK-2536: fix the regression introduced by 4c81ea69c4e8326cc81a0e2607f6a6d99645ce5f


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

Branch: refs/heads/4.2
Commit: 7ee655f5cd51bab1a5d654ce02a8ebb09d47f9a3
Parents: 3b39fb0
Author: Edison Su <su...@gmail.com>
Authored: Thu Jul 25 16:34:19 2013 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Thu Jul 25 16:35:09 2013 -0700

----------------------------------------------------------------------
 .../storage/snapshot/XenserverSnapshotStrategy.java    |  6 ++++--
 server/src/com/cloud/api/ApiDBUtils.java               |  9 +++++++--
 server/src/com/cloud/api/ApiResponseHelper.java        | 13 +++++++++----
 server/src/com/cloud/resource/ResourceManagerImpl.java |  4 ++++
 4 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ee655f5/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
index 79f7d65..ebbce5b 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
@@ -189,8 +189,10 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
             if (result) {
                 //snapshot is deleted on backup storage, need to delete it on primary storage
                 SnapshotDataStoreVO snapshotOnPrimary = snapshotStoreDao.findBySnapshot(snapshotId, DataStoreRole.Primary);
-                snapshotOnPrimary.setState(State.Destroyed);
-                snapshotStoreDao.update(snapshotOnPrimary.getId(), snapshotOnPrimary);
+                if (snapshotOnPrimary != null) {
+                    snapshotOnPrimary.setState(State.Destroyed);
+                    snapshotStoreDao.update(snapshotOnPrimary.getId(), snapshotOnPrimary);
+                }
             }
         } catch (Exception e) {
             s_logger.debug("Failed to delete snapshot: ", e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ee655f5/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 9b70e3c..b3dbe8d 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -782,8 +782,13 @@ public class ApiDBUtils {
         return _clusterDao.findById(clusterId);
     }
 
-    public static ClusterDetailsVO findClusterDetails(long clusterId, String name){
-         return _clusterDetailsDao.findDetail(clusterId,name);
+    public static String findClusterDetails(long clusterId, String name){
+        ClusterDetailsVO detailsVO = _clusterDetailsDao.findDetail(clusterId,name);
+        if (detailsVO != null) {
+            return detailsVO.getValue();
+        }
+
+        return null;
     }
 
     public static DiskOfferingVO findDiskOfferingById(Long diskOfferingId) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ee655f5/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index ec977ec..8e3d1ed 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -976,11 +976,12 @@ public class ApiResponseHelper implements ResponseGenerator {
         clusterResponse.setClusterType(cluster.getClusterType().toString());
         clusterResponse.setAllocationState(cluster.getAllocationState().toString());
         clusterResponse.setManagedState(cluster.getManagedState().toString());
-        String cpuOvercommitRatio=ApiDBUtils.findClusterDetails(cluster.getId(),"cpuOvercommitRatio").getValue();
-        String memoryOvercommitRatio=ApiDBUtils.findClusterDetails(cluster.getId(),"memoryOvercommitRatio").getValue();
+        String cpuOvercommitRatio = ApiDBUtils.findClusterDetails(cluster.getId(),"cpuOvercommitRatio");
+        String memoryOvercommitRatio = ApiDBUtils.findClusterDetails(cluster.getId(),"memoryOvercommitRatio");
         clusterResponse.setCpuOvercommitRatio(cpuOvercommitRatio);
         clusterResponse.setMemoryOvercommitRatio(memoryOvercommitRatio);
 
+
         if (showCapacities != null && showCapacities) {
             List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(null, null, cluster.getId());
             Set<CapacityResponse> capacityResponses = new HashSet<CapacityResponse>();
@@ -991,9 +992,13 @@ public class ApiResponseHelper implements ResponseGenerator {
                 capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
 
                 if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
-                    capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(cpuOvercommitRatio))));
+                    if (cpuOvercommitRatio != null) {
+                        capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(cpuOvercommitRatio))));
+                    }
                 } else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_MEMORY) {
-                    capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(memoryOvercommitRatio))));
+                    if (memoryOvercommitRatio != null) {
+                        capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity() * Float.parseFloat(memoryOvercommitRatio))));
+                    }
                 } else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
                     List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, null, cluster.getId());
                     capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ee655f5/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 12b9749..3985890 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -480,6 +480,10 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
         result.add(cluster);
 
         if (clusterType == Cluster.ClusterType.CloudManaged) {
+            Map<String, String> details = new HashMap<String, String>();
+            details.put("cpuOvercommitRatio", _configDao.getValue(Config.CPUOverprovisioningFactor.key()));
+            details.put("memoryOvercommitRatio", _configDao.getValue(Config.MemOverprovisioningFactor.key()));
+            _clusterDetailsDao.persist(cluster.getId(), details);
             return result;
         }