Package org.libvirt

Examples of org.libvirt.StorageVol


        }
        return true;
    }

    public StorageVol getVolume(StoragePool pool, String volName) {
        StorageVol vol = null;

        try {
            vol = pool.storageVolLookupByName(volName);
        } catch (LibvirtException e) {
            s_logger.debug("Can't find volume: " + e.toString());
View Full Code Here


    }

    public StorageVol copyVolume(StoragePool destPool,
            LibvirtStorageVolumeDef destVol, StorageVol srcVol, int timeout)
            throws LibvirtException {
        StorageVol vol = destPool.storageVolCreateXML(destVol.toString(), 0);
        String srcPath = srcVol.getKey();
        String destPath = vol.getKey();
        Script.runSimpleBashScript("cp " + srcPath + " " + destPath, timeout);
        return vol;
    }
View Full Code Here

    public KVMPhysicalDisk getPhysicalDisk(String volumeUuid,
            KVMStoragePool pool) {
        LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;

        try {
            StorageVol vol = this.getVolume(libvirtPool.getPool(), volumeUuid);
            KVMPhysicalDisk disk;
            LibvirtStorageVolumeDef voldef = getStorageVolumeDef(libvirtPool
                    .getPool().getConnect(), vol);
            disk = new KVMPhysicalDisk(vol.getPath(), vol.getName(), pool);
            disk.setSize(vol.getInfo().allocation);
            disk.setVirtualSize(vol.getInfo().capacity);

            /**
             * libvirt returns format = 'unknow', so we have to force
             * the format to RAW for RBD storage volumes
             */
 
View Full Code Here

            LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(name,
                    size, libvirtformat, null, null);
            s_logger.debug(volDef.toString());
            try {
                StorageVol vol = virtPool.storageVolCreateXML(volDef.toString(), 0);
                volPath = vol.getPath();
                volName = vol.getName();
                volAllocation = vol.getInfo().allocation;
                volCapacity = vol.getInfo().capacity;
            } catch (LibvirtException e) {
                throw new CloudRuntimeException(e.toString());
            }
        }
View Full Code Here

            }
        }

        LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
        try {
            StorageVol vol = this.getVolume(libvirtPool.getPool(), uuid);
            deleteVol(libvirtPool, vol);
            vol.free();
            return true;
        } catch (LibvirtException e) {
            throw new CloudRuntimeException(e.toString());
        }
    }
View Full Code Here

        }
        return true;
    }

    public StorageVol getVolume(StoragePool pool, String volName) {
        StorageVol vol = null;

        try {
            vol = pool.storageVolLookupByName(volName);
        } catch (LibvirtException e) {
            s_logger.debug("Can't find volume: " + e.toString());
View Full Code Here

    }

    public StorageVol copyVolume(StoragePool destPool,
            LibvirtStorageVolumeDef destVol, StorageVol srcVol, int timeout)
            throws LibvirtException {
        StorageVol vol = destPool.storageVolCreateXML(destVol.toString(), 0);
        String srcPath = srcVol.getKey();
        String destPath = vol.getKey();
        Script.runSimpleBashScript("cp " + srcPath + " " + destPath, timeout);
        return vol;
    }
View Full Code Here

    public KVMPhysicalDisk getPhysicalDisk(String volumeUuid,
            KVMStoragePool pool) {
        LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;

        try {
            StorageVol vol = this.getVolume(libvirtPool.getPool(), volumeUuid);
            KVMPhysicalDisk disk;
            LibvirtStorageVolumeDef voldef = getStorageVolumeDef(libvirtPool
                    .getPool().getConnect(), vol);
            disk = new KVMPhysicalDisk(vol.getPath(), vol.getName(), pool);
            disk.setSize(vol.getInfo().allocation);
            disk.setVirtualSize(vol.getInfo().capacity);

            /**
             * libvirt returns format = 'unknow', so we have to force
             * the format to RAW for RBD storage volumes
             */
 
View Full Code Here

            LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(name,
                    size, libvirtformat, null, null);
            s_logger.debug(volDef.toString());
            try {
                StorageVol vol = virtPool.storageVolCreateXML(volDef.toString(), 0);
                volPath = vol.getPath();
                volName = vol.getName();
                volAllocation = vol.getInfo().allocation;
                volCapacity = vol.getInfo().capacity;
            } catch (LibvirtException e) {
                throw new CloudRuntimeException(e.toString());
            }
        }
View Full Code Here

            }
        }

        LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
        try {
            StorageVol vol = this.getVolume(libvirtPool.getPool(), uuid);
            deleteVol(libvirtPool, vol);
            vol.free();
            return true;
        } catch (LibvirtException e) {
            throw new CloudRuntimeException(e.toString());
        }
    }
View Full Code Here

TOP

Related Classes of org.libvirt.StorageVol

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.