cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [03/20] git commit: updated refs/heads/4.5 to 64e938b
Date Mon, 02 Feb 2015 10:17:01 GMT
BUG-ID: CLOUDSTACK-7102. Volume migration fails with 'VM i-2-3-VM does not exist in VMware
datacenter' expection.
Look for a VM in vCenter based on both the vCenter name and CS internal name (required in
case 'vm.instancename.flag' is enabled).
During Attach Volume and Volume Migration, for lookup and other operations use VM's name as
obtained from vCenter instead of using the name set in the agent command.

(cherry picked from commit b8fdda0a34f5338db284ee616c5e04206c97b82e)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: c8a437b782296e2b4a9727b1204d7f1693f2c806
Parents: 8f4aa23
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Tue Oct 28 16:38:18 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Feb 2 13:51:04 2015 +0530

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java           |  6 ++++--
 .../storage/resource/VmwareStorageProcessor.java  |  1 +
 .../cloud/hypervisor/vmware/mo/DatacenterMO.java  | 18 ++++++------------
 3 files changed, 11 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c8a437b7/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 f55ca67..3b339ab 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
@@ -2921,7 +2921,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         }
 
         VirtualMachineTO vmTo = cmd.getVirtualMachine();
-        final String vmName = vmTo.getName();
+        String vmName = vmTo.getName();
 
         VmwareHypervisorHost srcHyperHost = null;
         VmwareHypervisorHost tgtHyperHost = null;
@@ -2971,6 +2971,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
+            vmName = vmMo.getName();
 
             // Get details of each target datastore & attach to source host.
             for (Entry<VolumeTO, StorageFilerTO> entry : volToFiler.entrySet()) {
@@ -3100,7 +3101,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
             s_logger.info("Executing resource MigrateVolumeCommand: " + _gson.toJson(cmd));
         }
 
-        final String vmName = cmd.getAttachedVmName();
+        String vmName = cmd.getAttachedVmName();
 
         VirtualMachineMO vmMo = null;
         VmwareHypervisorHost srcHyperHost = null;
@@ -3127,6 +3128,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
+            vmName = vmMo.getName();
             morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(srcHyperHost,
tgtDsName);
             if (morDs == null) {
                 String msg = "Unable to find the mounted datastore with name " + tgtDsName
+ " to execute MigrateVolumeCommand";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c8a437b7/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 7578261..621f005 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -1290,6 +1290,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
                 s_logger.error(msg);
                 throw new Exception(msg);
             }
+            vmName = vmMo.getName();
 
             ManagedObjectReference morDs = null;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c8a437b7/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
index ef13783..39a30be 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
@@ -82,19 +82,13 @@ public class DatacenterMO extends BaseMO {
     }
 
     public VirtualMachineMO findVm(String vmName) throws Exception {
-        List<ObjectContent> ocs = getVmPropertiesOnDatacenterVmFolder(new String[]
{"name"});
-        if (ocs != null && ocs.size() > 0) {
-            for (ObjectContent oc : ocs) {
-                List<DynamicProperty> props = oc.getPropSet();
-                if (props != null) {
-                    for (DynamicProperty prop : props) {
-                        if (prop.getVal().toString().equals(vmName))
-                            return new VirtualMachineMO(_context, oc.getObj());
-                    }
-                }
-            }
+        int key = getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
+        if (key == 0) {
+            s_logger.warn("Custom field " + CustomFieldConstants.CLOUD_VM_INTERNAL_NAME +
" is not registered ?!");
         }
-        return null;
+        String instanceNameCustomField = "value[" + key + "]";
+        List<ObjectContent> ocs = getVmPropertiesOnDatacenterVmFolder(new String[]
{"name", instanceNameCustomField});
+        return HypervisorHostHelper.findVmFromObjectContent(_context, ocs.toArray(new ObjectContent[0]),
vmName, instanceNameCustomField);
     }
 
     public List<VirtualMachineMO> findVmByNameAndLabel(String vmLabel) throws Exception
{


Mime
View raw message