cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject [8/50] [abbrv] git commit: refs/heads/cisco-vnmc-api-integration - CLOUDSTACK 711: CPU and RAM overcommit update cluster part
Date Wed, 13 Mar 2013 06:25:05 GMT
CLOUDSTACK 711: CPU and RAM overcommit update cluster part


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

Branch: refs/heads/cisco-vnmc-api-integration
Commit: 667aa1751219fc48daefba62a253baaf4b71c6e4
Parents: 54f7933
Author: Bharat Kumar <bharat.kumar@citrix.com>
Authored: Fri Feb 22 20:09:50 2013 +0530
Committer: Abhinandan Prateek <aprateek@apache.org>
Committed: Fri Feb 22 20:09:50 2013 +0530

----------------------------------------------------------------------
 api/src/com/cloud/resource/ResourceService.java    |    2 +-
 .../kvm/resource/LibvirtComputingResource.java     |   10 +---
 .../com/cloud/resource/ResourceManagerImpl.java    |   38 ++++++++++++++-
 .../cloud/resource/MockResourceManagerImpl.java    |    3 +
 4 files changed, 44 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/667aa175/api/src/com/cloud/resource/ResourceService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/resource/ResourceService.java b/api/src/com/cloud/resource/ResourceService.java
index 83718d4..08e2585 100755
--- a/api/src/com/cloud/resource/ResourceService.java
+++ b/api/src/com/cloud/resource/ResourceService.java
@@ -71,7 +71,7 @@ public interface ResourceService {
 
     boolean deleteCluster(DeleteClusterCmd cmd);
 
-    Cluster updateCluster(Cluster cluster, String clusterType, String hypervisor, String
allocationState, String managedstate, Float memoryOvercommitRaito, Float cpuOvercommitRatio);
+    Cluster updateCluster(Cluster cluster, String clusterType, String hypervisor, String
allocationState, String managedstate,Float memoryOvercommitRatio, Float cpuOvercommitRatio);
 
     List<? extends Host> discoverHosts(AddHostCmd cmd) throws IllegalArgumentException,
DiscoveryException, InvalidParameterValueException;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/667aa175/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index f7d1b4a..99b8723 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -2921,15 +2921,11 @@ ServerResource {
         vm.addComp(guest);
 
         GuestResourceDef grd = new GuestResourceDef();
-        //check if overcommit should be considered.
-        if(vmTO.getMinSpeed() == vmTO.getMaxSpeed()){
 
-
-        }
         if (vmTO.getMinRam() != vmTO.getMaxRam()){
-             grd.setMemBalloning(true);
-             grd.setCurrentMem((int)vmTO.getMinRam()/1024);
-             grd.setMemorySize((int)vmTO.getMaxRam()/1024);
+            grd.setMemBalloning(true);
+            grd.setCurrentMem((int)vmTO.getMinRam()/1024);
+            grd.setMemorySize((int)vmTO.getMaxRam()/1024);
         }
         else{
             grd.setMemorySize(vmTO.getMaxRam() / 1024);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/667aa175/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 0df1563..14628c1 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -496,6 +496,17 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
         _clusterDetailsDao.persist(cluster_detail_cpu);
         _clusterDetailsDao.persist(cluster_detail_ram);
+        //create a new entry only if the overcommit ratios are greater than 1.
+        if(cmd.getCpuOvercommitRatio().compareTo(1f) > 0) {
+            cluster_detail_cpu = new ClusterDetailsVO(clusterId, "cpuOvercommitRatio", Float.toString(cmd.getCpuOvercommitRatio()));
+            _clusterDetailsDao.persist(cluster_detail_cpu);
+        }
+
+
+        if(cmd.getMemoryOvercommitRaito().compareTo(1f) > 0) {
+             cluster_detail_ram = new ClusterDetailsVO(clusterId, "memoryOvercommitRatio",
Float.toString(cmd.getMemoryOvercommitRaito()));
+            _clusterDetailsDao.persist(cluster_detail_ram);
+        }
 
 
         boolean success = false;
@@ -1065,7 +1076,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
     @Override
     @DB
 	public Cluster updateCluster(Cluster clusterToUpdate, String clusterType,
-                                 String hypervisor, String allocationState, String managedstate,
Float memoryOvercommitRaito, Float cpuOvercommitRatio) {
+			String hypervisor, String allocationState, String managedstate,Float memoryovercommitratio,
Float cpuovercommitratio) {
 
         ClusterVO cluster = (ClusterVO) clusterToUpdate;
         // Verify cluster information and update the cluster if needed
@@ -1148,6 +1159,31 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
             }
         }
 
+       ClusterDetailsVO memory_detail = _clusterDetailsDao.findDetail(cluster.getId(),"memoryOvercommitRatio");
+       if( memory_detail == null){
+           if (memoryovercommitratio.compareTo(1f) > 0){
+               memory_detail = new ClusterDetailsVO(cluster.getId(),"memoryOvercommitRatio",Float.toString(memoryovercommitratio));
+               _clusterDetailsDao.persist(memory_detail);
+           }
+       }
+       else {
+           memory_detail.setValue(Float.toString(memoryovercommitratio));
+           _clusterDetailsDao.update(memory_detail.getId(),memory_detail);
+       }
+
+        ClusterDetailsVO cpu_detail = _clusterDetailsDao.findDetail(cluster.getId(),"cpuOvercommitRatio");
+        if( cpu_detail == null){
+            if (cpuovercommitratio.compareTo(1f) > 0){
+                cpu_detail = new ClusterDetailsVO(cluster.getId(),"cpuOvercommitRatio",Float.toString(cpuovercommitratio));
+                _clusterDetailsDao.persist(cpu_detail);
+            }
+        }
+        else {
+            cpu_detail.setValue(Float.toString(cpuovercommitratio));
+            _clusterDetailsDao.update(cpu_detail.getId(),cpu_detail);
+        }
+
+
         if (doUpdate) {
             Transaction txn = Transaction.currentTxn();
             try {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/667aa175/server/test/com/cloud/resource/MockResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/resource/MockResourceManagerImpl.java b/server/test/com/cloud/resource/MockResourceManagerImpl.java
index e7ab858..1d851a0 100644
--- a/server/test/com/cloud/resource/MockResourceManagerImpl.java
+++ b/server/test/com/cloud/resource/MockResourceManagerImpl.java
@@ -54,6 +54,9 @@ import com.cloud.storage.Swift;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.component.Manager;
+
+
 import com.cloud.utils.fsm.NoTransitionException;
 
 @Local(value = {ResourceManager.class})


Mime
View raw message