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:36:25 UTC

git commit: updated refs/heads/master to 5e427bd

Updated Branches:
  refs/heads/master 17a675942 -> 5e427bd2f


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/5e427bd2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5e427bd2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5e427bd2

Branch: refs/heads/master
Commit: 5e427bd2f676846c22bc503147cdee13ccb1dcf2
Parents: 17a6759
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:36:06 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/5e427bd2/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/5e427bd2/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 2cab44d..21fcb0c 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -783,8 +783,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/5e427bd2/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 60d535e..f7b740b 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -979,11 +979,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>();
@@ -994,9 +995,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/5e427bd2/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 6a9a434..cb0e633 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -479,6 +479,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;
         }