Search in sources :

Example 1 with InterfaceStatus

use of org.ovirt.engine.core.common.businessentities.network.InterfaceStatus in project ovirt-engine by oVirt.

the class HostNetworkInterfaceBondedListViewItem method createIcon.

@Override
protected IsWidget createIcon() {
    InterfaceStatus interfaceStatus = getEntity().getInterface().getStatistics().getStatus();
    SafeHtml bondPropertiesMessage = createBondTooltipMessage(getEntity(), interfaceStatus);
    SafeHtml bondMessage = templates.italicWordWrapMaxWidthWithBoldTitle(constants.bondProperties(), bondPropertiesMessage);
    WidgetTooltip iconTooltip = new WidgetTooltip(new BondedNetworkIcon());
    iconTooltip.setHtml(bondMessage);
    iconPanel.add(iconTooltip);
    return iconPanel;
}
Also used : InterfaceStatus(org.ovirt.engine.core.common.businessentities.network.InterfaceStatus) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) BondedNetworkIcon(org.ovirt.engine.ui.common.widget.uicommon.network.BondedNetworkIcon) WidgetTooltip(org.ovirt.engine.ui.common.widget.tooltip.WidgetTooltip)

Example 2 with InterfaceStatus

use of org.ovirt.engine.core.common.businessentities.network.InterfaceStatus in project ovirt-engine by oVirt.

the class HostMonitoring method reportNicStatusChanges.

private void reportNicStatusChanges() {
    List<VdsNetworkInterface> interfaces = vds.getInterfaces();
    Set<VdsNetworkInterface> slaves = new HashSet<>();
    Map<String, VdsNetworkInterface> monitoredInterfaces = new HashMap<>();
    Map<String, VdsNetworkInterface> interfaceByName = Entities.entitiesByName(interfaces);
    for (VdsNetworkInterface iface : interfaces) {
        if (iface.getBondName() != null) {
            slaves.add(iface);
        }
        String baseIfaceName = NetworkCommonUtils.stripVlan(iface);
        // If the parent interface already marked as monitored- no need to check it again
        if (monitoredInterfaces.containsKey(baseIfaceName)) {
            continue;
        }
        // The status of the interface should be monitored only if it has networks attached to it or has labels
        if (StringUtils.isNotEmpty(iface.getNetworkName()) || NetworkUtils.isLabeled(iface)) {
            VdsNetworkInterface baseIface = iface;
            // If vlan find the parent interface
            if (iface.getVlanId() != null) {
                baseIface = interfaceByName.get(baseIfaceName);
            }
            monitoredInterfaces.put(baseIfaceName, baseIface);
        }
    }
    // Slaves should be monitored if the bond is monitored
    for (VdsNetworkInterface slave : slaves) {
        if (monitoredInterfaces.containsKey(slave.getBondName())) {
            monitoredInterfaces.put(slave.getName(), slave);
        }
    }
    for (Map.Entry<String, InterfaceStatus> entry : oldInterfaceStatus.entrySet()) {
        VdsNetworkInterface iface = monitoredInterfaces.get(entry.getKey());
        InterfaceStatus oldStatus = entry.getValue();
        InterfaceStatus status;
        if (iface != null) {
            status = iface.getStatistics().getStatus();
            if (oldStatus != InterfaceStatus.NONE && oldStatus != status) {
                AuditLogable logable = createAuditLogableForHost();
                logable.setCustomId(iface.getName());
                if (iface.getBondName() != null) {
                    logable.addCustomValue("SlaveName", iface.getName());
                    logable.addCustomValue("BondName", iface.getBondName());
                    auditLog(logable, status == InterfaceStatus.UP ? AuditLogType.HOST_BOND_SLAVE_STATE_UP : AuditLogType.HOST_BOND_SLAVE_STATE_DOWN);
                } else {
                    logable.addCustomValue("InterfaceName", iface.getName());
                    auditLog(logable, status == InterfaceStatus.UP ? AuditLogType.HOST_INTERFACE_STATE_UP : AuditLogType.HOST_INTERFACE_STATE_DOWN);
                }
            }
        }
    }
}
Also used : InterfaceStatus(org.ovirt.engine.core.common.businessentities.network.InterfaceStatus) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) HashMap(java.util.HashMap) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

InterfaceStatus (org.ovirt.engine.core.common.businessentities.network.InterfaceStatus)2 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)1 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)1 WidgetTooltip (org.ovirt.engine.ui.common.widget.tooltip.WidgetTooltip)1 BondedNetworkIcon (org.ovirt.engine.ui.common.widget.uicommon.network.BondedNetworkIcon)1