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 s.manicka 1.7 //=============================================================================
|
31 a.dunfey 1.1
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 // 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 s.manicka 1.7 const CIMName
107 CIMXMLCOMMMECH_PROPERTY_CIMXMLPROTOVERSION("CIMXMLProtocolVersion");
|
108 a.dunfey 1.1 const CIMName CIMXMLCOMMMECH_PROPERTY_NAMESPACETYPE("namespaceType");
109 const CIMName CIMXMLCOMMMECH_PROPERTY_NAMESPACEACCESSPROTOCOL(
110 "namespaceAccessProtocol");
111 const CIMName CIMXMLCOMMMECH_PROPERTY_IPADDRESS("IPAddress");
112 #define CIMXMLCOMMMECH_PROPERTY_ELEMENTNAME OM_PROPERTY_ELEMENTNAME
113 #define CIMXMLCOMMMECH_PROPERTY_OPERATIONALSTATUS OM_PROPERTY_OPERATIONALSTATUS
114 #define CIMXMLCOMMMECH_PROPERTY_NAME COMMON_PROPERTY_NAME
115 #define CIMXMLCOMMMECH_PROPERTY_CREATIONCLASSNAME OM_PROPERTY_CREATIONCLASSNAME
116 const CIMName CIMXMLCOMMMECH_PROPERTY_ADVERTISETYPES("AdvertiseTypes");
117
118 //
119 // Fills in the CIMOperation functional profiles and corresponding description
120 // array. This function is closely linked to compile and configuration
121 // features in the CIM Server to determine if certain features are
122 // enabled and/or compiled. Definitions correspond to the DMTF SLP template
123 // version 1.0.
124 // @param Array<Uint16> profiles provides an array for the profiles
125 // @param Array<String> with the corresponding profile text descriptions
126 //
127 void getFunctionalProfiles(
128 Array<Uint16> & profiles,
129 a.dunfey 1.1 Array<String> & profileDescriptions)
130 {
131 // Note that zero and 1 are unknown and other. Not used by us
132 // 2 - 5 are not optional in Pegasus
133 profiles.append(2);
134 profileDescriptions.append("Basic Read");
135
136 profiles.append(3);
137 profileDescriptions.append("Basic Write");
138
139 profiles.append(4);
140 profileDescriptions.append("Schema Manipulation");
141
142 profiles.append(5);
143 profileDescriptions.append("Instance Manipulation");
144
145 ConfigManager* configManager = ConfigManager::getInstance();
146 if (String::equal(configManager->getCurrentValue(
147 "enableAssociationTraversal"), "true"))
148 {
149 profiles.append(6);
150 a.dunfey 1.1 profileDescriptions.append("Association Traversal");
151 }
152 #ifndef PEGASUS_DISABLE_EXECQUERY
153 profiles.append(7);
154 profileDescriptions.append("Query Execution");
155 #endif
156 profiles.append(8);
157 profileDescriptions.append("Qualifier Declaration");
158
159 if (String::equal(configManager->getCurrentValue(
160 "enableIndicationService"), "true"))
161 {
162 profiles.append(9);
163 profileDescriptions.append("Indications");
164 }
165 }
166
167 //
168 // Build a single instance of the CIMXMLCommunicationMechanism class using the
169 // parameters provided. Builds the complete instance and sets its object path.
170 //
171 a.dunfey 1.1 CIMInstance InteropProvider::buildCIMXMLCommunicationMechanismInstance(
172 const String& namespaceType,
173 const Uint16& accessProtocol,
174 const String& IPAddress,
175 const CIMClass & targetClass)
176 {
177 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
178 "InteropProvider::buildCIMXMLCommunicationMechanismInstance()");
179 CIMInstance instance = targetClass.buildInstance(false, false,
180 CIMPropertyList());
181
182 setCommonKeys(instance);
183
184 // CreationClassName property
185 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_CREATIONCLASSNAME,
186 PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM.getString());
187
188 // Name Property
189 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAME,
190 (String("PEGASUSCOMM") + namespaceType));
191
192 a.dunfey 1.1 // CommunicationMechanism Property - Force to 2.
193 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_COMMUNICATIONMECHANISM,
194 Uint16(2));
195
196 //Functional Profiles Supported Property.
197 Array<Uint16> profiles;
198 Array<String> profileDescriptions;
199 getFunctionalProfiles(profiles, profileDescriptions);
200
201 // Set functional profiles for the instance
202 setPropertyValue(instance,
203 CIMXMLCOMMMECH_PROPERTY_FUNCTIONALPROFILESSUPPORTED, profiles);
204
205 setPropertyValue(instance,
206 CIMXMLCOMMMECH_PROPERTY_FUNCTIONALPROFILEDESCRIPTIONS,
207 profileDescriptions);
208
209 // MultipleOperationsSupported Property
210 setPropertyValue(instance,
211 CIMXMLCOMMMECH_PROPERTY_MULTIPLEOPERATIONSSUPPORTED, false);
212
213 a.dunfey 1.1 // AuthenticationMechanismsSupported Property
214 Array<Uint16> authentications;
215 Array<String> authenticationDescriptions;
216
217 //TODO - get from system.
218 authentications.append(3);
219 authenticationDescriptions.append("Basic");
220
221 setPropertyValue(instance,
222 CIMXMLCOMMMECH_PROPERTY_AUTHENTICATIONMECHANISMSSUPPORTED,
223 authentications);
224
225 setPropertyValue(instance,
226 CIMXMLCOMMMECH_PROPERTY_AUTHENTICATIONMECHANISMDESCRIPTIONS,
227 authenticationDescriptions);
228
229 // Version Property
230 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_VERSION,
231 CIMXMLProtocolVersion);
232
|
233 s.manicka 1.7 //Populate "required" property that's not populated.
234 // CIMXMLProtocolVersion Property
235 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_CIMXMLPROTOVERSION,
236 Uint16(1));
237
|
238 a.dunfey 1.1 // NamespaceType Property
239 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAMESPACETYPE,
240 namespaceType);
241
242 // NamespaceAccessProtocol property
243 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAMESPACEACCESSPROTOCOL,
244 accessProtocol);
245
246 // IPAddress property
247 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_IPADDRESS,
248 IPAddress);
249
250 // ElementName property
251 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_ELEMENTNAME,
252 String("Pegasus CIMXML Communication Mechanism"));
253
254 // CIMValidated property
255 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_CIMVALIDATED,
256 Boolean(false));
257
258 // OperationalStatus property
259 a.dunfey 1.1 Array<Uint16> opStatus;
260 opStatus.append(2); // "OK"
261 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_OPERATIONALSTATUS,
262 opStatus);
263
264 // AdvertiseTypes property
265 Array<Uint16> advertiseTypes;
266 ConfigManager* configManager = ConfigManager::getInstance();
267 if (String::equal(configManager->getCurrentValue("slp"), "true"))
268 {
269 advertiseTypes.append(3); // Advertised via SLP
270 }
271 else
272 {
273 advertiseTypes.append(2); // Not advertised
274 }
275 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_ADVERTISETYPES,
276 advertiseTypes);
277
278 // build the instance path and set into instance
279 CIMObjectPath objPath = instance.buildPath(targetClass);
280 a.dunfey 1.1 objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
281 objPath.setHost(hostName);
282 instance.setPath(objPath);
283
284 PEG_METHOD_EXIT();
285 return instance;
286 }
287
288 //
289 // Retrieves all of the instances of CIMXMLCommunicationMechanism for the
290 // CIMOM.
291 //
292 Array<CIMInstance> InteropProvider::enumCIMXMLCommunicationMechanismInstances()
293 {
294 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
295 "InteropProvider::enumCIMXMLCommunicationMechanismInstances");
296
297 ConfigManager* configManager = ConfigManager::getInstance();
298 Boolean enableHttpConnection = String::equal(
299 configManager->getCurrentValue("enableHttpConnection"), "true");
300 Boolean enableHttpsConnection = String::equal(
301 a.dunfey 1.1 configManager->getCurrentValue("enableHttpsConnection"), "true");
302
303 Array<CIMInstance> instances;
304 Uint32 namespaceAccessProtocol;
305 String namespaceType;
306
307 CIMClass commMechClass = repository->getClass(
308 PEGASUS_NAMESPACENAME_INTEROP,
309 PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM, false, true, false);
310
311 if (enableHttpConnection)
312 {
313 // Build the CommunicationMechanism instance for the HTTP protocol
314 namespaceAccessProtocol = 2;
315 namespaceType = "http";
316 String httpPort = configManager->getCurrentValue("httpPort");
317 if (httpPort == String::EMPTY)
318 {
|
319 kumpf 1.3 Uint32 portNumberHttp = System::lookupPort(
320 WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
321 char buffer[32];
322 sprintf(buffer, "%u", portNumberHttp);
323 httpPort.assign(buffer);
|
324 a.dunfey 1.1 }
|
325 venkat.puvvada 1.6 CIMInstance instance;
326 Array<String> ips;
327 #ifdef PEGASUS_ENABLE_IPV6
328 ips = System::getInterfaceAddrs();
329 for (Uint32 i = 0; i < ips.size() ; ++i)
330 {
331 String addr = ips[i];
332 if (HostAddress::isValidIPV6Address(ips[i]))
333 {
334 addr = "[" + addr + "]";
335 }
336 addr.append(":");
337 addr.append(httpPort);
338
339 instance =
340 buildCIMXMLCommunicationMechanismInstance(
341 namespaceType,
342 namespaceAccessProtocol,
343 addr,
344 commMechClass);
345 instances.append(instance);
346 venkat.puvvada 1.6 }
347 #endif
348 // If System::getInterfaceAddrs() fails add ip4 addr here.
349 if (!ips.size())
350 {
351 instance = buildCIMXMLCommunicationMechanismInstance(
|
352 a.dunfey 1.1 namespaceType,
353 namespaceAccessProtocol,
|
354 kumpf 1.3 getHostAddress(hostName, namespaceAccessProtocol, httpPort),
355 commMechClass);
|
356 venkat.puvvada 1.6 instances.append(instance);
357 }
|
358 a.dunfey 1.1 }
359
360 if (enableHttpsConnection)
361 {
362 // Build the CommunicationMechanism instance for the HTTPS protocol
363 namespaceAccessProtocol = 3;
364 namespaceType = "https";
365 String httpsPort = configManager->getCurrentValue("httpsPort");
366 if (httpsPort == String::EMPTY)
367 {
|
368 kumpf 1.3 Uint32 portNumberHttps = System::lookupPort(
369 WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
370 char buffer[32];
371 sprintf(buffer, "%u", portNumberHttps);
372 httpsPort.assign(buffer);
|
373 a.dunfey 1.1 }
|
374 venkat.puvvada 1.6 CIMInstance instance;
375 Array<String> ips;
376 #ifdef PEGASUS_ENABLE_IPV6
377 ips = System::getInterfaceAddrs();
378 for (Uint32 i = 0; i < ips.size() ; ++i)
379 {
380 String addr = ips[i];
381 if (HostAddress::isValidIPV6Address(ips[i]))
382 {
383 addr = "[" + addr + "]";
384 }
385 addr.append(":");
386 addr.append(httpsPort);
387 instance =
388 buildCIMXMLCommunicationMechanismInstance(
389 namespaceType,
390 namespaceAccessProtocol,
391 addr,
392 commMechClass);
393 instances.append(instance);
394 }
395 venkat.puvvada 1.6 #endif
396 // If System::getInterfaceAddrs() fails add ip4 addr here.
397 if (!ips.size())
398 {
399 instance = buildCIMXMLCommunicationMechanismInstance(
|
400 a.dunfey 1.1 namespaceType,
401 namespaceAccessProtocol,
|
402 kumpf 1.3 getHostAddress(hostName, namespaceAccessProtocol, httpsPort),
403 commMechClass);
|
404 venkat.puvvada 1.6 instances.append(instance);
405 }
|
406 a.dunfey 1.1 }
407
408 PEG_METHOD_EXIT();
409 return instances;
410 }
411
412 //
413 // Get the instance of the CIM_ObjectManager class, creating the instance if it
414 // does not already exist in the repository.
415 //
416 // @param includeQualifiers Boolean
417 // @param includeClassOrigin Boolean
418 // @param propertylist CIMPropertyList
419 //
420 // @return CIMInstance with a single built instance of the class
421 //
422 // @exception repository instances if exception to enumerateInstances
423 // for this class.
424 //
425 CIMInstance InteropProvider::getObjectManagerInstance()
426 {
427 a.dunfey 1.1 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
428 "InteropProvider::getObjectManagerInstance");
429
430 // Try to get the instance from the repository.
431 CIMInstance instance;
432 bool found = false;
433 Array<CIMInstance> tmpInstances = repository->enumerateInstancesForClass(
434 PEGASUS_NAMESPACENAME_INTEROP,
435 PEGASUS_CLASSNAME_PG_OBJECTMANAGER, false, false, false,
436 CIMPropertyList());
437 Uint32 numInstances = tmpInstances.size();
438 if(numInstances == 1)
439 {
440 instance = tmpInstances[0];
441 }
442 PEGASUS_ASSERT(numInstances <= 1);
443
444
445 if(instance.isUninitialized())
446 {
447 //
448 a.dunfey 1.1 // No instance in the repository. Build new instance and save it.
449 //
450 CIMClass omClass;
451 instance = buildInstanceSkeleton(PEGASUS_NAMESPACENAME_INTEROP,
452 PEGASUS_CLASSNAME_PG_OBJECTMANAGER, omClass);
453
454 // Set the common key properties
455 setCommonKeys(instance);
456
457 setPropertyValue(instance, OM_PROPERTY_CREATIONCLASSNAME,
458 PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString());
459 setPropertyValue(instance, OM_PROPERTY_NAME,
460 String(PEGASUS_INSTANCEID_GLOBAL_PREFIX) + ":" + Guid::getGuid());
461 setPropertyValue(instance, OM_PROPERTY_ELEMENTNAME, String("Pegasus"));
462 Array<Uint16> operationalStatus;
463 operationalStatus.append(2);
464 setPropertyValue(instance, OM_PROPERTY_OPERATIONALSTATUS,
465 operationalStatus);
466 setPropertyValue(instance, OM_PROPERTY_STARTED,
467 CIMValue(Boolean(true)));
468
469 a.dunfey 1.1 //
470 // Description property this object manager instance.
471 // If PEGASUS_CIMOM_DESCRIPTION is non-zero length, use it.
472 // Otherwise build form the components below, as defined in
473 // PegasusVersion.h.
474 String descriptionStatus;
475 String pegasusProductStatus(PEGASUS_PRODUCT_STATUS);
476 if(pegasusProductStatus.size() > 0)
477 descriptionStatus = " " + pegasusProductStatus;
478
479 String description = (String(PEGASUS_CIMOM_DESCRIPTION).size() != 0) ?
480 String(PEGASUS_CIMOM_DESCRIPTION)
481 :
482 String(PEGASUS_CIMOM_GENERIC_NAME) + " " +
483 String(PEGASUS_PRODUCT_NAME) + " Version " +
484 String(PEGASUS_PRODUCT_VERSION) +
485 descriptionStatus;
486
487 setPropertyValue(instance, OM_PROPERTY_DESCRIPTION, description);
488
489 // Property GatherStatisticalData. Initially this is set to false
490 a.dunfey 1.1 // and can then be modified by a modify instance on the instance.
491 Boolean gatherStatDataFlag = false;
492 setPropertyValue(instance, OM_PROPERTY_GATHERSTATISTICALDATA,
493 gatherStatDataFlag);
494
495 // Set the statistics property into the Statisticaldata class so that
496 // it can perform statistics gathering if necessary.
|
497 kumpf 1.5 #ifndef PEGASUS_DISABLE_PERFINST
|
498 a.dunfey 1.1 StatisticalData* sd = StatisticalData::current();
499 sd->setCopyGSD(gatherStatDataFlag);
|
500 kumpf 1.5 #endif
|
501 a.dunfey 1.1
502 // write instance to the repository
503 CIMObjectPath instancePath = repository->createInstance(
504 PEGASUS_NAMESPACENAME_INTEROP, instance);
505 instance.setPath(instancePath);
506 }
507
508 CIMObjectPath currentPath = instance.getPath();
509 currentPath.setHost(hostName);
510 currentPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
511 instance.setPath(currentPath);
512 PEG_METHOD_EXIT();
513 return instance;
514 }
515
516 //
517 // Modify the existing Object Manager instance. Only a single property
518 // modification is allowed, the statistical data setting. Any other change is
519 // rejected with an exception.
520 //
521 void InteropProvider::modifyObjectManagerInstance(
522 a.dunfey 1.1 const OperationContext & context,
523 const CIMObjectPath & instanceReference,
524 const CIMInstance& modifiedIns,
525 const Boolean includeQualifiers,
526 const CIMPropertyList& propertyList)
527 {
528 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
529 "InteropProvider::modifyObjectManagerInstance");
530
531 // Modification only allowed when Performance staticistics are active
532 #ifndef PEGASUS_DISABLE_PERFINST
533 Uint32 propListSize = propertyList.size();
534 if(propListSize == 0 && !propertyList.isNull())
535 return;
536
537 if(propertyList.size() != 1 ||
538 propertyList[0] != OM_PROPERTY_GATHERSTATISTICALDATA)
539 {
540 throw CIMNotSupportedException(String("Only modification of ") +
541 OM_PROPERTY_GATHERSTATISTICALDATA.getString() + " allowed");
542 }
543 a.dunfey 1.1
544 Boolean statisticsFlag;
545 CIMInstance omInstance;
546
547 // We modify only if this property exists.
548 // could either use the property from modifiedIns or simply replace
549 // value in property from object manager.
550 if (modifiedIns.findProperty(OM_PROPERTY_GATHERSTATISTICALDATA) !=
551 PEG_NOT_FOUND)
552 {
553 omInstance = getObjectManagerInstance();
554 if(omInstance.isUninitialized())
555 {
556 throw CIMObjectNotFoundException(instanceReference.toString());
557 }
558 statisticsFlag = getPropertyValue(modifiedIns,
559 OM_PROPERTY_GATHERSTATISTICALDATA, false);
560 // set the changed property into the instance
561 setPropertyValue(omInstance, OM_PROPERTY_GATHERSTATISTICALDATA,
562 statisticsFlag);
563 }
564 a.dunfey 1.1 else
565 {
566 // if statistics property not in place, simply exit. Nothing to do
567 // not considered an error
568 PEG_METHOD_EXIT();
569 return;
570 }
571 // Modify the instance on disk
|
572 kumpf 1.4 repository->modifyInstance(instanceReference.getNameSpace(),
573 omInstance, false, propertyList);
|
574 marek 1.8 PEG_TRACE((
575 TRC_CONTROLPROVIDER,
576 Tracer::LEVEL3,
577 "Interop Provider Set Statistics gathering in CIM_ObjectManager: %s",
578 (statisticsFlag? "true" : "false")));
|
579 a.dunfey 1.1 StatisticalData* sd = StatisticalData::current();
580 sd->setCopyGSD(statisticsFlag);
581 PEG_METHOD_EXIT();
582 return;
583
584 #else
585 PEG_METHOD_EXIT();
586 throw CIMNotSupportedException
587 (OM_PROPERTY_GATHERSTATISTICALDATA.getString() +
588 " modify operation not supported by Interop Provider");
589 #endif
590 }
591
592
593 //
594 // Get an instance of the PG_ComputerSystem class produced by the
595 // ComputerSystem provider in the root/cimv2 namespace.
596 //
597 // @param includeQualifiers Boolean
598 // @param includeClassOrigin Boolean
599 // @param propertylist CIMPropertyList
600 a.dunfey 1.1 //
601 // @return CIMInstance of PG_ComputerSystem class.
602 //
603 // @exception ObjectNotFound exception if a ComputerSystem instance cannot
604 // be retrieved.
605 //
606 CIMInstance InteropProvider::getComputerSystemInstance()
607 {
608 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
609 "InteropProvider::getComputerSystemInstance");
610
611 CIMInstance instance;
612 AutoMutex mut(interopMut);
613 Array<CIMInstance> tmpInstances = cimomHandle.enumerateInstances(
614 OperationContext(),
615 PEGASUS_NAMESPACENAME_CIMV2,
616 PEGASUS_CLASSNAME_PG_COMPUTERSYSTEM, true, false, false, false,
617 CIMPropertyList());
618 Uint32 numInstances = tmpInstances.size();
619 PEGASUS_ASSERT(numInstances <= 1);
620 if(numInstances > 0)
621 a.dunfey 1.1 {
622 instance = tmpInstances[0];
623 CIMObjectPath tmpPath = instance.getPath();
624 tmpPath.setHost(hostName);
625 tmpPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
626 instance.setPath(tmpPath);
627 }
628
629 if(instance.isUninitialized())
630 {
631 PEG_METHOD_EXIT();
632 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND,
633 "Could not find ComputerSystem instance");
634 }
635
636 PEG_METHOD_EXIT();
637 return instance;
638 }
639
640 //
641 // Returns an instance of the HostedObjectManager association linking the
642 a.dunfey 1.1 // ObjectManager and ComputerSystem instances managed by this provider.
643 //
644 CIMInstance InteropProvider::getHostedObjectManagerInstance()
645 {
646 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
647 "InteropProvider::getHostedObjectManagerInstance");
648
649 // Try to get the current object. If true then it is already created.
650 CIMInstance instance;
651 bool found = false;
652
653 CIMObjectPath csPath = getComputerSystemInstance().getPath();
654 CIMObjectPath omPath = getObjectManagerInstance().getPath();
655 String csPathString = csPath.toString();
656 String omPathString = omPath.toString();
657
658 CIMClass hostedOMClass = repository->getClass(
659 PEGASUS_NAMESPACENAME_INTEROP,
660 PEGASUS_CLASSNAME_PG_HOSTEDOBJECTMANAGER,
661 false, true, false);
662
663 a.dunfey 1.1 instance = hostedOMClass.buildInstance(false, false, CIMPropertyList());
664
665 setPropertyValue(instance, PROPERTY_ANTECEDENT,
666 CIMValue(csPath));
667 setPropertyValue(instance, PROPERTY_DEPENDENT,
668 CIMValue(omPath));
669
670 instance.setPath(instance.buildPath(hostedOMClass));
671
672 PEG_METHOD_EXIT();
673 return instance;
674 }
675
676 //
677 // Returns an array containing all of the HostedAccessPoint association
678 // instances for this CIMOM. One will be produced for every instance of
679 // CIMXMLCommunicatiomMechanism managed by this provider.
680 //
681 Array<CIMInstance> InteropProvider::enumHostedAccessPointInstances()
682 {
683 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
684 a.dunfey 1.1 "InteropProvider::enumHostedAccessPointInstance");
685 Array<CIMInstance> instances;
686
687 CIMObjectPath csPath = getComputerSystemInstance().getPath();
688 Array<CIMInstance> commMechs = enumCIMXMLCommunicationMechanismInstances();
689 CIMClass hapClass = repository->getClass(PEGASUS_NAMESPACENAME_INTEROP,
690 PEGASUS_CLASSNAME_PG_HOSTEDACCESSPOINT, false, true, false);
691 for(Uint32 i = 0, n = commMechs.size(); i < n; ++i)
692 {
693 CIMInstance & currentCommMech = commMechs[i];
694 CIMInstance hapInstance = hapClass.buildInstance(false, false,
695 CIMPropertyList());
696 setPropertyValue(hapInstance, PROPERTY_ANTECEDENT, csPath);
697 setPropertyValue(hapInstance, PROPERTY_DEPENDENT,
698 currentCommMech.getPath());
699 hapInstance.setPath(hapInstance.buildPath(hapClass));
700 instances.append(hapInstance);
701 }
702
703 PEG_METHOD_EXIT();
704 return instances;
705 a.dunfey 1.1 }
706
707
708 //
709 // Returns an array containing all of the CommMechanismForManager association
710 // instances for this CIMOM. One will be produced for every instance of
711 // CIMXMLCommunicatiomMechanism managed by this provider.
712 //
713 Array<CIMInstance> InteropProvider::enumCommMechanismForManagerInstances()
714 {
715 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
716 "InteropProvider::enumCommMechanismForManagerInstances");
717
718 Array<CIMInstance> commInstances =
719 enumCIMXMLCommunicationMechanismInstances();
720
721 CIMInstance instanceObjMgr = getObjectManagerInstance();
722
723 CIMObjectPath refObjMgr = instanceObjMgr.getPath();
724
725 Array<CIMInstance> assocInstances;
726 a.dunfey 1.1 CIMClass targetClass;
727 CIMInstance instanceskel = buildInstanceSkeleton(
728 PEGASUS_NAMESPACENAME_INTEROP,
729 PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER, targetClass);
730 for (Uint32 i = 0, n = commInstances.size(); i < n; ++i)
731 {
732 CIMInstance instance = instanceskel.clone();
733
734 setPropertyValue(instance, PROPERTY_ANTECEDENT, refObjMgr);
735
736 setPropertyValue(instance, PROPERTY_DEPENDENT,
737 commInstances[i].getPath());
738
739 instance.setPath(instance.buildPath(targetClass));
740 assocInstances.append(instance);
741 }
742
743 PEG_METHOD_EXIT();
744 return assocInstances;
745 }
746
|
747 venkat.puvvada 1.9 #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
748
749 CIMInstance InteropProvider::buildAssociationInstance(
750 const CIMName &className,
751 const CIMName &propName1,
752 const CIMObjectPath &objPath1,
753 const CIMName &propName2,
754 const CIMObjectPath &objPath2)
755 {
756 CIMClass cimClass = repository->getClass(
757 PEGASUS_NAMESPACENAME_INTEROP,
758 className,
759 false,
760 true,
761 true);
762
763 CIMInstance instance = cimClass.buildInstance(
764 true,
765 true,
766 CIMPropertyList());
767
768 venkat.puvvada 1.9 instance.getProperty(instance.findProperty(propName1)).setValue(objPath1);
769 instance.getProperty(instance.findProperty(propName2)).setValue(objPath2);
770 instance.setPath(instance.buildPath(cimClass));
771
772 return instance;
773 }
774
775 Array<CIMInstance> InteropProvider::enumElementCapabilityInstances(
776 const OperationContext &opContext)
777 {
778 // Get CIM_IndicationServiceCapabilities instance
779 Array<CIMObjectPath> capPaths = cimomHandle.enumerateInstanceNames(
780 opContext,
781 PEGASUS_NAMESPACENAME_INTEROP,
782 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES);
783 PEGASUS_ASSERT(capPaths.size() == 1);
784
785 // Get CIM_IndicationService instance
786 Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
787 opContext,
788 PEGASUS_NAMESPACENAME_INTEROP,
789 venkat.puvvada 1.9 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
790 PEGASUS_ASSERT(servicePaths.size() == 1);
791
792 Array<CIMInstance> instances;
793
794 instances.append(
795 buildAssociationInstance(
796 PEGASUS_CLASSNAME_PG_ELEMENTCAPABILITIES,
797 PROPERTY_CAPABILITIES,
798 capPaths[0],
799 PROPERTY_MANAGEDELEMENT,
800 servicePaths[0]));
801
802 return instances;
803 }
804
805 Array<CIMInstance> InteropProvider::enumHostedIndicationServiceInstances(
806 const OperationContext &opContext)
807 {
808 Array<CIMInstance> instances;
809 CIMInstance cInst = getComputerSystemInstance();
810 venkat.puvvada 1.9
811 // Get CIM_IndicationService instance
812 Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
813 opContext,
814 PEGASUS_NAMESPACENAME_INTEROP,
815 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
816
817 PEGASUS_ASSERT(servicePaths.size() == 1);
818
819 instances.append(
820 buildAssociationInstance(
821 PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE,
822 PROPERTY_ANTECEDENT,
823 cInst.getPath(),
824 PROPERTY_DEPENDENT,
825 servicePaths[0]));
826
827 return instances;
828 }
829
830 Array<CIMInstance> InteropProvider::enumServiceAffectsElementInstances(
831 venkat.puvvada 1.9 const OperationContext &opContext)
832 {
833 Array<CIMInstance> instances;
834
835 // Get CIM_IndicationService instance
836 Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
837 opContext,
838 PEGASUS_NAMESPACENAME_INTEROP,
839 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
840 PEGASUS_ASSERT(servicePaths.size() == 1);
841
842 Array<CIMNamespaceName> namespaceNames = repository->enumerateNameSpaces();
843 // Get CIM_IndicationFilter and CIM_ListenerDestination instances in all
844 // namespaces and associate them with CIM_IndicationService instance using
845 // PG_ServiceAffectsElement instance.
846 for (Uint32 i = 0, n = namespaceNames.size() ; i < n ; ++i)
847 {
848 Array<CIMObjectPath> filterPaths;
849 try
850 {
851 // Get CIM_IndicationFilter instance names
852 venkat.puvvada 1.9 filterPaths = cimomHandle.enumerateInstanceNames(
853 opContext,
854 namespaceNames[i],
855 PEGASUS_CLASSNAME_INDFILTER);
856 }
857 catch(CIMException &e)
858 {
859 // Ignore exception with CIM_ERR_INVALID_CLASS code. This will
860 // happen when the class CIM_IndicationFilter can not be found
861 // in this namespace.
862 if (e.getCode() != CIM_ERR_INVALID_CLASS)
863 {
864 PEG_TRACE((
865 TRC_CONTROLPROVIDER,
|
866 marek 1.10 Tracer::LEVEL2,
|
867 venkat.puvvada 1.9 "CIMException while enumerating the "
868 "CIM_IndicationFilter instances"
869 " in the namespace %s: %s.",
870 (const char*)namespaceNames[i].getString().getCString(),
871 (const char*)e.getMessage().getCString()));
872 }
873 }
874 catch(Exception &e)
875 {
876 PEG_TRACE((
877 TRC_CONTROLPROVIDER,
878 Tracer::LEVEL1,
879 "Exception while enumerating the "
880 "CIM_IndicationFilter instances"
881 " in the namespace %s: %s.",
882 (const char*)namespaceNames[i].getString().getCString(),
883 (const char*)e.getMessage().getCString()));
884 }
885 catch(...)
886 {
887 PEG_TRACE((
888 venkat.puvvada 1.9 TRC_CONTROLPROVIDER,
|
889 marek 1.10 Tracer::LEVEL1,
|
890 venkat.puvvada 1.9 "Unknown error occurred while enumerating the "
891 "CIM_IndicationFilter instances in the namespace %s.",
892 (const char*)namespaceNames[i].getString().getCString()));
893 }
894 for (Uint32 f = 0, fn = filterPaths.size(); f < fn ; ++f)
895 {
896 filterPaths[f].setNameSpace(namespaceNames[i]);
897 instances.append(
898 buildAssociationInstance(
899 PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT,
900 PROPERTY_AFFECTEDELEMENT,
901 filterPaths[f],
902 PROPERTY_AFFECTINGELEMENT,
903 servicePaths[0]));
904 }
905
906 Array<CIMObjectPath> handlerPaths;
907 try
908 {
909 // Get CIM_ListenerDestination instance names
910 handlerPaths = cimomHandle.enumerateInstanceNames(
911 venkat.puvvada 1.9 opContext,
912 namespaceNames[i],
913 PEGASUS_CLASSNAME_LSTNRDST);
914 }
915 catch(CIMException &e)
916 {
917 // Ignore exception with CIM_ERR_INVALID_CLASS code. This will
918 // happen when the class CIM_ListenerDestination can not be found
919 // in this namespace.
920 if (e.getCode() != CIM_ERR_INVALID_CLASS)
921 {
922 PEG_TRACE((
923 TRC_CONTROLPROVIDER,
|
924 marek 1.10 Tracer::LEVEL2,
|
925 venkat.puvvada 1.9 "CIMException while enumerating the "
926 "CIM_ListenerDestination instances"
927 " in the namespace %s: %s.",
928 (const char*)namespaceNames[i].getString().getCString(),
929 (const char*)e.getMessage().getCString()));
930 }
931 }
932 catch(Exception &e)
933 {
934 PEG_TRACE((
935 TRC_CONTROLPROVIDER,
936 Tracer::LEVEL1,
937 "Exception while enumerating the "
938 "CIM_ListenerDestination instances"
939 " in the namespace %s: %s.",
940 (const char*)namespaceNames[i].getString().getCString(),
941 (const char*)e.getMessage().getCString()));
942 }
943 catch(...)
944 {
945 PEG_TRACE((
946 venkat.puvvada 1.9 TRC_CONTROLPROVIDER,
|
947 marek 1.10 Tracer::LEVEL1,
|
948 venkat.puvvada 1.9 "Unknown error occurred while enumerating the "
949 "CIM_ListenerDestination instances in the namespace %s.",
950 (const char*)namespaceNames[i].getString().getCString()));
951 }
952 for (Uint32 h = 0, hn = handlerPaths.size(); h < hn ; ++h)
953 {
954 handlerPaths[h].setNameSpace(namespaceNames[i]);
955 instances.append(
956 buildAssociationInstance(
957 PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT,
958 PROPERTY_AFFECTEDELEMENT,
959 handlerPaths[h],
960 PROPERTY_AFFECTINGELEMENT,
961 servicePaths[0]));
962 }
963 }
964 return instances;
965 }
966 #endif
967
|
968 a.dunfey 1.2 PEGASUS_NAMESPACE_END
|
969 a.dunfey 1.1
970 // END OF FILE
|