Ejemplo n.º 1
0
  public void testGetByName() {
    boolean getResult = true;
    ManagedObject getMo = null;
    TopoAPI api = getHandle();

    try {
      boolean wasAdded = true;
      final int NUM_NODES = 255;

      for (int i = 1; (i <= NUM_NODES) && wasAdded; 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("Printerfortestgetbyname" + i);
        newNode.setSysOID("10.100.10." + i);
        newNode.setManaged(false);
        newNode.setConsoleDispBufferText("testval");

        wasAdded = wasAdded & api.addObject(newNode);

        if (wasAdded) {
          System.err.println("testGetByName: added node " + i);
        } else {
          System.err.println("testGetByName: node " + i + " NOT added");
        }
      }
      java.util.Iterator objNames = api.getCompleteList().iterator();
      while (objNames.hasNext()) {
        String moName = (String) objNames.next();
        getMo = api.checkOut(moName, 2);
        // api.updateObject(getMo,false,false);
        api.unlock(getMo);

        if (getMo == null) {
          System.out.println("testGetByName  : The mo is null");
          getResult = false;
        } else {
          System.out.println("testGetByName : Sucessfully got the mo " + getMo.getName());
          getMo = null;
        }
      }
    } catch (Exception getEx) {
      System.out.println("testGetByName : Exception in testGetByName " + getEx);
    }
  }
Ejemplo n.º 2
0
  private void resetTopology() {

    final int NUM_NODES = 100;
    /*try
    		{
    			TopoAPI topoApi=getHandle();

    //			 TopoAPI topoAPI=com.adventnet.nms.topodb.DBServer.topodb;

    			boolean wasAdded=true;
    			for (int i = 1; (i <= NUM_NODES) && wasAdded; 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);

    				wasAdded = wasAdded & topoApi.addObject(newNode);

    				if (wasAdded)
    				{
    					System.err.println("resetTopology: added node " + i);
    				}
    				else
    				{
    					System.err.println("resetTopology: node " + i + " NOT added");
    				}
    			}
    		}
    		catch(Exception resetEx)
    		{
    			System.out.println("Exception in resetTopology "+resetEx);
    		}
    			*/

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

      java.util.Iterator objectNames = baseTopology.getCompleteList().iterator();

      while (objectNames.hasNext()) {
        String objectName = (String) objectNames.next();

        ManagedObject object = baseTopology.checkOut(objectName, 2);

        boolean wasDeleted = baseTopology.deleteObject(object, false, true); // 2.3

        if (!wasDeleted) {
          System.err.println("TOPOTEST: resetTopology: OBJ not deleted: " + objectName);
        }
      }
    } catch (Exception exception) {
      // Debug.print("TOPOTEST", Debug.CRITICAL_LEVEL, "resetTopology: exception: "
      // +exception.getMessage());
      System.out.println("Exception in resetTopology-delete " + exception);
    }
  }