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/vmware-storage-motion to 83f7310
Date Wed, 29 May 2013 13:46:52 GMT
Updated Branches:
  refs/heads/vmware-storage-motion 004e74de1 -> 83f731049


CLOUDSTACK-2701 - Enable storage migration for VMware resources

Moved 2 methods that are not specific to VMware but Volume are moved to VolumeManager from
VmwareManager.
Moved datastore volume path constructing code to separate method.
Added check for source and target host, if they are from different DCs/vCenter instances.


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

Branch: refs/heads/vmware-storage-motion
Commit: 83f731049f00741628697f266afeb1edc50995eb
Parents: 004e74d
Author: Sateesh Chodapuneedi <sateesh@apache.org>
Authored: Wed May 29 19:11:21 2013 +0530
Committer: Sateesh Chodapuneedi <sateesh@apache.org>
Committed: Wed May 29 19:11:21 2013 +0530

----------------------------------------------------------------------
 .../hypervisor/vmware/manager/VmwareManager.java   |    4 ---
 .../vmware/manager/VmwareManagerImpl.java          |   19 ---------------
 .../vmware/manager/VmwareStorageManagerImpl.java   |   14 ++++++----
 .../hypervisor/vmware/resource/VmwareResource.java |   15 ++++++++++-
 server/src/com/cloud/storage/VolumeManager.java    |    4 +++
 .../src/com/cloud/storage/VolumeManagerImpl.java   |   13 ++++++++++
 6 files changed, 38 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83f73104/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
index 9273143..1f4552e 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
@@ -67,8 +67,4 @@ public interface VmwareManager {
     String getPrivateVSwitchName(long dcId, HypervisorType hypervisorType);
     
     public String getRootDiskController();
-
-    String getVmName(long l);
-
-    String getStoragePoolOfVolume(long volumeId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83f73104/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index 0d50a2c..3d7d85f 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -877,23 +877,4 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager,
Vmw
     public String getRootDiskController() {
         return _rootDiskController;
     }
-
-    @Override
-    public String getVmName(long volumeId) {
-        Long instanceId;
-        VolumeVO vol = _volDao.findById(volumeId);
-        instanceId = vol.getInstanceId();
-        VMInstanceVO vmInstance = null;
-        if (instanceId != null) {
-            vmInstance = _vmDao.findById(instanceId);
-        }
-        return vmInstance.getInstanceName();
-    }
-
-    @Override
-    public String getStoragePoolOfVolume(long volumeId) {
-        VolumeVO vol = _volDao.findById(volumeId);
-        long poolId = vol.getPoolId();
-        return dataStoreMgr.getPrimaryDataStore(poolId).getUuid();
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83f73104/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
index 43b2f73..a4b9dd3 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
@@ -328,9 +328,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager
{
 						workerVm = vmMo;
 
 						// attach volume to worker VM
-                        String datastoreVolumePath = dsMo.searchFileInSubFolders(volumePath
+ ".vmdk", true);
-                        assert (datastoreVolumePath != null) : "Virtual disk file must be
present in the datastore to attach it to VM.";
-
+                        String datastoreVolumePath = getVolumePathInDatastore(dsMo, volumePath
+ ".vmdk");
 						vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
 					}
 				}
@@ -1061,9 +1059,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager
{
                 }
 
                 //attach volume to worker VM
-                String datastoreVolumePath = dsMo.searchFileInSubFolders(volumePath + ".vmdk",
true);
-                assert (datastoreVolumePath != null) : "Virtual disk file must be present
in the datastore to attach it to VM.";
-
+                String datastoreVolumePath = getVolumePathInDatastore(dsMo, volumePath +
".vmdk");
                 workerVm.attachDisk(new String[] { datastoreVolumePath }, morDs);
                 vmMo = workerVm;
             }
@@ -1084,6 +1080,12 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager
{
         }
     }
 
+    private String getVolumePathInDatastore(DatastoreMO dsMo, String volumeFileName) throws
Exception {
+        String datastoreVolumePath = dsMo.searchFileInSubFolders(volumeFileName, true);
+        assert (datastoreVolumePath != null) : "Virtual disk file missing from datastore.";
+        return datastoreVolumePath;
+    }
+
     private Pair<String, String> copyVolumeFromSecStorage(VmwareHypervisorHost hyperHost,
long volumeId,
         DatastoreMO dsMo, String secStorageUrl, String exportName) throws Exception {
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83f73104/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 12924d7..4dc80b0 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
@@ -37,6 +37,7 @@ import java.util.Random;
 import java.util.TimeZone;
 import java.util.UUID;
 
+import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
@@ -234,6 +235,7 @@ import com.cloud.storage.Storage;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.Volume;
+import com.cloud.storage.VolumeManager;
 import com.cloud.storage.resource.StoragePoolResource;
 import com.cloud.storage.template.TemplateInfo;
 import com.cloud.utils.DateUtil;
@@ -336,6 +338,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
 
     protected final int _shutdown_waitMs = 300000;		// wait up to 5 minutes for shutdown
 
+    @Inject
+    protected VolumeManager volMgr;
+
     // out an operation
     protected final int _retry = 24;
     protected final int _sleep = 10000;
@@ -3444,6 +3449,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         ManagedObjectReference morDsAtTarget = null;
         ManagedObjectReference morDsAtSource = null;
         ManagedObjectReference morDc = null;
+        ManagedObjectReference morDcOfTargetHost = null;
         ManagedObjectReference morTgtHost = new ManagedObjectReference();
         VirtualMachineRelocateSpec relocateSpec = new VirtualMachineRelocateSpec();
         List<VirtualMachineRelocateSpecDiskLocator> diskLocators = new ArrayList<VirtualMachineRelocateSpecDiskLocator>();
@@ -3470,6 +3476,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
             srcHyperHost = getHyperHost(getServiceContext());
             tgtHyperHost = new HostMO(getServiceContext(), morTgtHost);
             morDc = srcHyperHost.getHyperHostDatacenter();
+            morDcOfTargetHost = tgtHyperHost.getHyperHostDatacenter();
+            if (morDc != morDcOfTargetHost) {
+                String msg = "Source host & target host are in different datacentesr";
+                throw new CloudRuntimeException(msg);
+            }
             VmwareManager mgr = tgtHyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
 
             // find VM through datacenter (VM is not at the target host yet)
@@ -3598,7 +3609,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
 
         VmwareContext context = getServiceContext();
         VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
-        final String vmName = mgr.getVmName(cmd.getVolumeId());
+        final String vmName = volMgr.getVmNameFromVolumeId(cmd.getVolumeId());
 
         VirtualMachineMO vmMo = null;
         VmwareHypervisorHost srcHyperHost = null;
@@ -3616,7 +3627,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         try {
             srcHyperHost = getHyperHost(getServiceContext());
             morDc = srcHyperHost.getHyperHostDatacenter();
-            srcDsName = mgr.getStoragePoolOfVolume(cmd.getVolumeId());
+            srcDsName = volMgr.getStoragePoolOfVolume(cmd.getVolumeId());
             tgtDsName = poolTo.getUuid().replace("-", "");
 
             // find VM through datacenter (VM is not at the target host yet)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83f73104/server/src/com/cloud/storage/VolumeManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManager.java b/server/src/com/cloud/storage/VolumeManager.java
index d198e5d..47fbda8 100644
--- a/server/src/com/cloud/storage/VolumeManager.java
+++ b/server/src/com/cloud/storage/VolumeManager.java
@@ -105,4 +105,8 @@ public interface VolumeManager extends VolumeApiService {
     DiskProfile allocateTemplatedVolume(Type type, String name,
             DiskOfferingVO offering, VMTemplateVO template, VMInstanceVO vm,
             Account owner);
+
+    String getVmNameFromVolumeId(long volumeId);
+
+    String getStoragePoolOfVolume(long volumeId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83f73104/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index 4b654eb..230103d 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -2604,4 +2604,17 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         }
     }
 
+
+    @Override
+    public String getVmNameFromVolumeId(long volumeId) {
+        Long instanceId;
+        VolumeVO volume = _volsDao.findById(volumeId);
+        return getVmNameOnVolume(volume);
+    }
+
+    @Override
+    public String getStoragePoolOfVolume(long volumeId) {
+        VolumeVO vol = _volsDao.findById(volumeId);
+        return dataStoreMgr.getPrimaryDataStore(vol.getPoolId()).getUuid();
+    }
 }


Mime
View raw message