Repository: cloudstack Updated Branches: refs/heads/master aabe6f2ba -> db9de2e39
CLOUDSTACK-6488 Fixed an issue where the "path" field was not being set properly in the DB when the volume had a snapshot taken of it Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/db9de2e3 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/db9de2e3 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/db9de2e3 Branch: refs/heads/master Commit: db9de2e39b096696cb45fb845945ece857905d9f Parents: aabe6f2 Author: Mike Tutkowski <mike.tutkow...@solidfire.com> Authored: Wed Apr 23 10:32:55 2014 -0600 Committer: Mike Tutkowski <mike.tutkow...@solidfire.com> Committed: Wed Apr 23 18:30:19 2014 -0600 ---------------------------------------------------------------------- .../manager/VmwareStorageManagerImpl.java | 27 ++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/db9de2e3/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 e37bf38..fbba322 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 @@ -1169,21 +1169,28 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { if (input == null) { return null; } + String result = input; - if (result.endsWith(".vmdk")) { // get rid of vmdk file extension - result = result.substring(0, result.length() - (".vmdk").length()); + + final String fileType = ".vmdk"; + + if (result.endsWith(fileType)) { + // get rid of fileType + result = result.substring(0, result.length() - (fileType).length()); } - if (result.split("-").length == 1) { + + String[] str = result.split("-"); + int length = str.length; + + if (length == 1 || length == 2) { return result; } - if (result.split("-").length > 2) { - return result.split("-")[0] + "-" + result.split("-")[1]; - } - if (result.split("-").length == 2) { - return result.split("-")[0]; - } else { - return result; + + if (length > 2) { + return str[0] + "-" + str[1]; } + + return result; } @Override