cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sate...@apache.org
Subject git commit: updated refs/heads/master to 9ca34f1
Date Sat, 28 Dec 2013 09:21:06 GMT
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 <sateesh@apache.org>

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 <sateesh@apache.org>
Authored: Sat Dec 28 09:13:58 2013 +0530
Committer: Sateesh Chodapuneedi <sateesh@apache.org>
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<NicTO> listForSort = new ArrayList<NicTO>();


Mime
View raw message