mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-5658 CLOUDSTACK-5563 deploying VM from template created from volumes fails
This commit is contained in:
parent
6ce46e94f5
commit
9313a35f41
|
|
@ -341,6 +341,7 @@ namespace HypervResource
|
|||
public PrimaryDataStoreTO primaryDataStore = null;
|
||||
public string path;
|
||||
public string checksum;
|
||||
public string size;
|
||||
|
||||
public static TemplateObjectTO ParseJson(dynamic json)
|
||||
{
|
||||
|
|
@ -355,7 +356,8 @@ namespace HypervResource
|
|||
name = (string)templateObjectTOJson.name,
|
||||
uuid = (string)templateObjectTOJson.uuid,
|
||||
path = (string)templateObjectTOJson.path,
|
||||
checksum = (string)templateObjectTOJson.checksum
|
||||
checksum = (string)templateObjectTOJson.checksum,
|
||||
size = (string)templateObjectTOJson.size
|
||||
};
|
||||
result.s3DataStoreTO = S3TO.ParseJson(templateObjectTOJson.imageDataStore);
|
||||
result.nfsDataStoreTO = NFSTO.ParseJson(templateObjectTOJson.imageDataStore);
|
||||
|
|
|
|||
|
|
@ -1319,15 +1319,17 @@ namespace HypervResource
|
|||
bool result = false;
|
||||
string details = null;
|
||||
object newData = null;
|
||||
TemplateObjectTO destTemplateObjectTO = null;
|
||||
VolumeObjectTO destVolumeObjectTO = null;
|
||||
|
||||
try
|
||||
{
|
||||
dynamic timeout = cmd.wait; // TODO: Useful?
|
||||
|
||||
TemplateObjectTO srcTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.srcTO);
|
||||
TemplateObjectTO destTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.destTO);
|
||||
destTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.destTO);
|
||||
VolumeObjectTO srcVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.srcTO);
|
||||
VolumeObjectTO destVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.destTO);
|
||||
destVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.destTO);
|
||||
|
||||
string destFile = null;
|
||||
if (destTemplateObjectTO != null)
|
||||
|
|
@ -1469,7 +1471,16 @@ namespace HypervResource
|
|||
{
|
||||
// TODO: thin provision instead of copying the full file.
|
||||
File.Copy(srcFile, destFile);
|
||||
newData = cmd.destTO;
|
||||
VolumeObjectTO volume = new VolumeObjectTO();
|
||||
volume.path = destFile;
|
||||
volume.dataStore = destVolumeObjectTO.dataStore;
|
||||
volume.name = destVolumeObjectTO.name;
|
||||
volume.size = ulong.Parse(destVolumeObjectTO.size.ToString());
|
||||
volume.format = destVolumeObjectTO.format;
|
||||
volume.nfsDataStore = destVolumeObjectTO.nfsDataStore;
|
||||
volume.primaryDataStore = destVolumeObjectTO.primaryDataStore;
|
||||
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.VolumeObjectTO, volume);
|
||||
newData = ansObj;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1501,7 +1512,12 @@ namespace HypervResource
|
|||
// doesn't do anything if the directory is already present.
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destFile));
|
||||
File.Copy(srcFile, destFile);
|
||||
newData = cmd.destTO;
|
||||
// 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);
|
||||
newData = ansObj;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1533,7 +1549,15 @@ namespace HypervResource
|
|||
// doesn't do anything if the directory is already present.
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destFile));
|
||||
File.Copy(srcFile, destFile);
|
||||
newData = cmd.destTO;
|
||||
TemplateObjectTO destTemplateObject = new TemplateObjectTO();
|
||||
destTemplateObject.size = srcVolumeObjectTO.size.ToString();
|
||||
destTemplateObject.format = srcVolumeObjectTO.format;
|
||||
destTemplateObject.path = destFile;
|
||||
destTemplateObject.nfsDataStoreTO = destTemplateObjectTO.nfsDataStoreTO;
|
||||
destTemplateObject.checksum = destTemplateObjectTO.checksum;
|
||||
newData = destTemplateObject;
|
||||
JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.TemplateObjectTO, destTemplateObject);
|
||||
newData = ansObj;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1554,7 +1578,7 @@ namespace HypervResource
|
|||
{
|
||||
result = result,
|
||||
details = details,
|
||||
newData = cmd.destTO,
|
||||
newData = newData,
|
||||
contextMap = contextMap
|
||||
};
|
||||
return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.CopyCmdAnswer);
|
||||
|
|
|
|||
Loading…
Reference in New Issue