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); 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(); fileName = fileName + "." + this.format.ToLowerInvariant();
} }

View File

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