use of org.ovirt.engine.api.model.HostNics in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testCompleteListSubFields.
@Test
public void testCompleteListSubFields() throws Exception {
HostNic bond = new HostNic();
bond.setName("joe");
bond.setNetwork(new Network());
bond.getNetwork().setId("0");
bond.setBonding(new Bonding());
bond.getBonding().setSlaves(new HostNics());
HostNic slave = new HostNic();
slave.setId("0");
bond.getBonding().getSlaves().getHostNics().add(slave);
slave = new HostNic();
slave.setId("0");
bond.getBonding().getSlaves().getHostNics().add(slave);
CompletenessAssertor.validateParameters(bond, "name", "network.id|name", "bonding.slaves.id|name");
}
use of org.ovirt.engine.api.model.HostNics in project ovirt-engine by oVirt.
the class BackendHostNicsResource method list.
@Override
public HostNics list() {
HostNics ret = new HostNics();
List<VdsNetworkInterface> ifaces = getCollection();
Map<String, Guid> networkNameToNetworkIdMap = mapNetworkNamesToNetworkIds();
Map<Guid, NetworkAttachment> attachmentsByNetworkId = getAttachmentsByNetworkId();
for (VdsNetworkInterface iface : ifaces) {
HostNic hostNic = populate(map(iface, ifaces), iface);
setCustomProperties(attachmentsByNetworkId, networkNameToNetworkIdMap, hostNic);
String networkName = iface.getNetworkName();
if (networkNameToNetworkIdMap.containsKey(networkName)) {
Guid networkId = networkNameToNetworkIdMap.get(networkName);
hostNic.getNetwork().setId(networkId.toString());
hostNic.getNetwork().setName(null);
}
ret.getHostNics().add(addLinks(hostNic));
}
return addActions(ret);
}
use of org.ovirt.engine.api.model.HostNics in project ovirt-engine by oVirt.
the class V3BondingInAdapter method adapt.
@Override
public Bonding adapt(V3Bonding from) {
Bonding to = new Bonding();
if (from.isSetOptions()) {
to.setOptions(new Options());
to.getOptions().getOptions().addAll(adaptIn(from.getOptions().getOptions()));
}
if (from.isSetSlaves()) {
to.setSlaves(new HostNics());
to.getSlaves().getHostNics().addAll(adaptIn(from.getSlaves().getSlaves()));
}
return to;
}
use of org.ovirt.engine.api.model.HostNics in project ovirt-engine by oVirt.
the class V3HostNicsInAdapter method adapt.
@Override
public HostNics adapt(V3HostNics from) {
HostNics to = new HostNics();
if (from.isSetActions()) {
to.setActions(adaptIn(from.getActions()));
}
if (from.isSetActive()) {
to.setActive(from.getActive());
}
if (from.isSetSize()) {
to.setSize(from.getSize());
}
if (from.isSetTotal()) {
to.setTotal(from.getTotal());
}
to.getHostNics().addAll(adaptIn(from.getHostNics()));
return to;
}
use of org.ovirt.engine.api.model.HostNics 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()));
}
}
Aggregations