(file) Return to Server.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ControlProviders / InteropProvider

  1 a.dunfey 1.1 //%2006////////////////////////////////////////////////////////////////////////
  2              //
  3              // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4              // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5              // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6              // IBM Corp.; EMC Corporation, The Open Group.
  7              // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8              // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9              // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10              // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11              // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12              // EMC Corporation; Symantec Corporation; The Open Group.
 13              //
 14              // Permission is hereby granted, free of charge, to any person obtaining a copy
 15              // of this software and associated documentation files (the "Software"), to
 16              // deal in the Software without restriction, including without limitation the
 17              // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18              // sell copies of the Software, and to permit persons to whom the Software is
 19              // furnished to do so, subject to the following conditions:
 20              // 
 21              // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 a.dunfey 1.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23              // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24              // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25              // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26              // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27              // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28              // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29              //
 30              //==============================================================================
 31              
 32              
 33              ///////////////////////////////////////////////////////////////////////////////
 34              //  Interop Provider - This provider services those classes from the
 35              //  DMTF Interop schema in an implementation compliant with the SMI-S v1.1
 36              //  Server Profile
 37              //
 38              //  Please see PG_ServerProfile20.mof in the directory
 39              //  $(PEGASUS_ROOT)/Schemas/Pegasus/InterOp/VER20 for retails regarding the
 40              //  classes supported by this control provider.
 41              //
 42              //  Interop forces all creates to the PEGASUS_NAMESPACENAME_INTEROP 
 43 a.dunfey 1.1 //  namespace. There is a test on each operation that returns 
 44              //  the Invalid Class CIMDError
 45              //  This is a control provider and as such uses the Tracer functions
 46              //  for data and function traces.  Since we do not expect high volume
 47              //  use we added a number of traces to help diagnostics.
 48              ///////////////////////////////////////////////////////////////////////////////
 49              
 50              
 51              #include <Pegasus/Common/Config.h>
 52              #include <Pegasus/Common/PegasusVersion.h>
 53              
 54              #include <cctype>
 55              #include <iostream>
 56              
 57              #include "InteropProvider.h"
 58              #include "InteropProviderUtils.h"
 59              #include "InteropConstants.h"
 60              #include "Guid.h"
 61              
 62              #include <Pegasus/Common/StatisticalData.h>
 63              
 64 a.dunfey 1.1 PEGASUS_USING_STD;
 65 a.dunfey 1.2 PEGASUS_NAMESPACE_BEGIN
 66 a.dunfey 1.1 
 67              const String CIMXMLProtocolVersion = "1.0";
 68              
 69              // Property names for ObjectManager Class
 70              //#define OM_PROPERTY_NAME COMMON_PROPERTY_NAME
 71              #define OM_PROPERTY_ELEMENTNAME COMMON_PROPERTY_ELEMENTNAME
 72              #define OM_PROPERTY_CREATIONCLASSNAME COMMON_PROPERTY_CREATIONCLASSNAME
 73              //const CIMName OM_PROPERTY_GATHERSTATISTICALDATA("GatherStatisticalData");
 74              const CIMName OM_PROPERTY_DESCRIPTION("Description");
 75              const CIMName OM_PROPERTY_COMMUNICATIONMECHANISM("CommunicationMechanism");
 76              const CIMName OM_PROPERTY_FUNCTIONALPROFILESSUPPORTED(
 77                  "FunctionalProfilesSupported");
 78              const CIMName OM_PROPERTY_FUNCTIONALPROFILEDESCRIPTIONS(
 79                  "FunctionalProfileDescriptions");
 80              const CIMName OM_PROPERTY_AUTHENTICATIONMECHANISMSSUPPORTED(
 81                  "AuthenticationMechanismsSupported");
 82              const CIMName OM_PROPERTY_AUTHENTICATIONMECHANISMDESCRIPTIONS(
 83                  "AuthenticationMechanismDescriptions");
 84              const CIMName OM_PROPERTY_MULTIPLEOPERATIONSSUPPORTED(
 85                  "MultipleOperationsSupported");
 86              const CIMName OM_PROPERTY_VERSION("Version");
 87 a.dunfey 1.1 const CIMName OM_PROPERTY_OPERATIONALSTATUS("OperationalStatus");
 88              const CIMName OM_PROPERTY_STARTED("Started");
 89              
 90              // Property Names for CIMXML CommunicationMechanism
 91              const CIMName CIMXMLCOMMMECH_PROPERTY_CIMVALIDATED("CIMValidated");
 92              const CIMName CIMXMLCOMMMECH_PROPERTY_COMMUNICATIONMECHANISM(
 93                      "CommunicationMechanism");
 94              const CIMName CIMXMLCOMMMECH_PROPERTY_FUNCTIONALPROFILESSUPPORTED(
 95                      "FunctionalProfilesSupported");
 96              const CIMName CIMXMLCOMMMECH_PROPERTY_FUNCTIONALPROFILEDESCRIPTIONS(
 97                      "FunctionalProfileDescriptions");
 98              const CIMName CIMXMLCOMMMECH_PROPERTY_AUTHENTICATIONMECHANISMSSUPPORTED(
 99                      "AuthenticationMechanismsSupported");
100              const CIMName CIMXMLCOMMMECH_PROPERTY_AUTHENTICATIONMECHANISMDESCRIPTIONS(
101                      "AuthenticationMechanismDescriptions");
102              const CIMName CIMXMLCOMMMECH_PROPERTY_MULTIPLEOPERATIONSSUPPORTED(
103                      "MultipleOperationsSupported");
104              const CIMName CIMXMLCOMMMECH_PROPERTY_VERSION("Version");
105              const CIMName CIMXMLCOMMMECH_PROPERTY_NAMESPACETYPE("namespaceType");
106              const CIMName CIMXMLCOMMMECH_PROPERTY_NAMESPACEACCESSPROTOCOL(
107                  "namespaceAccessProtocol");
108 a.dunfey 1.1 const CIMName CIMXMLCOMMMECH_PROPERTY_IPADDRESS("IPAddress");
109              #define CIMXMLCOMMMECH_PROPERTY_ELEMENTNAME OM_PROPERTY_ELEMENTNAME
110              #define CIMXMLCOMMMECH_PROPERTY_OPERATIONALSTATUS OM_PROPERTY_OPERATIONALSTATUS
111              #define CIMXMLCOMMMECH_PROPERTY_NAME COMMON_PROPERTY_NAME
112              #define CIMXMLCOMMMECH_PROPERTY_CREATIONCLASSNAME OM_PROPERTY_CREATIONCLASSNAME
113              const CIMName CIMXMLCOMMMECH_PROPERTY_ADVERTISETYPES("AdvertiseTypes");
114              
115              //
116              // Fills in the CIMOperation functional profiles and corresponding description
117              // array.  This function is closely linked to compile and configuration
118              // features in the CIM Server to determine if certain features are 
119              // enabled and/or compiled.  Definitions correspond to the DMTF SLP template
120              // version 1.0.
121              // @param Array<Uint16> profiles provides an array for the profiles
122              // @param Array<String> with the corresponding profile text descriptions
123              //
124              void getFunctionalProfiles(
125                  Array<Uint16> & profiles,
126                  Array<String> & profileDescriptions)
127              {
128                  // Note that zero and 1 are unknown and other. Not used by us
129 a.dunfey 1.1     // 2 - 5 are not optional in Pegasus
130                  profiles.append(2);
131                  profileDescriptions.append("Basic Read");
132              
133                  profiles.append(3);
134                  profileDescriptions.append("Basic Write");
135              
136                  profiles.append(4);
137                  profileDescriptions.append("Schema Manipulation");
138              
139                  profiles.append(5);
140                  profileDescriptions.append("Instance Manipulation");
141              
142                  ConfigManager* configManager = ConfigManager::getInstance();
143                  if (String::equal(configManager->getCurrentValue(
144                      "enableAssociationTraversal"), "true"))
145                  {
146                      profiles.append(6);
147                      profileDescriptions.append("Association Traversal");
148                  }
149              #ifndef PEGASUS_DISABLE_EXECQUERY
150 a.dunfey 1.1     profiles.append(7);
151                  profileDescriptions.append("Query Execution");
152              #endif
153                  profiles.append(8);
154                  profileDescriptions.append("Qualifier Declaration");
155              
156                  if (String::equal(configManager->getCurrentValue(
157                      "enableIndicationService"), "true"))
158                  {
159                      profiles.append(9);
160                      profileDescriptions.append("Indications");
161                  }
162              }
163              
164              //
165              // Build a single instance of the CIMXMLCommunicationMechanism class using the
166              // parameters provided. Builds the complete instance and sets its object path.
167              //
168              CIMInstance InteropProvider::buildCIMXMLCommunicationMechanismInstance(
169                          const String& namespaceType,
170                          const Uint16& accessProtocol,
171 a.dunfey 1.1             const String& IPAddress,
172                          const CIMClass & targetClass)
173              {
174                  PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
175                          "InteropProvider::buildCIMXMLCommunicationMechanismInstance()");
176                  CIMInstance instance = targetClass.buildInstance(false, false,
177                      CIMPropertyList());
178              
179                  setCommonKeys(instance);
180              
181                  // CreationClassName property
182                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_CREATIONCLASSNAME,
183                      PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM.getString());
184              
185                  // Name Property
186                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAME,
187                      (String("PEGASUSCOMM") + namespaceType));
188              
189                  // CommunicationMechanism Property - Force to 2.
190                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_COMMUNICATIONMECHANISM,
191                      Uint16(2));
192 a.dunfey 1.1 
193                  //Functional Profiles Supported Property.
194                  Array<Uint16> profiles;
195                  Array<String> profileDescriptions;
196                  getFunctionalProfiles(profiles, profileDescriptions);
197              
198                  // Set functional profiles for the instance
199                  setPropertyValue(instance,
200                      CIMXMLCOMMMECH_PROPERTY_FUNCTIONALPROFILESSUPPORTED, profiles);
201              
202                  setPropertyValue(instance,
203                      CIMXMLCOMMMECH_PROPERTY_FUNCTIONALPROFILEDESCRIPTIONS,
204                      profileDescriptions);
205              
206                  // MultipleOperationsSupported Property
207                  setPropertyValue(instance,
208                      CIMXMLCOMMMECH_PROPERTY_MULTIPLEOPERATIONSSUPPORTED, false);
209              
210                  // AuthenticationMechanismsSupported Property
211                  Array<Uint16> authentications;
212                  Array<String> authenticationDescriptions;
213 a.dunfey 1.1 
214                  //TODO - get from system.
215                  authentications.append(3);
216                  authenticationDescriptions.append("Basic");
217              
218                  setPropertyValue(instance,
219                      CIMXMLCOMMMECH_PROPERTY_AUTHENTICATIONMECHANISMSSUPPORTED,
220                      authentications);
221              
222                  setPropertyValue(instance,
223                      CIMXMLCOMMMECH_PROPERTY_AUTHENTICATIONMECHANISMDESCRIPTIONS,
224                      authenticationDescriptions);
225              
226                  // Version Property
227                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_VERSION,
228                      CIMXMLProtocolVersion);
229              
230                  // NamespaceType Property
231                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAMESPACETYPE,
232                      namespaceType);
233              
234 a.dunfey 1.1     // NamespaceAccessProtocol property
235                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAMESPACEACCESSPROTOCOL,
236                      accessProtocol);
237              
238                  // IPAddress property
239                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_IPADDRESS,
240                      IPAddress);
241              
242                  // ElementName property
243                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_ELEMENTNAME,
244                      String("Pegasus CIMXML Communication Mechanism"));
245              
246                  // CIMValidated property
247                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_CIMVALIDATED,
248                      Boolean(false));
249              
250                  // OperationalStatus property
251                  Array<Uint16> opStatus;
252                  opStatus.append(2); // "OK"
253                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_OPERATIONALSTATUS,
254                      opStatus);
255 a.dunfey 1.1 
256                  // AdvertiseTypes property
257                  Array<Uint16> advertiseTypes;
258                  ConfigManager* configManager = ConfigManager::getInstance();
259                  if (String::equal(configManager->getCurrentValue("slp"), "true"))
260                  {
261                      advertiseTypes.append(3); // Advertised via SLP
262                  }
263                  else
264                  {
265                      advertiseTypes.append(2); // Not advertised
266                  }
267                  setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_ADVERTISETYPES,
268                      advertiseTypes);
269              
270                  // build the instance path and set into instance
271                  CIMObjectPath objPath = instance.buildPath(targetClass);
272                  objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
273                  objPath.setHost(hostName);
274                  instance.setPath(objPath);
275              
276 a.dunfey 1.1     PEG_METHOD_EXIT();
277                  return instance;
278              }
279              
280              //
281              // Retrieves all of the instances of CIMXMLCommunicationMechanism for the
282              // CIMOM.
283              //
284              Array<CIMInstance> InteropProvider::enumCIMXMLCommunicationMechanismInstances()
285              {
286                  PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
287                          "InteropProvider::enumCIMXMLCommunicationMechanismInstances");
288              
289                  ConfigManager* configManager = ConfigManager::getInstance();
290                  Boolean enableHttpConnection = String::equal(
291                      configManager->getCurrentValue("enableHttpConnection"), "true");
292                  Boolean enableHttpsConnection = String::equal(
293                      configManager->getCurrentValue("enableHttpsConnection"), "true");
294              
295                  Array<CIMInstance> instances;
296                  Uint32 namespaceAccessProtocol;
297 a.dunfey 1.1     String namespaceType;
298              
299                  CIMClass commMechClass = repository->getClass(
300                      PEGASUS_NAMESPACENAME_INTEROP,
301                      PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM, false, true, false);
302              
303                  if (enableHttpConnection)
304                  {
305                      // Build the CommunicationMechanism instance for the HTTP protocol
306                      namespaceAccessProtocol = 2;
307                      namespaceType = "http";
308                      Uint32 portNumberHttp;
309                      String httpPort = configManager->getCurrentValue("httpPort");
310                      if (httpPort == String::EMPTY)
311                      {
312                          portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME,
313                              WBEM_DEFAULT_HTTP_PORT);
314                      }
315                      CIMInstance instance = 
316                          buildCIMXMLCommunicationMechanismInstance(
317                              namespaceType,
318 a.dunfey 1.1                 namespaceAccessProtocol,
319                              getHostAddress(hostName, namespaceAccessProtocol, httpPort,
320                                  portNumberHttp), commMechClass);
321                      instances.append(instance);
322                  }
323              
324                  if (enableHttpsConnection)
325                  {
326                      // Build the CommunicationMechanism instance for the HTTPS protocol
327                      namespaceAccessProtocol = 3;
328                      namespaceType = "https";
329                      Uint32 portNumberHttps;
330                      String httpsPort = configManager->getCurrentValue("httpsPort");
331                      if (httpsPort == String::EMPTY)
332                      {
333                          portNumberHttps = System::lookupPort(WBEM_HTTPS_SERVICE_NAME,
334                              WBEM_DEFAULT_HTTPS_PORT);
335                      }
336                      CIMInstance instance = 
337                          buildCIMXMLCommunicationMechanismInstance(
338                              namespaceType,
339 a.dunfey 1.1                 namespaceAccessProtocol,
340                              getHostAddress(hostName, namespaceAccessProtocol, httpsPort,
341                                  portNumberHttps), commMechClass);
342              
343                      instances.append(instance);
344                  }
345              
346              
347                  PEG_METHOD_EXIT();
348                  return instances;
349              }
350              
351              //
352              // Get the instance of the CIM_ObjectManager class, creating the instance if it
353              // does not already exist in the repository.
354              //
355              // @param includeQualifiers Boolean
356              // @param includeClassOrigin Boolean
357              // @param propertylist CIMPropertyList
358              //
359              // @return CIMInstance with a single built instance of the class
360 a.dunfey 1.1 //
361              // @exception repository instances if exception to enumerateInstances
362              // for this class.
363              //
364              CIMInstance InteropProvider::getObjectManagerInstance()
365              {
366                  PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
367                      "InteropProvider::getObjectManagerInstance");
368              
369                  // Try to get the instance from the repository.
370                  CIMInstance instance;
371                  bool found = false;
372                  Array<CIMInstance> tmpInstances = repository->enumerateInstancesForClass(
373                      PEGASUS_NAMESPACENAME_INTEROP,
374                      PEGASUS_CLASSNAME_PG_OBJECTMANAGER, false, false, false,
375                      CIMPropertyList());
376                  Uint32 numInstances = tmpInstances.size();
377                  if(numInstances == 1)
378                  {
379                      instance = tmpInstances[0];
380                  }
381 a.dunfey 1.1     PEGASUS_ASSERT(numInstances <= 1);
382              
383              
384                  if(instance.isUninitialized())
385                  {
386                      //
387                      // No instance in the repository. Build new instance and save it.
388                      //
389                      CIMClass omClass;
390                      instance = buildInstanceSkeleton(PEGASUS_NAMESPACENAME_INTEROP,
391                          PEGASUS_CLASSNAME_PG_OBJECTMANAGER, omClass);
392              
393                      // Set the common key properties
394                      setCommonKeys(instance);
395              
396                      setPropertyValue(instance, OM_PROPERTY_CREATIONCLASSNAME,
397                          PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString());
398                      setPropertyValue(instance, OM_PROPERTY_NAME,
399                          String(PEGASUS_INSTANCEID_GLOBAL_PREFIX) + ":" + Guid::getGuid());
400                      setPropertyValue(instance, OM_PROPERTY_ELEMENTNAME, String("Pegasus"));
401                      Array<Uint16> operationalStatus;
402 a.dunfey 1.1         operationalStatus.append(2);
403                      setPropertyValue(instance, OM_PROPERTY_OPERATIONALSTATUS,
404                          operationalStatus);
405                      setPropertyValue(instance, OM_PROPERTY_STARTED,
406                          CIMValue(Boolean(true)));
407              
408                      //
409                      // Description property this object manager instance.
410                      // If PEGASUS_CIMOM_DESCRIPTION is non-zero length, use it.
411                      // Otherwise build form the components below, as defined in
412                      // PegasusVersion.h.
413                      String descriptionStatus;
414                      String pegasusProductStatus(PEGASUS_PRODUCT_STATUS);
415                      if(pegasusProductStatus.size() > 0)
416                          descriptionStatus = " " + pegasusProductStatus;
417              
418                      String description = (String(PEGASUS_CIMOM_DESCRIPTION).size() != 0) ?
419                              String(PEGASUS_CIMOM_DESCRIPTION)
420                          :
421                              String(PEGASUS_CIMOM_GENERIC_NAME) + " " +
422                              String(PEGASUS_PRODUCT_NAME) + " Version " +
423 a.dunfey 1.1                 String(PEGASUS_PRODUCT_VERSION) +
424                              descriptionStatus;
425              
426                      setPropertyValue(instance, OM_PROPERTY_DESCRIPTION, description);
427              
428                      // Property GatherStatisticalData. Initially this is set to false
429                      // and can then be modified by a modify instance on the instance.
430                      Boolean gatherStatDataFlag = false;
431                      setPropertyValue(instance, OM_PROPERTY_GATHERSTATISTICALDATA,
432                          gatherStatDataFlag);
433              
434                      // Set the statistics property into the Statisticaldata class so that
435                      // it can perform statistics gathering if necessary.
436                  #ifndef PEGASUS_DISABLE_PERFINST
437                      StatisticalData* sd = StatisticalData::current();
438                      sd->setCopyGSD(gatherStatDataFlag);
439                  #endif
440              
441                      // write instance to the repository
442                      CIMObjectPath instancePath = repository->createInstance(
443                          PEGASUS_NAMESPACENAME_INTEROP, instance);
444 a.dunfey 1.1         instance.setPath(instancePath);
445                  }
446              
447                  CIMObjectPath currentPath = instance.getPath();
448                  currentPath.setHost(hostName);
449                  currentPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
450                  instance.setPath(currentPath);
451                  PEG_METHOD_EXIT();
452                  return instance;
453              }
454              
455              //
456              // Modify the existing Object Manager instance.  Only a single property
457              // modification is allowed, the statistical data setting.  Any other change is
458              // rejected with an exception.
459              //
460              void InteropProvider::modifyObjectManagerInstance(
461                  const OperationContext & context,
462                  const CIMObjectPath & instanceReference,
463                  const CIMInstance& modifiedIns,
464                  const Boolean includeQualifiers,
465 a.dunfey 1.1     const CIMPropertyList& propertyList)
466              {
467                  PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
468                      "InteropProvider::modifyObjectManagerInstance");
469              
470                  // Modification only allowed when Performance staticistics are active
471              #ifndef PEGASUS_DISABLE_PERFINST
472                  Uint32 propListSize = propertyList.size();
473                  if(propListSize == 0 && !propertyList.isNull())
474                      return;
475              
476                  if(propertyList.size() != 1 ||
477                      propertyList[0] != OM_PROPERTY_GATHERSTATISTICALDATA)
478                  {
479                      throw CIMNotSupportedException(String("Only modification of ") +
480                          OM_PROPERTY_GATHERSTATISTICALDATA.getString() + " allowed");
481                  }
482              
483                  Boolean statisticsFlag;
484                  CIMInstance omInstance;
485              
486 a.dunfey 1.1     // We modify only if this property exists.
487                  // could either use the property from modifiedIns or simply replace
488                  // value in property from object manager.
489                  if (modifiedIns.findProperty(OM_PROPERTY_GATHERSTATISTICALDATA) !=
490                      PEG_NOT_FOUND)
491                  {
492                      omInstance = getObjectManagerInstance();
493                      if(omInstance.isUninitialized())
494                      {
495                          throw CIMObjectNotFoundException(instanceReference.toString());
496                      }
497                      statisticsFlag = getPropertyValue(modifiedIns,
498                          OM_PROPERTY_GATHERSTATISTICALDATA, false);
499                      // set the changed property into the instance
500                      setPropertyValue(omInstance, OM_PROPERTY_GATHERSTATISTICALDATA,
501                          statisticsFlag);
502                  }
503                  else
504                  {
505                      // if statistics property not in place, simply exit. Nothing to do
506                      // not considered an error
507 a.dunfey 1.1         PEG_METHOD_EXIT();
508                      return;
509                  }
510                  // Modify the instance on disk
511                  try
512                  {
513                      repository->modifyInstance(instanceReference.getNameSpace(),
514                          omInstance, false,  propertyList);
515                  }
516                  catch(const CIMException&)
517                  {
518                      PEG_METHOD_EXIT();
519                      throw;
520                  }
521                  catch(const Exception&)
522                  {
523                      PEG_METHOD_EXIT();
524                      throw;
525                  }
526                  Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
527                      "Interop Provider Set Statistics gathering in CIM_ObjectManager: $0",
528 a.dunfey 1.1         (statisticsFlag? "true" : "false"));
529                  StatisticalData* sd = StatisticalData::current();
530                  sd->setCopyGSD(statisticsFlag);
531                  PEG_METHOD_EXIT();
532                  return;
533              
534              #else
535                  PEG_METHOD_EXIT();
536                  throw CIMNotSupportedException
537                      (OM_PROPERTY_GATHERSTATISTICALDATA.getString() + 
538                              " modify operation not supported by Interop Provider");
539              #endif
540              }
541              
542              
543              //
544              // Get an instance of the PG_ComputerSystem class produced by the
545              // ComputerSystem provider in the root/cimv2 namespace.
546              //
547              // @param includeQualifiers Boolean
548              // @param includeClassOrigin Boolean
549 a.dunfey 1.1 // @param propertylist CIMPropertyList
550              //
551              // @return CIMInstance of PG_ComputerSystem class.
552              //
553              // @exception ObjectNotFound exception if a ComputerSystem instance cannot
554              //     be retrieved.
555              //
556              CIMInstance InteropProvider::getComputerSystemInstance()
557              {
558                  PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
559                      "InteropProvider::getComputerSystemInstance");
560              
561                  CIMInstance instance;
562                  AutoMutex mut(interopMut);
563                  Array<CIMInstance> tmpInstances = cimomHandle.enumerateInstances(
564                      OperationContext(),
565                      PEGASUS_NAMESPACENAME_CIMV2,
566                      PEGASUS_CLASSNAME_PG_COMPUTERSYSTEM, true, false, false, false,
567                      CIMPropertyList());
568                  Uint32 numInstances = tmpInstances.size();
569                  PEGASUS_ASSERT(numInstances <= 1);
570 a.dunfey 1.1     if(numInstances > 0)
571                  {
572                      instance = tmpInstances[0];
573                      CIMObjectPath tmpPath = instance.getPath();
574                      tmpPath.setHost(hostName);
575                      tmpPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
576                      instance.setPath(tmpPath);
577                  }
578              
579                  if(instance.isUninitialized())
580                  {
581                      PEG_METHOD_EXIT();
582                      throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND,
583                          "Could not find ComputerSystem instance");
584                  }
585              
586                  PEG_METHOD_EXIT();
587                  return instance;
588              }
589              
590              //
591 a.dunfey 1.1 // Returns an instance of the HostedObjectManager association linking the
592              // ObjectManager and ComputerSystem instances managed by this provider.
593              //
594              CIMInstance InteropProvider::getHostedObjectManagerInstance()
595              {
596                  PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
597                      "InteropProvider::getHostedObjectManagerInstance");
598              
599                  // Try to get the current object.  If true then it is already created.
600                  CIMInstance instance;
601                  bool found = false;
602              
603                  CIMObjectPath csPath = getComputerSystemInstance().getPath();
604                  CIMObjectPath omPath = getObjectManagerInstance().getPath();
605                  String csPathString = csPath.toString();
606                  String omPathString = omPath.toString();
607              
608                  CIMClass hostedOMClass = repository->getClass(
609                      PEGASUS_NAMESPACENAME_INTEROP,
610                      PEGASUS_CLASSNAME_PG_HOSTEDOBJECTMANAGER,
611                      false, true, false);
612 a.dunfey 1.1 
613                  instance = hostedOMClass.buildInstance(false, false, CIMPropertyList());
614              
615                  setPropertyValue(instance, PROPERTY_ANTECEDENT,
616                      CIMValue(csPath));
617                  setPropertyValue(instance, PROPERTY_DEPENDENT,
618                      CIMValue(omPath));
619              
620                  instance.setPath(instance.buildPath(hostedOMClass));
621              
622                  PEG_METHOD_EXIT();
623                  return instance;
624              }
625              
626              //
627              // Returns an array containing all of the HostedAccessPoint association
628              // instances for this CIMOM. One will be produced for every instance of
629              // CIMXMLCommunicatiomMechanism managed by this provider.
630              //
631              Array<CIMInstance> InteropProvider::enumHostedAccessPointInstances()
632              {
633 a.dunfey 1.1     PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
634                      "InteropProvider::enumHostedAccessPointInstance");
635                  Array<CIMInstance> instances;
636              
637                  CIMObjectPath csPath = getComputerSystemInstance().getPath();
638                  Array<CIMInstance> commMechs = enumCIMXMLCommunicationMechanismInstances();
639                  CIMClass hapClass = repository->getClass(PEGASUS_NAMESPACENAME_INTEROP,
640                      PEGASUS_CLASSNAME_PG_HOSTEDACCESSPOINT, false, true, false);
641                  for(Uint32 i = 0, n = commMechs.size(); i < n; ++i)
642                  {
643                      CIMInstance & currentCommMech = commMechs[i];
644                      CIMInstance hapInstance = hapClass.buildInstance(false, false,
645                          CIMPropertyList());
646                      setPropertyValue(hapInstance, PROPERTY_ANTECEDENT, csPath);
647                      setPropertyValue(hapInstance, PROPERTY_DEPENDENT,
648                          currentCommMech.getPath());
649                      hapInstance.setPath(hapInstance.buildPath(hapClass));
650                      instances.append(hapInstance);
651                  }
652              
653                  PEG_METHOD_EXIT();
654 a.dunfey 1.1     return instances;
655              }
656              
657              
658              //
659              // Returns an array containing all of the CommMechanismForManager association
660              // instances for this CIMOM. One will be produced for every instance of
661              // CIMXMLCommunicatiomMechanism managed by this provider.
662              //
663              Array<CIMInstance> InteropProvider::enumCommMechanismForManagerInstances()
664              {
665                  PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
666                      "InteropProvider::enumCommMechanismForManagerInstances");
667              
668                  Array<CIMInstance> commInstances =
669                      enumCIMXMLCommunicationMechanismInstances();
670              
671                  CIMInstance instanceObjMgr = getObjectManagerInstance();
672              
673                  CIMObjectPath refObjMgr = instanceObjMgr.getPath();
674              
675 a.dunfey 1.1     Array<CIMInstance> assocInstances;
676                  CIMClass targetClass;
677                  CIMInstance instanceskel = buildInstanceSkeleton(
678                      PEGASUS_NAMESPACENAME_INTEROP, 
679                      PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER, targetClass);
680                  for (Uint32 i = 0, n = commInstances.size(); i < n; ++i)
681                  {
682                      CIMInstance instance = instanceskel.clone();
683              
684                      setPropertyValue(instance, PROPERTY_ANTECEDENT, refObjMgr);
685              
686                      setPropertyValue(instance, PROPERTY_DEPENDENT,
687                        commInstances[i].getPath());
688              
689                      instance.setPath(instance.buildPath(targetClass));
690                      assocInstances.append(instance);
691                  }
692              
693                  PEG_METHOD_EXIT();
694                  return assocInstances;
695              }
696 a.dunfey 1.1 
697 a.dunfey 1.2 PEGASUS_NAMESPACE_END
698 a.dunfey 1.1 
699              // END OF FILE

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2