CLOUDSTACK-5788, CLOUDSTACK-5789: Attaching upload volume and download

volume was failing for hyper-v. Copy command answer was failing while
creating the answer object. Fixing the issue.
This commit is contained in:
Devdeep Singh 2014-01-06 23:33:55 +05:30
parent 1069f56f8e
commit 3116f51a26
2 changed files with 8 additions and 8 deletions

View File

@ -187,7 +187,7 @@ namespace HypervResource
throw new InvalidDataException(errMsg);
}
if (!Path.HasExtension(fileName) && this.format != null)
if (fileName != null && !Path.HasExtension(fileName) && this.format != null)
{
fileName = fileName + "." + this.format.ToLowerInvariant();
}

View File

@ -1321,14 +1321,16 @@ namespace HypervResource
object newData = null;
TemplateObjectTO destTemplateObjectTO = null;
VolumeObjectTO destVolumeObjectTO = null;
VolumeObjectTO srcVolumeObjectTO = null;
TemplateObjectTO srcTemplateObjectTO = null;
try
{
dynamic timeout = cmd.wait; // TODO: Useful?
TemplateObjectTO srcTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.srcTO);
srcTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.srcTO);
destTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.destTO);
VolumeObjectTO srcVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.srcTO);
srcVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.srcTO);
destVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.destTO);
string destFile = null;
@ -1512,11 +1514,9 @@ namespace HypervResource
// doesn't do anything if the directory is already present.
Directory.CreateDirectory(Path.GetDirectoryName(destFile));
File.Copy(srcFile, destFile);
// create volumeto object deserialize and send it
VolumeObjectTO volume = new VolumeObjectTO();
volume.path = destFile;
volume.size = ulong.Parse(destVolumeObjectTO.size.ToString());
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, volume);
// Create volumeto object deserialize and send it
destVolumeObjectTO.path = destFile;
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, destVolumeObjectTO);
newData = ansObj;
result = true;
}