use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostNetworkTopologyPersisterImpl method findNetworksOnInterfaces.
private Collection<Network> findNetworksOnInterfaces(Collection<VdsNetworkInterface> ifaces, Map<String, Network> clusterNetworksByName) {
final Collection<Network> networks = new ArrayList<>();
for (VdsNetworkInterface iface : ifaces) {
final String interfaceNetworkName = iface.getNetworkName();
if (clusterNetworksByName.containsKey(interfaceNetworkName)) {
final Network network = clusterNetworksByName.get(interfaceNetworkName);
networks.add(network);
}
}
return networks;
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostNetworkTopologyPersisterImpl method logChangedDisplayNetwork.
private void logChangedDisplayNetwork(VDS host, Collection<Network> engineHostNetworks, Collection<VdsNetworkInterface> engineInterfaces) {
if (isVmRunningOnHost(host.getId())) {
final Network engineDisplayNetwork = findDisplayNetwork(host.getClusterId(), engineHostNetworks);
if (engineDisplayNetwork == null) {
return;
}
final IsNetworkOnInterfacePredicate isNetworkOnInterfacePredicate = new IsNetworkOnInterfacePredicate(engineDisplayNetwork.getName());
final VdsNetworkInterface vdsmDisplayInterface = host.getInterfaces().stream().filter(isNetworkOnInterfacePredicate).findFirst().orElse(null);
final VdsNetworkInterface engineDisplayInterface = engineInterfaces.stream().filter(isNetworkOnInterfacePredicate).findFirst().orElse(null);
final DisplayInterfaceEqualityPredicate displayIneterfaceEqualityPredicate = new DisplayInterfaceEqualityPredicate(engineDisplayInterface);
if (// the display interface is't on host anymore
vdsmDisplayInterface == null || !displayIneterfaceEqualityPredicate.test(vdsmDisplayInterface)) {
final AuditLogable loggable = createAuditLogForHost(host);
auditLogDirector.log(loggable, AuditLogType.NETWORK_UPDATE_DISPLAY_FOR_HOST_WITH_ACTIVE_VM);
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostNetworkTopologyPersisterImpl method getVmNetworksImplementedAsBridgeless.
private String getVmNetworksImplementedAsBridgeless(VDS host, List<Network> clusterNetworks) {
Map<String, VdsNetworkInterface> interfacesByNetworkName = NetworkUtils.hostInterfacesByNetworkName(host.getInterfaces());
List<String> networkNames = new ArrayList<>();
for (Network net : clusterNetworks) {
if (net.isVmNetwork() && interfacesByNetworkName.containsKey(net.getName()) && !interfacesByNetworkName.get(net.getName()).isBridged()) {
networkNames.add(net.getName());
}
}
return StringUtils.join(networkNames, ",");
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostNetworkAttachmentsPersister method updateReportedNetworkAttachmentsNotMentionedInRequest.
/**
* Adds new network attachments for reported networks from the host which weren't associated to a user attachment.
* Updates existing network attachments which network get reported on different nic.
* <br/>
* The network attachment's attributes will be inherited from the network interface on which it is configured.
* @param networkAttachments already existing or newly created network attachments
*/
private void updateReportedNetworkAttachmentsNotMentionedInRequest(List<NetworkAttachment> networkAttachments) {
for (VdsNetworkInterface nic : nicsByName.values()) {
String networkName = nic.getNetworkName();
if (networkName != null && clusterNetworks.containsKey(networkName)) {
NetworkAttachment networkAttachmentRelatedToNetwork = getNetworkAttachmentRelatedToNetwork(networkAttachments, clusterNetworks.get(networkName));
boolean networkAttachmentRelatedToNetworkExist = networkAttachmentRelatedToNetwork != null;
if (networkAttachmentRelatedToNetworkExist) {
VdsNetworkInterface baseInterfaceNicOrThis = getBaseInterfaceNicOrThis(nic);
boolean networkMovedToDifferentNic = !baseInterfaceNicOrThis.getId().equals(networkAttachmentRelatedToNetwork.getNicId());
if (networkMovedToDifferentNic) {
networkAttachmentRelatedToNetwork.setNicId(baseInterfaceNicOrThis.getId());
networkAttachmentRelatedToNetwork.setNicName(baseInterfaceNicOrThis.getName());
networkAttachmentDao.update(networkAttachmentRelatedToNetwork);
}
} else {
if (!nic.isPartOfBond()) {
createNetworkAttachmentForReportedNetworksNotHavingOne(nic, networkName);
}
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostNetworkAttachmentsPersister method persistOrUpdateUserNetworkAttachments.
/**
* User provided network attachments, which relates to network configured on host, are inserted or updated
* into database and used to update passed in <code>networkAttachments</code> collection.
*/
private void persistOrUpdateUserNetworkAttachments(List<NetworkAttachment> networkAttachments) {
Map<Guid, NetworkAttachment> validDbAttachmentsById = Entities.businessEntitiesById(networkAttachments);
for (NetworkAttachment networkAttachment : userNetworkAttachments) {
if (networkConfiguredOnHost(networkAttachment.getNetworkId())) {
VdsNetworkInterface reportedNicToWhichIsNetworkAttached = reportedNicsByNetworkId.get(networkAttachment.getNetworkId());
Guid reportedNicId = baseInterfaceOfNic(reportedNicToWhichIsNetworkAttached).getId();
/*this is needed for attaching network to newly created bond, where network attachment
does not have nicId set and that nic id is known only after vdsm call.
* */
if (networkAttachment.getNicId() == null) {
networkAttachment.setNicId(reportedNicId);
} else {
if (!networkAttachment.getNicId().equals(reportedNicId)) {
throw new IllegalStateException(INCONSISTENCY_NETWORK_IS_REPORTED_ON_DIFFERENT_NIC_THAN_WAS_SPECIFIED);
}
}
boolean alreadyExistingAttachment = validDbAttachmentsById.containsKey(networkAttachment.getId());
if (alreadyExistingAttachment) {
networkAttachmentDao.update(networkAttachment);
networkAttachments.remove(validDbAttachmentsById.get(networkAttachment.getId()));
networkAttachments.add(networkAttachment);
} else {
networkAttachment.setId(Guid.newGuid());
networkAttachmentDao.save(networkAttachment);
networkAttachments.add(networkAttachment);
}
}
}
}
Aggregations