public AddDiskParameters(Disk diskInfo) { this(new DiskVmElement(Guid.Empty, null), diskInfo); }
private static void copyProperties(DiskVmElement source, DiskVmElement dest) { dest.setBoot(source.isBoot()); dest.setPassDiscard(source.isPassDiscard()); dest.setDiskInterface(source.getDiskInterface()); dest.setUsingScsiReservation(source.isUsingScsiReservation()); dest.setPlugged(source.isPlugged()); dest.setLogicalName(source.getLogicalName()); dest.setReadOnly(source.isReadOnly()); }
@Override protected MapSqlParameterSource createFullParametersMapper(DiskVmElement entity) { return createIdParameterMapper(entity.getId()) .addValue("is_boot", entity.isBoot()) .addValue("pass_discard", entity.isPassDiscard()) .addValue("disk_interface", EnumUtils.nameOrNull(entity.getDiskInterface())) .addValue("is_using_scsi_reservation", entity.isUsingScsiReservation()); }
public static DiskVmElement copyOf(DiskVmElement diskVmElement, Guid diskId, Guid vmId) { DiskVmElement newDve = new DiskVmElement(diskId, vmId); copyProperties(diskVmElement, newDve); return newDve; }
public static DiskVmElement copyOf(DiskVmElement diskVmElement) { DiskVmElement newDve = new DiskVmElement(diskVmElement.getId().getDeviceId(), diskVmElement.getId().getVmId()); copyProperties(diskVmElement, newDve); return newDve; }
@Mapping(from = org.ovirt.engine.core.common.businessentities.storage.DiskVmElement.class, to = DiskAttachment.class) public static DiskAttachment map(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement entity, DiskAttachment template) { DiskAttachment model = template != null ? template : new DiskAttachment(); Guid vmId = entity.getVmId(); if (vmId != null) { Vm vm = new Vm(); vm.setId(vmId.toString()); model.setVm(vm); } Guid diskId = entity.getDiskId(); if (diskId != null) { Disk disk = new Disk(); disk.setId(diskId.toString()); model.setDisk(disk); } model.setId(entity.getDiskId().toString()); model.setBootable(entity.isBoot()); model.setPassDiscard(entity.isPassDiscard()); model.setInterface(DiskMapper.mapInterface(entity.getDiskInterface())); model.setActive(entity.isPlugged()); model.setLogicalName(entity.getLogicalName()); model.setUsesScsiReservation(entity.isUsingScsiReservation()); model.setReadOnly(entity.isReadOnly()); return model; } }
@Mapping(from = DiskAttachment.class, to = org.ovirt.engine.core.common.businessentities.storage.DiskVmElement.class) public static org.ovirt.engine.core.common.businessentities.storage.DiskVmElement map(DiskAttachment model, org.ovirt.engine.core.common.businessentities.storage.DiskVmElement template) { org.ovirt.engine.core.common.businessentities.storage.DiskVmElement entity = template != null ? template : new DiskVmElement(); if (model.isSetId()) { entity.setId(new VmDeviceId(GuidUtils.asGuid(model.getId()), null)); } else { entity.setId(new VmDeviceId()); } if (model.isSetBootable()) { entity.setBoot(model.isBootable()); } if (model.isSetPassDiscard()) { entity.setPassDiscard(model.isPassDiscard()); } if (model.isSetInterface()) { entity.setDiskInterface(DiskMapper.mapInterface(model.getInterface())); } if (model.isSetUsesScsiReservation()) { entity.setUsingScsiReservation(model.isUsesScsiReservation()); } if (model.isSetReadOnly()) { entity.setReadOnly(model.isReadOnly()); } return entity; }
protected void initGeneralDiskAttributes(XmlNode node, Disk disk, DiskVmElement dve) { if (node.attributes.get("ovf:disk-interface") != null) { if (!StringUtils.isEmpty(node.attributes.get("ovf:disk-interface").getValue())) { dve.setDiskInterface(DiskInterface.valueOf(node.attributes.get("ovf:disk-interface") .getValue())); dve.setDiskInterface(DiskInterface.IDE); dve.setBoot(Boolean.parseBoolean(node.attributes.get("ovf:boot").getValue())); dve.setReadOnly(Boolean.parseBoolean(node.attributes.get("ovf:read-only").getValue())); dve.setPassDiscard(Boolean.parseBoolean(node.attributes.get("ovf:pass-discard").getValue())); dve.setUsingScsiReservation(Boolean.parseBoolean(node.attributes.get("ovf:scsi_reservation").getValue())); dve.setPlugged(Boolean.TRUE); if (node.attributes.get("ovf:plugged") != null) { if (!StringUtils.isEmpty(node.attributes.get("ovf:plugged").getValue())) { dve.setPlugged(Boolean.parseBoolean(node.attributes.get("ovf:plugged").getValue()));
_writer.writeAttributeString(getOvfUri(), "disk-description", lun.getDiskDescription()); _writer.writeAttributeString(getOvfUri(), "pass-discard", String.valueOf(dve.isPassDiscard())); _writer.writeAttributeString(getOvfUri(), "fileRef", OvfParser.createLunFile(lun)); _writer.writeAttributeString(getOvfUri(), "shareable", String.valueOf(lun.isShareable())); _writer.writeAttributeString(getOvfUri(), "boot", String.valueOf(dve.isBoot())); _writer.writeAttributeString(getOvfUri(), "disk-interface", dve.getDiskInterface().toString()); _writer.writeAttributeString(getOvfUri(), "read-only", String.valueOf(dve.isReadOnly())); _writer.writeAttributeString(getOvfUri(), "scsi_reservation", String.valueOf(dve.isUsingScsiReservation())); _writer.writeAttributeString(getOvfUri(), "plugged", String.valueOf(dve.isPlugged())); _writer.writeAttributeString(getOvfUri(), LUN_ID, String.valueOf(lun.getLun().getLUNId())); if (lun.getLun().getLunConnections() != null) {
DiskVmElement dve = new DiskVmElement(disk.getDisk().getId(), getVm().getId()); dve.setBoot(disk.getIsBootable().getEntity()); dve.setDiskInterface(disk.getDiskInterface().getSelectedItem()); dve.setReadOnly(disk.isReadOnly()); AttachDetachVmDiskParameters parameters = new AttachDetachVmDiskParameters(dve , activate);
private void setUpDiskVmElementExpectations() { DiskVmElement dve = new DiskVmElement(DISK_ID, VM_ID); dve.setDiskInterface(DiskInterface.VirtIO); dve.setBoot(false); setUpGetEntityExpectations( QueryType.GetDiskVmElementById, VmDeviceIdQueryParameters.class, new String[] { "Id"}, new Object[] { new VmDeviceId(DISK_ID, VM_ID)}, dve ); }
@Override protected void writeDisk(DiskImage image) { DiskVmElement dve = image.getDiskVmElementForVm(vmBase.getId()); _writer.writeAttributeString(getOvfUri(), "diskId", image.getImageId().toString()); _writer.writeAttributeString(getOvfUri(), "size", String.valueOf(bytesToGigabyte(image.getSize()))); _writer.writeAttributeString(getOvfUri(), "actual_size", String.valueOf(bytesToGigabyte(image.getActualSizeInBytes()))); _writer.writeAttributeString(getOvfUri(), "vm_snapshot_id", (image.getVmSnapshotId() != null) ? image .getVmSnapshotId().toString() : ""); writeDiskParentRef(image); _writer.writeAttributeString(getOvfUri(), "fileRef", OvfParser.createImageFile(image)); _writer.writeAttributeString(getOvfUri(), "format", getVolumeImageFormat(image.getVolumeFormat())); _writer.writeAttributeString(getOvfUri(), "volume-format", image.getVolumeFormat().toString()); _writer.writeAttributeString(getOvfUri(), "volume-type", image.getVolumeType().toString()); _writer.writeAttributeString(getOvfUri(), "disk-interface", dve.getDiskInterface().toString()); _writer.writeAttributeString(getOvfUri(), "read-only", String.valueOf(dve.isReadOnly())); _writer.writeAttributeString(getOvfUri(), "shareable", String.valueOf(image.isShareable())); _writer.writeAttributeString(getOvfUri(), "boot", String.valueOf(dve.isBoot())); _writer.writeAttributeString(getOvfUri(), "pass-discard", String.valueOf(dve.isPassDiscard())); if (image.getDiskAlias() != null) { _writer.writeAttributeString(getOvfUri(), "disk-alias", image.getDiskAlias()); } if (image.getDiskDescription() != null) { _writer.writeAttributeString(getOvfUri(), "disk-description", image.getDiskDescription()); } _writer.writeAttributeString(getOvfUri(), "wipe-after-delete", String.valueOf(image.isWipeAfterDelete())); }
private VmDevice createDiskDevice(boolean boot, Map<VmDeviceId, DiskVmElement> idToDiskElement) { Guid id = Guid.newGuid(); VmDevice device = new VmDevice(); device.setType(VmDeviceGeneralType.DISK); device.setDevice(VmDeviceType.DISK.getName()); device.setId(new VmDeviceId(id, null)); DiskVmElement dve = new DiskVmElement(new VmDeviceId(id, null)); dve.setBoot(boot); idToDiskElement.put(dve.getId(), dve); return device; }
getIsScsiPassthrough().setEntity(getDisk().isScsiPassthrough()); getIsSgIoUnfiltered().setEntity(getDisk().getSgio() == ScsiGenericIO.UNFILTERED); getIsReadOnly().setEntity(getDiskVmElement().isReadOnly()); getIsBootable().setEntity(getDiskVmElement().isBoot()); getPassDiscard().setEntity(getDiskVmElement().isPassDiscard()); getSize().setEntity(lunDisk.getLun().getDeviceSize()); getSizeExtend().setIsAvailable(false); getIsUsingScsiReservation().setEntity(getDiskVmElement().isUsingScsiReservation()); break; case CINDER:
private DiskVmElement updateDiskVmElementFromDisk(Disk disk, DiskVmElement diskVmElement) { if (disk.isSetInterface()) { diskVmElement.setDiskInterface(DiskMapper.mapInterface(disk.getInterface())); } if(disk.isSetBootable()) { diskVmElement.setBoot(disk.isBootable()); } if (disk.isSetReadOnly()) { diskVmElement.setReadOnly(disk.isReadOnly()); } return diskVmElement; } }
@Override public ImageResource getValue(Disk object) { if (object.getDiskVmElements().size() == 1) { if (object.getDiskVmElements().iterator().next().isBoot()) { return getDefaultImage(); } } return null; }
_writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "volume-format", image.getVolumeFormat().toString()); _writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "volume-type", image.getVolumeType().toString()); _writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "disk-interface", dve.getDiskInterface().toString()); _writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "boot", String.valueOf(dve.isBoot())); _writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "pass-discard", String.valueOf(dve.isPassDiscard())); if (image.getDiskAlias() != null) { _writer.writeAttributeString(OVF_PREFIX, getOvfUri(), "disk-alias", image.getDiskAlias());
@ParameterizedTest @ValueSource(strings = {"true", "false"}) public void testCopyOf(boolean boot) { DiskVmElement dve = new DiskVmElement(Guid.newGuid(), Guid.newGuid()); dve.setBoot(boot); DiskVmElement copy = DiskVmElement.copyOf(dve); assertEquals(copy, dve); assertNotSame(copy, dve); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DiskVmElement that = (DiskVmElement) o; return boot == that.boot && passDiscard == that.passDiscard && diskInterface == that.diskInterface && usingScsiReservation == that.usingScsiReservation && plugged == that.plugged && Objects.equals(logicalName, that.logicalName) && readOnly == that.readOnly && Objects.equals(id, that.getId()); }
@Override public ActionParametersBase getParameters(DiskAttachment incoming, org.ovirt.engine.core.common.businessentities.storage.DiskVmElement entity) { DiskVmElement dve = map(incoming, entity); dve.getId().setVmId(vmId); // Disk has to be sent along with the attachment data to the update command Disk disk = runQuery(QueryType.GetDiskByDiskId, new IdQueryParameters(Guid.createGuidFromString(diskId))).getReturnValue(); // If a <disk> was specified inside the attachment data we can update its properties too if (incoming.isSetDisk()) { disk = DiskMapper.map(incoming.getDisk(), disk); // TODO: Remove this in version 5 of the API as the setting of the read only attribute should be from DiskAttachment if (incoming.getDisk().isSetReadOnly()) { dve.setReadOnly(incoming.getDisk().isReadOnly()); } } return new VmDiskOperationParameterBase(dve, disk); } }