cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [12/50] [abbrv] git commit: updated refs/heads/reporter to 28300b5
Date Wed, 08 Jul 2015 19:19:47 GMT
CLOUDSTACK-8600. Upon detaching a disk, delete VM folder if empty.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #545


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

Branch: refs/heads/reporter
Commit: 9463356ca61dc77faf539b8018db1f834d8fe815
Parents: 23c6642
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Thu Apr 16 14:22:13 2015 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Wed Jul 1 14:53:23 2015 +0200

----------------------------------------------------------------------
 .../storage/resource/VmwareStorageLayoutHelper.java | 16 ++++++++++++++--
 .../storage/resource/VmwareStorageProcessor.java    |  2 +-
 2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9463356c/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
index 96197ff..4096333 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageLayoutHelper.java
@@ -109,7 +109,7 @@ public class VmwareStorageLayoutHelper {
             // be left over in its previous owner VM. We will do a fixup synchronization
here by moving it to root
             // again.
             //
-            syncVolumeToRootFolder(dcMo, ds, vmdkName);
+            syncVolumeToRootFolder(dcMo, ds, vmdkName, vmName);
         }
 
         if (ds.fileExists(vmdkFullCloneModeLegacyPair[1])) {
@@ -133,11 +133,16 @@ public class VmwareStorageLayoutHelper {
         return vmdkLinkedCloneModePair[0];
     }
 
-    public static void syncVolumeToRootFolder(DatacenterMO dcMo, DatastoreMO ds, String vmdkName)
throws Exception {
+    public static void syncVolumeToRootFolder(DatacenterMO dcMo, DatastoreMO ds, String vmdkName,
String vmName) throws Exception {
         String fileDsFullPath = ds.searchFileInSubFolders(vmdkName + ".vmdk", false);
         if (fileDsFullPath == null)
             return;
 
+        String folderName = null;
+        if (ds.folderExists(String.format("[%s]", ds.getName()), vmName)) {
+            folderName = String.format("[%s] %s", ds.getName(), vmName);
+        }
+
         DatastoreFile srcDsFile = new DatastoreFile(fileDsFullPath);
         String companionFilePath = srcDsFile.getCompanionPath(vmdkName + "-flat.vmdk");
         if (ds.fileExists(companionFilePath)) {
@@ -159,6 +164,13 @@ public class VmwareStorageLayoutHelper {
         String targetPath = getLegacyDatastorePathFromVmdkFileName(ds, vmdkName + ".vmdk");
         s_logger.info("Fixup folder-synchronization. move " + fileDsFullPath + " -> "
+ targetPath);
         ds.moveDatastoreFile(fileDsFullPath, dcMo.getMor(), ds.getMor(), targetPath, dcMo.getMor(),
true);
+
+        if (folderName != null) {
+            String[] files = ds.listDirContent(folderName);
+            if (files == null || files.length == 0) {
+                ds.deleteFolder(folderName, dcMo.getMor());
+            }
+        }
     }
 
     public static void moveVolumeToRootFolder(DatacenterMO dcMo, List<String> detachedDisks)
throws Exception {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9463356c/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 7295685..ab07ec5 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -1368,7 +1368,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
                 if (isManaged) {
                     handleDatastoreAndVmdkDetachManaged(diskUuid, iScsiName, storageHost,
storagePort);
                 } else {
-                    VmwareStorageLayoutHelper.syncVolumeToRootFolder(dsMo.getOwnerDatacenter().first(),
dsMo, volumeTO.getPath());
+                    VmwareStorageLayoutHelper.syncVolumeToRootFolder(dsMo.getOwnerDatacenter().first(),
dsMo, volumeTO.getPath(), vmName);
                 }
             }
 


Mime
View raw message