Search in sources :

Example 1 with LibvirtStorageVolumeDef

use of com.cloud.agent.resource.computing.LibvirtStorageVolumeDef in project CloudStack-archive by CloudStack-extras.

the class LibvirtStorageAdaptor method getPhysicalDisk.

@Override
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);
        if (voldef.getFormat() == null) {
            disk.setFormat(pool.getDefaultFormat());
        } else if (voldef.getFormat() == LibvirtStorageVolumeDef.volFormat.QCOW2) {
            disk.setFormat(KVMPhysicalDisk.PhysicalDiskFormat.QCOW2);
        } else if (voldef.getFormat() == LibvirtStorageVolumeDef.volFormat.RAW) {
            disk.setFormat(KVMPhysicalDisk.PhysicalDiskFormat.RAW);
        }
        return disk;
    } catch (LibvirtException e) {
        throw new CloudRuntimeException(e.toString());
    }
}
Also used : StorageVol(org.libvirt.StorageVol) LibvirtStorageVolumeDef(com.cloud.agent.resource.computing.LibvirtStorageVolumeDef) LibvirtException(org.libvirt.LibvirtException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 2 with LibvirtStorageVolumeDef

use of com.cloud.agent.resource.computing.LibvirtStorageVolumeDef in project CloudStack-archive by CloudStack-extras.

the class LibvirtStorageAdaptor method createVolume.

public StorageVol createVolume(Connect conn, StoragePool pool, String uuid, long size, volFormat format) throws LibvirtException {
    LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), size, format, null, null);
    s_logger.debug(volDef.toString());
    return pool.storageVolCreateXML(volDef.toString(), 0);
}
Also used : LibvirtStorageVolumeDef(com.cloud.agent.resource.computing.LibvirtStorageVolumeDef)

Example 3 with LibvirtStorageVolumeDef

use of com.cloud.agent.resource.computing.LibvirtStorageVolumeDef in project CloudStack-archive by CloudStack-extras.

the class LibvirtStorageAdaptor method createPhysicalDisk.

@Override
public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, PhysicalDiskFormat format, long size) {
    LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
    StoragePool virtPool = libvirtPool.getPool();
    LibvirtStorageVolumeDef.volFormat libvirtformat = null;
    if (format == PhysicalDiskFormat.QCOW2) {
        libvirtformat = LibvirtStorageVolumeDef.volFormat.QCOW2;
    } else if (format == PhysicalDiskFormat.RAW) {
        libvirtformat = LibvirtStorageVolumeDef.volFormat.RAW;
    }
    LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(name, size, libvirtformat, null, null);
    s_logger.debug(volDef.toString());
    try {
        StorageVol vol = virtPool.storageVolCreateXML(volDef.toString(), 0);
        KVMPhysicalDisk disk = new KVMPhysicalDisk(vol.getPath(), vol.getName(), pool);
        disk.setFormat(format);
        disk.setSize(vol.getInfo().allocation);
        disk.setVirtualSize(vol.getInfo().capacity);
        return disk;
    } catch (LibvirtException e) {
        throw new CloudRuntimeException(e.toString());
    }
}
Also used : StoragePool(org.libvirt.StoragePool) LibvirtStorageVolumeDef(com.cloud.agent.resource.computing.LibvirtStorageVolumeDef) StorageVol(org.libvirt.StorageVol) LibvirtException(org.libvirt.LibvirtException) LibvirtStorageVolumeDef.volFormat(com.cloud.agent.resource.computing.LibvirtStorageVolumeDef.volFormat) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

LibvirtStorageVolumeDef (com.cloud.agent.resource.computing.LibvirtStorageVolumeDef)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 LibvirtException (org.libvirt.LibvirtException)2 StorageVol (org.libvirt.StorageVol)2 LibvirtStorageVolumeDef.volFormat (com.cloud.agent.resource.computing.LibvirtStorageVolumeDef.volFormat)1 StoragePool (org.libvirt.StoragePool)1