Exemple #1
0
 /**
  * Constructor for OnmsMap.
  *
  * @param name a {@link java.lang.String} object.
  * @param owner a {@link java.lang.String} object.
  * @param accessMode a {@link java.lang.String} object.
  * @param width a int.
  * @param height a int.
  */
 public OnmsMap(String name, String owner, String accessMode, int width, int height) {
   this.name = name;
   this.owner = owner;
   this.userLastModifies = owner;
   this.createTime = new Date();
   this.lastModifiedTime = new Date();
   setAccessMode(accessMode);
   this.type = OnmsMap.USER_GENERATED_MAP;
   this.width = width;
   this.height = height;
 }
Exemple #2
0
 /**
  * Constructor for OnmsMap.
  *
  * @param name a {@link java.lang.String} object.
  * @param mapGroup a {@link java.lang.String} object.
  * @param background a {@link java.lang.String} object.
  * @param owner a {@link java.lang.String} object.
  * @param accessMode a {@link java.lang.String} object.
  * @param type a {@link java.lang.String} object.
  * @param width a int.
  * @param height a int.
  */
 public OnmsMap(
     String name,
     String mapGroup,
     String background,
     String owner,
     String accessMode,
     String type,
     int width,
     int height) {
   this.name = name;
   this.mapGroup = mapGroup;
   this.background = background;
   this.owner = owner;
   this.userLastModifies = owner;
   this.createTime = new Date();
   this.lastModifiedTime = new Date();
   setAccessMode(accessMode);
   setType(type);
   this.width = width;
   this.height = height;
 }
  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 ====");
  }