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;
}
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;
}
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;
}
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;
}
Aggregations