From 8f508a023beccd091996375ce699a8533a399275 Mon Sep 17 00:00:00 2001 From: Rajesh Battala Date: Mon, 28 Oct 2013 18:33:10 +0530 Subject: [PATCH] Fix to discover the seeded template to bring up the systemvm's for the first startup and fixed UNC path isues --- .../ServerResource/HypervResource/Utils.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs index c24a1ae82b9..3baab5ba039 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);