cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject git commit: updated refs/heads/4.3 to 1cdc064
Date Thu, 05 Dec 2013 22:14:40 GMT
Updated Branches:
  refs/heads/4.3 dd34ae97f -> 1cdc064c4


CLOUDSTACK-4880:
check for host cpu capability while dynamic scaling a vm on the same host


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

Branch: refs/heads/4.3
Commit: 1cdc064c438d155bedf451fab37b76a4b0a9773b
Parents: dd34ae9
Author: Nitin Mehta <nitin.mehta@citrix.com>
Authored: Thu Dec 5 14:14:31 2013 -0800
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Thu Dec 5 14:14:31 2013 -0800

----------------------------------------------------------------------
 .../src/com/cloud/capacity/CapacityManager.java |  9 ++++++++
 .../com/cloud/capacity/CapacityManagerImpl.java | 22 ++++++++++++++++++++
 .../VirtualNetworkApplianceManagerImpl.java     |  4 ++--
 server/src/com/cloud/vm/UserVmManagerImpl.java  |  3 ++-
 4 files changed, 35 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1cdc064c/engine/components-api/src/com/cloud/capacity/CapacityManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/capacity/CapacityManager.java b/engine/components-api/src/com/cloud/capacity/CapacityManager.java
index 979c6f7..5483d09 100755
--- a/engine/components-api/src/com/cloud/capacity/CapacityManager.java
+++ b/engine/components-api/src/com/cloud/capacity/CapacityManager.java
@@ -75,4 +75,13 @@ public interface CapacityManager {
      * @return true if the count of host's running VMs >= hypervisor limit
      */
     boolean checkIfHostReachMaxGuestLimit(Host host);
+
+    /**
+     * Check if specified host has capability to support cpu cores and speed freq
+     * @param hostId the host to be checked
+     * @param cpuNum cpu number to check
+     * @param cpuSpeed cpu Speed to check
+     * @return true if the count of host's running VMs >= hypervisor limit
+     */
+    boolean checkIfHostHasCpuCapability(long hostId, Integer cpuNum, Integer cpuSpeed);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1cdc064c/server/src/com/cloud/capacity/CapacityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java
index 07cd40f..e52916f 100755
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@ -363,6 +363,28 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
     }
 
     @Override
+    public boolean checkIfHostHasCpuCapability(long hostId, Integer cpuNum, Integer cpuSpeed){
+
+        // Check host can support the Cpu Number and Speed.
+        Host host = _hostDao.findById(hostId);
+        boolean isCpuNumGood = host.getCpus().intValue() >= cpuNum;
+        boolean isCpuSpeedGood = host.getSpeed().intValue() >= cpuSpeed;
+        if(isCpuNumGood && isCpuSpeedGood){
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Host: " + hostId + " has cpu capability (cpu:" +host.getCpus()+
", speed:" + host.getSpeed() +
+                        ") to support requested CPU: " + cpuNum + " and requested speed:
" + cpuSpeed);
+            }
+            return true;
+        }else{
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Host: " + hostId + " doesn't have cpu capability (cpu:" +host.getCpus()+
", speed:" + host.getSpeed() +
+                        ") to support requested CPU: " + cpuNum + " and requested speed:
" + cpuSpeed);
+            }
+            return false;
+        }
+    }
+
+    @Override
     public boolean checkIfHostHasCapacity(long hostId, Integer cpu, long ram, boolean checkFromReservedCapacity,
float cpuOvercommitRatio, float memoryOvercommitRatio, boolean considerReservedCapacity) {
         boolean hasCapacity = false;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1cdc064c/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 85c5bc1..32db6f0 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -3433,9 +3433,9 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
     }
 
     protected boolean sendCommandsToRouter(final VirtualRouter router, Commands cmds) throws
AgentUnavailableException {
-        if(!checkRouterVersion(router)){
+        /*if(!checkRouterVersion(router)){
             throw new CloudRuntimeException("Router requires upgrade. Unable to send command
to router:" + router.getId());
-        }
+        } */
         Answer[] answers = null;
         try {
             answers = _agentMgr.send(router.getHostId(), cmds);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1cdc064c/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index d630fd5..5264c71 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1371,7 +1371,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
 
                     // #1 Check existing host has capacity
                     if( !excludes.shouldAvoid(ApiDBUtils.findHostById(vmInstance.getHostId()))
){
-                        existingHostHasCapacity = _capacityMgr.checkIfHostHasCapacity(vmInstance.getHostId(),
newServiceOffering.getSpeed() - currentServiceOffering.getSpeed(),
+                        existingHostHasCapacity = _capacityMgr.checkIfHostHasCpuCapability(vmInstance.getHostId(),
newCpu, newSpeed)
+                                && _capacityMgr.checkIfHostHasCapacity(vmInstance.getHostId(),
newServiceOffering.getSpeed() - currentServiceOffering.getSpeed(),
                                 (newServiceOffering.getRamSize() - currentServiceOffering.getRamSize())
* 1024L * 1024L, false, ApiDBUtils.getCpuOverprovisioningFactor(), 1f, false); // TO DO fill
it with mem.
                         excludes.addHost(vmInstance.getHostId());
                     }


Mime
View raw message