@Override protected VmNetworkInterface getNetworkInterface(XmlNode node) { VmNetworkInterface iface = new VmNetworkInterface(); iface.setId(Guid.newGuid()); interfaces.add(iface); return iface; }
@Override protected VmNetworkInterface getNetworkInterface(XmlNode node) { // prior to 3.0 the instanceId is int , in 3.1 and on this is Guid String str = selectSingleNode(node, "rasd:InstanceId", _xmlNS).innerText; if (!StringUtils.isNumeric(str)) { // 3.1 and above OVF format final Guid guid = new Guid(str); VmNetworkInterface iface = interfaces.stream().filter(i -> i.getId().equals(guid)).findFirst().orElse(null); if (iface == null) { iface = new VmNetworkInterface(); iface.setId(guid); interfaces.add(iface); } return iface; } else { // 3.0 and below OVF format VmNetworkInterface iface = new VmNetworkInterface(); iface.setId(Guid.newGuid()); interfaces.add(iface); return iface; } }
@Override public VmNetworkInterface mapRow(ResultSet rs, int rowNum) throws SQLException { VmNetworkInterface entity = new VmNetworkInterface(); entity.setId(getGuidDefaultEmpty(rs, "id")); entity.setVmId(getGuid(rs, "vm_guid")); entity.setMacAddress(rs.getString("mac_addr")); entity.setSpeed(rs.getInt("speed")); entity.setStatistics(VmNetworkStatisticsRowMapper.INSTANCE.mapRow(rs, rowNum)); return entity; }
protected void buildNicReference() { XmlNodeList list = selectNodes(_document, "//*/Nic", _xmlNS); for (XmlNode node : list) { VmNetworkInterface iface = new VmNetworkInterface(); iface.setId(new Guid(node.attributes.get("ovf:id").getValue())); interfaces.add(iface); } if (!list.iterator().hasNext()) { String pattern = "//*/Item[" + VMD_RESOURCE_TYPE + "=" + OvfHardware.Network + "]"; list = selectNodes(_document, pattern, _xmlNS); int nicIdx = 0; for (XmlNode node : list) { VmNetworkInterface iface = new VmNetworkInterface(); iface.setId(Guid.newGuid()); updateSingleNic(node, iface, ++nicIdx); interfaces.add(iface); } } }
private VmDevice createNetworkInterface(boolean plugged, String name, List<VmNetworkInterface> interfaces) { Guid id = Guid.newGuid(); VmNetworkInterface vmNic = new VmNetworkInterface(); vmNic.setId(id); vmNic.setName(name); interfaces.add(vmNic); VmDevice device = createNetworkInterfaceDevice(plugged, id); device.setManaged(true); return device; }
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.setId(GuidUtils.asGuid(model.getId()));