From 8aa0ab99daa97bdcbf33e4cd1843f898a3949326 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 24 Mar 2011 12:56:56 -0700 Subject: [PATCH] Bug 8208 - bare metal provisioning Start vm on last stayed host if vm has lastHostId --- server/src/com/cloud/deploy/BareMetalPlanner.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/deploy/BareMetalPlanner.java b/server/src/com/cloud/deploy/BareMetalPlanner.java index 2046f22373f..809c0b26ea2 100644 --- a/server/src/com/cloud/deploy/BareMetalPlanner.java +++ b/server/src/com/cloud/deploy/BareMetalPlanner.java @@ -45,6 +45,15 @@ public class BareMetalPlanner implements DeploymentPlanner { ServiceOffering offering = vmProfile.getServiceOffering(); String hostTag = null; + if (vm.getLastHostId() != null) { + HostVO h = _hostDao.findById(vm.getLastHostId()); + DataCenter dc = _dcDao.findById(h.getDataCenterId()); + Pod pod = _podDao.findById(h.getPodId()); + Cluster c = _clusterDao.findById(h.getClusterId()); + s_logger.debug("Start baremetal vm " + vm.getId() + " on last stayed host " + h.getId()); + return new DeployDestination(dc, pod, c, h); + } + if (offering.getTags() != null) { String[] tags = offering.getTags().split(","); if (tags.length > 0) { @@ -83,7 +92,7 @@ public class BareMetalPlanner implements DeploymentPlanner { for (HostVO h : hosts) { if (h.getStatus() == Status.Up) { - if(_capacityMgr.checkIfHostHasCapacity(h.getId(), cpu_requested, ram_requested, false)){ + if(_capacityMgr.checkIfHostHasCapacity(h.getId(), cpu_requested, ram_requested, true)){ s_logger.debug("Find host " + h.getId() + " has enough capacity"); DataCenter dc = _dcDao.findById(h.getDataCenterId()); Pod pod = _podDao.findById(h.getPodId());