Package org.apache.cloudstack.utils.qemu.QemuImg

Examples of org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat


            It is however very unlikely that the destPool will be RBD, since it isn't supported
            for Secondary Storage
         */

        KVMStoragePool srcPool = disk.getPool();
        PhysicalDiskFormat sourceFormat = disk.getFormat();
        String sourcePath = disk.getPath();

        KVMPhysicalDisk newDisk;
        if (destPool.getType() != StoragePoolType.RBD) {
            if (disk.getFormat() == PhysicalDiskFormat.TAR) {
                newDisk = destPool.createPhysicalDisk(name, PhysicalDiskFormat.DIR, disk.getVirtualSize());
            } else {
                /* If the source device is on a RBD storage pool force the new disk to the same format (RAW) */
                if (srcPool.getType() != StoragePoolType.RBD) {
                    newDisk = destPool.createPhysicalDisk(name, disk.getVirtualSize());
                } else {
                    newDisk = destPool.createPhysicalDisk(name, sourceFormat, disk.getVirtualSize());
                }
            }
        } else {
            newDisk = new KVMPhysicalDisk(destPool.getSourceDir() + "/" + name, name, destPool);
            newDisk.setFormat(PhysicalDiskFormat.RAW);
            newDisk.setSize(disk.getVirtualSize());
            newDisk.setVirtualSize(disk.getSize());
        }

        String destPath = newDisk.getPath();
        PhysicalDiskFormat destFormat = newDisk.getFormat();

        QemuImg qemu = new QemuImg();
        QemuImgFile srcFile = null;
        QemuImgFile destFile = null;

View Full Code Here


        }
    }

    private String getResizeScriptType (KVMStoragePool pool, KVMPhysicalDisk vol) {
        StoragePoolType poolType = pool.getType();
        PhysicalDiskFormat volFormat = vol.getFormat();

        if(pool.getType() == StoragePoolType.CLVM && volFormat == PhysicalDiskFormat.RAW) {
            return "CLVM";
        } else if ((poolType == StoragePoolType.NetworkFilesystem
                  || poolType == StoragePoolType.SharedMountPoint
View Full Code Here

        assertEquals(file.getSize(), size);
    }

    @Test
    public void testFileNameAndSizeAndFormatAtContructor() {
        PhysicalDiskFormat format = PhysicalDiskFormat.RAW;
        long size = 1024;
        String filename = "/tmp/test-image.qcow2";
        QemuImgFile file = new QemuImgFile(filename, size, format);
        assertEquals(file.getFileName(), filename);
        assertEquals(file.getSize(), size);
View Full Code Here

        assertEquals(file.getFormat(), format);
    }

    @Test
    public void testFileNameAndFormatAtContructor() {
        PhysicalDiskFormat format = PhysicalDiskFormat.RAW;
        String filename = "/tmp/test-image.qcow2";
        QemuImgFile file = new QemuImgFile(filename, format);
        assertEquals(file.getFileName(), filename);
        assertEquals(file.getFormat(), format);
    }
View Full Code Here

    @Test
    public void testConvertAdvanced() throws QemuImgException {
        long srcSize = 4019200;
        String srcFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";
        String destFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";
        PhysicalDiskFormat srcFormat = PhysicalDiskFormat.RAW;
        PhysicalDiskFormat destFormat = PhysicalDiskFormat.QCOW2;

        QemuImgFile srcFile = new QemuImgFile(srcFileName, srcSize, srcFormat);
        QemuImgFile destFile = new QemuImgFile(destFileName, destFormat);

        QemuImg qemu = new QemuImg();
        qemu.create(srcFile);
        qemu.convert(srcFile, destFile);

        Map<String, String> info = qemu.info(destFile);

        PhysicalDiskFormat infoFormat = PhysicalDiskFormat.valueOf(info.get(new String("file_format")).toUpperCase());
        assertEquals(destFormat, infoFormat);

        Long infoSize = Long.parseLong(info.get(new String("virtual_size")));
        assertEquals(Long.valueOf(srcSize), Long.valueOf(infoSize));
View Full Code Here

            It is however very unlikely that the destPool will be RBD, since it isn't supported
            for Secondary Storage
         */

        KVMStoragePool srcPool = disk.getPool();
        PhysicalDiskFormat sourceFormat = disk.getFormat();
        String sourcePath = disk.getPath();

        KVMPhysicalDisk newDisk;
        if (destPool.getType() != StoragePoolType.RBD) {
            if (disk.getFormat() == PhysicalDiskFormat.TAR) {
                newDisk = destPool.createPhysicalDisk(name, PhysicalDiskFormat.DIR, disk.getVirtualSize());
            } else {
                /* If the source device is on a RBD storage pool force the new disk to the same format (RAW) */
                if (srcPool.getType() != StoragePoolType.RBD) {
                    newDisk = destPool.createPhysicalDisk(name, disk.getVirtualSize());
                } else {
                    newDisk = destPool.createPhysicalDisk(name, sourceFormat, disk.getVirtualSize());
                }
            }
        } else {
            newDisk = new KVMPhysicalDisk(destPool.getSourceDir() + "/" + name, name, destPool);
            newDisk.setFormat(PhysicalDiskFormat.RAW);
            newDisk.setSize(disk.getVirtualSize());
            newDisk.setVirtualSize(disk.getSize());
        }

        String destPath = newDisk.getPath();
        PhysicalDiskFormat destFormat = newDisk.getFormat();

        QemuImg qemu = new QemuImg(timeout);
        QemuImgFile srcFile = null;
        QemuImgFile destFile = null;

View Full Code Here

        }
    }

    private String getResizeScriptType (KVMStoragePool pool, KVMPhysicalDisk vol) {
        StoragePoolType poolType = pool.getType();
        PhysicalDiskFormat volFormat = vol.getFormat();

        if(pool.getType() == StoragePoolType.CLVM && volFormat == PhysicalDiskFormat.RAW) {
            return "CLVM";
        } else if ((poolType == StoragePoolType.NetworkFilesystem
                  || poolType == StoragePoolType.SharedMountPoint
View Full Code Here

        }
    }

    private String getResizeScriptType(KVMStoragePool pool, KVMPhysicalDisk vol) {
        StoragePoolType poolType = pool.getType();
        PhysicalDiskFormat volFormat = vol.getFormat();

        if (pool.getType() == StoragePoolType.CLVM && volFormat == PhysicalDiskFormat.RAW) {
            return "CLVM";
        } else if ((poolType == StoragePoolType.NetworkFilesystem
                  || poolType == StoragePoolType.SharedMountPoint
View Full Code Here

            It is however very unlikely that the destPool will be RBD, since it isn't supported
            for Secondary Storage
         */

        KVMStoragePool srcPool = disk.getPool();
        PhysicalDiskFormat sourceFormat = disk.getFormat();
        String sourcePath = disk.getPath();

        KVMPhysicalDisk newDisk;
        s_logger.debug("copyPhysicalDisk: disk size:" + disk.getSize() + ", virtualsize:" + disk.getVirtualSize()+" format:"+disk.getFormat());
        if (destPool.getType() != StoragePoolType.RBD) {
            if (disk.getFormat() == PhysicalDiskFormat.TAR) {
                newDisk = destPool.createPhysicalDisk(name, PhysicalDiskFormat.DIR, disk.getVirtualSize());
            } else {
                newDisk = destPool.createPhysicalDisk(name, disk.getVirtualSize());
            }
        } else {
            newDisk = new KVMPhysicalDisk(destPool.getSourceDir() + "/" + name, name, destPool);
            newDisk.setFormat(PhysicalDiskFormat.RAW);
            newDisk.setSize(disk.getVirtualSize());
            newDisk.setVirtualSize(disk.getSize());
        }

        String destPath = newDisk.getPath();
        PhysicalDiskFormat destFormat = newDisk.getFormat();

        QemuImg qemu = new QemuImg(timeout);
        QemuImgFile srcFile = null;
        QemuImgFile destFile = null;

View Full Code Here

        assertEquals(file.getSize(), size);
    }

    @Test
    public void testFileNameAndSizeAndFormatAtContructor() {
        PhysicalDiskFormat format = PhysicalDiskFormat.RAW;
        long size = 1024;
        String filename = "/tmp/test-image.qcow2";
        QemuImgFile file = new QemuImgFile(filename, size, format);
        assertEquals(file.getFileName(), filename);
        assertEquals(file.getSize(), size);
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.