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());
}
}
}
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);
}
}
Aggregations