Skip to content

Commit 9313a35

Browse files
CLOUDSTACK-5658 CLOUDSTACK-5563 deploying VM from template created from volumes fails
1 parent 6ce46e9 commit 9313a35

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

‎plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ public string FullFileName
341341
public PrimaryDataStoreTO primaryDataStore = null;
342342
public string path;
343343
public string checksum;
344+
public string size;
344345

345346
public static TemplateObjectTO ParseJson(dynamic json)
346347
{
@@ -355,7 +356,8 @@ public static TemplateObjectTO ParseJson(dynamic json)
355356
name = (string)templateObjectTOJson.name,
356357
uuid = (string)templateObjectTOJson.uuid,
357358
path = (string)templateObjectTOJson.path,
358-
checksum = (string)templateObjectTOJson.checksum
359+
checksum = (string)templateObjectTOJson.checksum,
360+
size = (string)templateObjectTOJson.size
359361
};
360362
result.s3DataStoreTO = S3TO.ParseJson(templateObjectTOJson.imageDataStore);
361363
result.nfsDataStoreTO = NFSTO.ParseJson(templateObjectTOJson.imageDataStore);

‎plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,15 +1319,17 @@ public JContainer CopyCommand(dynamic cmd)
13191319
bool result = false;
13201320
string details = null;
13211321
object newData = null;
1322+
TemplateObjectTO destTemplateObjectTO = null;
1323+
VolumeObjectTO destVolumeObjectTO = null;
13221324

13231325
try
13241326
{
13251327
dynamic timeout = cmd.wait; // TODO: Useful?
13261328

13271329
TemplateObjectTO srcTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.srcTO);
1328-
TemplateObjectTO destTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.destTO);
1330+
destTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.destTO);
13291331
VolumeObjectTO srcVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.srcTO);
1330-
VolumeObjectTO destVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.destTO);
1332+
destVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.destTO);
13311333

13321334
string destFile = null;
13331335
if (destTemplateObjectTO != null)
@@ -1469,7 +1471,16 @@ public JContainer CopyCommand(dynamic cmd)
14691471
{
14701472
// TODO: thin provision instead of copying the full file.
14711473
File.Copy(srcFile, destFile);
1472-
newData = cmd.destTO;
1474+
VolumeObjectTO volume = new VolumeObjectTO();
1475+
volume.path = destFile;
1476+
volume.dataStore = destVolumeObjectTO.dataStore;
1477+
volume.name = destVolumeObjectTO.name;
1478+
volume.size = ulong.Parse(destVolumeObjectTO.size.ToString());
1479+
volume.format = destVolumeObjectTO.format;
1480+
volume.nfsDataStore = destVolumeObjectTO.nfsDataStore;
1481+
volume.primaryDataStore = destVolumeObjectTO.primaryDataStore;
1482+
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, volume);
1483+
newData = ansObj;
14731484
result = true;
14741485
}
14751486
}
@@ -1501,7 +1512,12 @@ public JContainer CopyCommand(dynamic cmd)
15011512
// doesn't do anything if the directory is already present.
15021513
Directory.CreateDirectory(Path.GetDirectoryName(destFile));
15031514
File.Copy(srcFile, destFile);
1504-
newData = cmd.destTO;
1515+
// create volumeto object deserialize and send it
1516+
VolumeObjectTO volume = new VolumeObjectTO();
1517+
volume.path = destFile;
1518+
volume.size = ulong.Parse(destVolumeObjectTO.size.ToString());
1519+
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, volume);
1520+
newData = ansObj;
15051521
result = true;
15061522
}
15071523
}
@@ -1533,7 +1549,15 @@ public JContainer CopyCommand(dynamic cmd)
15331549
// doesn't do anything if the directory is already present.
15341550
Directory.CreateDirectory(Path.GetDirectoryName(destFile));
15351551
File.Copy(srcFile, destFile);
1536-
newData = cmd.destTO;
1552+
TemplateObjectTO destTemplateObject = new TemplateObjectTO();
1553+
destTemplateObject.size = srcVolumeObjectTO.size.ToString();
1554+
destTemplateObject.format = srcVolumeObjectTO.format;
1555+
destTemplateObject.path = destFile;
1556+
destTemplateObject.nfsDataStoreTO = destTemplateObjectTO.nfsDataStoreTO;
1557+
destTemplateObject.checksum = destTemplateObjectTO.checksum;
1558+
newData = destTemplateObject;
1559+
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.TemplateObjectTO, destTemplateObject);
1560+
newData = ansObj;
15371561
result = true;
15381562
}
15391563
}
@@ -1554,7 +1578,7 @@ public JContainer CopyCommand(dynamic cmd)
15541578
{
15551579
result = result,
15561580
details = details,
1557-
newData = cmd.destTO,
1581+
newData = newData,
15581582
contextMap = contextMap
15591583
};
15601584
return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.CopyCmdAnswer);

0 commit comments

Comments
 (0)