Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C7C62100DF for ; Sat, 28 Dec 2013 09:21:15 +0000 (UTC) Received: (qmail 17828 invoked by uid 500); 28 Dec 2013 09:21:12 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 17811 invoked by uid 500); 28 Dec 2013 09:21:09 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 17803 invoked by uid 99); 28 Dec 2013 09:21:06 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Dec 2013 09:21:06 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9101F880813; Sat, 28 Dec 2013 09:21:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sateesh@apache.org To: commits@cloudstack.apache.org Message-Id: <71189b9695434acfb0c82dc341709052@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to 9ca34f1 Date: Sat, 28 Dec 2013 09:21:06 +0000 (UTC) Updated Branches: refs/heads/master db9914618 -> 9ca34f14a CLOUDSTACK-5666 Cant remove a nic when a vm is in the Stopped state When VM is not running, existing code is unable to retrieve associated cluster's Id. Now we will try to get this information using previous host where the VM was running. Signed-off-by: Sateesh Chodapuneedi Conflicts: plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9ca34f14 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9ca34f14 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9ca34f14 Branch: refs/heads/master Commit: 9ca34f14a2fad303ba85f167150e3daf331082fa Parents: db99146 Author: Sateesh Chodapuneedi Authored: Sat Dec 28 09:13:58 2013 +0530 Committer: Sateesh Chodapuneedi Committed: Sat Dec 28 09:13:58 2013 +0530 ---------------------------------------------------------------------- .../src/com/cloud/hypervisor/guru/VMwareGuru.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ca34f14/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java index b326c54..d72787c 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java @@ -203,7 +203,8 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co break; } } - long clusterId = _hostDao.findById(_vmDao.findById(vm.getId()).getHostId()).getClusterId(); + + long clusterId = this.getClusterId(vm.getId()); details.put(Config.VmwareReserveCpu.key(), VmwareReserveCpu.valueIn(clusterId).toString()); details.put(Config.VmwareReserveMem.key(), VmwareReserveMemory.valueIn(clusterId).toString()); to.setDetails(details); @@ -298,6 +299,20 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co return to; } + private long getClusterId(long vmId) { + long clusterId; + Long hostId; + + hostId = _vmDao.findById(vmId).getHostId(); + if (hostId == null) { + // If VM is in stopped state then hostId would be undefined. Hence read last host's Id instead. + hostId = _vmDao.findById(vmId).getLastHostId(); + } + clusterId = _hostDao.findById(hostId).getClusterId(); + + return clusterId; + } + private NicTO[] sortNicsByDeviceId(NicTO[] nics) { List listForSort = new ArrayList();