use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class V3HostNICInAdapter method adapt.
@Override
public HostNic adapt(V3HostNIC from) {
HostNic to = new HostNic();
if (from.isSetLinks()) {
to.getLinks().addAll(adaptIn(from.getLinks()));
}
if (from.isSetActions()) {
to.setActions(adaptIn(from.getActions()));
}
if (from.isSetBaseInterface()) {
to.setBaseInterface(from.getBaseInterface());
}
if (from.isSetBonding()) {
to.setBonding(adaptIn(from.getBonding()));
}
if (from.isSetBootProtocol()) {
to.setBootProtocol(BootProtocol.fromValue(from.getBootProtocol()));
}
if (from.isSetBridged()) {
to.setBridged(from.isBridged());
}
if (from.isSetCheckConnectivity()) {
to.setCheckConnectivity(from.isCheckConnectivity());
}
if (from.isSetComment()) {
to.setComment(from.getComment());
}
if (from.isSetCustomConfiguration()) {
to.setCustomConfiguration(from.isCustomConfiguration());
}
if (from.isSetDescription()) {
to.setDescription(from.getDescription());
}
if (from.isSetHost()) {
to.setHost(adaptIn(from.getHost()));
}
if (from.isSetId()) {
to.setId(from.getId());
}
if (from.isSetHref()) {
to.setHref(from.getHref());
}
if (from.isSetIp()) {
to.setIp(adaptIn(from.getIp()));
}
if (from.isSetLabels()) {
to.setNetworkLabels(new NetworkLabels());
to.getNetworkLabels().getNetworkLabels().addAll(adaptIn(from.getLabels().getLabels()));
}
if (from.isSetMac()) {
to.setMac(adaptIn(from.getMac()));
}
if (from.isSetMtu()) {
to.setMtu(from.getMtu());
}
if (from.isSetName()) {
to.setName(from.getName());
}
if (from.isSetNetwork()) {
to.setNetwork(adaptIn(from.getNetwork()));
}
if (from.isSetOverrideConfiguration()) {
to.setOverrideConfiguration(from.isOverrideConfiguration());
}
if (from.isSetPhysicalFunction()) {
to.setPhysicalFunction(adaptIn(from.getPhysicalFunction()));
}
if (from.isSetProperties()) {
to.setProperties(new Properties());
to.getProperties().getProperties().addAll(adaptIn(from.getProperties().getProperties()));
}
if (from.isSetQos()) {
to.setQos(adaptIn(from.getQos()));
}
if (from.isSetSpeed()) {
to.setSpeed(from.getSpeed());
}
if (from.isSetStatistics()) {
to.setStatistics(new Statistics());
to.getStatistics().getStatistics().addAll(adaptIn(from.getStatistics().getStatistics()));
}
if (from.isSetStatus() && from.getStatus().isSetState()) {
to.setStatus(NicStatus.fromValue(from.getStatus().getState()));
}
if (from.isSetVirtualFunctionsConfiguration()) {
to.setVirtualFunctionsConfiguration(adaptIn(from.getVirtualFunctionsConfiguration()));
}
if (from.isSetVlan()) {
to.setVlan(adaptIn(from.getVlan()));
}
return to;
}
use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class HostNicMapperTest method testBondMapping.
@Test
public void testBondMapping() {
HostNic model = new HostNic();
model.setId(Guid.newGuid().toString());
model.setName(RandomUtils.instance().nextString(10));
model.setBonding(new Bonding());
model.getBonding().setSlaves(new HostNics());
HostNic slaveA = new HostNic();
slaveA.setName(RandomUtils.instance().nextString(10));
model.getBonding().getSlaves().getHostNics().add(slaveA);
Bond entity = HostNicMapper.map(model, null);
assertNotNull(entity);
assertEquals(model.getId(), entity.getId().toString());
assertEquals(model.getName(), entity.getName());
assertEquals(model.getBonding().getSlaves().getHostNics().size(), entity.getSlaves().size());
for (HostNic slave : model.getBonding().getSlaves().getHostNics()) {
assertTrue(entity.getSlaves().contains(slave.getName()));
}
}
use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class HostNicMapperTest method testCustomNetworkConfigurationMapped.
@Test
public void testCustomNetworkConfigurationMapped() throws Exception {
VdsNetworkInterface entity = new VdsNetworkInterface();
HostNic model = HostNicMapper.map(entity, null);
assertFalse(model.isSetCustomConfiguration());
entity.setNetworkImplementationDetails(new VdsNetworkInterface.NetworkImplementationDetails(false, true));
model = HostNicMapper.map(entity, null);
assertEquals(entity.getNetworkImplementationDetails().isInSync(), !model.isCustomConfiguration());
entity.setNetworkImplementationDetails(new VdsNetworkInterface.NetworkImplementationDetails(true, true));
model = HostNicMapper.map(entity, null);
assertEquals(entity.getNetworkImplementationDetails().isInSync(), !model.isCustomConfiguration());
}
use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class HostNicMapperTest method postPopulate.
@Override
protected HostNic postPopulate(HostNic model) {
HostNic hostNIC = super.postPopulate(model);
Qos qos = hostNIC.getQos();
qos.setType(QosType.HOSTNETWORK);
qos.setName(null);
qos.setDataCenter(null);
model.setBootProtocol(MappingTestHelper.shuffle(BootProtocol.class, BootProtocol.AUTOCONF));
return hostNIC;
}
use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class AbstractBaseHostNicLabelsResource method addParents.
@Override
protected NetworkLabel addParents(NetworkLabel model) {
model.setHostNic(new HostNic());
model.getHostNic().setId(nicId.toString());
model.getHostNic().setHost(new Host());
model.getHostNic().getHost().setId(hostId);
return model;
}
Aggregations