mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Merge pull request #1880 from Accelerite/CLOUDSTACK-9720
CLOUDSTACK-9720: [VMware] template_spool_ref table is not getting updated with correct template physical size in template_size column.Updated the template_spool_ref table with the correct template (VMware - OVA file) size. * pr/1880: CLOUDSTACK-9720: [VMware] template_spool_ref table is not getting updated with correct template physical size in template_size column. Signed-off-by: Rajani Karuturi <rajani.karuturi@accelerite.com>
This commit is contained in:
commit
4db186ef6f
@ -182,7 +182,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
private VirtualMachineMO copyTemplateFromSecondaryToPrimary(VmwareHypervisorHost hyperHost, DatastoreMO datastoreMo, String secondaryStorageUrl,
|
||||
private Pair<VirtualMachineMO, Long> copyTemplateFromSecondaryToPrimary(VmwareHypervisorHost hyperHost, DatastoreMO datastoreMo, String secondaryStorageUrl,
|
||||
String templatePathAtSecondaryStorage, String templateName, String templateUuid, boolean createSnapshot, Integer nfsVersion) throws Exception {
|
||||
|
||||
s_logger.info("Executing copyTemplateFromSecondaryToPrimary. secondaryStorage: " + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " +
|
||||
@ -229,6 +229,12 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
OVAProcessor processor = new OVAProcessor();
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put(StorageLayer.InstanceConfigKey, _storage);
|
||||
processor.configure("OVA Processor", params);
|
||||
long virtualSize = processor.getTemplateVirtualSize(secondaryMountPoint + "/" + templatePathAtSecondaryStorage, templateName);
|
||||
|
||||
if (createSnapshot) {
|
||||
if (vmMo.createSnapshot("cloud.template.base", "Base snapshot", false, false)) {
|
||||
// the same template may be deployed with multiple copies at per-datastore per-host basis,
|
||||
@ -246,7 +252,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
return vmMo;
|
||||
return new Pair<VirtualMachineMO, Long>(vmMo, new Long(virtualSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -322,6 +328,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
|
||||
VirtualMachineMO templateMo = VmwareHelper.pickOneVmOnRunningHost(dcMo.findVmByNameAndLabel(templateUuidName), true);
|
||||
DatastoreMO dsMo = null;
|
||||
Pair<VirtualMachineMO, Long> vmInfo = null;
|
||||
|
||||
if (templateMo == null) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
@ -343,9 +350,10 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
dsMo = new DatastoreMO(context, morDs);
|
||||
|
||||
if (managed) {
|
||||
VirtualMachineMO vmMo = copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(),
|
||||
vmInfo = copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(),
|
||||
managedStoragePoolRootVolumeName, false, _nfsVersion);
|
||||
|
||||
VirtualMachineMO vmMo = vmInfo.first();
|
||||
vmMo.unregisterVm();
|
||||
|
||||
String[] vmwareLayoutFilePair = VmwareStorageLayoutHelper.getVmdkFilePairDatastorePath(dsMo, managedStoragePoolRootVolumeName,
|
||||
@ -360,7 +368,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
dsMo.deleteFolder(folderToDelete, dcMo.getMor());
|
||||
}
|
||||
else {
|
||||
copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(),
|
||||
vmInfo = copyTemplateFromSecondaryToPrimary(hyperHost, dsMo, secondaryStorageUrl, templateInfo.first(), templateInfo.second(),
|
||||
templateUuidName, true, _nfsVersion);
|
||||
}
|
||||
} else {
|
||||
@ -378,7 +386,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
else {
|
||||
newTemplate.setPath(templateUuidName);
|
||||
}
|
||||
newTemplate.setSize(new Long(0)); // TODO: replace 0 with correct template physical_size.
|
||||
newTemplate.setSize((vmInfo != null)? vmInfo.second() : new Long(0));
|
||||
|
||||
return new CopyCmdAnswer(newTemplate);
|
||||
} catch (Throwable e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user