FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

CLOUDSTACK-8600. Upon detaching a disk, delete VM folder if empty. by likitha · Pull Request #545 · apache/cloudstack · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static String syncVolumeToVmDefaultFolder(DatacenterMO dcMo, String vmNam
// 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])) {
Expand All @@ -133,11 +133,16 @@ public static String syncVolumeToVmDefaultFolder(DatacenterMO dcMo, String vmNam
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)) {
Expand All @@ -159,6 +164,13 @@ public static void syncVolumeToRootFolder(DatacenterMO dcMo, DatastoreMO ds, Str
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 {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ private Answer attachVolume(Command cmd, DiskTO disk, boolean isAttach, boolean
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);
}
}

Expand Down

Back | FazBrowse Home | New Git URL