cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From likit...@apache.org
Subject [2/2] git commit: updated refs/heads/master to f1e3e83
Date Tue, 30 Sep 2014 10:02:41 GMT
BUG-ID: CLOUDSTACK-7653. VM's are not getting deleted from hypervisor after deleting from UI
when using zone wide primary storage.
While expunging a volume, CS chooses the endpoint to perform delete operation by selecting
any host that has the storage containing the volume mounted on it.
Instead, if the volume to be deleted is attached to a VM, the endpoint chosen by CCP should
be the host that contains the VM.


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

Branch: refs/heads/master
Commit: f1e3e83bbf763860dd33a18c36618b4714bf0dbe
Parents: 6b06970
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Mon Sep 8 15:42:48 2014 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Tue Sep 30 15:20:15 2014 +0530

----------------------------------------------------------------------
 .../engine/subsystem/api/storage/StorageAction.java      |  3 ++-
 .../storage/endpoint/DefaultEndPointSelector.java        | 11 +++++++++++
 .../cloud/storage/resource/VmwareStorageProcessor.java   |  9 ++++++---
 .../driver/CloudStackPrimaryDataStoreDriverImpl.java     |  7 ++++++-
 4 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1e3e83b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageAction.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageAction.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageAction.java
index 965df84..dc93f4a 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageAction.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageAction.java
@@ -22,5 +22,6 @@ public enum StorageAction {
     TAKESNAPSHOT,
     BACKUPSNAPSHOT,
     DELETESNAPSHOT,
-    MIGRATEVOLUME
+    MIGRATEVOLUME,
+    DELETEVOLUME
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1e3e83b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
index 0a867f6..c620c40 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
@@ -302,6 +302,17 @@ public class DefaultEndPointSelector implements EndPointSelector {
                     return getEndPointFromHostId(hostId);
                 }
             }
+        } else if (action == StorageAction.DELETEVOLUME) {
+            VolumeInfo volume = (VolumeInfo)object;
+            if (volume.getHypervisorType() == Hypervisor.HypervisorType.VMware) {
+                VirtualMachine vm = volume.getAttachedVM();
+                if (vm != null) {
+                    Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
+                    if (hostId != null) {
+                        return getEndPointFromHostId(hostId);
+                    }
+                }
+            }
         }
         return select(object);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1e3e83b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index b225e39..8a4ba08 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -1594,9 +1594,12 @@ public class VmwareStorageProcessor implements StorageProcessor {
 
                 String vmName = vol.getVmName();
                 if (vmName != null) {
-                    // Find VM under the datacenter and not just the cluster.
-                    DatacenterMO dcMo = new DatacenterMO(context, morDc);
-                    VirtualMachineMO vmMo = dcMo.findVm(vmName);
+                    VirtualMachineMO vmMo = clusterMo.findVmOnHyperHost(vmName);
+                    if (vmMo == null) {
+                        // Volume might be on a zone-wide storage pool, look for VM in datacenter
+                        DatacenterMO dcMo = new DatacenterMO(context, morDc);
+                        vmMo = dcMo.findVm(vmName);
+                    }
                     if (vmMo != null) {
                         if (s_logger.isInfoEnabled()) {
                             s_logger.info("Destroy root volume and VM itself. vmName " +
vmName);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1e3e83b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
index d58c0b1..bcc06b0 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java
@@ -204,7 +204,12 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
 
         CommandResult result = new CommandResult();
         try {
-            EndPoint ep = epSelector.select(data);
+            EndPoint ep = null;
+            if (data.getType() == DataObjectType.VOLUME) {
+                ep = epSelector.select(data, StorageAction.DELETEVOLUME);
+            } else {
+                ep = epSelector.select(data);
+            }
             if (ep == null) {
                 String errMsg = "No remote endpoint to send DeleteCommand, check if host
or ssvm is down?";
                 s_logger.error(errMsg);


Mime
View raw message