예제 #1
0
 @Override
 public void run() {
   try {
     OnmsSnmpInterface snmpIface = new OnmsSnmpInterface();
     snmpIface.setIfIndex(m_ifIndex);
     snmpIface.setIfName(m_ifName);
     m_upsertService.upsert(m_nodeId, snmpIface, 1000);
   } catch (Throwable t) {
     t.printStackTrace();
     m_throwable.set(t);
   }
 }
예제 #2
0
  @Test
  @JUnitTemporaryDatabase
  public void testInsert() {
    String newIfName = "newIf0";
    assertEquals(0, countIfs(m_populator.getNode1().getId(), 1001, newIfName));

    // add non existent snmpiface
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface();
    snmpIface.setNode(m_populator.getNode1());
    snmpIface.setIfIndex(1001);
    snmpIface.setIfName(newIfName);

    m_upsertService.upsert(m_populator.getNode1().getId() /* nodeid */, snmpIface, 0);

    assertEquals(1, countIfs(m_populator.getNode1().getId(), 1001, newIfName));
  }
예제 #3
0
  @Test
  @JUnitTemporaryDatabase
  public void testUpdate() {
    String oldIfName = "eth0";
    String newIfName = "newIf0";
    assertEquals(1, countIfs(m_populator.getNode1().getId(), 2, oldIfName));
    assertEquals(0, countIfs(m_populator.getNode1().getId(), 2, newIfName));

    // add non existent snmpiface
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface();
    snmpIface.setIfIndex(2);
    snmpIface.setIfName(newIfName);

    m_upsertService.upsert(m_populator.getNode1().getId(), snmpIface, 0);

    assertEquals(0, countIfs(m_populator.getNode1().getId(), 2, oldIfName));
    assertEquals(1, countIfs(m_populator.getNode1().getId(), 2, newIfName));
  }