use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostInterfaceListModel method classifyNics.
private void classifyNics(List<Bond> nonEmptyBonds, List<Nic> independentNics, Map<String, List<Nic>> bondToNics, Map<String, List<Vlan>> nicToVlans) {
for (VdsNetworkInterface nic : getOriginalItems()) {
if (nic instanceof Bond) {
nonEmptyBonds.add((Bond) nic);
} else if (nic instanceof Nic) {
if (nic.getBondName() == null) {
independentNics.add((Nic) nic);
} else {
if (bondToNics.containsKey(nic.getBondName())) {
bondToNics.get(nic.getBondName()).add((Nic) nic);
} else {
List<Nic> nicList = new ArrayList<>();
nicList.add((Nic) nic);
bondToNics.put(nic.getBondName(), nicList);
}
}
} else if (nic instanceof Vlan) {
String nameWithoutVlan = nic.getBaseInterface();
if (nicToVlans.containsKey(nameWithoutVlan)) {
nicToVlans.get(nameWithoutVlan).add((Vlan) nic);
} else {
List<Vlan> vlanList = new ArrayList<>();
vlanList.add((Vlan) nic);
nicToVlans.put(nameWithoutVlan, vlanList);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class NetworkHostListModel method syncSearch.
@Override
protected void syncSearch() {
if (getEntity() == null) {
return;
}
final NetworkHostFilter filter = getViewFilterType();
AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
if (filter.equals(getViewFilterType())) {
final Iterable returnList = returnValue.getReturnValue();
if (NetworkHostFilter.unattached.equals(getViewFilterType())) {
final List<PairQueryable<VdsNetworkInterface, VDS>> items = new ArrayList<>();
for (Object obj : returnList) {
items.add(new PairQueryable<VdsNetworkInterface, VDS>(null, (VDS) obj));
}
setItems(items);
} else if (NetworkHostFilter.attached.equals(getViewFilterType())) {
initAttachedInterfaces((Collection<PairQueryable<VdsNetworkInterface, VDS>>) returnList);
}
}
});
IdQueryParameters params = new IdQueryParameters(getEntity().getId());
params.setRefresh(getIsQueryFirstTime());
if (NetworkHostFilter.unattached.equals(getViewFilterType())) {
Frontend.getInstance().runQuery(QueryType.GetVdsWithoutNetwork, params, asyncQuery);
} else if (NetworkHostFilter.attached.equals(getViewFilterType())) {
Frontend.getInstance().runQuery(QueryType.GetVdsAndNetworkInterfacesByNetworkId, params, asyncQuery);
}
setIsQueryFirstTime(false);
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class LogicalNetworkModelParametersHelper method createAttachmentWhenAttachingTo.
private NetworkAttachment createAttachmentWhenAttachingTo(VdsNetworkInterface targetNic) {
NetworkAttachment networkAttachment = new NetworkAttachment(targetNic, networkModel.getNetwork(), NetworkCommonUtils.createDefaultIpConfiguration());
NetworkParameters netParams = networkModel.getSetupModel().getNetworkToLastDetachParams().get(networkModel.getName());
if (netParams != null) {
applyOnAttachmentParamsFrom(netParams, networkAttachment);
} else {
VdsNetworkInterface nicToTakeParamsFrom = null;
if (networkModel.hasVlan()) {
nicToTakeParamsFrom = getPotentialVlanDevice(targetNic);
} else {
nicToTakeParamsFrom = targetNic;
}
boolean newlyCreatedBond = nicToTakeParamsFrom != null && nicToTakeParamsFrom.getId() == null;
if (nicToTakeParamsFrom != null && !newlyCreatedBond) {
InterfacePropertiesAccessor.FromNic interfacePropertiesAccessor = new InterfacePropertiesAccessor.FromNic(nicToTakeParamsFrom, null);
applyOnAttachmentParamsFrom(interfacePropertiesAccessor, networkAttachment);
}
fixBootProtocolOfMgmtNetworkIfNeeded(networkAttachment);
}
return networkAttachment;
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostNetworkTopologyPersisterImpl method skipManagementNetworkCheck.
private void skipManagementNetworkCheck(List<VdsNetworkInterface> ifaces, List<Network> clusterNetworks, Guid clusterId) {
final Network managementNetwork = managementNetworkUtil.getManagementNetwork(clusterId);
final String managementNetworkName = managementNetwork.getName();
for (VdsNetworkInterface iface : ifaces) {
if (managementNetworkName.equals(iface.getNetworkName())) {
return;
}
}
for (Iterator<Network> iterator = clusterNetworks.iterator(); iterator.hasNext(); ) {
Network network = iterator.next();
if (managementNetworkName.equals(network.getName())) {
iterator.remove();
break;
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostNetworkTopologyPersisterImpl method persistAndEnforceNetworkCompliance.
@Override
public NonOperationalReason persistAndEnforceNetworkCompliance(VDS host, boolean skipManagementNetwork, UserConfiguredNetworkData userConfiguredData) {
return TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
List<VdsNetworkInterface> dbIfaces = interfaceDao.getAllInterfacesForVds(host.getId());
List<Network> clusterNetworks = networkDao.getAllForCluster(host.getClusterId());
persistTopology(host, dbIfaces, clusterNetworks, userConfiguredData);
NonOperationalReason nonOperationalReason = enforceNetworkCompliance(host, skipManagementNetwork, clusterNetworks);
auditNetworkCompliance(host, dbIfaces, clusterNetworks);
return nonOperationalReason;
});
}
Aggregations