You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/04/17 16:06:10 UTC

[1/7] git commit: updated refs/heads/4.5 to 48c1ffd

Repository: cloudstack
Updated Branches:
  refs/heads/4.5 9a8ee5664 -> 48c1ffd74


CLOUDSTACK-8134. Worker VMs don't have MS id set in vCenter annotation 'cloud.vm.workertag'.
Correctly register node info for a newly created VMware context.

(cherry picked from commit 13bdc1cef4ee0fae2f263777317c170302c49689)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 9565ad2f9cfa3240f1bb87e384a5c9819edb3037
Parents: 9a8ee56
Author: Likitha Shetty <li...@citrix.com>
Authored: Tue Dec 30 11:48:06 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Apr 17 15:34:43 2015 +0200

----------------------------------------------------------------------
 .../VmwareSecondaryStorageResourceHandler.java  | 23 +++++++++-----------
 1 file changed, 10 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9565ad2f/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
index e67fed6..8a27799 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
@@ -209,23 +209,20 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
             _resource.ensureOutgoingRuleForAddress(vCenterAddress);
 
             VmwareContext context = currentContext.get();
-            if (context != null) {
-                if(!context.validate()) {
-                    invalidateServiceContext(context);
-                    context = null;
-                } else {
-                    context.registerStockObject("serviceconsole", cmd.getContextParam("serviceconsole"));
-                    context.registerStockObject("manageportgroup", cmd.getContextParam("manageportgroup"));
-                    context.registerStockObject("noderuninfo", cmd.getContextParam("noderuninfo"));
-                }
+            if (context != null && !context.validate()) {
+                invalidateServiceContext(context);
+                context = null;
             }
-            if(context == null) {
-                s_logger.info("Open new VmwareContext. vCenter: " + vCenterAddress + ", user: " + username + ", password: " +
-                        StringUtils.getMaskedPasswordForDisplay(password));
+            if (context == null) {
+                s_logger.info("Open new VmwareContext. vCenter: " + vCenterAddress + ", user: " + username + ", password: " + StringUtils.getMaskedPasswordForDisplay(password));
                 VmwareSecondaryStorageContextFactory.setVcenterSessionTimeout(vCenterSessionTimeout);
                 context = VmwareSecondaryStorageContextFactory.getContext(vCenterAddress, username, password);
             }
-
+            if (context != null) {
+                context.registerStockObject("serviceconsole", cmd.getContextParam("serviceconsole"));
+                context.registerStockObject("manageportgroup", cmd.getContextParam("manageportgroup"));
+                context.registerStockObject("noderuninfo", cmd.getContextParam("noderuninfo"));
+            }
             currentContext.set(context);
             return context;
         } catch (Exception e) {


[4/7] git commit: updated refs/heads/4.5 to 48c1ffd

Posted by bh...@apache.org.
CLOUDSTACK-8319. For both 'MigrateVolume' and 'MigrateVMWithVolumes, ensure VM's vconfiguration files are migrated along with VM's root volume.

(cherry picked from commit bdd28a45ed1cc8046c63d0e840e54975e5b74ab5)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 55f2e45d14fe08fc88540616b7b3720fe12f5d4b
Parents: 89dbd1e
Author: Likitha Shetty <li...@citrix.com>
Authored: Thu Mar 5 14:24:46 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Apr 17 15:42:02 2015 +0200

----------------------------------------------------------------------
 .../agent/api/storage/MigrateVolumeCommand.java |  9 +++-
 .../motion/AncientDataMotionStrategy.java       |  2 +-
 .../vmware/resource/VmwareResource.java         | 45 +++++++++++++++-----
 .../hypervisor/vmware/mo/VirtualMachineMO.java  | 20 +++++++++
 4 files changed, 63 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55f2e45d/core/src/com/cloud/agent/api/storage/MigrateVolumeCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/storage/MigrateVolumeCommand.java b/core/src/com/cloud/agent/api/storage/MigrateVolumeCommand.java
index e5ba211..b409944 100644
--- a/core/src/com/cloud/agent/api/storage/MigrateVolumeCommand.java
+++ b/core/src/com/cloud/agent/api/storage/MigrateVolumeCommand.java
@@ -22,6 +22,7 @@ package com.cloud.agent.api.storage;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.to.StorageFilerTO;
 import com.cloud.storage.StoragePool;
+import com.cloud.storage.Volume;
 
 public class MigrateVolumeCommand extends Command {
 
@@ -29,6 +30,7 @@ public class MigrateVolumeCommand extends Command {
     String volumePath;
     StorageFilerTO pool;
     String attachedVmName;
+    Volume.Type volumeType;
 
     public MigrateVolumeCommand(long volumeId, String volumePath, StoragePool pool, int timeout) {
         this.volumeId = volumeId;
@@ -37,11 +39,12 @@ public class MigrateVolumeCommand extends Command {
         this.setWait(timeout);
     }
 
-    public MigrateVolumeCommand(long volumeId, String volumePath, StoragePool pool, String attachedVmName, int timeout) {
+    public MigrateVolumeCommand(long volumeId, String volumePath, StoragePool pool, String attachedVmName, Volume.Type volumeType, int timeout) {
         this.volumeId = volumeId;
         this.volumePath = volumePath;
         this.pool = new StorageFilerTO(pool);
         this.attachedVmName = attachedVmName;
+        this.volumeType = volumeType;
         this.setWait(timeout);
     }
 
@@ -65,4 +68,8 @@ public class MigrateVolumeCommand extends Command {
     public String getAttachedVmName() {
         return attachedVmName;
     }
+
+    public Volume.Type getVolumeType() {
+        return volumeType;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55f2e45d/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
index 203cfa4..7e572c3 100644
--- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
+++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
@@ -389,7 +389,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
 
         VolumeInfo volume = (VolumeInfo)srcData;
         StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(destData.getDataStore().getId(), DataStoreRole.Primary);
-        MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(), destPool, volume.getAttachedVmName(), waitInterval);
+        MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(), destPool, volume.getAttachedVmName(), volume.getVolumeType(), waitInterval);
         EndPoint ep = selector.select(srcData, StorageAction.MIGRATEVOLUME);
         Answer answer = null;
         if (ep == null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55f2e45d/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 8c7a012..ac93f9d 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -3029,7 +3029,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         List<VirtualMachineRelocateSpecDiskLocator> diskLocators = new ArrayList<VirtualMachineRelocateSpecDiskLocator>();
         VirtualMachineRelocateSpecDiskLocator diskLocator = null;
 
-        boolean isFirstDs = true;
         String tgtDsName = "";
         String tgtDsHost;
         String tgtDsPath;
@@ -3118,9 +3117,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                     morTgtDatastore = morDsAtSource;
                 }
 
-                if (isFirstDs) {
+                if (volume.getType() == Volume.Type.ROOT) {
                     relocateSpec.setDatastore(morTgtDatastore);
-                    isFirstDs = false;
                 }
                 diskLocator = new VirtualMachineRelocateSpecDiskLocator();
                 diskLocator.setDatastore(morTgtDatastore);
@@ -3130,6 +3128,18 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                 diskLocators.add(diskLocator);
                 volumeDeviceKey.put(volume.getId(), diskId);
             }
+            // If a target datastore is provided for the VM, then by default all volumes associated with the VM will be migrated to that target datastore.
+            // Hence set the existing datastore as target datastore for volumes that are not to be migrated.
+            List<Pair<Integer, ManagedObjectReference>> diskDatastores = vmMo.getAllDiskDatastores();
+            for (Pair<Integer, ManagedObjectReference> diskDatastore : diskDatastores) {
+                if (!volumeDeviceKey.containsValue(diskDatastore.first().intValue())) {
+                    diskLocator = new VirtualMachineRelocateSpecDiskLocator();
+                    diskLocator.setDiskId(diskDatastore.first().intValue());
+                    diskLocator.setDatastore(diskDatastore.second());
+                    diskLocators.add(diskLocator);
+                }
+            }
+
             relocateSpec.getDisk().addAll(diskLocators);
 
             // Prepare network at target before migration
@@ -3231,6 +3241,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
     private Answer execute(MigrateVolumeCommand cmd) {
         String volumePath = cmd.getVolumePath();
         StorageFilerTO poolTo = cmd.getPool();
+        Volume.Type volumeType = cmd.getVolumeType();
 
         if (s_logger.isInfoEnabled()) {
             s_logger.info("Executing resource MigrateVolumeCommand: " + _gson.toJson(cmd));
@@ -3277,9 +3288,23 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             diskLocator = new VirtualMachineRelocateSpecDiskLocator();
             diskLocator.setDatastore(morDs);
             diskLocator.setDiskId(diskId);
-
             diskLocators.add(diskLocator);
-            relocateSpec.getDisk().add(diskLocator);
+            if (cmd.getVolumeType() == Volume.Type.ROOT) {
+                relocateSpec.setDatastore(morDs);
+                // If a target datastore is provided for the VM, then by default all volumes associated with the VM will be migrated to that target datastore.
+                // Hence set the existing datastore as target datastore for volumes that are not to be migrated.
+                List<Pair<Integer, ManagedObjectReference>> diskDatastores = vmMo.getAllDiskDatastores();
+                for (Pair<Integer, ManagedObjectReference> diskDatastore : diskDatastores) {
+                    if (diskDatastore.first().intValue() != diskId) {
+                        diskLocator = new VirtualMachineRelocateSpecDiskLocator();
+                        diskLocator.setDiskId(diskDatastore.first().intValue());
+                        diskLocator.setDatastore(diskDatastore.second());
+                        diskLocators.add(diskLocator);
+                    }
+                }
+            }
+
+            relocateSpec.getDisk().addAll(diskLocators);
 
             // Change datastore
             if (!vmMo.changeDatastore(relocateSpec)) {
@@ -3292,12 +3317,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             // In case of a linked clone VM, if VM's disks are not consolidated,
             // further volume operations on the ROOT volume such as volume snapshot etc. will result in DB inconsistencies.
             String apiVersion = HypervisorHostHelper.getVcenterApiVersion(vmMo.getContext());
-            if (apiVersion.compareTo("5.0") >= 0) {
-                if (!vmMo.consolidateVmDisks()) {
-                    s_logger.warn("VM disk consolidation failed after storage migration.");
-                } else {
-                    s_logger.debug("Successfully consolidated disks of VM " + vmName + ".");
-                }
+            if (!vmMo.consolidateVmDisks()) {
+                s_logger.warn("VM disk consolidation failed after storage migration.");
+            } else {
+                s_logger.debug("Successfully consolidated disks of VM " + vmName + ".");
             }
 
             // Update and return volume path because that could have changed after migration

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55f2e45d/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 51ddd75..c037842 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -2083,6 +2083,26 @@ public class VirtualMachineMO extends BaseMO {
         return builder;
     }
 
+    public List<Pair<Integer, ManagedObjectReference>> getAllDiskDatastores() throws Exception {
+        List<Pair<Integer, ManagedObjectReference>> disks = new ArrayList<Pair<Integer, ManagedObjectReference>>();
+
+        List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
+        if (devices != null && devices.size() > 0) {
+            for (VirtualDevice device : devices) {
+                if (device instanceof VirtualDisk) {
+                    VirtualDeviceBackingInfo backingInfo = ((VirtualDisk)device).getBacking();
+                    if (backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
+                        VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
+                        disks.add(new Pair<Integer, ManagedObjectReference>(new Integer(device.getKey()), diskBackingInfo.getDatastore()));
+                    }
+                }
+            }
+        }
+
+        return disks;
+    }
+
+
     @Deprecated
     public List<Pair<String, ManagedObjectReference>> getDiskDatastorePathChain(VirtualDisk disk, boolean followChain) throws Exception {
         VirtualDeviceBackingInfo backingInfo = disk.getBacking();


[7/7] git commit: updated refs/heads/4.5 to 48c1ffd

Posted by bh...@apache.org.
CLOUDSTACK-8108. vCenter admin name is logged in clear text.
Revert back to TRACE logging while retrieving and recycling VMware context from the context pool.

(cherry picked from commit 0f224c858fd3612c66632ba3476bfc3f1f71e1df)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 48c1ffd740f4667ff0534a9a390784092825a202
Parents: 8aabab8
Author: Likitha Shetty <li...@citrix.com>
Authored: Wed Oct 22 14:40:39 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Apr 17 15:58:30 2015 +0200

----------------------------------------------------------------------
 .../cloud/hypervisor/vmware/util/VmwareContextPool.java | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/48c1ffd7/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java
index e28c974..c97c01f 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java
@@ -83,8 +83,8 @@ public class VmwareContextPool {
                 VmwareContext context = l.remove(0);
                 context.setPoolInfo(this, poolKey);
 
-                if (s_logger.isInfoEnabled())
-                    s_logger.info("Return a VmwareContext from the idle pool: " + poolKey + ". current pool size: " + l.size() + ", outstanding count: " +
+                if (s_logger.isTraceEnabled())
+                    s_logger.trace("Return a VmwareContext from the idle pool: " + poolKey + ". current pool size: " + l.size() + ", outstanding count: " +
                         VmwareContext.getOutstandingContextCount());
                 return context;
             }
@@ -108,12 +108,12 @@ public class VmwareContextPool {
                 context.clearStockObjects();
                 l.add(context);
 
-                if (s_logger.isInfoEnabled())
-                    s_logger.info("Recycle VmwareContext into idle pool: " + context.getPoolKey() + ", current idle pool size: " + l.size() + ", outstanding count: " +
+                if (s_logger.isTraceEnabled())
+                    s_logger.trace("Recycle VmwareContext into idle pool: " + context.getPoolKey() + ", current idle pool size: " + l.size() + ", outstanding count: " +
                         VmwareContext.getOutstandingContextCount());
             } else {
-                if (s_logger.isInfoEnabled())
-                    s_logger.info("VmwareContextPool queue exceeds limits, queue size: " + l.size());
+                if (s_logger.isTraceEnabled())
+                    s_logger.trace("VmwareContextPool queue exceeds limits, queue size: " + l.size());
                 context.close();
             }
         }


[6/7] git commit: updated refs/heads/4.5 to 48c1ffd

Posted by bh...@apache.org.
CLOUDSTACK-8119. [VMware] Cannot attach more than 8 volumes to a VM.

(cherry picked from commit b1bca2a2c02d0f0f5e3435fe2587334ae107495d)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 8aabab8a5629c06c8ee7aeffbf99dc67ccceb851
Parents: 4708a0b
Author: Likitha Shetty <li...@citrix.com>
Authored: Wed Dec 3 19:28:41 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Apr 17 15:54:03 2015 +0200

----------------------------------------------------------------------
 .../src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8aabab8a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 8f9eec0..ac5b414 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -2377,7 +2377,7 @@ public class VirtualMachineMO extends BaseMO {
 
         List<Integer> existingUnitNumbers = new ArrayList<Integer>();
         int deviceNumber = 0;
-        int ideControllerKey = getIDEDeviceControllerKey();
+        int scsiControllerKey = getScsiDeviceControllerKeyNoException();
         if (devices != null && devices.size() > 0) {
             for (VirtualDevice device : devices) {
                 if (device.getControllerKey() != null && device.getControllerKey().intValue() == controllerKey) {
@@ -2388,7 +2388,7 @@ public class VirtualMachineMO extends BaseMO {
         while (true) {
             // Next device number should be the lowest device number on the key that is not in use and is not reserved.
             if (!existingUnitNumbers.contains(Integer.valueOf(deviceNumber))) {
-                if (controllerKey != ideControllerKey && !VmwareHelper.isReservedScsiDeviceNumber(deviceNumber))
+                if (controllerKey != scsiControllerKey || !VmwareHelper.isReservedScsiDeviceNumber(deviceNumber))
                     break;
             }
             ++deviceNumber;


[5/7] git commit: updated refs/heads/4.5 to 48c1ffd

Posted by bh...@apache.org.
CLOUDSTACK-8119. [VMware] Cannot attach more than 8 volumes to a VM.
While attaching a new disk to an instance, the unit number on the controller key should be the lowest unit number
that is not in use. And in case the controller type is SCSI it shouln't be the reserved SCSI unit number.

(cherry picked from commit f420dd55fb5c4ec40aec0232618b2162c6d2f88c)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 4708a0b40dce0c4503a63e79190aefe0c011e298
Parents: 326bb3e
Author: Likitha Shetty <li...@citrix.com>
Authored: Mon Dec 1 19:49:06 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Apr 17 15:48:48 2015 +0200

----------------------------------------------------------------------
 .../com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java    | 9 ++++-----
 .../src/com/cloud/hypervisor/vmware/util/VmwareHelper.java  | 8 --------
 2 files changed, 4 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4708a0b4/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index c037842..8f9eec0 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -1056,8 +1056,6 @@ public class VirtualMachineMO extends BaseMO {
         }
 
         int deviceNumber = getNextDeviceNumber(controllerKey);
-        if (controllerKey != ideControllerKey && VmwareHelper.isReservedScsiDeviceNumber(deviceNumber))
-            deviceNumber++;
 
         newDisk.setControllerKey(controllerKey);
         newDisk.setKey(-deviceNumber);
@@ -1911,8 +1909,6 @@ public class VirtualMachineMO extends BaseMO {
     public int getNextScsiDiskDeviceNumber() throws Exception {
         int scsiControllerKey = getScsiDeviceControllerKey();
         int deviceNumber = getNextDeviceNumber(scsiControllerKey);
-        if (VmwareHelper.isReservedScsiDeviceNumber(deviceNumber))
-            deviceNumber++;
 
         return deviceNumber;
     }
@@ -2381,6 +2377,7 @@ public class VirtualMachineMO extends BaseMO {
 
         List<Integer> existingUnitNumbers = new ArrayList<Integer>();
         int deviceNumber = 0;
+        int ideControllerKey = getIDEDeviceControllerKey();
         if (devices != null && devices.size() > 0) {
             for (VirtualDevice device : devices) {
                 if (device.getControllerKey() != null && device.getControllerKey().intValue() == controllerKey) {
@@ -2389,8 +2386,10 @@ public class VirtualMachineMO extends BaseMO {
             }
         }
         while (true) {
+            // Next device number should be the lowest device number on the key that is not in use and is not reserved.
             if (!existingUnitNumbers.contains(Integer.valueOf(deviceNumber))) {
-                break;
+                if (controllerKey != ideControllerKey && !VmwareHelper.isReservedScsiDeviceNumber(deviceNumber))
+                    break;
             }
             ++deviceNumber;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4708a0b4/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
index 5e3daa2..7c69210 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
@@ -189,8 +189,6 @@ public class VmwareHelper {
             controllerKey = ideControllerKey;
         if (deviceNumber < 0) {
             deviceNumber = vmMo.getNextDeviceNumber(controllerKey);
-            if (controllerKey != ideControllerKey && isReservedScsiDeviceNumber(deviceNumber))
-                deviceNumber++;
         }
         disk.setControllerKey(controllerKey);
 
@@ -262,8 +260,6 @@ public class VmwareHelper {
         disk.setControllerKey(controllerKey);
         if (deviceNumber < 0) {
             deviceNumber = vmMo.getNextDeviceNumber(controllerKey);
-            if (controllerKey != ideControllerKey && isReservedScsiDeviceNumber(deviceNumber))
-                deviceNumber++;
         }
 
         disk.setKey(-contextNumber);
@@ -301,8 +297,6 @@ public class VmwareHelper {
                 controllerKey = ideControllerKey;
             if (deviceNumber < 0) {
                 deviceNumber = vmMo.getNextDeviceNumber(controllerKey);
-                if (controllerKey != ideControllerKey && isReservedScsiDeviceNumber(deviceNumber))
-                    deviceNumber++;
             }
 
             disk.setControllerKey(controllerKey);
@@ -355,8 +349,6 @@ public class VmwareHelper {
             controllerKey = ideControllerKey;
         if (deviceNumber < 0) {
             deviceNumber = vmMo.getNextDeviceNumber(controllerKey);
-            if (controllerKey != ideControllerKey && isReservedScsiDeviceNumber(deviceNumber))
-                deviceNumber++;
         }
 
         disk.setControllerKey(controllerKey);


[2/7] git commit: updated refs/heads/4.5 to 48c1ffd

Posted by bh...@apache.org.
CLOUDSTACK-8318. Storage vMotion support for VMFS.

MigrateVMWithVolumes-
1. If ESXi host version is below 5.1, ensure destination datastore(s) is mounted on the source host, then migrate the storage and then finally migrate the VM.
If destination storage(s) is not mounted on the source host,
- In case of NFS storage mount the storage(s).
- In case of VMFS storage fail the request for migration.
2. If EXi host version is 5.1 or above, simultaneously migrate the VM and its storage to the destination host and storage(s) respectively for both NFS and VMFS storage.

(cherry picked from commit adc836cc5eadb0b05aefa6fcdcf8c03841282609)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 89dbd1ea1ba8f365dcc30233ebbdef9d5ecf9fe9
Parents: 9565ad2
Author: Likitha Shetty <li...@citrix.com>
Authored: Thu Feb 26 15:42:40 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Apr 17 15:39:14 2015 +0200

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java         | 117 ++++++++++++-------
 .../cloud/hypervisor/vmware/mo/DatastoreMO.java |  20 ++++
 2 files changed, 94 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/89dbd1ea/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 3c7735d..8c7a012 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -3024,15 +3024,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         ManagedObjectReference morDc = null;
         ManagedObjectReference morDcOfTargetHost = null;
         ManagedObjectReference morTgtHost = new ManagedObjectReference();
+        ManagedObjectReference morTgtDatastore = new ManagedObjectReference();
         VirtualMachineRelocateSpec relocateSpec = new VirtualMachineRelocateSpec();
         List<VirtualMachineRelocateSpecDiskLocator> diskLocators = new ArrayList<VirtualMachineRelocateSpecDiskLocator>();
         VirtualMachineRelocateSpecDiskLocator diskLocator = null;
 
         boolean isFirstDs = true;
         String tgtDsName = "";
-        String tgtDsNfsHost;
-        String tgtDsNfsPath;
-        int tgtDsNfsPort;
+        String tgtDsHost;
+        String tgtDsPath;
+        int tgtDsPort;
         VolumeTO volume;
         StorageFilerTO filerTo;
         Set<String> mountedDatastoresAtSource = new HashSet<String>();
@@ -3055,6 +3056,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                 throw new CloudRuntimeException(msg);
             }
             VmwareManager mgr = tgtHyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
+            String srcHostApiVersion = ((HostMO)srcHyperHost).getHostAboutInfo().getApiVersion();
 
             // find VM through datacenter (VM is not at the target host yet)
             vmMo = srcHyperHost.findVmOnPeerHyperHost(vmName);
@@ -3065,47 +3067,68 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             }
             vmName = vmMo.getName();
 
-            // Get details of each target datastore & attach to source host.
+            // Specify destination datastore location for each volume
             for (Entry<VolumeTO, StorageFilerTO> entry : volToFiler.entrySet()) {
                 volume = entry.getKey();
                 filerTo = entry.getValue();
 
-                tgtDsName = filerTo.getUuid().replace("-", "");
-                tgtDsNfsHost = filerTo.getHost();
-                tgtDsNfsPath = filerTo.getPath();
-                tgtDsNfsPort = filerTo.getPort();
-
                 s_logger.debug("Preparing spec for volume : " + volume.getName());
                 morDsAtTarget = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(tgtHyperHost, filerTo.getUuid());
+                morDsAtSource = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(srcHyperHost, filerTo.getUuid());
                 if (morDsAtTarget == null) {
                     String msg = "Unable to find the mounted datastore with uuid " + morDsAtTarget + " to execute MigrateWithStorageCommand";
                     s_logger.error(msg);
                     throw new Exception(msg);
                 }
-                morDsAtSource = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(srcHyperHost, filerTo.getUuid());
-                if (morDsAtSource == null) {
-                    morDsAtSource = srcHyperHost.mountDatastore(false, tgtDsNfsHost, tgtDsNfsPort, tgtDsNfsPath, tgtDsName);
-                    if (morDsAtSource == null) {
-                        throw new Exception("Unable to mount datastore " + tgtDsNfsHost + ":/" + tgtDsNfsPath + " on " + _hostName);
+                morTgtDatastore = morDsAtTarget;
+
+                // If host version is below 5.1 then simultaneous change of VM's datastore and host is not supported.
+                // So since only the datastore will be changed first, ensure the target datastore is mounted on source host.
+                if (srcHostApiVersion.compareTo("5.1") < 0) {
+                    tgtDsName = filerTo.getUuid().replace("-", "");
+                    tgtDsHost = filerTo.getHost();
+                    tgtDsPath = filerTo.getPath();
+                    tgtDsPort = filerTo.getPort();
+
+                    // If datastore is NFS and target datastore is not already mounted on source host then mount the datastore.
+                    if (filerTo.getType().equals(StoragePoolType.NetworkFilesystem)) {
+                        if (morDsAtSource == null) {
+                            morDsAtSource = srcHyperHost.mountDatastore(false, tgtDsHost, tgtDsPort, tgtDsPath, tgtDsName);
+                            if (morDsAtSource == null) {
+                                throw new Exception("Unable to mount NFS datastore " + tgtDsHost + ":/" + tgtDsPath + " on " + _hostName);
+                            }
+                            mountedDatastoresAtSource.add(tgtDsName);
+                            s_logger.debug("Mounted datastore " + tgtDsHost + ":/" + tgtDsPath + " on " + _hostName);
+                        }
                     }
-                    mountedDatastoresAtSource.add(tgtDsName);
-                    s_logger.debug("Mounted datastore " + tgtDsNfsHost + ":/" + tgtDsNfsPath + " on " + _hostName);
+
+                    // If datastore is VMFS and target datastore is not mounted or accessible to source host then fail migration.
+                    if (filerTo.getType().equals(StoragePoolType.VMFS)) {
+                        if (morDsAtSource == null) {
+                            s_logger.warn("If host version is below 5.1, then target VMFS datastore(s) need to manually mounted on source host for a successful live storage migration.");
+                            throw new Exception("Target VMFS datastore: " + tgtDsPath + " is not mounted on source host: " + _hostName);
+                        }
+                        DatastoreMO dsAtSourceMo = new DatastoreMO(getServiceContext(), morDsAtSource);
+                        String srcHostValue = srcHyperHost.getMor().getValue();
+                        if(!dsAtSourceMo.isAccessibleToHost(srcHostValue)) {
+                            s_logger.warn("If host version is below 5.1, then target VMFS datastore(s) need to accessible to source host for a successful live storage migration.");
+                            throw new Exception("Target VMFS datastore: " + tgtDsPath + " is not accessible on source host: " + _hostName);
+                        }
+                    }
+                    morTgtDatastore = morDsAtSource;
                 }
 
                 if (isFirstDs) {
-                    relocateSpec.setDatastore(morDsAtSource);
+                    relocateSpec.setDatastore(morTgtDatastore);
                     isFirstDs = false;
                 }
-                VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(new DatastoreMO(srcHyperHost.getContext(), morDsAtSource), vmName, volume.getPath() +
-                        ".vmdk");
                 diskLocator = new VirtualMachineRelocateSpecDiskLocator();
-                diskLocator.setDatastore(morDsAtSource);
+                diskLocator.setDatastore(morTgtDatastore);
                 int diskId = getVirtualDiskInfo(vmMo, volume.getPath() + ".vmdk");
                 diskLocator.setDiskId(diskId);
 
                 diskLocators.add(diskLocator);
                 volumeDeviceKey.put(volume.getId(), diskId);
-
             }
             relocateSpec.getDisk().addAll(diskLocators);
 
@@ -3129,23 +3152,39 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                 throw new Exception(msg);
             }
 
-            // Change datastore
-            if (!vmMo.changeDatastore(relocateSpec)) {
-                throw new Exception("Change datastore operation failed during storage migration");
+            if (srcHostApiVersion.compareTo("5.1") < 0) {
+                // Migrate VM's volumes to target datastore(s).
+                if (!vmMo.changeDatastore(relocateSpec)) {
+                    throw new Exception("Change datastore operation failed during storage migration");
+                } else {
+                    s_logger.debug("Successfully migrated storage of VM " + vmName + " to target datastore(s)");
+                }
+
+                // Migrate VM to target host.
+                ManagedObjectReference morPool = tgtHyperHost.getHyperHostOwnerResourcePool();
+                if (!vmMo.migrate(morPool, tgtHyperHost.getMor())) {
+                    throw new Exception("VM migration to target host failed during storage migration");
+                } else {
+                    s_logger.debug("Successfully migrated VM " + vmName + " from " + _hostName + " to " + tgtHyperHost.getHyperHostName());
+                }
             } else {
-                s_logger.debug("Successfully migrated storage of VM " + vmName + " to target datastore(s)");
+                // Simultaneously migrate VM's volumes to target datastore and VM to target host.
+                relocateSpec.setHost(tgtHyperHost.getMor());
+                relocateSpec.setPool(tgtHyperHost.getHyperHostOwnerResourcePool());
+                if (!vmMo.changeDatastore(relocateSpec)) {
+                    throw new Exception("Change datastore operation failed during storage migration");
+                } else {
+                    s_logger.debug("Successfully migrated VM " + vmName + " from " + _hostName + " to " + tgtHyperHost.getHyperHostName() +
+                            " and its storage to target datastore(s)");
+                }
             }
 
             // Consolidate VM disks.
-            // In case of a linked clone VM, if VM's disks are not consolidated,
-            // further VM operations such as volume snapshot, VM snapshot etc. will result in DB inconsistencies.
-            String apiVersion = HypervisorHostHelper.getVcenterApiVersion(vmMo.getContext());
-            if (apiVersion.compareTo("5.0") >= 0) {
-                if (!vmMo.consolidateVmDisks()) {
-                    s_logger.warn("VM disk consolidation failed after storage migration. Yet proceeding with VM migration.");
-                } else {
-                    s_logger.debug("Successfully consolidated disks of VM " + vmName + ".");
-                }
+            // In case of a linked clone VM, if VM's disks are not consolidated, further VM operations such as volume snapshot, VM snapshot etc. will result in DB inconsistencies.
+            if (!vmMo.consolidateVmDisks()) {
+                s_logger.warn("VM disk consolidation failed after storage migration. Yet proceeding with VM migration.");
+            } else {
+                s_logger.debug("Successfully consolidated disks of VM " + vmName + ".");
             }
 
             // Update and return volume path for every disk because that could have changed after migration
@@ -3164,14 +3203,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                 }
             }
 
-            // Change host
-            ManagedObjectReference morPool = tgtHyperHost.getHyperHostOwnerResourcePool();
-            if (!vmMo.migrate(morPool, tgtHyperHost.getMor())) {
-                throw new Exception("Change datastore operation failed during storage migration");
-            } else {
-                s_logger.debug("Successfully relocated VM " + vmName + " from " + _hostName + " to " + tgtHyperHost.getHyperHostName());
-            }
-
             return new MigrateWithStorageAnswer(cmd, volumeToList);
         } catch (Throwable e) {
             if (e instanceof RemoteException) {
@@ -3221,7 +3252,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         try {
             srcHyperHost = getHyperHost(getServiceContext());
             morDc = srcHyperHost.getHyperHostDatacenter();
-            tgtDsName = poolTo.getUuid().replace("-", "");
+            tgtDsName = poolTo.getUuid();
 
             // find VM in this datacenter not just in this cluster.
             DatacenterMO dcMo = new DatacenterMO(getServiceContext(), morDc);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/89dbd1ea/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatastoreMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatastoreMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatastoreMO.java
index 7a1c28a..fbba33e 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatastoreMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatastoreMO.java
@@ -21,9 +21,11 @@ import java.util.List;
 
 import org.apache.log4j.Logger;
 
+import com.vmware.vim25.DatastoreHostMount;
 import com.vmware.vim25.DatastoreSummary;
 import com.vmware.vim25.FileInfo;
 import com.vmware.vim25.HostDatastoreBrowserSearchResults;
+import com.vmware.vim25.HostMountInfo;
 import com.vmware.vim25.ManagedObjectReference;
 import com.vmware.vim25.ObjectContent;
 import com.vmware.vim25.ObjectSpec;
@@ -66,6 +68,10 @@ public class DatastoreMO extends BaseMO {
         return new HostDatastoreBrowserMO(_context, (ManagedObjectReference)_context.getVimClient().getDynamicProperty(_mor, "browser"));
     }
 
+    public List<DatastoreHostMount> getHostMounts() throws Exception {
+        return _context.getVimClient().getDynamicProperty(_mor, "host");
+    }
+
     public String getInventoryPath() throws Exception {
         Pair<DatacenterMO, String> dcInfo = getOwnerDatacenter();
         return dcInfo.second() + "/" + getName();
@@ -380,4 +386,18 @@ public class DatastoreMO extends BaseMO {
         }
         return absoluteFileName;
     }
+
+    public boolean isAccessibleToHost(String hostValue) throws Exception {
+        boolean isAccessible = true;
+        List<DatastoreHostMount> hostMounts = getHostMounts();
+        for (DatastoreHostMount hostMount : hostMounts) {
+            String hostMountValue = hostMount.getKey().getValue();
+            if (hostMountValue.equalsIgnoreCase(hostValue)) {
+                HostMountInfo mountInfo = hostMount.getMountInfo();
+                isAccessible = mountInfo.isAccessible();
+                break;
+            }
+        }
+        return isAccessible;
+    }
 }


[3/7] git commit: updated refs/heads/4.5 to 48c1ffd

Posted by bh...@apache.org.
CLOUDSTACK-8320. Upon a failed migration, a dummy volume is created which remains in 'Expunging' state.

Set destination volume path as NULL while duplicating volume during migration.
If migration fails, destination volume will be marked as removed. And if migration succeeds, volume path will be rightly updated.

(cherry picked from commit d30d5644bb59898ac60884280bd0767bf429ede8)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 326bb3e0a4d876b38d78b7f7bebe0f6a08863866
Parents: 55f2e45
Author: Likitha Shetty <li...@citrix.com>
Authored: Wed Feb 11 16:10:50 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Apr 17 15:42:02 2015 +0200

----------------------------------------------------------------------
 .../src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/326bb3e0/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 02b4095..b0555e2 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -829,6 +829,7 @@ public class VolumeServiceImpl implements VolumeService {
         VolumeVO newVol = new VolumeVO(volume);
         newVol.setInstanceId(null);
         newVol.setChainInfo(null);
+        newVol.setPath(null);
         newVol.setFolder(folder);
         newVol.setPodId(pool.getPodId());
         newVol.setPoolId(pool.getId());