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

  1 martin 1.2 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.3 //
  3 martin 1.2 // Licensed to The Open Group (TOG) under one or more contributor license
  4            // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5            // this work for additional information regarding copyright ownership.
  6            // Each contributor licenses this file to you under the OpenPegasus Open
  7            // Source License; you may not use this file except in compliance with the
  8            // License.
  9 martin 1.3 //
 10 martin 1.2 // Permission is hereby granted, free of charge, to any person obtaining a
 11            // copy of this software and associated documentation files (the "Software"),
 12            // to deal in the Software without restriction, including without limitation
 13            // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14            // and/or sell copies of the Software, and to permit persons to whom the
 15            // Software is furnished to do so, subject to the following conditions:
 16 martin 1.3 //
 17 martin 1.2 // The above copyright notice and this permission notice shall be included
 18            // in all copies or substantial portions of the Software.
 19 martin 1.3 //
 20 martin 1.2 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.3 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.2 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23            // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24            // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25            // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26            // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.3 //
 28 martin 1.2 //////////////////////////////////////////////////////////////////////////
 29 mateus.baur 1.1 //
 30                 //
 31                 //%/////////////////////////////////////////////////////////////////////////////
 32                 
 33                 #include "IPInfo.h"
 34                 
 35                 PEGASUS_USING_PEGASUS;
 36                 PEGASUS_USING_STD;
 37                 
 38                 static const CIMName CLASS_NAME = CIMName("PG_RemoteServiceAccessPoint");
 39                 static const CIMNamespaceName NAMESPACE = CIMNamespaceName("root/cimv2");
 40                 static const CIMName PROPERTY_ACCESS_INFO = CIMName("AccessInfo");
 41                 static const CIMName PROPERTY_INFO_FORMAT = CIMName("InfoFormat");
 42                 static const CIMName PROPERTY_OTHER_INFO_FORMAT_DESCRIPTION = CIMName(
 43                     "OtherInfoFormatDescription");
 44                 
 45                 #define HeaderFormat "%-31s %-10s  %-38s"
 46                 
 47                 
 48                 ////////////////////////////////////////////////////////////////////////////////
 49                 //  Constructor for Remote Service Access Point  Info
 50 mateus.baur 1.1 ////////////////////////////////////////////////////////////////////////////////
 51                 RSApInfo::RSApInfo(
 52 kumpf       1.4     CIMClient &client,
 53 mateus.baur 1.1     Boolean enableDebug,
 54 kumpf       1.4     ostream& outPrintWriter,
 55 mateus.baur 1.1     ostream& errPrintWriter)
 56                 {
 57                     _enableDebug = enableDebug;
 58                 
 59                     try
 60                     {
 61                         Boolean deepInheritance = true;
 62                         Boolean localOnly = true;
 63                         Boolean includeQualifiers = false;
 64                         Boolean includeClassOrigin = false;
 65 kumpf       1.4 
 66 mateus.baur 1.1         Array<CIMInstance> cimInstances = client.enumerateInstances(
 67 kumpf       1.4             NAMESPACE,
 68 mateus.baur 1.1             CLASS_NAME,
 69                             deepInheritance,
 70                             localOnly,
 71                             includeQualifiers,
 72                             includeClassOrigin);
 73 kumpf       1.4 
 74 mateus.baur 1.1         Uint32 numberInstances = cimInstances.size();
 75                 
 76                         if (_enableDebug)
 77                         {
 78                             outPrintWriter << numberInstances << " instances of " <<
 79                                 CLASS_NAME.getString() << endl;
 80                         }
 81                 
 82                         if (numberInstances > 0)
 83                         {
 84                             _gatherProperties(cimInstances[0]);
 85                             _outputHeader(outPrintWriter);
 86                 
 87                             for (Uint32 i = 0; i < numberInstances; i++)
 88                             {
 89                                 _gatherProperties(cimInstances[i]);
 90                                 _outputInstance(outPrintWriter);
 91                 
 92                             }   // end for looping through instances.
 93                         }
 94                         else
 95 mateus.baur 1.1         {
 96 kumpf       1.4             outPrintWriter << "No instances of class "
 97 mateus.baur 1.1                 << CLASS_NAME.getString() << endl;
 98                         }
 99                 
100                     }  // end try .
101                     catch(Exception&)
102                     {
103                         errPrintWriter << "Error getting instances of class " <<
104                             CLASS_NAME.getString() << endl;
105                     }
106                 
107                 }
108                 
109                 ////////////////////////////////////////////////////////////////////////////////
110                 //  Destructor for Remote Service Access Point Info
111                 ////////////////////////////////////////////////////////////////////////////////
112                 RSApInfo::~RSApInfo(void)
113                 {
114                 }
115                 
116                 ////////////////////////////////////////////////////////////////////////////////
117                 //  Gather Properities for Remote Service Access Point Info
118 mateus.baur 1.1 ////////////////////////////////////////////////////////////////////////////////
119                 void RSApInfo::_gatherProperties(CIMInstance &inst)
120                 {
121                     _accessInfo = String::EMPTY;
122                 
123                     _infoFormat = 1;
124                     _otherInfoFmtDesc = String("Not Available");
125                 
126                     for (Uint32 j=0; j < inst.getPropertyCount(); j++)
127                     {
128                         CIMName propertyName = inst.getProperty(j).getName();
129                 
130                         // Properties that are also keys
131                         if (propertyName.equal(PROPERTY_ACCESS_INFO))
132                         {
133                             inst.getProperty(j).getValue().get(_accessInfo);
134                         }
135                         // Other properties
136                         else if (propertyName.equal(PROPERTY_INFO_FORMAT))
137                         {
138 kumpf       1.4             inst.getProperty(j).getValue().get(_infoFormat);
139 mateus.baur 1.1         }
140                         else if (propertyName.equal(PROPERTY_OTHER_INFO_FORMAT_DESCRIPTION))
141                         {
142                             _otherInfoFmtDesc.clear();
143 kumpf       1.4             inst.getProperty(j).getValue().get(_otherInfoFmtDesc);
144 mateus.baur 1.1         }
145                    } // end for loop through properties
146                 
147                 }
148                 
149                 
150                 ////////////////////////////////////////////////////////////////////////////////
151                 //  Header Section for Remote Service Access Point Info
152                 ////////////////////////////////////////////////////////////////////////////////
153                 void RSApInfo::_outputHeader(ostream &outPrintWriter)
154                 {
155                 
156 kumpf       1.4     outPrintWriter << endl
157                         << ">>>> Remote Service Access Point Information <<<<"
158 mateus.baur 1.1         << endl << endl;
159                 
160 ashok.pathak 1.5     char header[84];
161 mateus.baur  1.1 
162                      sprintf(
163 kumpf        1.4         header,
164                          HeaderFormat,
165                          "AccessInfo",
166                          "InfoFormat",
167 mateus.baur  1.1         "OtherInfoFormatDescription");
168                  
169                      outPrintWriter << endl << header << endl;
170 kumpf        1.4 
171 mateus.baur  1.1 }
172                  
173                  ////////////////////////////////////////////////////////////////////////////////
174                  //  Output an instance of an Remote Service Access Point Info
175                  ////////////////////////////////////////////////////////////////////////////////
176                  void RSApInfo::_outputInstance(ostream &outPrintWriter)
177                  {
178 ashok.pathak 1.5     char row[84];
179 mateus.baur  1.1 
180                      if (_accessInfo.size() > 31)
181                      {
182                          sprintf(
183 kumpf        1.4             row,
184                              HeaderFormat,
185 mateus.baur  1.1             (const char *)_accessInfo.getCString(),
186                              "",
187                              "");
188                  
189                          outPrintWriter << row << endl;
190                          _accessInfo.clear();
191                      }
192                  
193                      char _if[10];
194                      sprintf(_if,"%d",_infoFormat);
195                  
196                      sprintf(
197                          row,
198                          HeaderFormat,
199                          (const char *)_accessInfo.getCString(),
200                          _if,
201                          (const char *)_otherInfoFmtDesc.getCString());
202                  
203 kumpf        1.4     outPrintWriter << row << endl << endl;
204 mateus.baur  1.1 
205                  }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2