public VmNic() { super(new VmNetworkStatistics(), VmInterfaceType.pv.getValue()); linked = true; }
private int getVmInterfaceType(XmlNode resourceSubTypeNode) { String resourceSubType = resourceSubTypeNode != null ? resourceSubTypeNode.innerText : null; if (StringUtils.isNotEmpty(resourceSubType)) { try { return Integer.parseInt(resourceSubType); } catch(NumberFormatException ex) { for (VmInterfaceType vmInterfaceType : VmInterfaceType.values()) { if (vmInterfaceType.getInternalName().equalsIgnoreCase(resourceSubType)) { return vmInterfaceType.getValue(); } } } } return VmInterfaceType.pv.getValue(); }
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()); } } }
private static NetworkInterface<?> createNic(String macAddress, String name, VmInterfaceType vmInterfaceType) { NetworkInterface<?> nic = new VmNetworkInterface(); nic.setName(name); nic.setMacAddress(macAddress); nic.setType(vmInterfaceType == null ? null : vmInterfaceType.getValue()); return nic; }
nic.setType(null); } else { nic.setType(getNicType().getSelectedItem().getValue());