int _getInstance(const int argc, const char **argv) { if (argv[0] == 0) { _giUsage(); return 1; } // need to get class definition to find keys // first arg is name of class CIMClass cldef; try { cldef = _c.getClass( _nameSpace, argv[0] ); } catch(Exception& e) { cerr << /* "getInstance: " << */ e.getMessage() << endl; return 1; } CIMObjectPath ref; CIMInstance inst; // If there are no more args, prompt user for keys if (argv[1] == 0) ref = CIMObjectPath(String::EMPTY, // hostname left blank _nameSpace, argv[0], _inputInstanceKeys(cldef)); // else if there's another arg and it's "list", enumInstNames and print // a list from which user will select (return if none) else if (String::equalNoCase("list",argv[1])) { ref = _selectInstance(argv[0]); // An empty ObjectPath means nothing was selected if (ref.identical(CIMObjectPath())) return 0; } // else there's another arg but it's invalid else { _giUsage(); return 1; } // get the specified instance try { inst = _c.getInstance(_nameSpace,ref); } catch(Exception& e) { cerr << /* "getInstance: " << */ e.getMessage() << endl; return 1; } _displayInstance(inst); return 0; }
int _getProperty(const int argc, const char **argv) { // need to get class definition to find keys // first arg is name of class CIMClass cldef; try { cldef = _c.getClass( PEGASUS_NAMESPACENAME_INTEROP, argv[0] ); } catch(Exception& e) { cerr << /* "getProperty: " << */ e.getMessage() << endl; return 1; } CIMObjectPath ref; CIMInstance inst; // If next arg is "ask", prompt user for keys if (String::equalNoCase("ask",argv[1])) ref = CIMObjectPath(String::EMPTY, PEGASUS_NAMESPACENAME_INTEROP, argv[0], _inputInstanceKeys(cldef) ); // else if the next arg and is "list", enumInstNames and print // a list from which user will select else if (String::equalNoCase("list",argv[1])) { ref = _selectInstance( argv[0] ); if (ref.identical(CIMObjectPath())) return 0; } // else there's another arg but it's invalid else { return 1; } CIMProperty pDef; // if no more args, display property names and ask which if (argc < 3) { int n; for (n=0; n<cldef.getPropertyCount(); n++) cerr << n+1 << ": " << cldef.getProperty(n).getName().getString() << endl; cerr << "Property (1.." << cldef.getPropertyCount() << ")? "; cin >> n; pDef = cldef.getProperty(n-1); }