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

Diff for /pegasus/src/Pegasus/ControlProviders/InteropProvider/Server.cpp between version 1.8 and 1.15

version 1.8, 2008/05/12 09:14:52 version 1.15, 2008/12/01 17:50:33
Line 1 
Line 1 
 //%2006////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;  //
 // EMC Corporation; VERITAS Software Corporation; The Open Group.  // Permission is hereby granted, free of charge, to any person obtaining a
 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;  // copy of this software and associated documentation files (the "Software"),
 // EMC Corporation; Symantec Corporation; The Open Group.  // to deal in the Software without restriction, including without limitation
 //  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // and/or sell copies of the Software, and to permit persons to whom the
 // of this software and associated documentation files (the "Software"), to  // Software is furnished to do so, subject to the following conditions:
 // deal in the Software without restriction, including without limitation the  //
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // The above copyright notice and this permission notice shall be included
 // sell copies of the Software, and to permit persons to whom the Software is  // in all copies or substantial portions of the Software.
 // furnished to do so, subject to the following conditions:  //
 //  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
 // //
 //=============================================================================  //////////////////////////////////////////////////////////////////////////
  
  
 /////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
Line 186 
Line 184 
         PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM.getString());         PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM.getString());
  
     // Name Property     // Name Property
       String nameProperty(STRLIT_ARGS("PEGASUSCOMM"));
       nameProperty.append(namespaceType);
       nameProperty.append(Char16('+'));
       nameProperty.append(IPAddress);
   
     setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAME,     setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAME,
         (String("PEGASUSCOMM") + namespaceType));          nameProperty);
  
     // CommunicationMechanism Property - Force to 2.     // CommunicationMechanism Property - Force to 2.
     setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_COMMUNICATIONMECHANISM,     setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_COMMUNICATIONMECHANISM,
Line 263 
Line 266 
  
     // AdvertiseTypes property     // AdvertiseTypes property
     Array<Uint16> advertiseTypes;     Array<Uint16> advertiseTypes;
     ConfigManager* configManager = ConfigManager::getInstance();      if (enableSLP)
     if (String::equal(configManager->getCurrentValue("slp"), "true"))  
     {     {
         advertiseTypes.append(3); // Advertised via SLP         advertiseTypes.append(3); // Advertised via SLP
     }     }
Line 308 
Line 310 
         PEGASUS_NAMESPACENAME_INTEROP,         PEGASUS_NAMESPACENAME_INTEROP,
         PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM, false, true, false);         PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM, false, true, false);
  
       Array<String> ips;
   #ifdef PEGASUS_ENABLE_IPV6
       ips = System::getInterfaceAddrs();
   #endif
     if (enableHttpConnection)     if (enableHttpConnection)
     {     {
         // Build the CommunicationMechanism instance for the HTTP protocol         // Build the CommunicationMechanism instance for the HTTP protocol
         namespaceAccessProtocol = 2;         namespaceAccessProtocol = 2;
         namespaceType = "http";         namespaceType = "http";
         String httpPort = configManager->getCurrentValue("httpPort");  
         if (httpPort == String::EMPTY)  
         {  
             Uint32 portNumberHttp = System::lookupPort(  
                 WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);  
             char buffer[32];  
             sprintf(buffer, "%u", portNumberHttp);  
             httpPort.assign(buffer);  
         }  
         CIMInstance instance;         CIMInstance instance;
         Array<String> ips;  
 #ifdef PEGASUS_ENABLE_IPV6  
         ips = System::getInterfaceAddrs();  
         for (Uint32 i = 0; i < ips.size() ; ++i)         for (Uint32 i = 0; i < ips.size() ; ++i)
         {         {
             String addr = ips[i];             String addr = ips[i];
Line 344 
Line 338 
                     commMechClass);                     commMechClass);
             instances.append(instance);             instances.append(instance);
         }         }
 #endif  
         // If System::getInterfaceAddrs() fails add ip4 addr here.         // If System::getInterfaceAddrs() fails add ip4 addr here.
         if (!ips.size())         if (!ips.size())
         {         {
Line 362 
Line 355 
         // Build the CommunicationMechanism instance for the HTTPS protocol         // Build the CommunicationMechanism instance for the HTTPS protocol
         namespaceAccessProtocol = 3;         namespaceAccessProtocol = 3;
         namespaceType = "https";         namespaceType = "https";
         String httpsPort = configManager->getCurrentValue("httpsPort");  
         if (httpsPort == String::EMPTY)  
         {  
             Uint32 portNumberHttps = System::lookupPort(  
                 WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);  
             char buffer[32];  
             sprintf(buffer, "%u", portNumberHttps);  
             httpsPort.assign(buffer);  
         }  
         CIMInstance instance;         CIMInstance instance;
         Array<String> ips;  
 #ifdef PEGASUS_ENABLE_IPV6  
         ips = System::getInterfaceAddrs();  
         for (Uint32 i = 0; i < ips.size() ; ++i)         for (Uint32 i = 0; i < ips.size() ; ++i)
         {         {
             String addr = ips[i];             String addr = ips[i];
Line 392 
Line 373 
                     commMechClass);                     commMechClass);
             instances.append(instance);             instances.append(instance);
         }         }
 #endif  
         // If System::getInterfaceAddrs() fails add ip4 addr here.         // If System::getInterfaceAddrs() fails add ip4 addr here.
         if (!ips.size())         if (!ips.size())
         {         {
Line 449 
Line 429 
         //         //
         CIMClass omClass;         CIMClass omClass;
         instance = buildInstanceSkeleton(PEGASUS_NAMESPACENAME_INTEROP,         instance = buildInstanceSkeleton(PEGASUS_NAMESPACENAME_INTEROP,
             PEGASUS_CLASSNAME_PG_OBJECTMANAGER, omClass);              PEGASUS_CLASSNAME_PG_OBJECTMANAGER, false, omClass);
  
         // Set the common key properties         // Set the common key properties
         setCommonKeys(instance);         setCommonKeys(instance);
Line 502 
Line 482 
         // write instance to the repository         // write instance to the repository
         CIMObjectPath instancePath = repository->createInstance(         CIMObjectPath instancePath = repository->createInstance(
             PEGASUS_NAMESPACENAME_INTEROP, instance);             PEGASUS_NAMESPACENAME_INTEROP, instance);
           // Get an updated copy of the instance that was saved
           instance = repository->getInstance(
               PEGASUS_NAMESPACENAME_INTEROP, instancePath, false);
         instance.setPath(instancePath);         instance.setPath(instancePath);
     }     }
  
Line 726 
Line 709 
     CIMClass targetClass;     CIMClass targetClass;
     CIMInstance instanceskel = buildInstanceSkeleton(     CIMInstance instanceskel = buildInstanceSkeleton(
         PEGASUS_NAMESPACENAME_INTEROP,         PEGASUS_NAMESPACENAME_INTEROP,
         PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER, targetClass);          PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER, true, targetClass);
     for (Uint32 i = 0, n = commInstances.size(); i < n; ++i)     for (Uint32 i = 0, n = commInstances.size(); i < n; ++i)
     {     {
         CIMInstance instance = instanceskel.clone();         CIMInstance instance = instanceskel.clone();
Line 744 
Line 727 
     return assocInstances;     return assocInstances;
 } }
  
   #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
   
   CIMInstance InteropProvider::buildAssociationInstance(
       const CIMName &className,
       const CIMName &propName1,
       const CIMObjectPath &objPath1,
       const CIMName &propName2,
       const CIMObjectPath &objPath2)
   {
       CIMClass cimClass = repository->getClass(
           PEGASUS_NAMESPACENAME_INTEROP,
           className,
           false,
           true,
           true);
   
       CIMInstance instance = cimClass.buildInstance(
           true,
           true,
           CIMPropertyList());
   
       instance.getProperty(instance.findProperty(propName1)).setValue(objPath1);
       instance.getProperty(instance.findProperty(propName2)).setValue(objPath2);
       instance.setPath(instance.buildPath(cimClass));
   
       return instance;
   }
   
   Array<CIMInstance> InteropProvider::enumElementCapabilityInstances(
       const OperationContext &opContext)
   {
       // Get CIM_IndicationServiceCapabilities instance
       Array<CIMObjectPath> capPaths = cimomHandle.enumerateInstanceNames(
           opContext,
           PEGASUS_NAMESPACENAME_INTEROP,
           PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES);
       PEGASUS_ASSERT(capPaths.size() == 1);
   
       // Get CIM_IndicationService instance
       Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
           opContext,
           PEGASUS_NAMESPACENAME_INTEROP,
           PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
       PEGASUS_ASSERT(servicePaths.size() == 1);
   
       Array<CIMInstance> instances;
   
       instances.append(
           buildAssociationInstance(
               PEGASUS_CLASSNAME_PG_ELEMENTCAPABILITIES,
               PROPERTY_CAPABILITIES,
               capPaths[0],
               PROPERTY_MANAGEDELEMENT,
               servicePaths[0]));
   
       return instances;
   }
   
   Array<CIMInstance> InteropProvider::enumHostedIndicationServiceInstances(
       const OperationContext &opContext)
   {
       Array<CIMInstance> instances;
       CIMInstance cInst = getComputerSystemInstance();
   
       // Get CIM_IndicationService instance
       Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
           opContext,
           PEGASUS_NAMESPACENAME_INTEROP,
           PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
   
       PEGASUS_ASSERT(servicePaths.size() == 1);
   
       instances.append(
           buildAssociationInstance(
               PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE,
               PROPERTY_ANTECEDENT,
               cInst.getPath(),
               PROPERTY_DEPENDENT,
               servicePaths[0]));
   
       return instances;
   }
   
   Array<CIMInstance> InteropProvider::enumServiceAffectsElementInstances(
       const OperationContext &opContext)
   {
       Array<CIMInstance> instances;
   
       // Get CIM_IndicationService instance
       Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
           opContext,
           PEGASUS_NAMESPACENAME_INTEROP,
           PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
       PEGASUS_ASSERT(servicePaths.size() == 1);
   
       Array<CIMNamespaceName> namespaceNames = repository->enumerateNameSpaces();
       // Get CIM_IndicationFilter and CIM_ListenerDestination instances in all
       // namespaces and associate them with CIM_IndicationService instance using
       // PG_ServiceAffectsElement instance.
       for (Uint32 i = 0, n = namespaceNames.size() ; i < n ; ++i)
       {
           Array<CIMObjectPath> filterPaths;
           try
           {
               // Get CIM_IndicationFilter instance names
               filterPaths = cimomHandle.enumerateInstanceNames(
                   opContext,
                   namespaceNames[i],
                   PEGASUS_CLASSNAME_INDFILTER);
           }
           catch(CIMException &e)
           {
               // Ignore exception with CIM_ERR_INVALID_CLASS code. This will
               // happen when the class CIM_IndicationFilter can not be found
               // in this namespace.
               if (e.getCode() != CIM_ERR_INVALID_CLASS)
               {
                   PEG_TRACE((
                       TRC_CONTROLPROVIDER,
                       Tracer::LEVEL2,
                       "CIMException while enumerating the "
                           "CIM_IndicationFilter instances"
                               " in the namespace %s: %s.",
                        (const char*)namespaceNames[i].getString().getCString(),
                        (const char*)e.getMessage().getCString()));
               }
           }
           catch(Exception &e)
           {
               PEG_TRACE((
                   TRC_CONTROLPROVIDER,
                   Tracer::LEVEL1,
                   "Exception while enumerating the "
                       "CIM_IndicationFilter instances"
                           " in the namespace %s: %s.",
                   (const char*)namespaceNames[i].getString().getCString(),
                   (const char*)e.getMessage().getCString()));
           }
           catch(...)
           {
               PEG_TRACE((
                   TRC_CONTROLPROVIDER,
                   Tracer::LEVEL1,
                   "Unknown error occurred while enumerating the "
                       "CIM_IndicationFilter instances in the namespace %s.",
                   (const char*)namespaceNames[i].getString().getCString()));
           }
           for (Uint32 f = 0, fn = filterPaths.size(); f < fn ; ++f)
           {
               filterPaths[f].setNameSpace(namespaceNames[i]);
               instances.append(
                   buildAssociationInstance(
                       PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT,
                       PROPERTY_AFFECTEDELEMENT,
                       filterPaths[f],
                       PROPERTY_AFFECTINGELEMENT,
                       servicePaths[0]));
           }
   
           Array<CIMObjectPath> handlerPaths;
           try
           {
               // Get CIM_ListenerDestination instance names
               handlerPaths = cimomHandle.enumerateInstanceNames(
                   opContext,
                   namespaceNames[i],
                   PEGASUS_CLASSNAME_LSTNRDST);
           }
           catch(CIMException &e)
           {
               // Ignore exception with CIM_ERR_INVALID_CLASS code. This will
               // happen when the class CIM_ListenerDestination can not be found
               // in this namespace.
               if (e.getCode() != CIM_ERR_INVALID_CLASS)
               {
                   PEG_TRACE((
                       TRC_CONTROLPROVIDER,
                       Tracer::LEVEL2,
                       "CIMException while enumerating the "
                           "CIM_ListenerDestination instances"
                               " in the namespace %s: %s.",
                        (const char*)namespaceNames[i].getString().getCString(),
                        (const char*)e.getMessage().getCString()));
               }
           }
           catch(Exception &e)
           {
               PEG_TRACE((
                   TRC_CONTROLPROVIDER,
                   Tracer::LEVEL1,
                   "Exception while enumerating the "
                       "CIM_ListenerDestination instances"
                           " in the namespace %s: %s.",
                   (const char*)namespaceNames[i].getString().getCString(),
                   (const char*)e.getMessage().getCString()));
           }
           catch(...)
           {
               PEG_TRACE((
                   TRC_CONTROLPROVIDER,
                   Tracer::LEVEL1,
                   "Unknown error occurred while enumerating the "
                       "CIM_ListenerDestination instances in the namespace %s.",
                   (const char*)namespaceNames[i].getString().getCString()));
           }
           for (Uint32 h = 0, hn = handlerPaths.size(); h < hn ; ++h)
           {
               handlerPaths[h].setNameSpace(namespaceNames[i]);
               instances.append(
                   buildAssociationInstance(
                       PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT,
                       PROPERTY_AFFECTEDELEMENT,
                       handlerPaths[h],
                       PROPERTY_AFFECTINGELEMENT,
                       servicePaths[0]));
           }
       }
       return instances;
   }
   #endif
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
  
 // END OF FILE // END OF FILE


Legend:
Removed from v.1.8  
changed lines
  Added in v.1.15

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2