use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.
the class VmHandlerTest method createLunDisk.
private LunDisk createLunDisk() {
LunDisk lunDisk = new LunDisk();
lunDisk.setId(Guid.newGuid());
return lunDisk;
}
use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.
the class DiskMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.storage.Disk.class, to = Disk.class)
public static Disk map(org.ovirt.engine.core.common.businessentities.storage.Disk entity, Disk template) {
Disk model = template != null ? template : new Disk();
// name is depreciated, use alias instead.
model.setName(entity.getDiskAlias());
model.setAlias(entity.getDiskAlias());
if (entity.getId() != null) {
model.setId(entity.getId().toString());
}
model.setPropagateErrors(PropagateErrors.On == entity.getPropagateErrors());
model.setWipeAfterDelete(entity.isWipeAfterDelete());
model.setShareable(entity.isShareable());
model.setDescription(entity.getDiskDescription());
model.setLogicalName(entity.getLogicalName());
model.setStorageType(map(entity.getDiskStorageType()));
if (entity.getDiskStorageType() == org.ovirt.engine.core.common.businessentities.storage.DiskStorageType.IMAGE || entity.getDiskStorageType() == org.ovirt.engine.core.common.businessentities.storage.DiskStorageType.CINDER) {
mapDiskImageToDiskFields((DiskImage) entity, model);
} else {
model.setLunStorage(StorageLogicalUnitMapper.map(((LunDisk) entity).getLun(), new HostStorage()));
if (entity.getSgio() != null) {
model.setSgio(map(entity.getSgio(), null));
}
}
model.setContentType(mapDiskContentType(entity.getContentType()));
return model;
}
use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.
the class LunDiskMapperTest method testRoundtrip.
@Test
@Override
public void testRoundtrip() throws Exception {
setUpConfigExpectations();
Disk model = Disk.class.cast(populate(Disk.class));
model = postPopulate(model);
Mapper<Disk, org.ovirt.engine.core.common.businessentities.storage.Disk> out = getMappingLocator().getMapper(Disk.class, org.ovirt.engine.core.common.businessentities.storage.Disk.class);
Mapper<org.ovirt.engine.core.common.businessentities.storage.Disk, Disk> back = getMappingLocator().getMapper(org.ovirt.engine.core.common.businessentities.storage.Disk.class, Disk.class);
LunDisk to = (LunDisk) out.map(model, null);
LunDisk inverse = getInverse(to);
Disk transform = back.map(inverse, null);
verify(model, transform);
}
use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.
the class LibvirtVmXmlBuilder method writeDiskSource.
private void writeDiskSource(Disk disk, String dev) {
writer.writeStartElement("source");
switch(disk.getDiskStorageType()) {
case IMAGE:
DiskImage diskImage = (DiskImage) disk;
// Change parameters for the HE disk
if (vm.isHostedEngine()) {
// Hosted engine disk images have to have empty storage pool ID,
// so they can be mounted even if storage pool is not connected.
diskImage.setStoragePoolId(Guid.Empty);
diskImage.setPropagateErrors(PropagateErrors.Off);
// The disk requires a lease
addVolumeLease(diskImage.getImageId(), diskImage.getStorageIds().get(0));
}
String diskType = this.vmInfoBuildUtils.getDiskType(this.vm, diskImage);
switch(diskType) {
case "block":
writer.writeAttributeString("dev", vmInfoBuildUtils.getPathToImage(diskImage));
break;
case "network":
String[] volInfo = vmInfoBuildUtils.getGlusterVolInfo(disk);
// drop to the 'file' case as a fallback.
if (volInfo != null) {
writer.writeAttributeString("protocol", "gluster");
writer.writeAttributeString("name", String.format("%s/%s/images/%s/%s", volInfo[1], diskImage.getStorageIds().get(0), diskImage.getId(), diskImage.getImageId()));
writer.writeStartElement("host");
writer.writeAttributeString("name", volInfo[0]);
writer.writeAttributeString("port", "0");
writer.writeEndElement();
break;
}
case "file":
writer.writeAttributeString("file", vmInfoBuildUtils.getPathToImage(diskImage));
break;
}
diskMetadata.put(dev, createDiskParams(diskImage));
break;
case LUN:
LunDisk lunDisk = (LunDisk) disk;
writer.writeAttributeString("dev", String.format("/dev/mapper/%s", lunDisk.getLun().getLUNId()));
diskMetadata.put(dev, Collections.singletonMap("GUID", lunDisk.getLun().getLUNId()));
break;
case CINDER:
// case RBD
CinderDisk cinderDisk = (CinderDisk) disk;
Map<String, Object> connectionInfoData = cinderDisk.getCinderConnectionInfo().getData();
writer.writeAttributeString("protocol", cinderDisk.getCinderConnectionInfo().getDriverVolumeType());
writer.writeAttributeString("name", connectionInfoData.get("name").toString());
List<String> hostAddresses = (List<String>) connectionInfoData.get("hosts");
List<String> hostPorts = (List<String>) connectionInfoData.get("ports");
// (Cinder should ensure that the addresses and ports lists are synced in order).
for (int i = 0; i < hostAddresses.size(); i++) {
writer.writeStartElement("host");
writer.writeAttributeString("name", hostAddresses.get(i));
writer.writeAttributeString("port", hostPorts.get(i));
// If no transport is specified, "tcp" is assumed.
writer.writeEndElement();
}
break;
}
writer.writeEndElement();
}
use of org.ovirt.engine.core.common.businessentities.storage.LunDisk in project ovirt-engine by oVirt.
the class DisksFilterTest method testFilterNonLunDisks.
@Test
public void testFilterNonLunDisks() {
Disk lunDisk = createDisk(DiskStorageType.LUN, false, false, false, false);
Disk imageDisk = createDisk(DiskStorageType.IMAGE, false, false, true, false);
Disk cinderDisk = createDisk(DiskStorageType.CINDER, false, false, true, false);
List<Disk> disksList = Arrays.asList(lunDisk, imageDisk, cinderDisk);
List<LunDisk> filteredList = DisksFilter.filterLunDisks(disksList);
assertEquals(1, filteredList.size());
assertThat(filteredList, containsInAnyOrder(lunDisk));
}
Aggregations