(file) Return to ProviderRegistrar.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / Attic

Diff for /pegasus/src/Pegasus/ProviderManager2/Attic/ProviderRegistrar.cpp between version 1.2 and 1.13

version 1.2, 2003/10/08 16:31:16 version 1.13, 2004/05/21 03:16:37
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2003////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000 - 2003 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development
 // The Open Group, Tivoli Systems  // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
   // IBM Corp.; EMC Corporation, The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 23 
Line 25 
 // //
 // Author: Chip Vincent (cvincent@us.ibm.com) // Author: Chip Vincent (cvincent@us.ibm.com)
 // //
 // Modified By:  // Modified By: Adrian Schuur (schuur@de-ibm.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 32 
Line 34 
 #include <Pegasus/Common/Constants.h> #include <Pegasus/Common/Constants.h>
 #include <Pegasus/Common/Tracer.h> #include <Pegasus/Common/Tracer.h>
 #include <Pegasus/Common/Pair.h> #include <Pegasus/Common/Pair.h>
   #include <Pegasus/Common/Tracer.h>
   #include <Pegasus/Common/Logger.h>
   #include <Pegasus/Common/MessageLoader.h> //l10n
  
 #include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h> #include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
   #include <Pegasus/ProviderManager2/ProviderType.h>
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 64 
Line 70 
         // get the PG_ProviderCapabilities instances for the specified namespace:class_name. use the matching         // get the PG_ProviderCapabilities instances for the specified namespace:class_name. use the matching
         // instance to gather the PG_Provider instance name (logical name).         // instance to gather the PG_Provider instance name (logical name).
  
         Array<CIMInstance> cimInstances = _prm->enumerateInstances(CIMObjectPath(String::EMPTY, "root/PG_Interop", "PG_ProviderCapabilities"));          Array<CIMObjectPath> cimInstanceNames = _prm->enumerateInstanceNames(CIMObjectPath(String::EMPTY, "root/PG_Interop", "PG_ProviderCapabilities"));
  
         for(Uint32 i = 0, n = cimInstances.size(); i < n; i++)          for(Uint32 i = 0, n = cimInstanceNames.size(); i < n; i++)
         {         {
             CIMInstance cimInstance = cimInstances[i];              CIMInstance cimInstance = _prm->getInstance(cimInstanceNames[i]);
  
             // check ClassName property value             // check ClassName property value
             if(String::equalNoCase(cimObjectPath.getClassName().getString(), _getPropertyValue(cimInstance, "ClassName").toString()))             if(String::equalNoCase(cimObjectPath.getClassName().getString(), _getPropertyValue(cimInstance, "ClassName").toString()))
Line 78 
Line 84 
  
                 _getPropertyValue(cimInstance, "Namespaces").get(nameSpaces);                 _getPropertyValue(cimInstance, "Namespaces").get(nameSpaces);
  
                 for(Uint32 i = 0, n = nameSpaces.size(); i < n; i++)                  // ATTN: need to walk the array
                 {                  if(String::equalNoCase(cimObjectPath.getNameSpace().getString(), nameSpaces[0]))
                     if(String::equalNoCase(cimObjectPath.getNameSpace().getString(), nameSpaces[i]))  
                     {                     {
                         providerName = _getPropertyValue(cimInstance, "ProviderName").toString();                         providerName = _getPropertyValue(cimInstance, "ProviderName").toString();
  
Line 89 
Line 94 
                 }                 }
             }             }
         }         }
     }  
     catch(...)     catch(...)
     {     {
     }     }
Line 105 
Line 109 
         // get the PG_Provider instances associated with the specified namespace:class_name. use the matching         // get the PG_Provider instances associated with the specified namespace:class_name. use the matching
         // instance to gather the PG_ProviderModule instance name.         // instance to gather the PG_ProviderModule instance name.
  
         Array<CIMInstance> cimInstances = _prm->enumerateInstances(CIMObjectPath(String::EMPTY, "root/PG_Interop", "PG_Provider"));          Array<CIMObjectPath> cimInstanceNames = _prm->enumerateInstanceNames(CIMObjectPath(String::EMPTY, "root/PG_Interop", "PG_Provider"));
  
         for(Uint32 i = 0, n = cimInstances.size(); i < n; i++)          for(Uint32 i = 0, n = cimInstanceNames.size(); i < n; i++)
         {         {
             CIMInstance cimInstance = cimInstances[i];              CIMInstance cimInstance = _prm->getInstance(cimInstanceNames[i]);
  
             if(String::equalNoCase(providerName, _getPropertyValue(cimInstance, "Name").toString()))             if(String::equalNoCase(providerName, _getPropertyValue(cimInstance, "Name").toString()))
             {             {
Line 137 
Line 141 
         // get the PG_ProviderModule instances associated with the specified namespace:class_name. use the matching         // get the PG_ProviderModule instances associated with the specified namespace:class_name. use the matching
         // instance to gather the module status and location (physical name).         // instance to gather the module status and location (physical name).
  
         Array<CIMInstance> cimInstances = _prm->enumerateInstances(CIMObjectPath(String::EMPTY, "root/PG_Interop", "PG_ProviderModule"));          Array<CIMObjectPath> cimInstanceNames = _prm->enumerateInstanceNames(CIMObjectPath(String::EMPTY, "root/PG_Interop", "PG_ProviderModule"));
  
         for(Uint32 i = 0, n = cimInstances.size(); i < n; i++)          for(Uint32 i = 0, n = cimInstanceNames.size(); i < n; i++)
         {         {
             CIMInstance cimInstance = cimInstances[i];              CIMInstance cimInstance = _prm->getInstance(cimInstanceNames[i]);
  
             if(String::equalNoCase(moduleName, _getPropertyValue(cimInstance, "Name").toString()))             if(String::equalNoCase(moduleName, _getPropertyValue(cimInstance, "Name").toString()))
             {             {
                 // check status                  // ATTN: check operational status
                 if(String::equalNoCase("2", _getPropertyValue(cimInstance, "OperationalStatus").toString()))  
                 {  
                     // get interface                     // get interface
                     interfaceType = _getPropertyValue(cimInstance, "InterfaceType").toString();                     interfaceType = _getPropertyValue(cimInstance, "InterfaceType").toString();
  
Line 158 
Line 161 
                 }                 }
             }             }
         }         }
     }  
     catch(...)     catch(...)
     {     {
     }     }
Line 169 
Line 171 
         throw Exception("Could not determine PG_ProviderModule.InterfaceType or PG_ProviderModule.Location or module is disabled.");         throw Exception("Could not determine PG_ProviderModule.InterfaceType or PG_ProviderModule.Location or module is disabled.");
     }     }
  
     // fully qualify physical provider name (module), if not already done so.      // DEBUG
     #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)      CString s1 = interfaceType.getCString();
     moduleLocation = moduleLocation + String(".dll");      const char * p1 = s1;
     #elif defined(PEGASUS_PLATFORM_LINUX_IX86_GNU) || defined(PEGASUS_PLATFORM_LINUX_IA86_GNU)  
     String temp = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir"));      CString s2 = moduleLocation.getCString();
       const char * p2 = s2;
     moduleLocation = temp + String("/lib") + moduleLocation + String(".so"));  
     #elif defined(PEGASUS_OS_HPUX)  
     String temp = ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("providerDir"));  
   
     moduleLocation = temp + String("/lib") + moduleLocation + String(".sl"));  
     #elif defined(PEGASUS_OS_OS400)  
     // do nothing  
     #else  
     foo // needs code  
     #endif  
  
     ProviderName temp(     ProviderName temp(
         cimObjectPath.toString(),  
         providerName,         providerName,
         moduleLocation,         moduleLocation,
         interfaceType,         interfaceType,
Line 204 
Line 195 
 { {
 } }
  
   ProviderName ProviderRegistrar::findConsumerProvider(const String & destinationPath)
   {
      CIMInstance provider;
      CIMInstance providerModule;
      ProviderName temp;
   
      if (_prm->lookupIndicationConsumer(destinationPath,provider,providerModule))
         return ProviderName(
                  provider.getProperty(provider.findProperty
                      ("Name")).getValue ().toString (),
                  providerModule.getProperty(providerModule.findProperty
                       ("Location")).getValue().toString(),
                  providerModule.getProperty(providerModule.findProperty
                       ("InterfaceType")).getValue().toString(),
                  0);
   
      return temp;
   }
   
   static const Uint16 _MODULE_STOPPING = 9;
   static const Uint16 _MODULE_STOPPED  = 10;
   
   static void checkBlocked(CIMInstance &pm)
   {
       PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "checkBlocked");
   
       Array<Uint16> operationalStatus;
   
       Uint32 pos = pm.findProperty(CIMName ("OperationalStatus"));
       if(pos == PEG_NOT_FOUND) {
           PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,
               "OperationalStatus not found.");
           PEG_METHOD_EXIT();
           //l10n
           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "provider lookup failed.");
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
                                                   "ProviderManager.ProviderManagerService.PROVIDER_LOOKUP_FAILED",
                                                   "provider lookup failed."));
       }
   
       pm.getProperty(pos).getValue().get(operationalStatus);
       for(Uint32 i = 0; i < operationalStatus.size(); i++) {
           if(operationalStatus[i] == _MODULE_STOPPED ||
              operationalStatus[i] == _MODULE_STOPPING) {
               PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,
                   "Provider blocked.");
               PEG_METHOD_EXIT();
                           //l10n
               //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED, "provider blocked.");
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, MessageLoaderParms(
                                   "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",
                                   "provider blocked."));
           }
       }
   }
   
 // need at least the object and the one capability. // need at least the object and the one capability.
 // for example, // for example,
 //  "//localhost/root/cimv2:CIM_ComputerSystem", INSTANCE //  "//localhost/root/cimv2:CIM_ComputerSystem", INSTANCE
Line 213 
Line 260 
  
 // the method will return the logical and physical provider names associated with the object and capability. // the method will return the logical and physical provider names associated with the object and capability.
  
 ProviderName ProviderRegistrar::findProvider(const ProviderName & providerName)  ProviderName ProviderRegistrar::findProvider(const ProviderName & providerName, Boolean test)
 { {
     CIMObjectPath objectName = providerName.getObjectName();   //   CIMObjectPath objectName = providerName.getObjectName();
     Uint32 flags = providerName.getCapabilitiesMask();     Uint32 flags = providerName.getCapabilitiesMask();
  
     // validate arguments     // validate arguments
     if(objectName.getNameSpace().isNull() || objectName.getClassName().isNull() || (flags == 0))  /*    if(objectName.getNameSpace().isNull() || objectName.getClassName().isNull())
     {     {
         throw Exception("Invalid argument.");         throw Exception("Invalid argument.");
     }     }
   */
     ProviderName temp = _lookupProvider(objectName);      CIMInstance provider;
       CIMInstance providerModule;
       ProviderName temp;
       Boolean hasNoQuery;
   
      switch (flags) {
          case ProviderType_INSTANCE:
             if (_prm->lookupInstanceProvider(providerName.getNameSpace(),providerName.getClassName(),
                   provider,providerModule,0)) {
                if (test) checkBlocked(providerModule);
                     return ProviderName(
                        provider.getProperty(provider.findProperty
                          ("Name")).getValue ().toString (),
                             providerModule.getProperty(providerModule.findProperty
                          ("Location")).getValue().toString(),
                        providerModule.getProperty(providerModule.findProperty
                          ("InterfaceType")).getValue().toString(),
                             ProviderType::INSTANCE);
             }
             break;
          case ProviderType_ASSOCIATION:
             if (_prm->lookupInstanceProvider(providerName.getNameSpace(),providerName.getClassName(),
                   provider,providerModule,1)) {
                if (test) checkBlocked(providerModule);
                     return ProviderName(
                        provider.getProperty(provider.findProperty
                          ("Name")).getValue ().toString (),
                             providerModule.getProperty(providerModule.findProperty
                          ("Location")).getValue().toString(),
                        providerModule.getProperty(providerModule.findProperty
                          ("InterfaceType")).getValue().toString(),
                             ProviderType::ASSOCIATION);
             }
             break;
          case ProviderType_QUERY:
             if (_prm->lookupInstanceProvider(providerName.getNameSpace(),providerName.getClassName(),
                   provider,providerModule,0,&hasNoQuery)) {
                if (test) checkBlocked(providerModule);
                     return ProviderName(
                        provider.getProperty(provider.findProperty
                          ("Name")).getValue ().toString (),
                             providerModule.getProperty(providerModule.findProperty
                          ("Location")).getValue().toString(),
                        providerModule.getProperty(providerModule.findProperty
                          ("InterfaceType")).getValue().toString(),
                             ProviderType::INSTANCE);
             }
             break;
           case ProviderType_METHOD:
             if (_prm->lookupMethodProvider(providerName.getNameSpace(),providerName.getClassName(),
                   providerName.getMethodName(),provider,providerModule)) {
                if (test) checkBlocked(providerModule);
                     return ProviderName(
                        provider.getProperty(provider.findProperty
                          ("Name")).getValue ().toString (),
                             providerModule.getProperty(providerModule.findProperty
                          ("Location")).getValue().toString(),
                        providerModule.getProperty(providerModule.findProperty
                          ("InterfaceType")).getValue().toString(),
                             ProviderType::METHOD);
             }
             break;
         default:
             CIMObjectPath objectName(String::EMPTY,
                 providerName.getNameSpace(),providerName.getClassName());
             temp = _lookupProvider(objectName);
       }
  
     return(temp);     return(temp);
 } }
Line 245 
Line 358 
     return(false);     return(false);
 } }
  
 // resolve a partial internal name into a fully qualified (as much as possible) internal  
 // provider name. for example, given a namespace and class name (embedded in the object  
 // name component), this method will determine the physical provider name, the logical  
 // provider name, and the provider capabilities for the specific object name  
 //  
 // given X, this method will provide O.  
 //  
 // physical_name    logical_name    object_name     capabilities  
 // =============================================================  
 //      X  
 //      O                X  
 //      O                O              X                O  
 //  
   
 void SetProviderRegistrationManager(ProviderRegistrationManager * p) void SetProviderRegistrationManager(ProviderRegistrationManager * p)
 { {
     _prm = p;     _prm = p;


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.13

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2