Fix to discover the seeded template to bring up the systemvm's for the first 
startup and fixed UNC path isues


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

Branch: refs/heads/hyperv
Commit: 8f508a023beccd091996375ce699a8533a399275
Parents: f1b8aa9
Author: Rajesh Battala <[email protected]>
Authored: Mon Oct 28 18:33:10 2013 +0530
Committer: Rajesh Battala <[email protected]>
Committed: Mon Oct 28 18:33:10 2013 +0530

----------------------------------------------------------------------
 .../ServerResource/HypervResource/Utils.cs      | 24 +++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f508a02/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs 
b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs
index c24a1ae..3baab5b 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs
@@ -66,7 +66,29 @@ namespace HypervResource
                 bool isSuccess = LogonUser(cifsShareDetails.User, 
cifsShareDetails.Domain, cifsShareDetails.Password, 
LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_DEFAULT, ref token);
                 using (WindowsImpersonationContext remoteIdentity = new 
WindowsIdentity(token).Impersonate())
                 {
-                    String dest = Path.Combine(cifsShareDetails.UncPath, 
filePathRelativeToShare);
+
+                 // if the filePathRelativeToShare string don't have filename 
and only a dir point then find the vhd files in that folder and use
+                 // In the clean setup, first copy command wont be having the 
filename it contains onlyu dir path.
+                 // we need to scan the folder point and then copy the file to 
destination.
+                 String dest = "";
+                 if (!filePathRelativeToShare.Contains(".vhd"))
+                 {
+                     // scan the folder and get the vhd filename.
+                     String uncPath = cifsShareDetails.UncPath + "\\" + 
filePathRelativeToShare;
+                     uncPath = uncPath.Replace("/", "\\");
+                     DirectoryInfo dir = new DirectoryInfo(uncPath);
+                     FileInfo[] vhdFiles = dir.GetFiles("*.vhd");
+                     if (vhdFiles.Length > 0)
+                     {
+                         FileInfo file = vhdFiles[0];
+                         dest = file.FullName;
+                     }
+                 }
+                 else
+                 {
+                     dest = Path.Combine(cifsShareDetails.UncPath, 
filePathRelativeToShare);
+                     dest = dest.Replace("/", "\\");
+                 }
                     s_logger.Info(CloudStackTypes.CopyCommand + ": copy " + 
Path.Combine(cifsShareDetails.UncPath, filePathRelativeToShare) + " to " + 
destFile);
 
                     File.Copy(dest, destFile, true);

Reply via email to