cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devd...@apache.org
Subject git commit: updated refs/heads/master to 1a033ed
Date Thu, 26 Dec 2013 10:16:24 GMT
Updated Branches:
  refs/heads/master c75f8bcc0 -> 1a033edda


CLOUDSTACK-5308, CLOUDSTACK-5542: Copy command didn't handle the scenario
when a volume is copied to secondary storage for template creation.
Updated the command to handle it.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1a033edd
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1a033edd
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1a033edd

Branch: refs/heads/master
Commit: 1a033eddae378ce6bd2c2a2bf6acc089e790a238
Parents: c75f8bc
Author: Devdeep Singh <devdeep@gmail.com>
Authored: Thu Dec 26 22:30:27 2013 +0530
Committer: Devdeep Singh <devdeep@gmail.com>
Committed: Thu Dec 26 15:32:41 2013 +0530

----------------------------------------------------------------------
 .../HypervResource/CloudStackTypes.cs           | 28 ++++++++---
 .../HypervResource/HypervResourceController.cs  | 51 ++++++++++++++++++--
 2 files changed, 67 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a033edd/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 896a324..f8ca49e 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs
@@ -301,20 +301,34 @@ namespace HypervResource
         {
             get
             {
-                if (String.IsNullOrEmpty(this.path))
+                string fileName = null;
+                if (this.primaryDataStore != null)
                 {
-                    string fileName = null;
-                    if (this.primaryDataStore.isLocal)
+                    PrimaryDataStoreTO store = this.primaryDataStore;
+                    if (store.isLocal)
                     {
-                        fileName = Path.Combine(this.primaryDataStore.Path, this.name);
+                        fileName = Path.Combine(store.Path, this.name);
                     }
                     else
                     {
-                        fileName = @"\\" + this.primaryDataStore.uri.Host + this.primaryDataStore.uri.LocalPath
+ @"\" + this.name;
+                        fileName = @"\\" + store.uri.Host + store.uri.LocalPath + @"\" +
this.name;
                     }
-                    return fileName +'.' + this.format.ToLowerInvariant();
+                    fileName = fileName + '.' + this.format.ToLowerInvariant();
+                }
+                else if (this.nfsDataStoreTO != null)
+                {
+                    NFSTO store = this.nfsDataStoreTO;
+                    fileName = store.UncPath + @"\" + this.path + @"\" + this.name;
+                    if (!this.format.Equals("RAW"))
+                    {
+                        fileName = fileName + '.' + this.format.ToLowerInvariant();
+                    }
+                }
+                else
+                {
+                    fileName = this.path;
                 }
-                return this.path;
+                return Utils.NormalizePath(fileName);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a033edd/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 35bce5d..700b7da 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -1262,13 +1262,22 @@ namespace HypervResource
                     VolumeObjectTO destVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.destTO);
 
                     string destFile = null;
-                    if (destTemplateObjectTO != null && destTemplateObjectTO.primaryDataStore
!= null)
+                    if (destTemplateObjectTO != null)
                     {
-                        destFile = destTemplateObjectTO.FullFileName;
-                        if (!destTemplateObjectTO.primaryDataStore.isLocal)
+                        if (destTemplateObjectTO.primaryDataStore != null)
                         {
-                            PrimaryDataStoreTO primary = destTemplateObjectTO.primaryDataStore;
-                            Utils.ConnectToRemote(primary.UncPath, primary.Domain, primary.User,
primary.Password);
+                            destFile = destTemplateObjectTO.FullFileName;
+                            if (!destTemplateObjectTO.primaryDataStore.isLocal)
+                            {
+                                PrimaryDataStoreTO primary = destTemplateObjectTO.primaryDataStore;
+                                Utils.ConnectToRemote(primary.UncPath, primary.Domain, primary.User,
primary.Password);
+                            }
+                        }
+                        else if (destTemplateObjectTO.nfsDataStoreTO != null)
+                        {
+                            destFile = destTemplateObjectTO.FullFileName;
+                            NFSTO store = destTemplateObjectTO.nfsDataStoreTO;
+                            Utils.ConnectToRemote(store.UncPath, store.Domain, store.User,
store.Password);
                         }
                     }
 
@@ -1428,6 +1437,38 @@ namespace HypervResource
                                 result = true;
                             }
                         }
+                        else if (srcVolumeObjectTO != null && destTemplateObjectTO
!= null)
+                        {
+                            var guessedDestFile = destTemplateObjectTO.FullFileName;
+                            if (File.Exists(guessedDestFile))
+                            {
+                                logger.Info("Deleting existing file " + guessedDestFile);
+                                File.Delete(guessedDestFile);
+                            }
+
+                            destTemplateObjectTO.format = srcVolumeObjectTO.format;
+                            destFile = destTemplateObjectTO.FullFileName;
+                            if (File.Exists(destFile))
+                            {
+                                logger.Info("Deleting existing file " + destFile);
+                                File.Delete(destFile);
+                            }
+
+                            string srcFile = srcVolumeObjectTO.FullFileName;
+                            if (!File.Exists(srcFile))
+                            {
+                                details = "Local template file missing from " + srcFile;
+                            }
+                            else
+                            {
+                                // Create the directory before copying the files. CreateDirectory
+                                // doesn't do anything if the directory is already present.
+                                Directory.CreateDirectory(Path.GetDirectoryName(destFile));
+                                File.Copy(srcFile, destFile);
+                                newData = cmd.destTO;
+                                result = true;
+                            }
+                        }
                         else
                         {
                             details = "Data store combination not supported";


Mime
View raw message