Search in sources :

Example 1 with BootDevice

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;
}
Also used : BootDevice(org.ovirt.engine.api.model.BootDevice) Boot(org.ovirt.engine.api.model.Boot)

Example 2 with BootDevice

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;
}
Also used : V3OperatingSystem(org.ovirt.engine.api.v3.types.V3OperatingSystem) OperatingSystem(org.ovirt.engine.api.model.OperatingSystem) V3Boot(org.ovirt.engine.api.v3.types.V3Boot) BootDevice(org.ovirt.engine.api.model.BootDevice) V3Boot(org.ovirt.engine.api.v3.types.V3Boot) Boot(org.ovirt.engine.api.model.Boot)

Example 3 with BootDevice

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;
}
Also used : DisplayType(org.ovirt.engine.api.model.DisplayType) VmDeviceType(org.ovirt.engine.api.model.VmDeviceType) BootDevice(org.ovirt.engine.api.model.BootDevice) NicConfiguration(org.ovirt.engine.api.model.NicConfiguration) VmStorageErrorResumeBehaviour(org.ovirt.engine.api.model.VmStorageErrorResumeBehaviour) VcpuPin(org.ovirt.engine.api.model.VcpuPin) TimeZone(org.ovirt.engine.api.model.TimeZone) VcpuPins(org.ovirt.engine.api.model.VcpuPins) CpuTune(org.ovirt.engine.api.model.CpuTune) VmType(org.ovirt.engine.api.model.VmType) BootProtocol(org.ovirt.engine.api.model.BootProtocol)

Example 4 with BootDevice

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;
}
Also used : TimeZone(org.ovirt.engine.api.model.TimeZone) BootDevice(org.ovirt.engine.api.model.BootDevice) VmType(org.ovirt.engine.api.model.VmType) NicConfiguration(org.ovirt.engine.api.model.NicConfiguration) VmStorageErrorResumeBehaviour(org.ovirt.engine.api.model.VmStorageErrorResumeBehaviour) BootProtocol(org.ovirt.engine.api.model.BootProtocol)

Aggregations

BootDevice (org.ovirt.engine.api.model.BootDevice)4 Boot (org.ovirt.engine.api.model.Boot)2 BootProtocol (org.ovirt.engine.api.model.BootProtocol)2 NicConfiguration (org.ovirt.engine.api.model.NicConfiguration)2 TimeZone (org.ovirt.engine.api.model.TimeZone)2 VmStorageErrorResumeBehaviour (org.ovirt.engine.api.model.VmStorageErrorResumeBehaviour)2 VmType (org.ovirt.engine.api.model.VmType)2 CpuTune (org.ovirt.engine.api.model.CpuTune)1 DisplayType (org.ovirt.engine.api.model.DisplayType)1 OperatingSystem (org.ovirt.engine.api.model.OperatingSystem)1 VcpuPin (org.ovirt.engine.api.model.VcpuPin)1 VcpuPins (org.ovirt.engine.api.model.VcpuPins)1 VmDeviceType (org.ovirt.engine.api.model.VmDeviceType)1 V3Boot (org.ovirt.engine.api.v3.types.V3Boot)1 V3OperatingSystem (org.ovirt.engine.api.v3.types.V3OperatingSystem)1