private void updateVnicType(VnicProfileView profile, VmNetworkInterface existingVnic, VmNetworkInterface editedVnic) { boolean shouldBePciPassthroughType = profile != null && profile.isPassthrough() && supportedInterfaceTypes != null && supportedInterfaceTypes.contains(VmInterfaceType.pciPassthrough); if (existingVnic == null) { if (shouldBePciPassthroughType) { editedVnic.setType(VmInterfaceType.pciPassthrough.getValue()); } else { editedVnic.setType(defaultType == null ? null : defaultType.getValue()); } } else { VmInterfaceType existingInterfaceType = VmInterfaceType.forValue(existingVnic.getType()); boolean shouldRestoreToDefault = profile != null && !profile.isPassthrough() && VmInterfaceType.pciPassthrough.equals(existingInterfaceType); if (shouldBePciPassthroughType) { existingVnic.setType(VmInterfaceType.pciPassthrough.getValue()); } else if (shouldRestoreToDefault || supportedInterfaceTypes == null || !supportedInterfaceTypes.contains(existingInterfaceType)) { existingVnic.setType(defaultType == null ? null : defaultType.getValue()); } } }
protected void updateSingleNic(XmlNode node, VmNetworkInterface iface, int nicIdx) { String networkName = selectSingleNode(node, VMD_CONNECTION, _xmlNS).innerText; iface.setRemoteNetworkName(networkName); iface.setNetworkName(StringUtils.defaultIfEmpty(networkName, null)); XmlNode vnicProfileNameNode = selectSingleNode(node, VMD_VNIC_PROFILE_NAME, _xmlNS); iface.setVnicProfileName(vnicProfileNameNode == null ? null : StringUtils.defaultIfEmpty(vnicProfileNameNode.innerText, null)); XmlNode linkedNode = selectSingleNode(node, VMD_LINKED, _xmlNS); iface.setLinked(linkedNode == null ? true : Boolean.valueOf(linkedNode.innerText)); XmlNode nameNode = selectSingleNode(node, VMD_NAME, _xmlNS); iface.setName(nameNode != null ? nameNode.innerText : String.format("nic%d", nicIdx)); XmlNode resourceSubTypeNode = selectSingleNode(node, "rasd:ResourceSubType", _xmlNS); iface.setType(getVmInterfaceType(resourceSubTypeNode)); XmlNode speed = selectSingleNode(node, "rasd:speed", _xmlNS); iface.setSpeed(speed != null ? Integer.parseInt(speed.innerText) : VmInterfaceType.forValue(iface.getType()) .getSpeed()); }
public VmNetworkInterface(VmNetworkInterface iface) { setId(iface.getId()); setMacAddress(iface.getMacAddress()); setName(iface.getName()); setNetworkName(iface.getNetworkName()); setLinked(iface.isLinked()); setSpeed(iface.getSpeed()); setType(iface.getType()); setVmId(iface.getVmId()); setVmName(iface.getVmName()); setVmTemplateId(iface.getVmTemplateId()); setStatistics(new VmNetworkStatistics(iface.getStatistics())); }
@BeforeEach @Override public void setUp() throws Exception { super.setUp(); existingVmInterface = dao.get(FixturesTool.VM_NETWORK_INTERFACE); existingTemplateInterface = dao.get(FixturesTool.TEMPLATE_NETWORK_INTERFACE); newVmInterface = new VmNetworkInterface(); newVmInterface.setStatistics(new VmNetworkStatistics()); newVmInterface.setId(Guid.newGuid()); newVmInterface.setVnicProfileId(FixturesTool.VM_NETWORK_INTERFACE_PROFILE); newVmInterface.setName("eth77"); newVmInterface.setNetworkName("enginet"); newVmInterface.setLinked(true); newVmInterface.setSpeed(1000); newVmInterface.setType(3); newVmInterface.setMacAddress("01:C0:81:21:71:17"); newVmDevice.setType(VmDeviceGeneralType.INTERFACE); newVmDevice.setDevice("bridge"); newVmDevice.setAddress("sample"); newVmDevice.setManaged(true); newVmDevice.setPlugged(true); newVmDevice.setReadOnly(false); Map<String, String> customProp = new LinkedHashMap<>(); customProp.put("prop1", "val1"); newVmDevice.setCustomProperties(customProp); }
entity.setType(map(model.getInterface()));