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 02E14100D8 for ; Sat, 28 Dec 2013 09:15:38 +0000 (UTC) Received: (qmail 16995 invoked by uid 500); 28 Dec 2013 09:15:36 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 16784 invoked by uid 500); 28 Dec 2013 09:15:32 -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 16777 invoked by uid 99); 28 Dec 2013 09:15:30 -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:15:30 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B96D28807FF; Sat, 28 Dec 2013 09:15:29 +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: <274ae61b5cd745e58fc5d1ada1aadf4e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/4.3 to c15cf12 Date: Sat, 28 Dec 2013 09:15:29 +0000 (UTC) Updated Branches: refs/heads/4.3 8eb430f60 -> c15cf1230 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 Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c15cf123 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c15cf123 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c15cf123 Branch: refs/heads/4.3 Commit: c15cf1230841bcc107d923e1f126fe15763617ad Parents: 8eb430f Author: Sateesh Chodapuneedi Authored: Sat Dec 28 09:09:37 2013 +0530 Committer: Sateesh Chodapuneedi Committed: Sat Dec 28 09:09:37 2013 +0530 ---------------------------------------------------------------------- .../src/com/cloud/hypervisor/guru/VMwareGuru.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c15cf123/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 326a950..349b516 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java @@ -197,7 +197,7 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru, Co } } - 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); @@ -293,6 +293,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();