mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-5455: Fix detach iso on hyperv. Made sure normalized path is
used while attaching and detaching iso. Also made normalization of path across the agent code.
This commit is contained in:
parent
e498bf00d4
commit
78b39bbe12
|
|
@ -160,7 +160,7 @@ namespace HypervResource
|
|||
else
|
||||
{
|
||||
fileName = @"\\" + this.primaryDataStore.uri.Host + this.primaryDataStore.uri.LocalPath + @"\" + this.name;
|
||||
fileName = fileName.Replace(@"/", @"\");
|
||||
fileName = Utils.NormalizePath(fileName);
|
||||
}
|
||||
|
||||
if (this.format != null)
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ namespace HypervResource
|
|||
Utils.ConnectToRemote(share.UncPath, share.Domain, share.User, share.Password);
|
||||
|
||||
// The share is mapped, now attach the iso
|
||||
string isoPath = Path.Combine(share.UncPath.Replace('/', Path.DirectorySeparatorChar), dataStore.path);
|
||||
string isoPath = Utils.NormalizePath(Path.Combine(share.UncPath, dataStore.path));
|
||||
wmiCallsV2.AttachIso(vmName, isoPath);
|
||||
result = true;
|
||||
}
|
||||
|
|
@ -267,8 +267,7 @@ namespace HypervResource
|
|||
{
|
||||
NFSTO share = dataStore.nfsDataStoreTO;
|
||||
// The share is mapped, now attach the iso
|
||||
string isoPath = Path.Combine(share.UncPath.Replace('/', Path.DirectorySeparatorChar),
|
||||
dataStore.path.Replace('/', Path.DirectorySeparatorChar));
|
||||
string isoPath = Utils.NormalizePath(Path.Combine(share.UncPath, dataStore.path));
|
||||
wmiCallsV2.DetachDisk(vmName, isoPath);
|
||||
result = true;
|
||||
}
|
||||
|
|
@ -957,7 +956,7 @@ namespace HypervResource
|
|||
share.uri = new Uri(uriStr);
|
||||
string defaultDataPath = wmiCallsV2.GetDefaultDataRoot();
|
||||
|
||||
string secondaryPath = Path.Combine(share.UncPath, "systemvm").Replace(@"/", @"\");
|
||||
string secondaryPath = Utils.NormalizePath(Path.Combine(share.UncPath, "systemvm"));
|
||||
string[] choices = choices = Directory.GetFiles(secondaryPath, "systemvm*.iso");
|
||||
if (choices.Length != 1)
|
||||
{
|
||||
|
|
@ -966,7 +965,7 @@ namespace HypervResource
|
|||
}
|
||||
else
|
||||
{
|
||||
systemVmIsoPath = Path.Combine(defaultDataPath, Path.GetFileName(choices[0]));
|
||||
systemVmIsoPath = Utils.NormalizePath(Path.Combine(defaultDataPath, Path.GetFileName(choices[0])));
|
||||
if (!File.Exists(systemVmIsoPath))
|
||||
{
|
||||
Utils.DownloadCifsFileToLocalFile(choices[0], share, systemVmIsoPath);
|
||||
|
|
@ -1057,7 +1056,7 @@ namespace HypervResource
|
|||
else
|
||||
{
|
||||
volumePath = @"\\" + primary.uri.Host + primary.uri.LocalPath + @"\" + volumeName;
|
||||
volumePath = volumePath.Replace('/', '\\');
|
||||
volumePath = Utils.NormalizePath(volumePath);
|
||||
Utils.ConnectToRemote(primary.UncPath, primary.Domain, primary.User, primary.Password);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,16 @@ namespace HypervResource
|
|||
return objContent;
|
||||
}
|
||||
|
||||
public static string NormalizePath(string path)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(path))
|
||||
{
|
||||
path = path.Replace('/', Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy file on network share to local volume.
|
||||
/// </summary>
|
||||
|
|
@ -80,7 +90,7 @@ namespace HypervResource
|
|||
if (filePathRelativeToShare.EndsWith(".iso") || filePathRelativeToShare.EndsWith(".vhd") || filePathRelativeToShare.EndsWith(".vhdx"))
|
||||
{
|
||||
dest = Path.Combine(cifsShareDetails.UncPath, filePathRelativeToShare);
|
||||
dest = dest.Replace('/', Path.DirectorySeparatorChar);
|
||||
dest = Utils.NormalizePath(dest);
|
||||
}
|
||||
// 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.
|
||||
|
|
@ -117,7 +127,7 @@ namespace HypervResource
|
|||
{
|
||||
NETRESOURCE nr = new NETRESOURCE();
|
||||
nr.dwType = RESOURCETYPE_DISK;
|
||||
nr.lpRemoteName = remoteUNC.Replace('/', Path.DirectorySeparatorChar);
|
||||
nr.lpRemoteName = Utils.NormalizePath(remoteUNC);
|
||||
if (domain != null)
|
||||
{
|
||||
username = domain + @"\" + username;
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ namespace HypervResource
|
|||
NFSTO share = templateInfo.nfsDataStoreTO;
|
||||
Utils.ConnectToRemote(share.UncPath, share.Domain, share.User, share.Password);
|
||||
// The share is mapped, now attach the iso
|
||||
isoPath = Path.Combine(share.UncPath.Replace('/', Path.DirectorySeparatorChar), templateInfo.path);
|
||||
isoPath = Utils.NormalizePath(Path.Combine(share.UncPath, templateInfo.path));
|
||||
}
|
||||
|
||||
string driveType = diskDrive.type;
|
||||
|
|
|
|||
Loading…
Reference in New Issue