You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by jb...@apache.org on 2016/11/17 05:32:43 UTC

[1/4] git commit: updated refs/heads/master to 5cc9070

Repository: cloudstack
Updated Branches:
  refs/heads/master becec33c2 -> 5cc9070b0


CLOUDSTACK-9502: DS template copies don\u2019t get deleted in VMware ESXi with multiple clusters and zone wide storage


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

Branch: refs/heads/master
Commit: 4104cea300504fe18445dfc3f0d1ac877baf66b6
Parents: a661a11
Author: nvazquez <ni...@gmail.com>
Authored: Mon Sep 19 10:52:52 2016 -0300
Committer: nvazquez <ni...@gmail.com>
Committed: Mon Sep 19 07:49:31 2016 -0700

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java         | 31 +++++++++++------
 .../vmware/resource/VmwareResourceTest.java     | 35 ++++++++++++++++++--
 2 files changed, 54 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4104cea3/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 238ba3e..75ed342 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -5539,17 +5539,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             VmwareHypervisorHost hyperHost = getHyperHost(context, null);
             VolumeTO vol = cmd.getVolume();
 
-            ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, vol.getPoolUuid());
-            if (morDs == null) {
-                String msg = "Unable to find datastore based on volume mount point " + vol.getMountPoint();
-                s_logger.error(msg);
-                throw new Exception(msg);
-            }
-
-            ManagedObjectReference morCluster = hyperHost.getHyperHostCluster();
-            ClusterMO clusterMo = new ClusterMO(context, morCluster);
+            VirtualMachineMO vmMo = findVmOnDatacenter(context, hyperHost, vol);
 
-            VirtualMachineMO vmMo = clusterMo.findVmOnHyperHost(vol.getPath());
             if (vmMo != null && vmMo.isTemplate()) {
                 if (s_logger.isInfoEnabled()) {
                     s_logger.info("Destroy template volume " + vol.getPath());
@@ -5574,6 +5565,26 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         }
     }
 
+    /**
+     * Use data center to look for vm, instead of randomly picking up a cluster<br/>
+     * (in multiple cluster environments vm could not be found if wrong cluster was chosen)
+     * @param context vmware context
+     * @param hyperHost vmware hv host
+     * @param vol volume
+     * @return a virtualmachinemo if could be found on datacenter.
+     * @throws Exception if there is an error while finding vm
+     * @throws CloudRuntimeException if datacenter cannot be found
+     */
+    protected VirtualMachineMO findVmOnDatacenter(VmwareContext context, VmwareHypervisorHost hyperHost, VolumeTO vol) throws Exception {
+        DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
+        if (dcMo.getMor() == null) {
+            String msg = "Unable to find VMware DC";
+            s_logger.error(msg);
+            throw new CloudRuntimeException(msg);
+        }
+        return dcMo.findVm(vol.getPath());
+    }
+
     private String getAbsoluteVmdkFile(VirtualDisk disk) {
         String vmdkAbsFile = null;
         VirtualDeviceBackingInfo backingInfo = disk.getBacking();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4104cea3/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java b/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
index 22388a8..a3e2daa 100644
--- a/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
+++ b/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
@@ -26,6 +26,8 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.never;
 
+import static org.powermock.api.mockito.PowerMockito.whenNew;
+
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
@@ -42,6 +44,7 @@ import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
+import com.vmware.vim25.ManagedObjectReference;
 import com.vmware.vim25.VirtualDevice;
 import com.vmware.vim25.VirtualMachineConfigSpec;
 import com.vmware.vim25.VirtualMachineVideoCard;
@@ -51,16 +54,22 @@ import com.cloud.agent.api.ScaleVmCommand;
 import com.cloud.agent.api.to.DataTO;
 import com.cloud.agent.api.to.NfsTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.agent.api.to.VolumeTO;
+import com.cloud.hypervisor.vmware.mo.DatacenterMO;
 import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
 import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.storage.resource.VmwareStorageProcessor;
 import com.cloud.storage.resource.VmwareStorageSubsystemCommandHandler;
 
+import com.cloud.utils.exception.CloudRuntimeException;
+
 @RunWith(PowerMockRunner.class)
-@PrepareForTest(CopyCommand.class)
+@PrepareForTest({CopyCommand.class, DatacenterMO.class, VmwareResource.class})
 public class VmwareResourceTest {
 
+    private static final String VOLUME_PATH = "XXXXXXXXXXXX";
+
     @Mock
     VmwareStorageProcessor storageProcessor;
     @Mock
@@ -102,6 +111,12 @@ public class VmwareResourceTest {
     DataTO srcDataTO;
     @Mock
     NfsTO srcDataNfsTO;
+    @Mock
+    VolumeTO volume;
+    @Mock
+    ManagedObjectReference mor;
+    @Mock
+    DatacenterMO datacenter;
 
     CopyCommand storageCmd;
 
@@ -117,6 +132,7 @@ public class VmwareResourceTest {
         when(storageCmd.getSrcTO()).thenReturn(srcDataTO);
         when(srcDataTO.getDataStore()).thenReturn(srcDataNfsTO);
         when(srcDataNfsTO.getNfsVersion()).thenReturn(NFS_VERSION);
+        when(volume.getPath()).thenReturn(VOLUME_PATH);
     }
 
     //Test successful scaling up the vm
@@ -210,4 +226,19 @@ public class VmwareResourceTest {
         verify(_resource, never()).examineStorageSubSystemCommandNfsVersion(storageCmd);
     }
 
-}
\ No newline at end of file
+    @Test(expected=CloudRuntimeException.class)
+    public void testFindVmOnDatacenterNullHyperHostReference() throws Exception {
+        when(hyperHost.getMor()).thenReturn(null);
+        _resource.findVmOnDatacenter(context, hyperHost, volume);
+    }
+
+    @Test
+    public void testFindVmOnDatacenter() throws Exception {
+        when(hyperHost.getHyperHostDatacenter()).thenReturn(mor);
+        when(datacenter.getMor()).thenReturn(mor);
+        when(datacenter.findVm(VOLUME_PATH)).thenReturn(vmMo);
+        whenNew(DatacenterMO.class).withArguments(context, mor).thenReturn(datacenter);
+        VirtualMachineMO result = _resource.findVmOnDatacenter(context, hyperHost, volume);
+        assertEquals(vmMo, result);
+    }
+}


[4/4] git commit: updated refs/heads/master to 5cc9070

Posted by jb...@apache.org.
Cleanup merge mistakes


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

Branch: refs/heads/master
Commit: 5cc9070b0b2663656af1c772800350ea2265c4ce
Parents: c66cf1c
Author: John Burwell <me...@cockamamy.net>
Authored: Thu Nov 17 00:09:56 2016 -0500
Committer: John Burwell <me...@cockamamy.net>
Committed: Thu Nov 17 00:09:56 2016 -0500

----------------------------------------------------------------------
 .../cloud/hypervisor/vmware/resource/VmwareResourceTest.java | 8 --------
 1 file changed, 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5cc9070b/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java b/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
index c8143a7..6f411dc 100644
--- a/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
+++ b/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
@@ -30,8 +30,6 @@ import static org.mockito.Mockito.times;
 import java.util.ArrayList;
 import static org.powermock.api.mockito.PowerMockito.whenNew;
 
-import static org.powermock.api.mockito.PowerMockito.whenNew;
-
 import java.util.Arrays;
 import java.util.EnumMap;
 import java.util.HashMap;
@@ -341,12 +339,6 @@ public class VmwareResourceTest {
         _resource.findVmOnDatacenter(context, hyperHost, volume);
     }
 
-    @Test(expected=CloudRuntimeException.class)
-    public void testFindVmOnDatacenterNullHyperHostReference() throws Exception {
-        when(hyperHost.getMor()).thenReturn(null);
-        _resource.findVmOnDatacenter(context, hyperHost, volume);
-    }
-
     @Test
     public void testFindVmOnDatacenter() throws Exception {
         when(hyperHost.getHyperHostDatacenter()).thenReturn(mor);


[2/4] git commit: updated refs/heads/master to 5cc9070

Posted by jb...@apache.org.
Merge pull request #1676 from nvazquez/dstemplates49

CLOUDSTACK-9502: DS template copies dont get deleted in VMware ESXi with multiple clusters and zone wide storage (include CLOUDSTACK-9386 into 4.9 release branch)Include #1560 into 4.9 release branch

* pr/1676:
  CLOUDSTACK-9502: DS template copies don\u2019t get deleted in VMware ESXi with multiple clusters and zone wide storage

Signed-off-by: John Burwell <me...@cockamamy.net>


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

Branch: refs/heads/master
Commit: 20b43767d72672119e56b04a2e5c2e6c54e40ad5
Parents: 74639b3 4104cea
Author: John Burwell <me...@cockamamy.net>
Authored: Wed Nov 16 22:15:50 2016 -0500
Committer: John Burwell <me...@cockamamy.net>
Committed: Wed Nov 16 22:15:50 2016 -0500

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java         | 31 +++++++++++------
 .../vmware/resource/VmwareResourceTest.java     | 35 ++++++++++++++++++--
 2 files changed, 54 insertions(+), 12 deletions(-)
----------------------------------------------------------------------



[3/4] git commit: updated refs/heads/master to 5cc9070

Posted by jb...@apache.org.
Merge release branch 4.9 to master

* 4.9:
  CLOUDSTACK-9502: DS template copies don\u2019t get deleted in VMware ESXi with multiple clusters and zone wide storage


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

Branch: refs/heads/master
Commit: c66cf1c60d78c44ba8a8402056e317bfff5c4283
Parents: becec33 20b4376
Author: John Burwell <me...@cockamamy.net>
Authored: Wed Nov 16 23:23:09 2016 -0500
Committer: John Burwell <me...@cockamamy.net>
Committed: Wed Nov 16 23:23:09 2016 -0500

----------------------------------------------------------------------
 .../hypervisor/vmware/resource/VmwareResourceTest.java      | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c66cf1c6/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
index 3aac132,a3e2daa..c8143a7
--- a/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
+++ b/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
@@@ -24,14 -25,10 +24,16 @@@ import static org.junit.Assert.assertFa
  import static org.junit.Assert.assertTrue;
  import static org.mockito.Mockito.any;
  import static org.mockito.Mockito.never;
 +import static org.mockito.Matchers.eq;
 +import static org.mockito.Mockito.times;
 +
 +import java.util.ArrayList;
 +import static org.powermock.api.mockito.PowerMockito.whenNew;
  
+ import static org.powermock.api.mockito.PowerMockito.whenNew;
+ 
  import java.util.Arrays;
 +import java.util.EnumMap;
  import java.util.HashMap;
  import java.util.Map;
  
@@@ -155,13 -132,7 +157,14 @@@ public class VmwareResourceTest 
          when(storageCmd.getSrcTO()).thenReturn(srcDataTO);
          when(srcDataTO.getDataStore()).thenReturn(srcDataNfsTO);
          when(srcDataNfsTO.getNfsVersion()).thenReturn(NFS_VERSION);
 +        when(videoCard.getVideoRamSizeInKB()).thenReturn(VIDEO_CARD_MEMORY_SIZE);
 +        when(volume.getPath()).thenReturn(VOLUME_PATH);
 +
 +        when(storageCmd.getDestTO()).thenReturn(destDataTO);
 +        when(destDataTO.getHypervisorType()).thenReturn(HypervisorType.VMware);
 +        when(destDataTO.getDataStore()).thenReturn(destDataStoreTO);
 +        when(destDataStoreTO.isFullCloneFlag()).thenReturn(FULL_CLONE_FLAG);
+         when(volume.getPath()).thenReturn(VOLUME_PATH);
      }
  
      //Test successful scaling up the vm
@@@ -329,15 -223,15 +332,21 @@@
      public void checkStorageProcessorAndHandlerNfsVersionAttributeVersionSet(){
          _resource.storageNfsVersion = NFS_VERSION;
          _resource.checkStorageProcessorAndHandlerNfsVersionAttribute(storageCmd);
 -        verify(_resource, never()).examineStorageSubSystemCommandNfsVersion(storageCmd);
 +        verify(_resource, never()).examineStorageSubSystemCommandNfsVersion(Matchers.eq(storageCmd), any(EnumMap.class));
 +    }
 +
 +    @Test(expected=CloudRuntimeException.class)
 +    public void testFindVmOnDatacenterNullHyperHostReference() throws Exception {
 +        when(hyperHost.getMor()).thenReturn(null);
 +        _resource.findVmOnDatacenter(context, hyperHost, volume);
      }
  
+     @Test(expected=CloudRuntimeException.class)
+     public void testFindVmOnDatacenterNullHyperHostReference() throws Exception {
+         when(hyperHost.getMor()).thenReturn(null);
+         _resource.findVmOnDatacenter(context, hyperHost, volume);
+     }
+ 
      @Test
      public void testFindVmOnDatacenter() throws Exception {
          when(hyperHost.getHyperHostDatacenter()).thenReturn(mor);