Example #1
0
 @Override
 protected void generateId(final OnmsMap map) {
   map.setId(m_id.incrementAndGet());
 }
Example #2
0
 @Override
 protected Integer getId(final OnmsMap map) {
   return map.getId();
 }
Example #3
0
  private void doPopulateDatabase() {
    LOG.debug("==== DatabasePopulator Starting ====");

    final OnmsDistPoller distPoller = getDistPoller("localhost", "127.0.0.1");
    final NetworkBuilder builder = new NetworkBuilder(distPoller);

    final OnmsNode node1 = buildNode1(builder);
    getNodeDao().save(node1);
    getNodeDao().flush();

    OnmsNode node2 = buildNode2(builder);
    getNodeDao().save(node2);
    getNodeDao().flush();
    setNode2(node2);

    OnmsNode node3 = buildNode3(builder);
    getNodeDao().save(node3);
    getNodeDao().flush();
    setNode3(node3);

    OnmsNode node4 = buildNode4(builder);
    getNodeDao().save(node4);
    getNodeDao().flush();
    setNode4(node4);

    OnmsNode node5 = buildNode5(builder);
    getNodeDao().save(node5);
    getNodeDao().flush();
    setNode5(node5);

    OnmsNode node6 = buildNode6(builder);
    getNodeDao().save(node6);
    getNodeDao().flush();
    setNode6(node6);

    final OnmsEvent event = buildEvent(distPoller);
    getEventDao().save(event);
    getEventDao().flush();

    final OnmsNotification notif = buildTestNotification(builder, event);
    getNotificationDao().save(notif);
    getNotificationDao().flush();

    final OnmsUserNotification userNotif = buildTestUserNotification(notif);
    getUserNotificationDao().save(userNotif);
    getUserNotificationDao().flush();

    final OnmsUserNotification userNotif2 = buildTestUser2Notification(notif);
    getUserNotificationDao().save(userNotif2);
    getUserNotificationDao().flush();

    final OnmsMonitoredService svc =
        getMonitoredServiceDao().get(node1.getId(), InetAddressUtils.addr("192.168.1.1"), "SNMP");
    final OnmsOutage resolved =
        new OnmsOutage(new Date(), new Date(), event, event, svc, null, null);
    getOutageDao().save(resolved);
    getOutageDao().flush();

    final OnmsOutage unresolved = new OnmsOutage(new Date(), event, svc);
    getOutageDao().save(unresolved);
    getOutageDao().flush();

    final OnmsAlarm alarm = buildAlarm(event);
    getAlarmDao().save(alarm);
    getAlarmDao().flush();

    final OnmsMap map = new OnmsMap("DB_Pop_Test_Map", "admin");
    map.setBackground("fake_background.jpg");
    map.setAccessMode(OnmsMap.ACCESS_MODE_ADMIN);
    map.setType(OnmsMap.USER_GENERATED_MAP);
    map.setMapGroup("admin");
    getOnmsMapDao().save(map);
    getOnmsMapDao().flush();

    final OnmsMapElement mapElement =
        new OnmsMapElement(
            map, 1, OnmsMapElement.NODE_TYPE, "Test Node", OnmsMapElement.defaultNodeIcon, 0, 10);
    getOnmsMapElementDao().save(mapElement);
    getOnmsMapElementDao().flush();

    final DataLinkInterface dli =
        new DataLinkInterface(node1, 1, node1.getId(), 1, StatusType.ACTIVE, new Date());
    getDataLinkInterfaceDao().save(dli);
    getDataLinkInterfaceDao().flush();

    final DataLinkInterface dli2 =
        new DataLinkInterface(node1, 2, node1.getId(), 1, StatusType.ACTIVE, new Date());
    getDataLinkInterfaceDao().save(dli2);
    getDataLinkInterfaceDao().flush();

    final DataLinkInterface dli3 =
        new DataLinkInterface(node2, 1, node1.getId(), 1, StatusType.ACTIVE, new Date());
    getDataLinkInterfaceDao().save(dli3);
    getDataLinkInterfaceDao().flush();

    final OnmsAcknowledgment ack = new OnmsAcknowledgment();
    ack.setAckTime(new Date());
    ack.setAckType(AckType.UNSPECIFIED);
    ack.setAckAction(AckAction.UNSPECIFIED);
    ack.setAckUser("admin");
    getAcknowledgmentDao().save(ack);
    getAcknowledgmentDao().flush();

    final OnmsMonitoringLocationDefinition def = new OnmsMonitoringLocationDefinition();
    def.setName("RDU");
    def.setArea("East Coast");
    def.setPollingPackageName("example1");
    def.setGeolocation("Research Triangle Park, NC");
    def.setCoordinates("35.715751,-79.16262");
    def.setPriority(1L);
    m_locationMonitorDao.saveMonitoringLocationDefinition(def);

    LOG.debug("= DatabasePopulatorExtension Populate Starting =");
    for (Extension eachExtension : extensions) {
      DaoSupport daoSupport = eachExtension.getDaoSupport();
      OnmsDao dao = daoSupport != null ? daoSupport.getDao() : null;
      Class<? super OnmsDao> daoClass = daoSupport != null ? daoSupport.getDaoClass() : null;
      registerDao(daoClass, dao);

      dao = lookupDao(daoClass);
      eachExtension.onPopulate(this, dao);
      if (dao != null) {
        dao.flush();
      }
    }
    LOG.debug("= DatabasePopulatorExtension Populate Finished =");

    LOG.debug("==== DatabasePopulator Finished ====");
  }