(file) Return to tomof.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Clients / tomof

  1 kumpf 1.15 //%/////////////////////////////////////////////////////////////////////////////
  2 karl  1.1  //
  3 kumpf 1.15 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4 karl  1.1  // The Open Group, Tivoli Systems
  5            //
  6            // Permission is hereby granted, free of charge, to any person obtaining a copy
  7            // of this software and associated documentation files (the "Software"), to
  8            // deal in the Software without restriction, including without limitation the
  9            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10            // sell copies of the Software, and to permit persons to whom the Software is
 11            // furnished to do so, subject to the following conditions:
 12 kumpf 1.15 // 
 13 karl  1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 14            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 15            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 16            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 17            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 18            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 19            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 20            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 21            //
 22            //==============================================================================
 23 kumpf 1.15 
 24 karl  1.1  //
 25            // Author: Karl Schopmeyer (k.schopmeyer@opengroup.org)
 26            //
 27 kumpf 1.14 // Modified By:  Carol Ann Krug Graves, Hewlett-Packard Company
 28            //               (carolann_graves@hp.com)
 29 karl  1.1  //
 30            //%/////////////////////////////////////////////////////////////////////////////
 31            
 32            #include <Pegasus/Common/Config.h>
 33            #include <cassert>
 34            #include <Pegasus/Common/OptionManager.h>
 35            #include <Pegasus/Common/FileSystem.h>
 36            #include <Pegasus/Common/Stopwatch.h>
 37            #include <Pegasus/Repository/CIMRepository.h>
 38            #include <Pegasus/Common/PegasusVersion.h>
 39            #include <Pegasus/Client/CIMClient.h>
 40 karl  1.7  #include <Pegasus/Common/XmlWriter.h>
 41 kumpf 1.12 #include <Pegasus/Common/MofWriter.h>
 42 karl  1.1  #include "clientRepositoryInterface.h"
 43            
 44            PEGASUS_USING_PEGASUS;
 45            PEGASUS_USING_STD;
 46            
 47 kumpf 1.19 CIMNamespaceName nameSpace = CIMNamespaceName ("root/cimv2");
 48 karl  1.1  /*
 49            class classNameList
 50            {
 51            public:
 52 kumpf 1.19     classNameList(CIMNamespaceName& nameSpace, clientRepositoryInterface& cli)
 53 karl  1.1      {
 54                };
 55            };
 56            */
 57            
 58 karl  1.6  /* class classNameList - Provides creation and management of classNames in a
 59                list form.
 60            */
 61 karl  1.1  class classNameList
 62            {
 63            public:
 64 karl  1.6      // constructor - Creates empty list
 65 karl  1.1      classNameList()
 66                {
 67                _nameSpace = String::EMPTY;
 68                //_cli = 0;
 69                _index = 0;
 70                }
 71 karl  1.6      // constructor - with nameSpace and Interface
 72 kumpf 1.19     classNameList(const CIMNamespaceName& nameSpace, const clientRepositoryInterface& cli)
 73 karl  1.1  
 74                {
 75                _nameSpace = nameSpace,
 76                _cli = cli,
 77                _index = 0;
 78                }
 79                ~classNameList()
 80                {
 81            
 82                }
 83 karl  1.6      // Set Namespace
 84 kumpf 1.19     void setNameSpace (const CIMNamespaceName& nameSpac)
 85 karl  1.1      {
 86            	_nameSpace = nameSpace;
 87                }
 88 karl  1.6      // enumerate - Executes the enumerate
 89 kumpf 1.19     void enumerate(CIMName& className, Boolean deepInheritance)
 90 karl  1.1      {
 91                	/*cout << "enumerate function " << className 
 92            	    << " namespace " << _nameSpace
 93            	    << endl;*/
 94            	// put try around this
 95            	_classNameList =  _cli.enumerateClassNames(
 96            	    _nameSpace, className, deepInheritance);
 97            	//cout << "enum finished " << _classNameList.size() << endl;
 98                }
 99            
100 karl  1.6      /* filter - Filters the list against a defined pattern using the
101                    glob type filter.
102 kumpf 1.8         NOTICE: This method no longer performs glob-style matching.  The
103                   list is now filtered using exact matching, except that it also
104                   recognizes the "*" pattern which matches everything.  While the new
105                   functionality is quite limited, this change is consistent with
106                   the way this method was being used at the time of the change.
107 karl  1.6          @param pattern -String defining the pattern used to filter the
108                    list. 
109                    @return Result is the list with all names that do not pass the
110                    filter removed.
111                    
112                */
113 karl  1.1      void filter(String& pattern)
114                {
115            	// Filter the list in accordance with the pattern
116            	//cout << "Filter Start " << _classNameList.size() << endl;
117 kumpf 1.17 	Array<CIMName> tmp;
118 karl  1.1  	for (Uint32 i = 0; i < _classNameList.size(); i++)
119            	{
120            	   /* cout << "Loop in filter " << i << " " 
121            		<<  _classNameList[i] << " pattern " 
122            		<<  pattern
123 kumpf 1.8  		<< " Return is " << String::equalNoCase(_classNameList[i], pattern)
124 karl  1.1  	        << " size " <<  _classNameList.size()
125            		<< endl; */
126 kumpf 1.19             if (String::equalNoCase(_classNameList[i].getString(), pattern))
127 karl  1.1  		tmp.append(_classNameList[i]);
128            	}
129            	_classNameList.swap(tmp);
130 kumpf 1.8        }
131 karl  1.1  	//cout << "Filter finished " << _classNameList.size() << endl;
132            
133 karl  1.6      /* getIndex - Get the current index in the list.  This is used with
134                    next and start functions to get entries in the list one by one.
135                */
136 karl  1.1      Uint32 getIndex() {
137            	return _index;
138                }
139 karl  1.6      /* size - returns the number of entires in the list
140                    @return Uint32 with number of entires in the list.
141                */
142 karl  1.1      Uint32 size() {
143            	return _classNameList.size();
144                }
145 karl  1.6      /* next - get the next entry in the list.  If there are no more entires
146                   returns String:EMPTY
147                   @return String containing next entry or String::EMPTY if at end of list
148                */
149 karl  1.1      String next()
150                {
151            	if (_index < _classNameList.size())
152 kumpf 1.19 	    return _classNameList[_index++].getString();
153 karl  1.1  	else
154            	    return String::EMPTY;
155                }
156 karl  1.6      /* start - Set the index to the start of the list
157                */
158                void start()
159                {
160                    _index = 0;
161                }
162 karl  1.1  private:
163 kumpf 1.17     Array<CIMName> _classNameList;
164 karl  1.1      clientRepositoryInterface _cli;
165 kumpf 1.19     CIMNamespaceName _nameSpace;
166 karl  1.1      Uint32 _index;
167            };
168            
169            /** ErrorExit - Print out the error message as an
170                and get out.
171                @param - Text for error message
172                @return - None, Terminates the program
173                @execption - This function terminates the program
174            */
175            void ErrorExit(const String& message)
176            {
177            
178 karl  1.6      cerr << message << endl;
179 karl  1.1      exit(1);
180            }
181            
182            //------------------------------------------------------------------------------
183            //
184            // _indent()
185            //
186            //------------------------------------------------------------------------------
187            
188            static void _indent(PEGASUS_STD(ostream)& os, Uint32 level, Uint32 indentSize)
189            {
190                Uint32 n = level * indentSize;
191                if (n > 50)
192                {
193                cout << "Jumped Ship " << level << " size " << indentSize << endl;
194                exit(1);
195                }
196            
197                for (Uint32 i = 0; i < n; i++)
198            	os << ' ';
199            }
200 karl  1.1  void mofFormat(
201                PEGASUS_STD(ostream)& os, 
202                const char* text, 
203                Uint32 indentSize)
204            {
205                char* tmp = strcpy(new char[strlen(text) + 1], text);
206                Uint32 count = 0;
207                Uint32 indent = 0;
208                Boolean quoteState = false;
209                Boolean qualifierState = false;
210                char c;
211                char prevchar;
212                while (c = *tmp++)
213                {
214            	count++;
215            	// This is too simplistic and must move to a token based mini parser
216            	// but will do for now. One problem is tokens longer than 12 characters that
217            	// overrun the max line length.
218            	switch (c)
219            	{
220            	    case '\n':
221 karl  1.1  		os << Sint8(c);
222            		prevchar = c;
223            		count = 0 + (indent * indentSize);
224            		_indent(os, indent, indentSize);   
225            		break;
226            
227            	    case '\"':	 // quote 
228            		os << Sint8(c);
229            		prevchar = c;
230            		quoteState = !quoteState;
231            		break;
232            
233            	    case ' ':
234            		os << Sint8(c);
235            		prevchar = c;
236            		if (count > 66)
237            		{
238            		    if (quoteState)
239            		    {	
240            			os << "\"\n";
241            			_indent(os, indent + 1, indentSize);   
242 karl  1.1  			os <<"\"";
243            		    }
244            		    else
245            		    {
246            			os <<"\n";
247            			_indent(os, indent + 1,  indentSize);   
248            		    }
249            		    count = 0 + ((indent + 1) * indentSize);
250            		}
251            		break;
252            	    case '[':
253            		if (prevchar == '\n')
254            		{
255            		    indent++;
256            		    _indent(os, indent,  indentSize);
257            		    qualifierState = true;
258            		}
259            		os << Sint8(c);
260            		prevchar = c;
261            		break;
262            
263 karl  1.1  	    case ']':
264            		if (qualifierState)
265            		{
266            		    if (indent > 0)
267            			indent--;
268            		    qualifierState = false;
269            		}
270            		os << Sint8(c);
271            		prevchar = c;
272            		break;
273            
274            	    default:
275            		os << Sint8(c);
276            		prevchar = c;
277            	}
278            
279                }
280            }
281            
282            ///////////////////////////////////////////////////////////////
283            //    OPTION MANAGEMENT
284 karl  1.1  ///////////////////////////////////////////////////////////////
285            
286            /** GetOptions function - This function defines the Options Table
287                and sets up the options from that table using the option manager.
288                const char* optionName;
289                const char* defaultValue;
290                int required;
291                Option::Type type;
292                char** domain;
293                Uint32 domainSize;
294                const char* commandLineOptionName;
295                const char* optionHelpMessage;
296                
297            */
298            void GetOptions(
299                OptionManager& om,
300                int& argc,
301                char** argv,
302                const String& pegasusHome)
303            {
304 kumpf 1.16     const char* tmpDir = getenv ("PEGASUS_TMP");
305                if (tmpDir == NULL)
306                {
307                    tmpDir = ".";
308                }
309            
310 karl  1.1      static struct OptionRow optionsTable[] =
311                {
312                    //optionname defaultvalue rqd  type domain domainsize clname hlpmsg
313                     
314                     {"namespace", "root/cimv2", false, Option::STRING, 0, 0, "n",
315                                   "Specifies namespace to use for"},
316            
317                     {"version", "false", false, Option::BOOLEAN, 0, 0, "v",
318                                   "Displays Program Version identification"},
319                     // set to true for testing
320                     {"verbose", "true", false, Option::BOOLEAN, 0, 0, "verbose",
321                                   "Displays Extra information"},
322            
323                     {"help", "false", false, Option::BOOLEAN, 0, 0, "h",
324                                   "Prints help message with command line options"},
325            
326                     {"qualifiers", "false", false, Option::BOOLEAN, 0, 0, "q", 
327                                  "If set, show the qualifier declarations"},
328            
329                     {"instances", "false", false, Option::BOOLEAN, 0, 0, "i", 
330                                  "If set, show the instances"},
331 karl  1.1  
332                     {"all", "false", false, Option::BOOLEAN, 0, 0, "a", 
333                                  "If set, show qualifiers, classes, and instances"},
334            
335 karl  1.5           {"summary", "false", false, Option::BOOLEAN, 0, 0, "s", 
336                                  "Print only a summary count at end"},
337 karl  1.1  
338 kumpf 1.16          {"location", tmpDir, false, Option::STRING, 0, 0, "l", 
339 karl  1.1          "Repository directory (/run if repository directory is /run/repository"},
340            
341                     {"client", "false", false, Option::BOOLEAN, 0, 0, "c", 
342                                  "Runs as Pegasus client using client interface"},
343            
344                     {"onlynames", "false", false, Option::BOOLEAN, 0, 0, "o", 
345                                  "Show Names only, not the MOF"},
346            
347 karl  1.2           {"xml", "false", false, Option::BOOLEAN, 0, 0, "x", 
348                                  "Output result in XML rather than MOF"},
349 karl  1.1  
350                };
351                const Uint32 NUM_OPTIONS = sizeof(optionsTable) / sizeof(optionsTable[0]);
352            
353                om.registerOptions(optionsTable, NUM_OPTIONS);
354            
355                String configFile = pegasusHome + "/cimserver.conf";
356            
357                if (FileSystem::exists(configFile))
358                {
359                    om.mergeFile(configFile);
360                    cout << "Config file from " << configFile << endl;
361                }
362            
363                om.mergeCommandLine(argc, argv);
364            
365                om.checkRequiredOptions();
366            }
367            
368            void printHelp(char* name, OptionManager om)
369            {
370 karl  1.1      String header = "Usage ";
371                header.append(name);
372                header.append(" -parameters [class]");
373                header.append("  - Generate MOF output from the repository or client\n");
374            
375                String trailer = "\nAssumes  PEGASUS_HOME for repository unless -r specified";
376                trailer.append("\nClient location assumesIf class only that class mof is output.");
377            
378                trailer.append("\nIf class only that class mof is output.");
379                trailer.append("\nExamples:");
380                trailer.append("\n  tomof CIM_DOOR - Shows mof for CIM_Door");
381                trailer.append("\n  tomof *door* - Shows mof for classes with 'door' in name.");
382                trailer.append("\n  tomof -o *software* - Lists Class names with 'door' in name.");
383                trailer.append("\n  tomof - outputs mof for all classes");
384                trailer.append("\n  tomof -c - outputs mof for all classes using client interface.");
385                trailer.append("\n  tomof -q - Outputs mof for qualifiers and classes");
386            
387                om.printOptionsHelpTxt(header, trailer);
388            }
389            
390            
391 karl  1.1  
392            
393            ///////////////////////////////////////////////////////////////
394            //    MAIN
395            ///////////////////////////////////////////////////////////////
396            
397            int main(int argc, char** argv)
398            {   
399            
400                String pegasusHome;
401                pegasusHome = "/";
402 karl  1.6  
403 karl  1.1      // GetEnvironmentVariables(argv[0], pegasusHome);
404            
405                // Get options (from command line and from configuration file); this
406                // removes corresponding options and their arguments fromt he command
407                // line.
408            
409                // Get options (from command line and from configuration file); this
410                // removes corresponding options and their arguments fromt he command
411                // line.
412            
413                OptionManager om;
414            
415                try
416                {
417 karl  1.6          GetOptions(om, argc, argv, pegasusHome);
418            
419 karl  1.1      }
420 karl  1.6      catch(Exception& e)
421 karl  1.1      {
422                    cout << "Error Qualifier Enumeration:" << endl;
423                    cerr << argv[0] << ": " << e.getMessage() << endl;
424 karl  1.6          exit(1);
425 karl  1.1      }
426            
427                // Check to see if user asked for help (-h otpion):
428 karl  1.6      if(om.isTrue("help"))
429 karl  1.1      {
430                    printHelp(argv[0], om);
431                    exit (0);
432                }
433                // Check for Version flag and print version message
434 karl  1.6      if(om.isTrue("version"))
435 karl  1.1      {
436                    cout << "Pegasus Version " << PEGASUS_VERSION 
437 karl  1.6                  << " " << argv[0] << " version 1.0 " << endl;
438 karl  1.1          return 0;
439                }
440            
441                Boolean showOnlyNames = om.isTrue("onlynames");
442            
443            
444                // Check for namespace flag and set namespace
445                String localNameSpace;
446                if(om.lookupValue("namespace", localNameSpace))
447 karl  1.6      {
448 karl  1.1          cout << "Namespace = " << localNameSpace << endl;
449 karl  1.6      }
450 karl  1.1  
451            
452                // Check for the show qualifiers flag
453                Boolean showQualifiers = om.isTrue("qualifiers");
454            
455                // Check for the summary count flag
456                Boolean summary = om.isTrue("summary");
457                Uint32 qualifierCount = 0;
458                Uint32 classCount = 0;
459                Uint32 classCountDisplayed = 0;
460                Uint32 instanceCount = 0;
461            
462                // Check for the instances 
463                Boolean showInstances = om.isTrue("instances");
464            
465                Boolean showAll = om.isTrue("all");
466            
467                Boolean verbose = om.isTrue("verbose");
468            
469                Boolean singleClass = true;
470 kumpf 1.19     CIMName className;
471 karl  1.1  
472                // Set the flags to determine whether we show all or simply some classes
473 karl  1.6      if(showAll)
474                    singleClass = false;
475 karl  1.1      else    // if no classes in list.
476 karl  1.6          if(argc < 2)
477                    singleClass = false;
478 karl  1.1  
479                // Build the classList from the input parameters
480                Array<String> classList;
481            
482 karl  1.6      if(argc > 1)
483 karl  1.1      {
484                    // while there are entries in the argv list
485 karl  1.6          for(int i = 1; i < argc; i++)
486 karl  1.1              classList.append(argv[i]);
487                }
488                else
489 karl  1.6          classList.append("*");
490 karl  1.1  
491 karl  1.6      if(verbose)
492 karl  1.1      {
493 karl  1.6          if(verbose) cout << "Class list is ";
494                    for(Uint32 i = 0 ; i < classList.size(); i++)
495                    {
496                        if(verbose) cout << classList[i] << " ";
497                    }
498                    cout << endl;
499 karl  1.1      }
500            
501                // Test to determine if we have a filter pattern to limit classes displayed
502                String pattern;
503                Boolean doWildCard = false;
504            
505                // if "Client" set, open a connected and set 
506                Boolean isClient = om.isTrue("client");
507            
508 karl  1.2      // if "Client" set, open a connected and set 
509                Boolean isXMLOutput = om.isTrue("xml");
510 karl  1.1  
511                // Check for repository path flag and set repository directory
512 karl  1.6      // ATTN: P4 Defer Apr 2002KS Clean this up so the priority is better defined.
513 karl  1.2      // Should probably also put under directory functions also
514 karl  1.1      String location = "";
515            
516                if(om.lookupValue("location", location))
517 karl  1.6      {
518                    if(verbose) cout << "location Path = " << location << endl;
519 karl  1.1  
520 karl  1.6      }
521 karl  1.1  
522                const char* tmp = getenv("PEGASUS_HOME");
523            
524            
525                // Need to set the location value
526                // clientCommonDefs::operationType _ot;
527                clientRepositoryInterface clRepository; // the repository interface object
528                clientRepositoryInterface::_repositoryType rt;
529            
530 karl  1.6      if(isClient)
531 karl  1.1      {
532 karl  1.6          location = "localhost:5988";
533                    rt = clientRepositoryInterface::REPOSITORY_INTERFACE_CLIENT;
534 karl  1.1      }
535                else
536                {
537 karl  1.6          rt = clientRepositoryInterface::REPOSITORY_INTERFACE_LOCAL;
538 kumpf 1.18         location.append("/repository");
539 karl  1.6          location = location;
540 karl  1.1      }
541            
542                // How do we set a context that would be either client or repository
543                // Test to determine if we have proper location, etc. for opening
544            
545 karl  1.6      if(verbose)
546 karl  1.1      {
547 karl  1.6          cout << "Get from " << ((isClient) ? "client" : "repository ") 
548                    << " at " << location << endl;
549 karl  1.1      }
550            
551                // Create the repository object
552                CIMRepository repository(location);
553                CIMClient client;
554 karl  1.6  
555 karl  1.1      // if client mode, do client connection, else do repository connection
556 karl  1.6      try
557 karl  1.1      {
558 karl  1.6          clRepository.init(rt, location);
559 karl  1.1      }
560                catch(Exception &e)
561                {
562 karl  1.6          // add message here
563                    return false;
564 karl  1.1      }
565 karl  1.6      // Get the complete class name list	before we start anything else
566 karl  1.1  
567 karl  1.6      if(showQualifiers || showAll || summary)
568 karl  1.1      {
569 karl  1.6          try
570                    {
571                        // Enumerate the qualifiers:
572            
573                        Array<CIMQualifierDecl> qualifierDecls 
574                                = clRepository.enumerateQualifiers(nameSpace);
575                        qualifierCount = qualifierDecls.size();
576            
577                        if(showOnlyNames)
578                        {
579                            for(Uint32 i = 0; i < qualifierDecls.size(); i++)
580                                cout << "Qualifier " << qualifierDecls[i].getName() << endl;    
581                        }
582                        if(showQualifiers || showAll)
583                        {
584                            for(Uint32 i = 0; i < qualifierDecls.size(); i++)
585                            {
586                                CIMQualifierDecl tmp = qualifierDecls[i];
587            
588                                if(isXMLOutput)
589                                {
590 kumpf 1.11                         XmlWriter::printQualifierDeclElement(tmp, cout);            
591 karl  1.6                      }
592                                else
593                                {
594                                    Array<Sint8> x;
595 kumpf 1.12                         MofWriter::appendQualifierDeclElement(x, tmp);
596 karl  1.6  
597                                    x.append('\0');
598            
599                                    mofFormat(cout, x.getData(), 4);
600                                }
601                            }
602                        }
603                    }
604                    catch(Exception& e)
605                    {
606                        ErrorExit(e.getMessage());
607                    }
608                }
609 karl  1.1      // Show classes from the list of input classes
610 karl  1.6      for(Uint32 i = 0; i < classList.size(); i++)
611 karl  1.1      {
612 karl  1.6          try
613                    {
614                        Boolean localOnly = true;
615                        Boolean includeQualifiers = true;
616                        Boolean includeClassOrigin = true;
617            
618                        classNameList list(nameSpace, clRepository);
619            
620 kumpf 1.19             CIMName temp;
621 karl  1.6              list.enumerate(temp,true);
622            
623                        // Filter to this class specification
624                        list.filter(classList[i]);
625                        classCount = list.size();
626            
627                        if(showOnlyNames)
628                        {
629                            for(Uint32 j = 0; j < list.size(); j++)
630                                cout << "Class " << list.next();
631                        }
632                        if(!summary)
633                        {
634                            // Print out the MOF for those found
635                            for(Uint32 j = 0; j < list.size(); j++)
636                            {
637            
638                                CIMClass cimClass = clRepository.getClass(nameSpace, list.next(),
639                                                                          localOnly, includeQualifiers, includeClassOrigin);
640            
641                                // Note we get and print ourselves rather than use the generic printMof
642 karl  1.6                      if(isXMLOutput)
643 kumpf 1.10                         XmlWriter::printClassElement(cimClass, cout);
644 karl  1.6                      else
645                                {
646                                    Array<Sint8> x;
647 kumpf 1.12                         MofWriter::appendClassElement(x, cimClass);
648 karl  1.6  
649                                    x.append('\0');
650            
651                                    mofFormat(cout, x.getData(), 4);
652                                }
653                            }
654                        }
655                    }
656                    catch(Exception& e)
657                    {
658                        // ErrorExit(e.getMessage());
659                        cout << "Class get error " << e.getMessage() << " Class " << classList[i];
660                    }
661 karl  1.1      }
662            
663                // Note that we can do this so we get all instances or just the given class
664            
665 karl  1.6      if(showInstances | showAll)
666 karl  1.1      {
667 karl  1.6          for(Uint32 i = 0; i < classList.size(); i++)
668                    {
669                        // Get Class Names
670 kumpf 1.19             Array<CIMName> classNames;
671 karl  1.6  
672                        // try Block around basic instance processing
673                        try
674                        {
675                            Boolean deepInheritance = true;
676                            Boolean localOnly = false;
677                            Boolean includeClassOrigin = false;
678                            Boolean includeQualifiers = false;
679            
680 kumpf 1.19                 CIMName className;
681 karl  1.6  
682                            //	classNames = clRepository.enumerateClassNames(
683                            //		nameSpace, className, deepInheritance);
684                            // Start with List from class enum
685                            classNameList myClassNameList(nameSpace, clRepository);
686            
687 kumpf 1.19                 CIMName temp;
688 karl  1.6                  myClassNameList.enumerate(temp,true);
689            
690                            // Filter to this class specification
691                            myClassNameList.filter(classList[i]);
692                            classCount = myClassNameList.size();
693            
694                            if(showOnlyNames)
695                            {
696                                for(Uint32 j = 0; j < myClassNameList.size(); j++)
697                                {
698 kumpf 1.13                         Array<CIMObjectPath> instanceNames;
699 karl  1.6                          instanceNames = clRepository.enumerateInstanceNames(nameSpace,
700                                                                                        className);
701                                    for(Uint32 j = 0; j < instanceNames.size(); j++)
702 kumpf 1.20                             cout << "Instance " << instanceNames[i].toString();
703 karl  1.6                      }
704                            }
705                            else    // Process complete instances
706                            {
707                                // Process classlist to enumerate and print instances
708                                for(Uint32 j = 0; j < myClassNameList.size(); j++)
709                                {
710 kumpf 1.14                         Array<CIMInstance> namedInstances;
711 karl  1.6                          namedInstances = clRepository.enumerateInstances(nameSpace,
712                                                                                     className,
713                                                                                     deepInheritance,
714                                                                                     localOnly,
715                                                                                     includeQualifiers,
716                                                                                     includeClassOrigin);
717                                    // const CIMPropertyList& propertyList = CIMPropertyList());
718            
719                                    // Process and output each instance
720                                    for(Uint32 k = 0; k < namedInstances.size(); k++)
721                                    {
722            
723 kumpf 1.14                             CIMInstance instance = namedInstances[i];
724 karl  1.6                              if(isXMLOutput)
725 kumpf 1.10                                 XmlWriter::printInstanceElement(instance, cout);
726 karl  1.6                              else
727                                        {
728                                            Array<Sint8> x;
729 kumpf 1.12                                 MofWriter::appendInstanceElement(x, instance);
730 karl  1.6  
731                                            x.append('\0');
732            
733                                            mofFormat(cout, x.getData(), 4);
734                                        }
735                                    }
736                                }
737                            }
738                        }
739                        catch(Exception& e)
740                        {
741                            cout << "Error Class Name Enumeration:" << endl;
742                            cout << e.getMessage() << endl;
743                        }
744            
745                        // Get instances for each class
746                        /*  Double check.  Think this just for delete now.
747                        try
748                        {
749                            for(Uint32 i = 0; i < classNames.size(); i++)
750                            {
751 karl  1.6                      // Enumerate the Instances of this class
752                                // ENUM and DISPLAY CODE HERE
753                                //ATTN: KS P3 17 APR 2002 Instance display incomplete
754                                cout << "WORK In Process" << endl;
755                            }
756                        }
757                        catch(Exception& e)
758                        {
759                            cout << "Error Instance Enumeration:" << endl;
760                            cout << e.getMessage() << endl;
761                        }
762                        */
763                    }
764                }
765            
766                if(summary)
767                {
768                    if(qualifierCount != 0)
769                        cout << "Qualifiers - " << qualifierCount << endl;
770                    if(classCount != 0)
771 karl  1.5              cout << "Classes - " << classCount << " found and " << classCountDisplayed
772 karl  1.6                      << " output" << endl;
773                    if(instanceCount != 0)
774 karl  1.1              cout << "Instances - " << instanceCount << endl;
775                }
776                exit(0); 
777            } 
778            //PEGASUS_NAMESPACE_END
779            
780            

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2