Search in sources :

Example 16 with OnmsOutage

use of org.opennms.netmgt.model.OnmsOutage 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 17 with OnmsOutage

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

the class DefaultSiteStatusServiceIT method createOutageForService.

protected void createOutageForService(OnmsMonitoredService monSvc) {
    OnmsEvent outageEvent = new OnmsEvent();
    outageEvent.setEventUei("TEST_UEI");
    outageEvent.setDistPoller(m_databasePopulator.getDistPollerDao().whoami());
    outageEvent.setEventTime(new Date());
    outageEvent.setEventSource("Me");
    outageEvent.setEventCreateTime(new Date());
    outageEvent.setEventSeverity(OnmsSeverity.INDETERMINATE.getId());
    outageEvent.setEventLog("L");
    outageEvent.setEventDisplay("D");
    m_eventDao.save(outageEvent);
    m_eventDao.flush();
    OnmsOutage outage = new OnmsOutage(new Date(), outageEvent, monSvc);
    m_outageDao.save(outage);
    m_outageDao.flush();
}
Also used : OnmsEvent(org.opennms.netmgt.model.OnmsEvent) OnmsOutage(org.opennms.netmgt.model.OnmsOutage) Date(java.util.Date)

Example 18 with OnmsOutage

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

the class DaoWebOutageRepository method getMatchingOutages.

/* (non-Javadoc)
     * @see org.opennms.web.outage.WebOutageRepository#getMatchingOutages(org.opennms.web.outage.filter.OutageCriteria)
     */
/**
 * {@inheritDoc}
 */
@Transactional
@Override
public Outage[] getMatchingOutages(final OutageCriteria criteria) {
    final List<Outage> outages = new ArrayList<>();
    final List<OnmsOutage> onmsOutages = m_outageDao.findMatching(getOnmsCriteria(criteria));
    for (final OnmsOutage outage : onmsOutages) {
        outages.add(mapOnmsOutageToOutage(outage));
    }
    return outages.toArray(new Outage[0]);
}
Also used : OnmsOutage(org.opennms.netmgt.model.OnmsOutage) OnmsOutage(org.opennms.netmgt.model.OnmsOutage) ArrayList(java.util.ArrayList) Transactional(org.springframework.transaction.annotation.Transactional)

Example 19 with OnmsOutage

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

the class DefaultCategoryStatusService method createCategory.

private StatusCategory createCategory(String category) {
    Collection<OnmsOutage> outages;
    CategoryBuilder categoryBuilder = new CategoryBuilder();
    StatusCategory statusCategory = new StatusCategory();
    Category categoryDetail = m_categoryConfigDao.getCategoryByLabel(category);
    // statusCategory.setComment(categoryDetail.getCategoryComment());
    statusCategory.setLabel(category);
    ServiceSelector selector = new ServiceSelector(categoryDetail.getRule(), getServicesForCategory(categoryDetail));
    outages = m_outageDao.matchingCurrentOutages(selector);
    for (OnmsOutage outage : outages) {
        OnmsMonitoredService monitoredService = outage.getMonitoredService();
        OnmsServiceType serviceType = monitoredService.getServiceType();
        OnmsIpInterface ipInterface = monitoredService.getIpInterface();
        final String ipAddress = InetAddressUtils.str(ipInterface.getIpAddress());
        categoryBuilder.addOutageService(monitoredService.getNodeId(), ipAddress, ipAddress, ipInterface.getNode().getLabel(), serviceType.getName());
    }
    for (StatusNode node : categoryBuilder.getNodes()) {
        statusCategory.addNode(node);
    }
    return statusCategory;
}
Also used : OnmsOutage(org.opennms.netmgt.model.OnmsOutage) StatusCategory(org.opennms.web.svclayer.catstatus.model.StatusCategory) Category(org.opennms.netmgt.config.categories.Category) StatusCategory(org.opennms.web.svclayer.catstatus.model.StatusCategory) StatusNode(org.opennms.web.svclayer.catstatus.model.StatusNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) ServiceSelector(org.opennms.netmgt.model.ServiceSelector) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 20 with OnmsOutage

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

the class PollerIT method getOutages.

/**
 * Retrieves all of the outages (using DAOs) associated with
 * the given service.
 */
private List<OnmsOutage> getOutages(MockService svc) {
    OnmsMonitoredService monitoredSvc = m_monitoredServiceDao.get(svc.getNodeId(), svc.getAddress(), svc.getSvcName());
    Criteria criteria = new CriteriaBuilder(OnmsOutage.class).eq("monitoredService", monitoredSvc).orderBy("ifLostService").toCriteria();
    return m_outageDao.findMatching(criteria);
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsOutage(org.opennms.netmgt.model.OnmsOutage) Criteria(org.opennms.core.criteria.Criteria) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Aggregations

OnmsOutage (org.opennms.netmgt.model.OnmsOutage)47 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)26 Date (java.util.Date)23 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)16 OnmsNode (org.opennms.netmgt.model.OnmsNode)12 Test (org.junit.Test)8 Transactional (org.springframework.transaction.annotation.Transactional)8 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)7 Alias (org.opennms.core.criteria.Alias)5 Criteria (org.opennms.core.criteria.Criteria)5 EqRestriction (org.opennms.core.criteria.restrictions.EqRestriction)5 NullRestriction (org.opennms.core.criteria.restrictions.NullRestriction)5 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)4 ArrayList (java.util.ArrayList)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 Before (org.junit.Before)3 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)3 Font (java.awt.Font)2