Fixed CLOUDSTACK-6942: LXC: optimize template copy to primary

saving LXC template as tar to primary and extracting it only when
required.
This would improve the template copy time.

Reviewed By: Kishan Kavala
This commit is contained in:
Rajani Karuturi 2014-09-04 14:37:10 +05:30
parent 355eb72c7d
commit 17164c3c83
1 changed files with 4 additions and 2 deletions

View File

@ -890,7 +890,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
} else if (template.getFormat() == PhysicalDiskFormat.DIR) {
Script.runSimpleBashScript("mkdir -p " + disk.getPath());
Script.runSimpleBashScript("chmod 755 " + disk.getPath());
Script.runSimpleBashScript("cp -p -r " + template.getPath() + "/* " + disk.getPath(), timeout); // TO BE FIXED to aware provisioningType
Script.runSimpleBashScript("tar -x -f " + template.getPath() + "/*.tar -C " + disk.getPath(), timeout);
} else if (format == PhysicalDiskFormat.QCOW2) {
QemuImg qemu = new QemuImg(timeout);
QemuImgFile destFile = new QemuImgFile(disk.getPath(), format);
@ -1183,7 +1183,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
QemuImgFile destFile = null;
if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() != StoragePoolType.RBD)) {
if (sourceFormat == PhysicalDiskFormat.TAR) {
if(sourceFormat == PhysicalDiskFormat.TAR && destFormat == PhysicalDiskFormat.DIR) { //LXC template
Script.runSimpleBashScript("cp "+ sourcePath + " " + destPath);
} else if (sourceFormat == PhysicalDiskFormat.TAR) {
Script.runSimpleBashScript("tar -x -f " + sourcePath + " -C " + destPath, timeout);
} else if (sourceFormat == PhysicalDiskFormat.DIR) {
Script.runSimpleBashScript("mkdir -p " + destPath);