int main(int argc, char** argv) { // Get options (from command line and from configuration file); this // removes corresponding options and their arguments fromt he command // line. // Get options (from command line and from configuration file); this // removes corresponding options and their arguments fromt he command // line. OptionManager om; try { String testHome = "."; GetOptions(om, argc, argv, testHome); // om.print(); } catch (Exception& e) { cerr << argv[0] << ": " << e.getMessage() << endl; exit(1); } // Check to see if user asked for help (-h otpion): if (om.valueEquals("verbose", "true")) { printHelpMsg(argv[0], usage, extra, om); exit(0); } // Establish the namespace from the input parameters String nameSpace; if(om.lookupValue("namespace", nameSpace)) { cout << "Namespace = " << nameSpace << endl; } Boolean verboseTest = (om.valueEquals("verbose", "true")) ? true :false; /* Boolean activeTest = false; if (om.valueEquals("active", "true")) activeTest = true; */ // Now develop the target instname from the arglist // For this one, at least one arguement is required // Not sure if this is true. // Think we should be able to get by with no argument. if (om.valueEquals("help", "true")) { String header = "Usage "; String trailer = ""; om.printOptionsHelpTxt(header, trailer); exit(0); } String location = "localhost:5988"; if(om.lookupValue("location", location)) { cout << "Location = " << location << endl; } // here we assume class name = null if none specified. String className = ""; if (argc > 1) { className = argv[1]; } CIMClient client; try { client.connect(location, String::EMPTY, String::EMPTY); } catch(Exception &e) { cerr << "Internal Error:" << e.getMessage() << endl; } Array<CIMObjectPath> instanceNames = client.enumerateInstanceNames(nameSpace, className); try { //simply output the list one per line for the moment. for (Uint32 i = 0; i < instanceNames.size(); i++) cout << instanceNames[i] << endl; } catch(Exception& e) { PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl); exit(1); } PEGASUS_STD(cout) << "+++++ passed all tests" << PEGASUS_STD(endl); return 0; }
int main(int argc, char** argv) { // char connection[50] = "localhost:5988"; char *address_string = NULL; Uint32 repetitions = 1; // Get environment variables: String pegasusHome; pegasusHome = "/"; // GetEnvironmentVariables(argv[0], pegasusHome); // Get options (from command line and from configuration file); this // removes corresponding options and their arguments fromt he command // line. // Get options (from command line and from configuration file); this // removes corresponding options and their arguments fromt he command // line. OptionManager om; try { GetOptions(om, argc, argv, pegasusHome); } catch (Exception& e) { cerr << argv[0] << ": " << e.getMessage() << endl; exit(1); } // Check to see if user asked for help (-h otpion): if (om.valueEquals("help", "true")) { String header = "Usage "; header.append(argv[0]); header.append(" -parameters host [host]"); String trailer = "Assumes localhost:5988 if host not specified"; trailer.append("\nHost may be of the form name or name:port"); trailer.append("\nPort 5988 assumed if port number missing."); om.printOptionsHelpTxt(header, trailer); exit(0); } String localNameSpace; om.lookupValue("namespace", localNameSpace); globalNamespace = localNameSpace; cout << "Namespace = " << localNameSpace << endl; String userName; om.lookupValue("user", userName); if (userName != String::EMPTY) { cout << "Username = "******"verbose"); String password; om.lookupValue("password", password); if (password != String::EMPTY) { cout << "password = "******"repeat", repeatTestCount)) repeatTestCount = 1; /* if (om.lookupValue("repeat", repeats)) { repeatTestCount = atol(repeats.getCString()); } else repeatTestCount = 1; */ if(verboseTest) cout << "Test repeat count " << repeatTestCount << endl; // Setup the active test flag. Determines if we change repository. Boolean activeTest = false; if (om.valueEquals("active", "true")) activeTest = true; // here we determine the list of systems to test. // All arguments remaining in argv go into list. Boolean localConnection = (om.valueEquals("local", "true"))? true: false; cout << "localConnection " << (localConnection ? "true" : "false") << endl; Array<String> connectionList; if (argc > 1 && !localConnection) for (Sint32 i = 1; i < argc; i++) connectionList.append(argv[i]); // substitute the default if no params if(argc < 2) connectionList.append("localhost:5988"); // Expand host to add port if not defined Boolean useSSL = om.isTrue("ssl"); // Show the connectionlist cout << "Connection List size " << connectionList.size() << endl; for (Uint32 i = 0; i < connectionList.size(); i++) cout << "Connection " << i << " address " << connectionList[i] << endl; for(Uint32 numTests = 1; numTests <= repeatTestCount; numTests++) { cout << "Test Repetition # " << numTests << endl; for (Uint32 i = 0; i < connectionList.size(); i++) { cout << "Start Try Block" << endl; try { cout << "Set Stopwatch" << endl; Stopwatch elapsedTime; cout << "Create client" << endl; CIMClient client; client.setTimeout(60 * 1000); cout << "Client created" << endl; // // Get host and port number from connection list entry // Uint32 index = connectionList[i].find (':'); String host = connectionList[i].subString (0, index); Uint32 portNumber = 0; if (index != PEG_NOT_FOUND) { String portStr = connectionList[i].subString (index + 1, connectionList[i].size ()); sscanf (portStr.getCString (), "%u", &portNumber); } if (useSSL) { // // Get environment variables: // const char* pegasusHome = getenv("PEGASUS_HOME"); String certpath = FileSystem::getAbsolutePath( pegasusHome, PEGASUS_SSLCLIENT_CERTIFICATEFILE); String randFile; #ifdef PEGASUS_SSL_RANDOMFILE randFile = FileSystem::getAbsolutePath( pegasusHome, PEGASUS_SSLCLIENT_RANDOMFILE); #endif SSLContext sslcontext(certpath,verifyServerCertificate, randFile); if (om.isTrue("local")) { cout << "Using local SSL connection mechanism " << endl; client.connectLocal(); } else { cout << "connecting to " << connectionList[i] << " using SSL" << endl; client.connect (host, portNumber, sslcontext, userName, password); } } else { if (om.isTrue("local")) { cout << "Using local connection mechanism " << endl; client.connectLocal(); } else { cout << "Connecting to " << connectionList[i] << endl; client.connect (host, portNumber, userName, password); } } cout << "Client Connected" << endl; testStart("Test NameSpace Operations - Relative Name"); elapsedTime.reset(); elapsedTime.start(); TestNamespaceHierarchy1(client, activeTest, verboseTest); elapsedTime.stop(); testEnd(elapsedTime.getElapsed()); testStart("Test NameSpace Operations - Absolute Name"); elapsedTime.reset(); elapsedTime.start(); TestNamespaceHierarchy2(client, activeTest, verboseTest); elapsedTime.stop(); testEnd(elapsedTime.getElapsed()); client.disconnect(); } catch(Exception& e) { PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl); exit(1); } } } PEGASUS_STD(cout) << "+++++ "<< argv[0] << " Terminated Normally" << PEGASUS_STD(endl); return 0; }