public void testAddUpdateDeleteNode() {
    System.err.println("testUpdateNode: BEGIN");

    boolean testSuccess = false;

    try {
      // TopoAPI topoApi = com.adventnet.nms.topodb.DBServer.topodb;
      TopoAPI topoApi = getHandle();

      boolean wasAdded = true;
      boolean wasUpdated = true;
      boolean wasDeleted = true;
      final int NUM_NODES = 100;

      for (int i = 1; (i <= NUM_NODES) && wasAdded; i++) {
        // MaxxanNode newNode = new MaxxanNode();
        Printer newNode = new Printer();
        newNode.setIpAddress("10.100.10." + i);
        newNode.setName("Node" + i);
        newNode.setSysOID("10.100.10." + i);
        newNode.setManaged(false);
        newNode.setIsSNMP(false);

        wasAdded = wasAdded & topoApi.addObject(newNode);

        if (wasAdded) {
          System.err.println("testAddUpdateDeleteNode: added node " + i);
        } else {
          System.err.println("testAddUpdateDeleteNode: node " + i + " NOT added");
        }

        ManagedObject updatedObject = (ManagedObject) topoApi.checkOut("Node" + i, 2);
        if (wasAdded) {
          wasUpdated = wasUpdated & topoApi.updateObject(updatedObject, false, false);
        }
        if (wasUpdated) {
          System.err.println("testAddUpdateDeleteNode: updated node " + i);
        } else {
          System.err.println("testAddUpdateDeleteNode: node " + i + " NOT updated");
        }
        // ManagedObject deleteObject = (ManagedObject)topoApi.checkOut("Node" + i);
        if (wasAdded & wasUpdated) {
          wasDeleted = wasDeleted & topoApi.deleteObject(updatedObject, true, true);
        }
        if (wasDeleted) {
          System.err.println("testAddUpdateDeleteNode: deleted node " + i);
        } else {
          System.err.println("testAddUpdateDeleteNode: node " + i + " NOT deleted");
        }
      }

      testSuccess = wasAdded & wasUpdated & wasDeleted;
    } catch (Exception exception) {
      System.err.println("testUpdateNode: " + exception.getMessage());

      testSuccess = false;
    }

    System.err.println("testAddUpdateDeleteNode: END");
  }
  public void testDelete() {
    System.err.println("testDelete: BEGIN");

    boolean testSuccess = false;

    try {
      // TopoAPI topoApi = com.adventnet.nms.topodb.DBServer.topodb;
      TopoAPI topoApi = getHandle();

      boolean wasAdded = true;
      boolean wasDeleted = true;

      final int NUM_NODES = 255;

      for (int i = 1; (i <= NUM_NODES) && wasAdded && wasDeleted; i++) {

        /*MaxxanNode newNode = new MaxxanNode();

        newNode.setIpAddress("10.100.10." + i);
        newNode.setName("Node" + i);
        newNode.setSysOID("10.100.10." + i);
        newNode.setManaged(false);
        newNode.setIsSNMP(false);*/
        Printer newNode = new Printer();
        newNode.setIpAddress("10.100.10." + i);
        newNode.setName("Printer4nd" + i);
        newNode.setSysOID("10.100.10." + i);
        newNode.setManaged(false);
        newNode.setConsoleDispBufferText("testval");

        wasAdded = wasAdded && topoApi.addObject(newNode);

        if (wasAdded) {
          System.err.println("testDelete: added node " + i);
        } else {
          System.err.println("testDelete: node " + i + " NOT added");
        }

        ManagedObject updatedObject = (ManagedObject) topoApi.checkOut("Printer4nd" + i);

        wasDeleted = wasDeleted && topoApi.deleteObject(updatedObject, false, true);
        if (wasDeleted) {
          System.err.println("testDelete: deleted node " + i);
        } else {
          System.err.println("testDelete: node " + i + " NOT deleted");
        }
      }

      testSuccess = wasAdded && wasDeleted;
    } catch (Exception exception) {
      System.err.println("testDelete: " + exception.getMessage());
      exception.printStackTrace();

      testSuccess = false;
    }

    System.err.println("testDelete: END");
  }
示例#3
0
  /**
   * Returns the TabularData
   *
   * @return TabularData containing the rows corresponding the NetworkTable
   */
  public TabularData getNetworkTable() {
    try {
      if (table != null)
        return Utilities.getTabularData(this, indexNames, table, instrClassName, null);
      else if (vec != null)
        return Utilities.getTabularData(this, indexNames, vec, instrClassName, null);
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return null;
  }
  /**
   * PollAPI's handle is obtained using the NmsUtil's getAPI() method. A schema to store the data
   * collected for the three dataIdentifieres namely IFINOCTETS,IFOUTOCTETS,IFERRORS of an agent for
   * a particular time in a single row of a table called 'WinNTtable' is created and added to the
   * database using the PollAPI. Then the table 'WintNTtable' is created corresponding to this
   * schema using the PollAPI's createTable() method. Finally this table is asscociated with all
   * PolledData whose policyName equals 'WindowsNT'
   */
  public Vector applyPollFilter(ManagedObject obj, Vector pdatasVect) {
    Vector pvector = pdatasVect;
    PolledData pd = null;

    if (flag) {
      try {
        // PollAPI's handle is obtained using NmsUtil's
        // getAPI() method.
        api = (PollAPI) NmsUtil.getAPI("PollAPI");
      } catch (Exception e) {
        System.out.println("Error occurred while getting PollAPI handle: " + e);
        e.printStackTrace();
      }

      try {
        // form the schema and create the WinNTtable.
        // Note: This schema is created for mysql database. User should
        // modify this schema depending upon the database.
        String schema =
            "create table <> (AGENT varchar(100),IFINOCTETS BIGINT, IFOUTOCTETS BIGINT, IFERRORS BIGINT,TIMEOFCOL varchar(100))";
        String tablename = "WinNTtable";
        api.addCreateSchema(tablename, schema);
        api.createTable("WinNTtable");
      } catch (Exception e) {
        System.out.println("Exception in creating Schema and adding table");
        e.printStackTrace();
      }
      // flag is set to false since table is created
      flag = false;
    }

    // The vector of PolledData objects is enumerated and checked for the
    // policyName. If it equals to 'WindowsNT, then the statsDataTableName
    // of the PolledData is set to "WinNTtable" so that all the data
    // collected for this PolledData would be stored in this table.

    for (Enumeration e = pvector.elements(); e.hasMoreElements(); ) {
      pd = (PolledData) e.nextElement();
      if (pd.getPolicyName().equals("WindowsNT")) {
        pd.setStatsDataTableName("WinNTtable");
      }
    }
    // finally return the PolledData vector after setting the table name
    // to all PolledData whose policyName equals "WindowsNT".
    return pvector;
  }
示例#5
0
  /**
   * Returns the TabularData
   *
   * @return TabularData containing the rows corresponding the AlarmTable
   */
  public TabularData getAlarmTable() {

    // User code starts here
    if (true) {
      return getTable();
    }
    // User code ends here

    try {
      if (table != null)
        return Utilities.getTabularData(this, indexNames, table, instrClassName, null);
      else if (vec != null)
        return Utilities.getTabularData(this, indexNames, vec, instrClassName, null);
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return null;
  }