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 2013/12/26 11:00:46 UTC
git commit: updated refs/heads/4.3 to 93ea31c
Updated Branches:
refs/heads/4.3 079323f59 -> 93ea31c6e
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/93ea31c6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/93ea31c6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/93ea31c6
Branch: refs/heads/4.3
Commit: 93ea31c6e4b2cae393e245e9c4ff48577e732d37
Parents: 079323f
Author: Devdeep Singh <de...@gmail.com>
Authored: Thu Dec 26 22:30:27 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Thu Dec 26 15:31:18 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/93ea31c6/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/93ea31c6/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 b4d018f..0bbec16 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";