Search in sources :

Example 1 with NicConfiguration

use of org.ovirt.engine.api.model.NicConfiguration in project ovirt-engine by oVirt.

the class InitializationMapper method map.

@Mapping(from = VmInitNetwork.class, to = NicConfiguration.class)
public static NicConfiguration map(VmInitNetwork entity, NicConfiguration template) {
    NicConfiguration model = template != null ? template : new NicConfiguration();
    model.setName(entity.getName());
    model.setOnBoot(entity.getStartOnBoot());
    populateModelWithIpv4Details(entity, model);
    populateModelWithIpv6Details(entity, model);
    return model;
}
Also used : NicConfiguration(org.ovirt.engine.api.model.NicConfiguration)

Example 2 with NicConfiguration

use of org.ovirt.engine.api.model.NicConfiguration in project ovirt-engine by oVirt.

the class InitializationMapper method map.

@Mapping(from = Initialization.class, to = VmInit.class)
public static VmInit map(Initialization model, VmInit template) {
    VmInit entity = template != null ? template : new VmInit();
    boolean someSubTagSet = false;
    if (model.isSetHostName()) {
        someSubTagSet = true;
        entity.setHostname(model.getHostName());
    }
    if (model.isSetDomain()) {
        someSubTagSet = true;
        entity.setDomain(model.getDomain());
    }
    if (model.isSetTimezone()) {
        someSubTagSet = true;
        entity.setTimeZone(model.getTimezone());
    }
    if (model.isSetAuthorizedSshKeys()) {
        someSubTagSet = true;
        entity.setAuthorizedKeys(model.getAuthorizedSshKeys());
    }
    if (model.isSetRegenerateSshKeys()) {
        someSubTagSet = true;
        entity.setRegenerateKeys(model.isRegenerateSshKeys());
    }
    if (model.isSetDnsServers()) {
        someSubTagSet = true;
        entity.setDnsServers(model.getDnsServers());
    }
    if (model.isSetDnsSearch()) {
        someSubTagSet = true;
        entity.setDnsSearch(model.getDnsSearch());
    }
    if (model.isSetWindowsLicenseKey()) {
        someSubTagSet = true;
        entity.setWinKey(model.getWindowsLicenseKey());
    }
    if (model.isSetRootPassword()) {
        someSubTagSet = true;
        entity.setRootPassword(model.getRootPassword());
    }
    if (model.isSetCustomScript()) {
        someSubTagSet = true;
        entity.setCustomScript(model.getCustomScript());
    }
    if (model.isSetNicConfigurations()) {
        someSubTagSet = true;
        List<VmInitNetwork> networks = new ArrayList<>();
        for (NicConfiguration nic : model.getNicConfigurations().getNicConfigurations()) {
            networks.add(map(nic, null));
        }
        entity.setNetworks(networks);
    }
    if (model.isSetInputLocale()) {
        someSubTagSet = true;
        entity.setInputLocale(model.getInputLocale());
    }
    if (model.isSetUiLanguage()) {
        someSubTagSet = true;
        entity.setUiLanguage(model.getUiLanguage());
    }
    if (model.isSetSystemLocale()) {
        someSubTagSet = true;
        entity.setSystemLocale(model.getSystemLocale());
    }
    if (model.isSetUserLocale()) {
        someSubTagSet = true;
        entity.setUserLocale(model.getUserLocale());
    }
    if (model.isSetUserName()) {
        someSubTagSet = true;
        entity.setUserName(model.getUserName());
    }
    if (model.isSetActiveDirectoryOu()) {
        someSubTagSet = true;
        entity.setActiveDirectoryOU(model.getActiveDirectoryOu());
    }
    if (model.isSetOrgName()) {
        someSubTagSet = true;
        entity.setOrgName(model.getOrgName());
    }
    if (model.isSetCloudInit()) {
        someSubTagSet = true;
        VmMapper.map(model.getCloudInit(), entity);
    }
    if (!someSubTagSet) {
        return null;
    }
    return entity;
}
Also used : VmInit(org.ovirt.engine.core.common.businessentities.VmInit) VmInitNetwork(org.ovirt.engine.core.common.businessentities.VmInitNetwork) ArrayList(java.util.ArrayList) NicConfiguration(org.ovirt.engine.api.model.NicConfiguration)

Example 3 with NicConfiguration

use of org.ovirt.engine.api.model.NicConfiguration 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 NicConfiguration

use of org.ovirt.engine.api.model.NicConfiguration 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

NicConfiguration (org.ovirt.engine.api.model.NicConfiguration)4 BootDevice (org.ovirt.engine.api.model.BootDevice)2 BootProtocol (org.ovirt.engine.api.model.BootProtocol)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 ArrayList (java.util.ArrayList)1 CpuTune (org.ovirt.engine.api.model.CpuTune)1 DisplayType (org.ovirt.engine.api.model.DisplayType)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 VmInit (org.ovirt.engine.core.common.businessentities.VmInit)1 VmInitNetwork (org.ovirt.engine.core.common.businessentities.VmInitNetwork)1