You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by de...@apache.org on 2014/03/18 08:50:10 UTC

git commit: updated refs/heads/4.3-forward to d417ce0

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 <de...@gmail.com>
Authored: Tue Mar 4 15:41:55 2014 +0530
Committer: Devdeep Singh <de...@gmail.com>
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;