|
34 | 34 | import java.util.concurrent.Executors; |
35 | 35 | import java.util.concurrent.Future; |
36 | 36 |
|
| 37 | +import org.apache.commons.lang.StringUtils; |
37 | 38 | import org.apache.log4j.Logger; |
38 | 39 |
|
39 | 40 | import com.google.gson.Gson; |
@@ -1939,14 +1940,28 @@ public void ensureScsiDeviceController() throws Exception { |
1939 | 1940 | } |
1940 | 1941 | } |
1941 | 1942 |
|
| 1943 | + private static String trimSnapshotDeltaPostfix(String name) { |
| 1944 | + String[] tokens = name.split("-"); |
| 1945 | + if (tokens.length > 1 && tokens[tokens.length - 1].matches("[0-9]{6,}")) { |
| 1946 | + List<String> trimmedTokens = new ArrayList<String>(); |
| 1947 | + for (int i = 0; i < tokens.length - 1; i++) |
| 1948 | + trimmedTokens.add(tokens[i]); |
| 1949 | + return StringUtils.join(trimmedTokens, "-"); |
| 1950 | + } |
| 1951 | + return name; |
| 1952 | + } |
| 1953 | + |
1942 | 1954 | // return pair of VirtualDisk and disk device bus name(ide0:0, etc) |
1943 | 1955 | public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath, boolean matchExactly) throws Exception { |
1944 | 1956 | List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); |
1945 | 1957 |
|
1946 | | - s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath); |
1947 | 1958 | DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath); |
1948 | 1959 | String srcBaseName = dsSrcFile.getFileBaseName(); |
1949 | 1960 |
|
| 1961 | + srcBaseName = trimSnapshotDeltaPostfix(srcBaseName); |
| 1962 | + |
| 1963 | + s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath + " with trimmed base name: " + srcBaseName); |
| 1964 | + |
1950 | 1965 | if (devices != null && devices.size() > 0) { |
1951 | 1966 | for (VirtualDevice device : devices) { |
1952 | 1967 | if (device instanceof VirtualDisk) { |
|
0 commit comments