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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2