Search in sources :

Example 31 with OnmsSnmpInterface

use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.

the class DefaultCategoryStatusServiceTest method testGetCategoriesStatus.

public void testGetCategoriesStatus() {
    View view = new View();
    Section section = new Section();
    section.setSectionName("Section One");
    section.addCategory("Category One");
    OnmsOutage outage = new OnmsOutage();
    Collection<OnmsOutage> outages = new ArrayList<>();
    outage.setId(300);
    OnmsServiceType svcType = new OnmsServiceType();
    svcType.setId(3);
    svcType.setName("HTTP");
    OnmsNode node = new OnmsNode();
    node.setId(1);
    node.setLabel("superLabel");
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(node, 1);
    OnmsIpInterface iface = new OnmsIpInterface("192.168.1.1", node);
    iface.setSnmpInterface(snmpIface);
    // iface.setId(9);
    OnmsMonitoredService monSvc = new OnmsMonitoredService(iface, svcType);
    outage.setMonitoredService(monSvc);
    outages.add(outage);
    view.addSection(section);
    List<String> services = new ArrayList<>();
    services.add("HTTP");
    // ServiceSelector selector = new ServiceSelector("isHTTP",(List<String>) services);
    expect(viewDisplayDao.getView()).andReturn(view);
    expect(categoryDao.getCategoryByLabel("Category One")).andReturn(createCategoryFromLabel("Category One"));
    expect(outageDao.matchingCurrentOutages(isA(ServiceSelector.class))).andReturn(outages);
    replay(categoryDao);
    replay(viewDisplayDao);
    replay(outageDao);
    Collection<StatusSection> statusSections = categoryStatusService.getCategoriesStatus();
    verify(viewDisplayDao);
    verify(categoryDao);
    verify(outageDao);
    assertEquals("Wrong Number of StatusSections", view.getSections().size(), statusSections.size());
    for (StatusSection statusSection : statusSections) {
        assertEquals("StatusSection Name Does Not Match", "Section One", statusSection.getName());
        Collection<StatusCategory> statusCategorys = statusSection.getCategories();
        for (StatusCategory statusCategory : statusCategorys) {
            assertEquals("StatusCategoryName does not match", "Category One", statusCategory.getLabel());
            // assertEquals("Category Comment Does not match","Category One Comment",statusCategory.getComment());
            assertTrue("Nodes >= 1", statusCategory.getNodes().size() >= 1);
            for (StatusNode statusNode : statusCategory.getNodes()) {
                assertEquals("Label does not match", "superLabel", statusNode.getLabel());
            }
        }
    }
}
Also used : OnmsOutage(org.opennms.netmgt.model.OnmsOutage) OnmsNode(org.opennms.netmgt.model.OnmsNode) StatusNode(org.opennms.web.svclayer.catstatus.model.StatusNode) ServiceSelector(org.opennms.netmgt.model.ServiceSelector) ArrayList(java.util.ArrayList) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) StatusSection(org.opennms.web.svclayer.catstatus.model.StatusSection) View(org.opennms.netmgt.config.viewsdisplay.View) StatusSection(org.opennms.web.svclayer.catstatus.model.StatusSection) Section(org.opennms.netmgt.config.viewsdisplay.Section) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) StatusCategory(org.opennms.web.svclayer.catstatus.model.StatusCategory) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType)

Example 32 with OnmsSnmpInterface

use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.

the class NetworkElementFactory method getInterfaceArrayWithSnmpData.

private Interface[] getInterfaceArrayWithSnmpData(List<OnmsIpInterface> ipIfaces) {
    List<Interface> intfs = new LinkedList<>();
    for (OnmsIpInterface iface : ipIfaces) {
        Interface intf = new Interface(iface);
        if (iface.getSnmpInterface() != null) {
            OnmsSnmpInterface snmpIface = iface.getSnmpInterface();
            intf.createSnmpInterface(snmpIface);
        }
        intfs.add(intf);
    }
    Collections.sort(intfs, INTERFACE_COMPARATOR);
    return intfs.toArray(new Interface[intfs.size()]);
}
Also used : OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) LinkedList(java.util.LinkedList)

Example 33 with OnmsSnmpInterface

use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.

the class DefaultSnmpCollectionAgentService method getSnmpInterfaceData.

/**
 * <p>getSnmpInterfaceData</p>
 *
 * @return a {@link java.util.Set} object.
 */
@Override
public Set<SnmpIfData> getSnmpInterfaceData() {
    Set<OnmsSnmpInterface> snmpIfs = getSnmpInterfaces();
    Set<SnmpIfData> ifData = new LinkedHashSet<SnmpIfData>(snmpIfs.size());
    for (OnmsSnmpInterface snmpIface : snmpIfs) {
        logInitializeSnmpIf(snmpIface);
        SnmpIfData snmpIfData = new SnmpIfData(snmpIface);
        ifData.add(snmpIfData);
    // ifInfos.add(new IfInfo(type, agent, snmpIfData));
    }
    return ifData;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface)

Example 34 with OnmsSnmpInterface

use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.

the class IfTable method updateSnmpInterfaceData.

/**
 * <p>updateSnmpInterfaceData</p>
 *
 * @param node a {@link org.opennms.netmgt.model.OnmsNode} object.
 * @param ifIndex a {@link java.lang.Integer} object.
 */
public void updateSnmpInterfaceData(OnmsNode node, Integer ifIndex) {
    // first look to see if an snmpIf was created already
    OnmsSnmpInterface snmpIf = node.getSnmpInterfaceWithIfIndex(ifIndex);
    if (snmpIf == null) {
        // if not then create one
        snmpIf = new OnmsSnmpInterface(node, ifIndex);
    }
    // IfTable Attributes
    snmpIf.setIfType(getIfType(ifIndex));
    snmpIf.setIfAdminStatus(getAdminStatus(ifIndex));
    snmpIf.setIfDescr(getIfDescr(ifIndex));
    snmpIf.setIfSpeed(getIfSpeed(ifIndex));
    snmpIf.setPhysAddr(getPhysAddr(ifIndex));
}
Also used : OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface)

Example 35 with OnmsSnmpInterface

use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.

the class IfXTable method updateSnmpInterfaceData.

/**
 * <p>updateSnmpInterfaceData</p>
 *
 * @param node a {@link org.opennms.netmgt.model.OnmsNode} object.
 * @param ifIndex a {@link java.lang.Integer} object.
 */
public void updateSnmpInterfaceData(OnmsNode node, Integer ifIndex) {
    // first look to see if an snmpIf was created already
    OnmsSnmpInterface snmpIf2 = node.getSnmpInterfaceWithIfIndex(ifIndex);
    if (snmpIf2 == null) {
        // if not then create one
        snmpIf2 = new OnmsSnmpInterface(node, ifIndex);
    }
    // ifXTable Attributes
    snmpIf2.setIfAlias(getIfAlias(ifIndex));
    snmpIf2.setIfName(getIfName(ifIndex));
}
Also used : OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface)

Aggregations

OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)73 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)39 OnmsNode (org.opennms.netmgt.model.OnmsNode)38 Test (org.junit.Test)17 InetAddress (java.net.InetAddress)16 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)10 NorthboundAlarm (org.opennms.netmgt.alarmd.api.NorthboundAlarm)9 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)9 Transactional (org.springframework.transaction.annotation.Transactional)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 OnmsEventParameter (org.opennms.netmgt.model.OnmsEventParameter)8 LinkedHashSet (java.util.LinkedHashSet)5 LinkedList (java.util.LinkedList)5 HashSet (java.util.HashSet)4 List (java.util.List)4 Before (org.junit.Before)4 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)4 IpNetToMedia (org.opennms.netmgt.model.IpNetToMedia)4 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)4