Search in sources :

Example 11 with OnmsServiceType

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

the class ServiceTypeDaoIT method tweakSvcType.

private void tweakSvcType(String name) {
    OnmsServiceType svcType = m_serviceTypeDao.findByName(name);
    if (svcType == null)
        m_serviceTypeDao.save(new OnmsServiceType(name));
    else {
        svcType.setName(svcType.getName() + '-' + svcType.getId());
        m_serviceTypeDao.update(svcType);
    }
    m_serviceTypeDao.clear();
}
Also used : OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType)

Example 12 with OnmsServiceType

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

the class MockMonitoredServiceDao method updateSubObjects.

private void updateSubObjects(final OnmsMonitoredService svc) {
    final OnmsServiceType serviceType = svc.getServiceType();
    final OnmsServiceType existingServiceType = getServiceTypeDao().findByName(serviceType.getName());
    if (existingServiceType != null && existingServiceType.getId() != serviceType.getId()) {
        svc.setServiceType(existingServiceType);
    }
    getServiceTypeDao().saveOrUpdate(svc.getServiceType());
}
Also used : OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType)

Example 13 with OnmsServiceType

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

the class AvailabilityDatabasePopulator method getServiceType.

private OnmsServiceType getServiceType(String name) {
    OnmsServiceType serviceType = getServiceTypeDao().findByName(name);
    if (serviceType == null) {
        serviceType = new OnmsServiceType(name);
        getServiceTypeDao().save(serviceType);
        getServiceTypeDao().flush();
    }
    return serviceType;
}
Also used : OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType)

Example 14 with OnmsServiceType

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

the class DatabasePopulator method doResetDatabase.

private void doResetDatabase() {
    LOG.debug("==== DatabasePopulator Reset ====");
    for (final OnmsOutage outage : m_outageDao.findAll()) {
        m_outageDao.delete(outage);
    }
    for (final OnmsUserNotification not : m_userNotificationDao.findAll()) {
        m_userNotificationDao.delete(not);
    }
    for (final OnmsNotification not : m_notificationDao.findAll()) {
        m_notificationDao.delete(not);
    }
    for (final OnmsAlarm alarm : m_alarmDao.findAll()) {
        m_alarmDao.delete(alarm);
    }
    for (final OnmsEvent event : m_eventDao.findAll()) {
        m_eventDao.delete(event);
    }
    for (final OnmsSnmpInterface snmpIface : m_snmpInterfaceDao.findAll()) {
        for (OnmsIpInterface eachIf : snmpIface.getIpInterfaces()) {
            eachIf.setSnmpInterface(null);
            snmpIface.getNode().getIpInterfaces().remove(eachIf);
        }
        snmpIface.getNode().getSnmpInterfaces().remove(snmpIface);
        m_snmpInterfaceDao.delete(snmpIface);
    }
    for (final OnmsIpInterface iface : m_ipInterfaceDao.findAll()) {
        iface.setSnmpInterface(null);
        iface.getNode().getIpInterfaces().remove(iface);
        m_ipInterfaceDao.delete(iface);
    }
    for (final OnmsNode node : m_nodeDao.findAll()) {
        m_nodeDao.delete(node);
    }
    for (final OnmsServiceType service : m_serviceTypeDao.findAll()) {
        m_serviceTypeDao.delete(service);
    }
    for (final OnmsMonitoringLocation location : m_monitoringLocationDao.findAll()) {
        // Don't delete the default localhost monitoring location
        if (!MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID.equals(location.getLocationName())) {
            m_monitoringLocationDao.delete(location);
        }
    }
    for (final OnmsCategory category : m_categoryDao.findAll()) {
        m_categoryDao.delete(category);
    }
    LOG.debug("= DatabasePopulatorExtension Reset Starting =");
    for (Extension eachExtension : extensions) {
        DaoSupport daoSupport = eachExtension.getDaoSupport();
        OnmsDao<?, ?> dao = daoSupport != null && daoSupport.getDaoClass() != null ? lookupDao(daoSupport.getDaoClass()) : null;
        eachExtension.onShutdown(this, dao);
        if (dao != null) {
            dao.flush();
        }
    }
    LOG.debug("= DatabasePopulatorExtension Reset Finished =");
    m_outageDao.flush();
    m_userNotificationDao.flush();
    m_notificationDao.flush();
    m_alarmDao.flush();
    m_eventDao.flush();
    m_snmpInterfaceDao.flush();
    m_ipInterfaceDao.flush();
    m_nodeDao.flush();
    m_serviceTypeDao.flush();
    LOG.debug("==== DatabasePopulator Reset Finished ====");
}
Also used : OnmsOutage(org.opennms.netmgt.model.OnmsOutage) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) OnmsUserNotification(org.opennms.netmgt.model.OnmsUserNotification) OnmsNotification(org.opennms.netmgt.model.OnmsNotification) OnmsEvent(org.opennms.netmgt.model.OnmsEvent) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 15 with OnmsServiceType

use of org.opennms.netmgt.model.OnmsServiceType 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)

Aggregations

OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)34 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)19 OnmsNode (org.opennms.netmgt.model.OnmsNode)17 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)16 Date (java.util.Date)7 Test (org.junit.Test)7 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)6 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)4 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)4 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)4 Transactional (org.springframework.transaction.annotation.Transactional)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)3 MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)3 MockPersisterFactory (org.opennms.netmgt.mock.MockPersisterFactory)3 ServiceSelector (org.opennms.netmgt.model.ServiceSelector)3 Properties (java.util.Properties)2 InsufficientInformationException (org.opennms.core.utils.InsufficientInformationException)2 DefaultServiceCollectorRegistry (org.opennms.netmgt.collection.support.DefaultServiceCollectorRegistry)2