cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject git commit: updated refs/heads/master to bfb28da
Date Fri, 11 Jul 2014 21:43:08 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 87effa40e -> bfb28da9f


Trim postfix appended to the disk name by vCenter after snapshot operation when we are locating
disk chain by name


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

Branch: refs/heads/master
Commit: bfb28da9fced01987796efd4cebd5766eb77a06e
Parents: 87effa4
Author: Kelven Yang <kelveny@gmail.com>
Authored: Fri Jul 11 14:42:46 2014 -0700
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Fri Jul 11 14:42:46 2014 -0700

----------------------------------------------------------------------
 .../hypervisor/vmware/mo/VirtualMachineMO.java     | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bfb28da9/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 df05f8a..e8d91f6 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -34,6 +34,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 
 import com.google.gson.Gson;
@@ -1939,14 +1940,28 @@ public class VirtualMachineMO extends BaseMO {
         }
     }
 
+    private static String trimSnapshotDeltaPostfix(String name) {
+        String[] tokens = name.split("-");
+        if (tokens.length > 1 && tokens[tokens.length - 1].matches("[0-9]{6,}"))
{
+            List<String> trimmedTokens = new ArrayList<String>();
+            for (int i = 0; i < tokens.length - 1; i++)
+                trimmedTokens.add(tokens[i]);
+            return StringUtils.join(trimmedTokens, "-");
+        }
+        return name;
+    }
+
     // return pair of VirtualDisk and disk device bus name(ide0:0, etc)
     public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath, boolean
matchExactly) throws Exception {
         List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor,
"config.hardware.device");
 
-        s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath);
         DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath);
         String srcBaseName = dsSrcFile.getFileBaseName();
 
+        srcBaseName = trimSnapshotDeltaPostfix(srcBaseName);
+
+        s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath + "
with trimmed base name: " + srcBaseName);
+
         if (devices != null && devices.size() > 0) {
             for (VirtualDevice device : devices) {
                 if (device instanceof VirtualDisk) {


Mime
View raw message