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"); }
private Connection getSOLIDConnection() { try { Class.forName("solid.jdbc.SolidDriver"); return DriverManager.getConnection("jdbc:solid://nms-clienttest1:1313/dba/dba", "dba", "dba"); } catch (Exception e) { e.printStackTrace(); return null; } }
private Connection getTIMESTENConnection() { try { Class.forName("com.timesten.jdbc.TimesTenDriver"); return DriverManager.getConnection("jdbc:timesten:direct:WebNmsDB", "root", null); } catch (Exception e) { e.printStackTrace(); return null; } }
private Connection getMYSQLConnection() { try { Class.forName("org.gjt.mm.mysql.Driver"); return DriverManager.getConnection("jdbc:mysql://localhost/WebNmsDB", "root", null); } catch (Exception e) { e.printStackTrace(); return null; } }
private Connection getSYBASEConnection() { try { Class.forName("com.sybase.jdbc2.jdbc.SybDriver"); return DriverManager.getConnection("jdbc:sybase:Tds:fe-test:2048/feDB", "sa", null); } catch (Exception e) { e.printStackTrace(); return null; } }
private void executeTestCase004() { try { System.out.println("Properties " + dbxmlutil.getAllAttributes("test", "Network Database")); } catch (Exception es) { // return new OperationResult(userName,"Failed", "Failed", es.toString()); // es.printStackTrace(); es.printStackTrace(); } }
private void executeTestCase034() { try { System.out.println( "Properties " + dbxmlutil.getNodeAttributes("Network Database", "root", "Network Database")); } catch (Exception e) { e.printStackTrace(); } }
private Connection getORACLEConnection() { try { Class.forName("oracle.jdbc.driver.OracleDriver"); return DriverManager.getConnection( "jdbc:oracle:thin:@kernel-win:1521:oracle", "BFW3", "BFW3"); } catch (Exception e) { e.printStackTrace(); return null; } }
private void executeTestCase028() { try { boolean movenode = dbxmlutil.moveNode("ipnet.netmap", "All", "WebNMS-Panels"); if (movenode) { System.out.println("CATS-JCF-API-DXU-028 ---> PASSED"); } else { System.out.println("CATS-JCF-API-DXU-028 ---> FAILED"); } } catch (Exception e) { e.printStackTrace(); } }
private void executeTestCase001() { try { Vector v = dbxmlutil.getAllNodeID("root", "Events"); if (v != null) { System.out.println("CATS-JCF-API-DXU-001 ---> PASSED"); } else { System.out.println("CATS-JCF-API-DXU-001 ---> FAILED"); } } catch (Exception e) { e.printStackTrace(); } }
private void executeTestCase108() { try { boolean root = dbxmlutil.isRootNodeExist("root", "Maps"); // System.out.println("Root Node = " +root); if (root) { System.out.println("CATS-JCF-API-DXU-108 ---> PASSED"); } else { System.out.println("CATS-JCF-API-DXU-108 ---> FAILED"); } } catch (Exception e) { e.printStackTrace(); } }
private void executeTestCase122() { try { Hashtable hash = dbxmlutil.getAllPanelAttribute("root"); System.out.println("The all panel attributes are = " + hash); if (hash != null) { System.out.println("CATS-JCF-API-DXU-122 ---> PASSED"); } else { System.out.println("CATS-JCF-API-DXU-122 ---> FAILED"); } } catch (Exception e) { e.printStackTrace(); } }
private void executeTestCase123() { try { Hashtable hash = dbxmlutil.getAllPanelAttribute("SHIVA"); int s = (int) hash.size(); if (s == 0) { System.out.println("CATS-JCF-API-DXU-123 ---> PASSED"); } else { System.out.println("CATS-JCF-API-DXU-123 ---> FAILED"); } } catch (Exception e) { e.printStackTrace(); } }
private void executeTestCase075() { try { String rootnode = dbxmlutil.getRootNodeID("root", null); if (rootnode.equals("AdventNet")) { System.out.println("CATS-JCF-API-DXU-075 ---> PASSED"); } else { System.out.println("CATS-JCF-API-DXU-075 ---> FAILED"); } } catch (Exception e) { e.printStackTrace(); } }
private void executeTestCase109() { try { boolean root109 = dbxmlutil.isRootNodeExist("root", "SHIVA"); if (root109) { System.out.println("CATS-JCF-API-DXU-109 ---> FAILED"); } else { System.out.println("CATS-JCF-API-DXU-109 ---> PASSED"); } } catch (Exception e) { e.printStackTrace(); } }
private void executeTestCase087() { try { boolean add1 = dbxmlutil.removeNode("Fault", "root", "Default", true); if (add1) { System.out.println("CATS-JCF-API-DXU-086 ---> PASSED"); } else { System.out.println("CATS-JCF-API-DXU-086 ---> FAILED"); } } catch (Exception e) { e.printStackTrace(); } }
private void executeTestCase116() { try { String last = dbxmlutil.getLastChild("root", "shivaprakash"); if (last == "START") { System.out.println("CATS-JCF-API-DXU-116 ---> PASSED"); } else { System.out.println("CATS-JCF-API-DXU-116 ---> FAILED"); } } catch (Exception e) { e.printStackTrace(); } }
/** * 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; }
private void executeTestCase085() { try { Properties viewProperties = new Properties(); viewProperties.put("ICON-FILE", "images/AdventNet.jpg"); viewProperties.put("TREE-NAME", "MKG"); viewProperties.put("ID", "Map_Val22"); // viewProperties.put("PARENT","Fault"); Properties panelProperties = new Properties(); // panelProperties.put("PARENT","Fault"); boolean add1 = dbxmlutil.modifyNode("Map_Val22", "All", "Default", viewProperties, panelProperties); if (add1) { System.out.println("CATS-JCF-API-DXU-085 ---> PASSED"); } else { System.out.println("CATS-JCF-API-DXU-085 ---> FAILED"); } } catch (Exception e) { e.printStackTrace(); } }
private void executeTestCase084() { try { Properties viewProperties = new Properties(); viewProperties.put("ICON-FILE", "images/tick.png"); viewProperties.put("TREE-NAME", "MKG"); viewProperties.put("ID", "Maps_Val22"); viewProperties.put("PARENT", "Maps"); Properties panelProperties = new Properties(); panelProperties.put("PARENT", "Maps"); boolean add1 = dbxmlutil.addNode( "Maps_Val22", "LEVEL-1", "All", "Maps", "Default", viewProperties, panelProperties); if (add1) { System.out.println("CATS-JCF-API-DXU-084 ---> PASSED"); } else { System.out.println("CATS-JCF-API-DXU-084 ---> FAILED"); } } catch (Exception e) { e.printStackTrace(); } }
public void showStatus(String message, Exception ex) { // <Begin_showStatus_String_Exception> System.out.println(NmsClientUtil.GetString("Internal Error :") + message); ex.printStackTrace(); // <End_showStatus_String_Exception> }
private void startProcess(String WebNmsHome, String Database) { // Connection con=null; String webnmshome = WebNmsHome + File.separator; System.out.println("WEBNMS HOME... : " + webnmshome); PureUtils.rootDir = webnmshome; PureUtils.usersDir = webnmshome; String db1 = Database.toUpperCase(); System.out.println("DATA BASE..... : " + db1); System.out.println(); try { if (db1.equals("MYSQL")) { con = getMYSQLConnection(); } else if (db1.equals("ORACLE")) { con = getORACLEConnection(); } else if (db1.equals("TIMESTEN")) { con = getTIMESTENConnection(); } else if (db1.equals("SOLID")) { con = getSOLIDConnection(); } else if (db1.equals("SYBASE")) { con = getSYBASEConnection(); } else { System.out.println("DATABASE NOT SELECTED"); System.exit(0); } // sunilg dbxmlutil = DBXmlUtility.getInstance(con); String parseFileName = PureUtils.rootDir + "conf" + "/" + "database_params.conf"; File parseFile = new File(parseFileName); DBParamsParser parse = DBParamsParser.getInstance( parseFile); // Database related details are read to create a DB connection. String url = parse.getURL(); String user = parse.getUserName(); String driver = parse.getDriverName(); String passwd = parse.getPassword(); RelationalAPI relapi = new RelationalAPI(url, user, passwd, driver, false); RelationalUtil.init(relapi); } catch (Exception e) { // return new OperationResult(userName,"Failed", "Failed", e.toString()); e.printStackTrace(); } try { // CustomViewUtilities for all are created to register in DBXmlUtility to get update for CV // related tables. AlertCustomViewUtility acvu = new AlertCustomViewUtility(con); EventCustomViewUtility ecvu = new EventCustomViewUtility(con); TopoCustomViewUtility tcvu = new TopoCustomViewUtility(con); AuditCustomViewUtility aucvu = new AuditCustomViewUtility(con); PerfCustomViewUtility pcvu = new PerfCustomViewUtility(con); JdbcAPI jdbc = (JdbcAPI) JdbcAPIImpl.getAPI(); PureServerUtils.getDatabaseParams(); acvu.setJDBCAPI(jdbc); ecvu.setJDBCAPI(jdbc); tcvu.setJDBCAPI(jdbc); pcvu.setJDBCAPI(jdbc); aucvu.setJDBCAPI(jdbc); SeverityFEAPIImpl sevAPI = (SeverityFEAPIImpl) SeverityFEAPIImpl.getAPI(); acvu.setSeverityAPI(sevAPI); ecvu.setSeverityAPI(sevAPI); tcvu.setSeverityAPI(sevAPI); pcvu.setSeverityAPI(sevAPI); aucvu.setSeverityAPI(sevAPI); // Register to update Custonview related table when DB is updated dbxmlutil.registerObjectForTable("Alerts", acvu); dbxmlutil.registerObjectForTable("Events", ecvu); dbxmlutil.registerObjectForTable("Network Database", tcvu); dbxmlutil.registerObjectForTable("Audit", aucvu); dbxmlutil.registerObjectForTable("Stats Admin", pcvu); } catch (Exception e) { System.out.println("unable to instantiate DBXmlUtility"); e.printStackTrace(); System.exit(0); } /* try { //String sr = dbxmlutil.getPreviousNode("root","Alerts"); String sr = dbxmlutil.getPreviousNodeForNodeIndex("root","Fault",2); System.out.println("The previous node is ... "+sr); } catch(Exception e) { e.printStackTrace(); } */ // sunil /*executeTestCase004(); executeTestCase028(); executeTestCase029(); executeTestCase034(); executeTestCase075();*/ // executeTestCase084(); // executeTestCase085(); // executeTestCase086(); // executeTestCase087(); executeTestCase108(); executeTestCase122(); // sunil // System.out.println(" DBXmlUpdate object is successfully created"); /*executeTestCase025(); executeTestCase001(); executeTestCase002(); executeTestCase012(); executeTestCase026(); executeTestCase029_1(); executeTestCase075(); executeTestCase109(); executeTestCase116(); executeTestCase123(); executeTestCase124(); System.out.println();*/ System.exit(0); }