use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class VmDevicesConverter method parseInterfaces.
private List<Map<String, Object>> parseInterfaces(XmlDocument document, List<VmDevice> devices, Guid vmId, MemoizingSupplier<Map<Map<String, String>, HostDevice>> addressToHostDeviceSupplier) {
List<VmDevice> dbDevices = filterDevices(devices, VmDeviceGeneralType.INTERFACE);
Map<Guid, VmDevice> devIdToDbDev = dbDevices.stream().collect(Collectors.toMap(device -> device.getDeviceId(), device -> device));
List<VmNetworkInterface> dbInterfaces = vmNetworkInterfaceDao.getAllForVm(vmId);
List<Map<String, Object>> result = new ArrayList<>();
for (XmlNode node : selectNodes(document, VmDeviceGeneralType.INTERFACE)) {
String type = parseAttribute(node, TYPE);
Map<String, Object> dev = new HashMap<>();
if (VmDeviceType.HOST_DEVICE.getName().equals(type)) {
dev.put(VdsProperties.HostDev, getHostDeviceName(node, addressToHostDeviceSupplier));
}
dev.put(VdsProperties.Type, VmDeviceGeneralType.INTERFACE.getValue());
dev.put(VdsProperties.Device, type);
dev.put(VdsProperties.Address, parseAddress(node));
dev.put(VdsProperties.Alias, parseAlias(node));
String macAddress = parseMacAddress(node);
// MAC address is a unique identifier of network interface devices
VmDevice dbDev = correlate(dev, dbDevices, device -> {
VmNetworkInterface dbInterface = dbInterfaces.stream().filter(iface -> iface.getMacAddress().equalsIgnoreCase(macAddress)).findFirst().orElse(null);
return dbInterface != null ? devIdToDbDev.get(dbInterface.getId()) : null;
});
if (dbDev == null) {
log.warn("unmanaged network interface with mac address '{}' is ignored", macAddress);
continue;
}
dev.put(VdsProperties.DeviceId, dbDev.getDeviceId().toString());
dev.put(VdsProperties.SpecParams, dbDev.getSpecParams());
result.add(dev);
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class NetworkTemplateListModel method remove.
private void remove() {
if (getWindow() != null) {
return;
}
List<VmNetworkInterface> vnics = new ArrayList<>();
for (PairQueryable<VmNetworkInterface, VmTemplate> pair : getSelectedItems()) {
vnics.add(pair.getFirst());
}
RemoveVmTemplateInterfaceModel model = new RemoveVmTemplateInterfaceModel(this, vnics, true);
setWindow(model);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class NetworkVmListModel method remove.
private void remove() {
if (getWindow() != null) {
return;
}
List<VmNetworkInterface> vnics = new ArrayList<>();
for (Object item : getSelectedItems()) {
PairQueryable<VmNetworkInterface, VM> pair = (PairQueryable<VmNetworkInterface, VM>) item;
vnics.add(pair.getFirst());
}
RemoveVmInterfaceModel model = new RemoveVmInterfaceModel(this, vnics, true);
setWindow(model);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class NetworkVmListModel method syncSearch.
@Override
protected void syncSearch() {
if (getEntity() == null) {
return;
}
GetVmsAndNetworkInterfacesByNetworkIdParameters params = new GetVmsAndNetworkInterfacesByNetworkIdParameters(getEntity().getId(), NetworkVmFilter.running.equals(getViewFilterType()));
params.setRefresh(getIsQueryFirstTime());
final NetworkVmFilter filter = getViewFilterType();
Frontend.getInstance().runQuery(QueryType.GetVmsAndNetworkInterfacesByNetworkId, params, new AsyncQuery<QueryReturnValue>(returnValue -> {
if (filter.equals(getViewFilterType())) {
setItems((Collection<PairQueryable<VmNetworkInterface, VM>>) returnValue.getReturnValue());
}
}));
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class NetworkVmListModel method updateActionAvailability.
private void updateActionAvailability() {
ArrayList<VM> vms = new ArrayList<>();
Iterable<PairQueryable<VmNetworkInterface, VM>> selectedItems = getSelectedItems() != null ? getSelectedItems() : new ArrayList();
for (PairQueryable<VmNetworkInterface, VM> item : selectedItems) {
vms.add(item.getSecond());
}
getRemoveCommand().setIsExecutionAllowed(ActionUtils.canExecute(vms, VM.class, ActionType.RemoveVmInterface) && getSelectedItems() != null && !getSelectedItems().isEmpty() && canRemoveVnics());
}
Aggregations