cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [39/50] [abbrv] git commit: updated refs/heads/reporter to b26f3fc
Date Fri, 02 Jan 2015 14:36:31 GMT
CLOUDSTACK-8121. Data disk properties are not updated upon Creation/Deletion of VM snapshots.
Update the path and size of data volumes after snapshot creation/deletion by correctly trimming
only the snapshot postfix of a disk.


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

Branch: refs/heads/reporter
Commit: ac491c96075d65e35157380fe7d28fdd917c0e90
Parents: b1bca2a
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Thu Dec 4 19:20:45 2014 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Wed Dec 24 13:04:12 2014 +0530

----------------------------------------------------------------------
 .../manager/VmwareStorageManagerImpl.java       | 34 ++------------------
 .../hypervisor/vmware/mo/VirtualMachineMO.java  | 14 +-------
 .../hypervisor/vmware/util/VmwareHelper.java    | 13 ++++++++
 3 files changed, 16 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ac491c96/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 86b1edf..1981303 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
@@ -1159,36 +1159,6 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager
{
         return size;
     }
 
-    private String extractSnapshotBaseFileName(String input) {
-        if (input == null) {
-            return null;
-        }
-
-        String result = input;
-
-        final String fileType = ".vmdk";
-
-        if (result.endsWith(fileType)) {
-            // get rid of fileType
-            result = result.substring(0, result.length() - (fileType).length());
-        }
-
-        final String token = "-";
-
-        String[] str = result.split(token);
-        int length = str.length;
-
-        if (length == 1 || length == 2) {
-            return result;
-        }
-
-        if (length > 2) {
-            return str[0] + token + str[1];
-        }
-
-        return result;
-    }
-
     @Override
     public CreateVMSnapshotAnswer execute(VmwareHostService hostService, CreateVMSnapshotCommand
cmd) {
         List<VolumeObjectTO> volumeTOs = cmd.getVolumeTOs();
@@ -1291,7 +1261,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager
{
                         vmdkName = vmdkName.substring(vmdkName.indexOf(token) + token.length());
                     }
 
-                    baseName = extractSnapshotBaseFileName(vmdkName);
+                    baseName = VmwareHelper.trimSnapshotDeltaPostfix(vmdkName);
                 }
 
                 mapNewDisk.put(baseName, vmdkName);
@@ -1316,7 +1286,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager
{
                 baseName = oldPath.substring(1, oldPath.length() - 1);
             }
             else {
-                baseName = extractSnapshotBaseFileName(volumeTO.getPath());
+                baseName = VmwareHelper.trimSnapshotDeltaPostfix(volumeTO.getPath());
             }
 
             String newPath = mapNewDisk.get(baseName);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ac491c96/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 727903e..286aedd 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -34,7 +34,6 @@ 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;
@@ -1918,24 +1917,13 @@ 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");
 
         DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath);
         String srcBaseName = dsSrcFile.getFileBaseName();
-        String trimmedSrcBaseName = trimSnapshotDeltaPostfix(srcBaseName);
+        String trimmedSrcBaseName = VmwareHelper.trimSnapshotDeltaPostfix(srcBaseName);
 
         if (matchExactly) {
             s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath
+ " with base name: " + srcBaseName);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ac491c96/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 e38e7ee..b2b1090 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
@@ -29,6 +29,7 @@ import java.util.List;
 import java.util.Random;
 import java.util.UUID;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 
 import com.vmware.vim25.DistributedVirtualSwitchPortConnection;
@@ -703,4 +704,16 @@ public class VmwareHelper {
         // Object name that is greater than 32 is not safe in vCenter
         return UUID.randomUUID().toString().replaceAll("-", "");
     }
+
+    public 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;
+    }
+
 }


Mime
View raw message