Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 056F710EFA for ; Tue, 18 Mar 2014 07:50:14 +0000 (UTC) Received: (qmail 9440 invoked by uid 500); 18 Mar 2014 07:50:13 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 9221 invoked by uid 500); 18 Mar 2014 07:50:12 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 9213 invoked by uid 99); 18 Mar 2014 07:50:10 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Mar 2014 07:50:10 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 98C23946B4F; Tue, 18 Mar 2014 07:50:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: devdeep@apache.org To: commits@cloudstack.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/4.3-forward to d417ce0 Date: Tue, 18 Mar 2014 07:50:10 +0000 (UTC) Repository: cloudstack Updated Branches: refs/heads/4.3-forward 33476b873 -> d417ce0d7 CLOUDSTACK-5743. The link generated for downlading a volume or a template was giving a permission error on hyper-v. Fixed the path with which a softlink is created for a downloaded volume or template. Also addressed the issue at other places where the path field wasn't set correctly when a volume was migrated or a template was created from a volume. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d417ce0d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d417ce0d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d417ce0d Branch: refs/heads/4.3-forward Commit: d417ce0d70c9337748ba6598332d04c7581942d2 Parents: 33476b8 Author: Devdeep Singh Authored: Tue Mar 4 15:41:55 2014 +0530 Committer: Devdeep Singh Committed: Tue Mar 18 11:49:14 2014 +0530 ---------------------------------------------------------------------- .../storage/volume/VolumeServiceImpl.java | 10 ++++- .../HypervResource/CloudStackTypes.cs | 47 ++++++++++++-------- .../HypervResource/HypervResourceController.cs | 29 ++++++++++-- 3 files changed, 63 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d417ce0d/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java ---------------------------------------------------------------------- diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index 7796565..d221fa9 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -75,6 +75,7 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.host.Host; import com.cloud.storage.DataStoreRole; import com.cloud.storage.ScopeType; +import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StoragePool; import com.cloud.storage.VMTemplateStoragePoolVO; import com.cloud.storage.VMTemplateStorageResourceAssoc; @@ -679,9 +680,16 @@ public class VolumeServiceImpl implements VolumeService { protected VolumeVO duplicateVolumeOnAnotherStorage(Volume volume, StoragePool pool) { Long lastPoolId = volume.getPoolId(); + String folder = pool.getPath(); + // For SMB, pool credentials are also stored in the uri query string. We trim the query string + // part here to make sure the credentials do not get stored in the db unencrypted. + if (pool.getPoolType() == StoragePoolType.SMB && folder != null && folder.contains("?")) { + folder = folder.substring(0, folder.indexOf("?")); + } + VolumeVO newVol = new VolumeVO(volume); newVol.setPoolId(pool.getId()); - newVol.setFolder(pool.getPath()); + newVol.setFolder(folder); newVol.setPodId(pool.getPodId()); newVol.setPoolId(pool.getId()); newVol.setLastPoolId(lastPoolId); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d417ce0d/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs index 541c205..b6989a9 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs @@ -173,33 +173,35 @@ namespace HypervResource PrimaryDataStoreTO store = this.primaryDataStore; if (store.isLocal) { - fileName = Path.Combine(store.Path, this.uuid); + String volume = this.path; + if (String.IsNullOrEmpty(volume)) + { + volume = this.uuid; + } + fileName = Path.Combine(store.Path, volume); } else { - fileName = @"\\" + store.uri.Host + store.uri.LocalPath + @"\" + this.uuid; + String volume = this.path; + if (String.IsNullOrEmpty(volume)) + { + volume = this.uuid; + } + fileName = @"\\" + store.uri.Host + store.uri.LocalPath + @"\" + volume; fileName = Utils.NormalizePath(fileName); } } else if (this.nfsDataStore != null) { - if (this.path != null && File.Exists(this.path)) + fileName = this.nfsDataStore.UncPath; + if (this.path != null) { - fileName = this.path; + fileName = Utils.NormalizePath(fileName + @"\" + this.path); } - else - { - fileName = this.nfsDataStore.UncPath; - if (this.path != null) - { - fileName += @"\" + this.path; - } - fileName = Utils.NormalizePath(fileName); - if (Directory.Exists(fileName)) - { - fileName = Utils.NormalizePath(fileName + @"\" + this.uuid); - } + if (fileName != null && !File.Exists(fileName)) + { + fileName = Utils.NormalizePath(fileName + @"\" + this.uuid); } } else @@ -344,8 +346,17 @@ namespace HypervResource } else if (this.nfsDataStoreTO != null) { - NFSTO store = this.nfsDataStoreTO; - fileName = store.UncPath + @"\" + this.path + @"\" + this.uuid; + fileName = this.nfsDataStoreTO.UncPath; + if (this.path != null) + { + fileName = Utils.NormalizePath(fileName + @"\" + this.path); + } + + if (fileName != null && !File.Exists(fileName)) + { + fileName = Utils.NormalizePath(fileName + @"\" + this.uuid); + } + if (!this.format.Equals("RAW")) { fileName = fileName + '.' + this.format.ToLowerInvariant(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d417ce0d/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs index 8fd15f4..5d9f2af 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs @@ -1169,7 +1169,7 @@ namespace HypervResource volumePath = Utils.NormalizePath(volumePath); Utils.ConnectToRemote(primary.UncPath, primary.Domain, primary.User, primary.Password); } - volume.path = volumePath; + volume.path = volume.uuid; wmiCallsV2.CreateDynamicVirtualHardDisk(volumeSize, volumePath); if (File.Exists(volumePath)) { @@ -1478,7 +1478,7 @@ namespace HypervResource { // TODO: thin provision instead of copying the full file. File.Copy(srcFile, destFile); - destVolumeObjectTO.path = destFile; + destVolumeObjectTO.path = destVolumeObjectTO.uuid; JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, destVolumeObjectTO); newData = ansObj; result = true; @@ -1512,8 +1512,25 @@ namespace HypervResource // doesn't do anything if the directory is already present. Directory.CreateDirectory(Path.GetDirectoryName(destFile)); File.Copy(srcFile, destFile); + + if (srcVolumeObjectTO.nfsDataStore != null && srcVolumeObjectTO.primaryDataStore == null) + { + logger.Info("Copied volume from secondary data store to primary. Path: " + destVolumeObjectTO.path); + } + else if (srcVolumeObjectTO.primaryDataStore != null && srcVolumeObjectTO.nfsDataStore == null) + { + destVolumeObjectTO.path = destVolumeObjectTO.path + "/" + destVolumeObjectTO.uuid; + if (destVolumeObjectTO.format != null) + { + destVolumeObjectTO.path += "." + destVolumeObjectTO.format.ToLower(); + } + } + else + { + logger.Error("Destination volume path wasn't set. Unsupported source volume data store."); + } + // Create volumeto object deserialize and send it - destVolumeObjectTO.path = destFile; JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, destVolumeObjectTO); newData = ansObj; result = true; @@ -1556,7 +1573,11 @@ namespace HypervResource TemplateObjectTO destTemplateObject = new TemplateObjectTO(); destTemplateObject.size = srcVolumeObjectTO.size.ToString(); destTemplateObject.format = srcVolumeObjectTO.format; - destTemplateObject.path = destFile; + destTemplateObject.path = destTemplateObjectTO.path + "/" + destTemplateObjectTO.uuid; + if (destTemplateObject.format != null) + { + destTemplateObject.path += "." + destTemplateObject.format.ToLower(); + } destTemplateObject.nfsDataStoreTO = destTemplateObjectTO.nfsDataStoreTO; destTemplateObject.checksum = destTemplateObjectTO.checksum; newData = destTemplateObject;