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

This commit is contained in:
Rajesh Battala 2013-10-28 18:33:10 +05:30
parent f1b8aa90a0
commit 8f508a023b
1 changed files with 23 additions and 1 deletions

View File

@ -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);