/** * Create an instance of {@link HostNic } * */ public HostNic createHostNic() { return new HostNic(); }
private static HostNic getModelHostNic(NetworkAttachment model) { HostNic hostNic = model.getHostNic(); if (hostNic == null) { hostNic = new HostNic(); model.setHostNic(hostNic); } return hostNic; }
@Override public Response add(org.ovirt.engine.api.model.NetworkAttachment attachment) { verifyHostAndNicExistence(); if (attachment.isSetHostNic()) { Guid hostNicGuid = Guid.createGuidFromString(attachment.getHostNic().getId()); if (!nicId.equals(hostNicGuid)) { //TODO MM: add message. return Response.status(Response.Status.BAD_REQUEST).build(); } } else { HostNic hostNIC = new HostNic(); hostNIC.setId(nicId.toString()); attachment.setHostNic(hostNIC); } return super.add(attachment); } }
protected HostNic slave(String id) { HostNic slave = new HostNic(); slave.setId(id); slave.setHost(new Host()); slave.getHost().setId(hostId); slave = LinkHelper.addLinks(slave, null, false); slave.setHost(null); return slave; }
private String idToHref(String id) { HostNic master = new HostNic(); master.setId(id); master.setHost(new Host()); master.getHost().setId(hostId); return LinkHelper.addLinks(master).getHref(); }
private HostNic clone(HostNic parent) { HostNic nic = new HostNic(); nic.setId(parent.getId()); nic.setHost(new Host()); nic.getHost().setId(parent.getHost().getId()); return nic; } };
@Test public void testMissingListSubFields() { HostNic bond = new HostNic(); try { CompletenessAssertor.validateParameters(bond, "name", "network.id|name", "bonding.slaves.id|name"); fail("expected WebApplicationException on incomplete model"); } catch (WebApplicationException wae) { verifyIncompleteException(wae, "HostNic", "name, network.id|name, bonding.slaves.id|name"); } }
@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; }
@Override protected HostNic doPopulate(HostNic model, VdsNetworkInterface entity) { final HostNic hostNic = super.doPopulate(model, entity); final Guid nicId = entity.getId(); final HostNicVfsConfig hostNicVfsConfig = findVfsConfig(nicId); if (hostNicVfsConfig == null) { final Map<Guid, Guid> vfMap = retriveVfMap(); final Guid physicalFunctionNicId = vfMap.get(nicId); if (physicalFunctionNicId != null) { final HostNic physicalFunction = new HostNic(); physicalFunction.setId(physicalFunctionNicId.toString()); hostNic.setPhysicalFunction(physicalFunction); } } else { final Mapper<HostNicVfsConfig, HostNicVirtualFunctionsConfiguration> mapper = getMapper(HostNicVfsConfig.class, HostNicVirtualFunctionsConfiguration.class); final HostNicVirtualFunctionsConfiguration vfsConfigModel = mapper.map(hostNicVfsConfig, new HostNicVirtualFunctionsConfiguration()); hostNic.setVirtualFunctionsConfiguration(vfsConfigModel); } return hostNic; }
@Override protected org.ovirt.engine.api.model.NetworkAttachment addParents(org.ovirt.engine.api.model.NetworkAttachment model) { model.setHostNic(new HostNic()); model.getHostNic().setId(nicId.toString()); model.getHostNic().setHost(new Host()); model.getHostNic().getHost().setId(getHostId().toString()); return model; }
@Override protected org.ovirt.engine.api.model.NetworkAttachment getModel(int index) { org.ovirt.engine.api.model.NetworkAttachment model = super.getModel(index); model.setHostNic(new HostNic()); model.getHostNic().setId(HOST_NIC_ID.toString()); return model; }
@Override protected org.ovirt.engine.api.model.NetworkAttachment getModel(int index) { org.ovirt.engine.api.model.NetworkAttachment model = super.getModel(index); model.setHostNic(new HostNic()); model.getHostNic().setId(HOST_NIC_ID.toString()); return model; }
@Test public void testCompleteListSubFields() { 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"); }
@Mapping(from = org.ovirt.engine.core.common.businessentities.UnmanagedNetwork.class, to = UnmanagedNetwork.class) public static UnmanagedNetwork map(org.ovirt.engine.core.common.businessentities.UnmanagedNetwork entity, UnmanagedNetwork template) { if (entity == null) { return template; } UnmanagedNetwork model = template == null ? new UnmanagedNetwork() : template; model.setId(HexUtils.string2hex(entity.getId())); if (entity.getNicId() != null) { HostNic hostNic = new HostNic(); hostNic.setId(entity.getNicId().toString()); model.setHostNic(hostNic); } model.setName(entity.getNetworkName()); return model; } }
@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())); } }
@Mapping(from = VdsNetworkInterface.class, to = HostNic.class) public static HostNic map(VdsNetworkInterface entity, HostNic template) { HostNic model = template != null ? template : new HostNic(); if (entity.getId() != null) { model.setId(entity.getId().toString());
@Override public HostNic adapt(V3HostNIC from) { HostNic to = new HostNic(); if (from.isSetLinks()) { to.getLinks().addAll(adaptIn(from.getLinks()));