@Mapping(from = Nic.class, to = VmNetworkInterface.class) public static VmNetworkInterface map(Nic model, VmNetworkInterface template) { VmNetworkInterface entity = template != null ? template : new VmNetworkInterface(); if (model.isSetVm() && model.getVm().isSetId()) { entity.setVmId(GuidUtils.asGuid(model.getVm().getId())); if (model.isSetId()) { entity.setId(GuidUtils.asGuid(model.getId())); if (model.isSetName()) { entity.setName(model.getName()); if (model.isSetMac() && model.getMac().isSetAddress()) { entity.setMacAddress(model.getMac().getAddress()); if (model.isSetLinked()) { entity.setLinked(model.isLinked()); if (model.isSetInterface()) { entity.setType(map(model.getInterface())); if (model.isSetPlugged()) { entity.setPlugged(model.isPlugged()); if (model.isSetVnicProfile()) { if (model.getVnicProfile().isSetId()) { entity.setVnicProfileId(GuidUtils.asGuid(model.getVnicProfile().getId())); } else { entity.setVnicProfileId(null);
static Nic getModel(int index) { Nic model = new Nic(); model.setName(NAMES[index]); model.setInterface(NicInterface.RTL8139_VIRTIO); return model; }
@Override public V3NIC adapt(Nic from) { V3NIC to = new V3NIC(); if (from.isSetLinks()) { to.getLinks().addAll(adaptOut(from.getLinks())); if (from.isSetActions()) { to.setActions(adaptOut(from.getActions())); if (from.isSetBootProtocol()) { to.setBootProtocol(from.getBootProtocol().value()); if (from.isSetComment()) { to.setComment(from.getComment()); if (from.isSetDescription()) { to.setDescription(from.getDescription()); if (from.isSetId()) { to.setId(from.getId()); if (from.isSetHref()) { to.setHref(from.getHref()); if (from.isSetInstanceType()) { to.setInstanceType(adaptOut(from.getInstanceType())); if (from.isSetInterface()) { to.setInterface(from.getInterface().value());
@Override public Nic adapt(V3NIC from) { Nic to = new Nic(); if (from.isSetLinks()) { to.getLinks().addAll(adaptIn(from.getLinks())); to.setActions(adaptIn(from.getActions())); to.setBootProtocol(BootProtocol.fromValue(from.getBootProtocol())); to.setComment(from.getComment()); to.setDescription(from.getDescription()); to.setId(from.getId()); to.setHref(from.getHref()); to.setInstanceType(adaptIn(from.getInstanceType())); to.setInterface(NicInterface.fromValue(from.getInterface())); to.setLinked(from.isLinked()); to.setMac(adaptIn(from.getMac())); to.setName(from.getName()); to.setNetwork(adaptIn(from.getNetwork()));
static void verifyModelSpecific(Nic model, int index) { assertEquals(GUIDS[index].toString(), model.getId()); assertEquals(NAMES[index], model.getName()); assertTrue(model.isSetVm()); assertEquals(VM_ID.toString(), model.getVm().getId()); assertTrue(model.isSetMac()); assertEquals(ADDRESSES[2], model.getMac().getAddress()); }
@Mapping(from = VmNetworkInterface.class, to = Nic.class) public static Nic map(VmNetworkInterface entity, Nic template) { Nic model = template != null ? template : new Nic(); if (entity.getVmId() != null) { model.setVm(new Vm()); model.getVm().setId(entity.getVmId().toString()); } if (entity.getId() != null) { model.setId(entity.getId().toString()); } if (entity.getName() != null) { model.setName(entity.getName()); } if (entity.getMacAddress() != null) { model.setMac(new Mac()); model.getMac().setAddress(entity.getMacAddress()); } model.setLinked(entity.isLinked()); model.setInterface(map(entity.getType())); model.setPlugged(entity.isPlugged()); if (entity.getVnicProfileId() != null) { model.setVnicProfile(new VnicProfile()); model.getVnicProfile().setId(entity.getVnicProfileId().toString()); } return model; }
@Override protected void verify(Nic model, Nic transform) { assertNotNull(transform); assertEquals(model.getName(), transform.getName()); assertEquals(model.getId(), transform.getId()); assertNotNull(transform.getVm()); assertEquals(model.getVm().getId(), transform.getVm().getId()); assertNotNull(transform.getMac()); assertThat(model.getMac().getAddress(), IsEqualIgnoringCase.equalToIgnoringCase(transform.getMac().getAddress())); assertEquals(model.getInterface(), transform.getInterface()); assertEquals(model.isLinked(), transform.isLinked()); assertEquals(model.isPlugged(), transform.isPlugged()); assertNotNull(transform.getVnicProfile()); assertEquals(model.getVnicProfile().getId(), transform.getVnicProfile().getId()); } }
for (Nic iface : model.getNetworkConfiguration().getNics().getNics()) { VmInitNetwork vmInitInterface = new VmInitNetwork(); if (iface.isSetName()) { vmInitInterface.setName(iface.getName()); if (iface.isSetBootProtocol()) { Ipv4BootProtocol protocol = Ipv4BootProtocolMapper.map(iface.getBootProtocol()); vmInitInterface.setBootProtocol(protocol); if (protocol != Ipv4BootProtocol.DHCP && iface.isSetNetwork() && iface.getNetwork().isSetIp()) { if (iface.getNetwork().getIp().isSetAddress()) { vmInitInterface.setIp(iface.getNetwork().getIp().getAddress()); if (iface.getNetwork().getIp().isSetNetmask()) { vmInitInterface.setNetmask(iface.getNetwork().getIp().getNetmask()); if (iface.getNetwork().getIp().isSetGateway()) { vmInitInterface.setGateway(iface.getNetwork().getIp().getGateway()); if (iface.isSetOnBoot() && iface.isOnBoot()) { vmInitInterface.setStartOnBoot(true);
protected Nic getNic(boolean withNetwork) { Nic nic = new Nic(); nic.setMac(new Mac()); nic.getMac().setAddress("00:1a:4a:16:85:18"); if (withNetwork) { Network network = new Network(); network.setId(GUIDS[0].toString()); } Network network = new Network(); network.setId(GUIDS[0].toString()); return nic; }
public static void validateAdd(Nic nic) { if (nic == null) { throw new ValidationException("Parameter 'nic' is mandatory but was not provided."); } if (nic.getName()==null) { throw new ValidationException("Parameter 'nic.name' is mandatory but was not provided."); } }
@Override public Nic get() { for (Nic nic : collection.list().getNics()) { if (nic.getId().equals(nicId)) { return nic; } } throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()); } }
/** * Create an instance of {@link Nic } * */ public Nic createNic() { return new Nic(); }
@Override protected Nic postPopulate(Nic model) { model.setInterface(NicInterface.E1000); return model; }
VnicProfile v4Profile = v4Nic.getVnicProfile(); if (v4Profile == null) { return;