Search in sources :

Example 1 with AttachVolumeAnswer

use of com.cloud.agent.api.AttachVolumeAnswer in project CloudStack-archive by CloudStack-extras.

the class LibvirtComputingResource method execute.

private AttachVolumeAnswer execute(AttachVolumeCommand cmd) {
    try {
        Connect conn = LibvirtConnection.getConnection();
        KVMStoragePool primary = _storagePoolMgr.getStoragePool(cmd.getPoolUuid());
        KVMPhysicalDisk disk = primary.getPhysicalDisk(cmd.getVolumePath());
        attachOrDetachDisk(conn, cmd.getAttach(), cmd.getVmName(), disk, cmd.getDeviceId().intValue());
    } catch (LibvirtException e) {
        return new AttachVolumeAnswer(cmd, e.toString());
    } catch (InternalErrorException e) {
        return new AttachVolumeAnswer(cmd, e.toString());
    }
    return new AttachVolumeAnswer(cmd, cmd.getDeviceId());
}
Also used : AttachVolumeAnswer(com.cloud.agent.api.AttachVolumeAnswer) LibvirtException(org.libvirt.LibvirtException) KVMStoragePool(com.cloud.agent.storage.KVMStoragePool) KVMPhysicalDisk(com.cloud.agent.storage.KVMPhysicalDisk) Connect(org.libvirt.Connect) InternalErrorException(com.cloud.exception.InternalErrorException)

Example 2 with AttachVolumeAnswer

use of com.cloud.agent.api.AttachVolumeAnswer in project CloudStack-archive by CloudStack-extras.

the class MockStorageManagerImpl method AttachVolume.

@Override
public AttachVolumeAnswer AttachVolume(AttachVolumeCommand cmd) {
    String poolid = cmd.getPoolUuid();
    String volumeName = cmd.getVolumeName();
    MockVolumeVO volume = _mockVolumeDao.findByStoragePathAndType(cmd.getVolumePath());
    if (volume == null) {
        return new AttachVolumeAnswer(cmd, "Can't find volume:" + volumeName + "on pool:" + poolid);
    }
    String vmName = cmd.getVmName();
    MockVMVO vm = _mockVMDao.findByVmName(vmName);
    if (vm == null) {
        return new AttachVolumeAnswer(cmd, "can't vm :" + vmName);
    }
    return new AttachVolumeAnswer(cmd, cmd.getDeviceId());
}
Also used : MockVMVO(com.cloud.simulator.MockVMVO) AttachVolumeAnswer(com.cloud.agent.api.AttachVolumeAnswer) MockVolumeVO(com.cloud.simulator.MockVolumeVO)

Aggregations

AttachVolumeAnswer (com.cloud.agent.api.AttachVolumeAnswer)2 KVMPhysicalDisk (com.cloud.agent.storage.KVMPhysicalDisk)1 KVMStoragePool (com.cloud.agent.storage.KVMStoragePool)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 MockVMVO (com.cloud.simulator.MockVMVO)1 MockVolumeVO (com.cloud.simulator.MockVolumeVO)1 Connect (org.libvirt.Connect)1 LibvirtException (org.libvirt.LibvirtException)1