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