use of org.ovirt.engine.api.model.BootDevice in project ovirt-engine by oVirt.
the class VmMapper method map.
@Mapping(from = BootSequence.class, to = Boot.class)
public static Boot map(BootSequence bootSequence, Boot template) {
Boot boot = template != null ? template : new Boot();
Boot.DevicesList list = new Boot.DevicesList();
boot.setDevices(list);
List<BootDevice> devices = list.getDevices();
switch(bootSequence) {
case C:
devices.add(BootDevice.HD);
break;
case DC:
devices.add(BootDevice.CDROM);
devices.add(BootDevice.HD);
break;
case N:
devices.add(BootDevice.NETWORK);
break;
case CDN:
devices.add(BootDevice.HD);
devices.add(BootDevice.CDROM);
devices.add(BootDevice.NETWORK);
break;
case CND:
devices.add(BootDevice.HD);
devices.add(BootDevice.NETWORK);
devices.add(BootDevice.CDROM);
break;
case DCN:
devices.add(BootDevice.CDROM);
devices.add(BootDevice.HD);
devices.add(BootDevice.NETWORK);
break;
case DNC:
devices.add(BootDevice.CDROM);
devices.add(BootDevice.NETWORK);
devices.add(BootDevice.HD);
break;
case NCD:
devices.add(BootDevice.NETWORK);
devices.add(BootDevice.HD);
devices.add(BootDevice.CDROM);
break;
case NDC:
devices.add(BootDevice.NETWORK);
devices.add(BootDevice.CDROM);
devices.add(BootDevice.HD);
break;
case CD:
devices.add(BootDevice.HD);
devices.add(BootDevice.CDROM);
break;
case D:
devices.add(BootDevice.CDROM);
break;
case CN:
devices.add(BootDevice.HD);
devices.add(BootDevice.NETWORK);
break;
case DN:
devices.add(BootDevice.CDROM);
devices.add(BootDevice.NETWORK);
break;
case NC:
devices.add(BootDevice.NETWORK);
devices.add(BootDevice.HD);
break;
case ND:
devices.add(BootDevice.NETWORK);
devices.add(BootDevice.CDROM);
break;
}
return boot;
}
use of org.ovirt.engine.api.model.BootDevice in project ovirt-engine by oVirt.
the class V3OperatingSystemInAdapter method adapt.
@Override
public OperatingSystem adapt(V3OperatingSystem from) {
OperatingSystem to = new OperatingSystem();
if (from.isSetBoot()) {
Boot toBoot = new Boot();
Boot.DevicesList toDevicesList = new Boot.DevicesList();
List<BootDevice> toDevices = toDevicesList.getDevices();
from.getBoot().stream().map(V3Boot::getDev).map(BootDevice::fromValue).forEach(toDevices::add);
toBoot.setDevices(toDevicesList);
to.setBoot(toBoot);
}
if (from.isSetCmdline()) {
to.setCmdline(from.getCmdline());
}
if (from.isSetInitrd()) {
to.setInitrd(from.getInitrd());
}
if (from.isSetKernel()) {
to.setKernel(from.getKernel());
}
if (from.isSetType()) {
to.setType(from.getType());
}
if (from.isSetVersion()) {
to.setVersion(adaptIn(from.getVersion()));
}
return to;
}
use of org.ovirt.engine.api.model.BootDevice in project ovirt-engine by oVirt.
the class VmMapperTest method postPopulate.
@Override
protected Vm postPopulate(Vm from) {
from.setType(MappingTestHelper.shuffle(VmType.class));
from.setStorageErrorResumeBehaviour(MappingTestHelper.shuffle(VmStorageErrorResumeBehaviour.class));
from.setOrigin(OriginType.VMWARE.name().toLowerCase());
from.getDisplay().setType(MappingTestHelper.shuffle(DisplayType.class));
from.getPayloads().getPayloads().get(0).setType(MappingTestHelper.shuffle(VmDeviceType.class));
List<BootDevice> devices = from.getOs().getBoot().getDevices().getDevices();
for (int i = 0; i < devices.size(); i++) {
devices.set(i, MappingTestHelper.shuffle(BootDevice.class));
}
while (from.getCpu().getTopology().getSockets() == 0) {
from.getCpu().getTopology().setSockets(MappingTestHelper.rand(100));
}
while (from.getCpu().getTopology().getCores() == 0) {
from.getCpu().getTopology().setCores(MappingTestHelper.rand(100));
}
CpuTune cpuTune = new CpuTune();
VcpuPin pin = new VcpuPin();
pin.setVcpu(33);
pin.setCpuSet("1-4,6");
VcpuPins pins = new VcpuPins();
pins.getVcpuPins().add(pin);
cpuTune.setVcpuPins(pins);
from.getCpu().setCpuTune(cpuTune);
from.setTimeZone(new TimeZone());
from.getTimeZone().setName("Australia/Darwin");
// VmPlacement - multiple hosts
from.setPlacementPolicy(createPlacementPolicy(Guid.EVERYONE, Guid.SYSTEM));
// Guest Nics configurations
for (NicConfiguration guestNic : from.getInitialization().getNicConfigurations().getNicConfigurations()) {
guestNic.setBootProtocol(MappingTestHelper.shuffle(BootProtocol.class, BootProtocol.AUTOCONF));
}
from.getDisplay().setType(DisplayType.SPICE);
from.getSerialNumber().setPolicy(SerialNumberPolicy.CUSTOM);
from.getDisplay().setFileTransferEnabled(true);
from.getDisplay().setCopyPasteEnabled(true);
from.getMigration().setAutoConverge(InheritableBoolean.TRUE);
from.getMigration().setCompressed(InheritableBoolean.TRUE);
from.getDisplay().setDisconnectAction(DisplayDisconnectAction.LOCK_SCREEN.toString());
return from;
}
use of org.ovirt.engine.api.model.BootDevice in project ovirt-engine by oVirt.
the class TemplateMapperTest method postPopulate.
@Override
protected Template postPopulate(Template from) {
from.setType(MappingTestHelper.shuffle(VmType.class));
from.setStorageErrorResumeBehaviour(MappingTestHelper.shuffle(VmStorageErrorResumeBehaviour.class));
from.setOrigin(OriginType.VMWARE.name().toLowerCase());
List<BootDevice> devices = from.getOs().getBoot().getDevices().getDevices();
for (int i = 0; i < devices.size(); i++) {
devices.set(i, MappingTestHelper.shuffle(BootDevice.class));
}
while (from.getCpu().getTopology().getSockets() == 0) {
from.getCpu().getTopology().setSockets(MappingTestHelper.rand(100));
}
while (from.getCpu().getTopology().getCores() == 0) {
from.getCpu().getTopology().setCores(MappingTestHelper.rand(100));
}
from.setTimeZone(new TimeZone());
from.getTimeZone().setName("Australia/Darwin");
from.getSerialNumber().setPolicy(SerialNumberPolicy.CUSTOM);
from.getMigration().setAutoConverge(InheritableBoolean.TRUE);
from.getMigration().setCompressed(InheritableBoolean.TRUE);
from.getDisplay().setDisconnectAction(DisplayDisconnectAction.LOCK_SCREEN.toString());
for (NicConfiguration nicConfiguration : from.getInitialization().getNicConfigurations().getNicConfigurations()) {
nicConfiguration.setBootProtocol(MappingTestHelper.shuffle(BootProtocol.class, BootProtocol.AUTOCONF));
}
return from;
}
Aggregations