Search in sources :

Example 1 with DiskLunMapId

use of org.ovirt.engine.core.common.businessentities.storage.DiskLunMapId in project ovirt-engine by oVirt.

the class ImportVmCommand method addVmExternalLuns.

protected void addVmExternalLuns() {
    if (getParameters().getVm().getDiskMap() != null) {
        List<LunDisk> lunDisks = DisksFilter.filterLunDisks(getParameters().getVm().getDiskMap().values());
        for (LunDisk lun : lunDisks) {
            StorageType storageType = StorageType.UNKNOWN;
            if (lun.getLun().getLunConnections() != null && !lun.getLun().getLunConnections().isEmpty()) {
                // We set the storage type based on the first connection since connections should be with the same
                // storage type
                storageType = lun.getLun().getLunConnections().get(0).getStorageType();
            }
            lunHelper.proceedDirectLUNInDb(lun.getLun(), storageType);
            // Only if the LUN disk does not exists in the setup add it.
            if (baseDiskDao.get(lun.getId()) == null) {
                baseDiskDao.save(lun);
            }
            if (diskLunMapDao.get(new DiskLunMapId(lun.getId(), lun.getLun().getLUNId())) == null) {
                diskLunMapDao.save(new DiskLunMap(lun.getId(), lun.getLun().getLUNId()));
            }
            // Add disk VM element to attach the disk to the VM.
            DiskVmElement diskVmElement = lun.getDiskVmElementForVm(getVmId());
            diskVmElementDao.save(diskVmElement);
            getVmDeviceUtils().addDiskDevice(getVmId(), lun.getId(), diskVmElement.isPlugged(), diskVmElement.isReadOnly());
        }
    }
}
Also used : StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) DiskLunMapId(org.ovirt.engine.core.common.businessentities.storage.DiskLunMapId) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) DiskLunMap(org.ovirt.engine.core.common.businessentities.storage.DiskLunMap)

Example 2 with DiskLunMapId

use of org.ovirt.engine.core.common.businessentities.storage.DiskLunMapId in project ovirt-engine by oVirt.

the class ImagesHandler method removeLunDisk.

public void removeLunDisk(LunDisk lunDisk) {
    vmDeviceDao.remove(new VmDeviceId(lunDisk.getId(), null));
    LUNs lun = lunDisk.getLun();
    diskLunMapDao.remove(new DiskLunMapId(lunDisk.getId(), lun.getLUNId()));
    baseDiskDao.remove(lunDisk.getId());
    lun.setLunConnections(new ArrayList<>(storageServerConnectionDao.getAllForLun(lun.getLUNId())));
    if (!lun.getLunConnections().isEmpty()) {
        storageHelperDirector.getItem(lun.getLunConnections().get(0).getStorageType()).removeLun(lun);
    } else {
        // if there are no connections then the lun is fcp.
        storageHelperDirector.getItem(StorageType.FCP).removeLun(lun);
    }
}
Also used : DiskLunMapId(org.ovirt.engine.core.common.businessentities.storage.DiskLunMapId) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Aggregations

DiskLunMapId (org.ovirt.engine.core.common.businessentities.storage.DiskLunMapId)2 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)1 DiskLunMap (org.ovirt.engine.core.common.businessentities.storage.DiskLunMap)1 DiskStorageType (org.ovirt.engine.core.common.businessentities.storage.DiskStorageType)1 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)1 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)1 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)1 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)1