|
31 | 31 |
|
32 | 32 | import org.apache.log4j.Logger; |
33 | 33 |
|
| 34 | +import com.cloud.hypervisor.vmware.mo.DatastoreFile; |
34 | 35 | import com.vmware.vim25.FileInfo; |
35 | 36 | import com.vmware.vim25.FileQueryFlags; |
36 | 37 | import com.vmware.vim25.HostDatastoreBrowserSearchResults; |
@@ -1140,12 +1141,12 @@ private static String getSnapshotRelativeDirInSecStorage(long accountId, long vo |
1140 | 1141 | return "snapshots/" + accountId + "/" + volumeId; |
1141 | 1142 | } |
1142 | 1143 |
|
1143 | | - private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost, String fileName, ManagedObjectReference morDs, String exceptFileName) |
1144 | | - throws Exception { |
| 1144 | + private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost, String fileName, ManagedObjectReference morDs, |
| 1145 | + String exceptFileName, String vmName) throws Exception { |
1145 | 1146 | long size = 0; |
1146 | 1147 | DatastoreMO dsMo = new DatastoreMO(context, morDs); |
1147 | 1148 | HostDatastoreBrowserMO browserMo = dsMo.getHostDatastoreBrowserMO(); |
1148 | | - String datastorePath = "[" + dsMo.getName() + "]"; |
| 1149 | + String datastorePath = (new DatastoreFile(dsMo.getName(), vmName)).getPath(); |
1149 | 1150 | HostDatastoreBrowserSearchSpec searchSpec = new HostDatastoreBrowserSearchSpec(); |
1150 | 1151 | FileQueryFlags fqf = new FileQueryFlags(); |
1151 | 1152 | fqf.setFileSize(true); |
@@ -1306,11 +1307,11 @@ private void setVolumeToPathAndSize(List<VolumeObjectTO> volumeTOs, Map<String, |
1306 | 1307 | // get volume's chain size for this VM snapshot; exclude current volume vdisk |
1307 | 1308 | DataStoreTO store = volumeTO.getDataStore(); |
1308 | 1309 | ManagedObjectReference morDs = getDatastoreAsManagedObjectReference(baseName, hyperHost, store); |
1309 | | - long size = getVMSnapshotChainSize(context, hyperHost, baseName + "-*.vmdk", morDs, newPath); |
| 1310 | + long size = getVMSnapshotChainSize(context, hyperHost, baseName + "-*.vmdk", morDs, newPath, vmName); |
1310 | 1311 |
|
1311 | 1312 | if (volumeTO.getVolumeType() == Volume.Type.ROOT) { |
1312 | 1313 | // add memory snapshot size |
1313 | | - size += getVMSnapshotChainSize(context, hyperHost, vmName + "-*.vmsn", morDs, null); |
| 1314 | + size += getVMSnapshotChainSize(context, hyperHost, vmName + "-*.vmsn", morDs, null, vmName); |
1314 | 1315 | } |
1315 | 1316 |
|
1316 | 1317 | volumeTO.setSize(size); |
|
0 commit comments