1 martin 1.15 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.16 //
|
3 martin 1.15 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.16 //
|
10 martin 1.15 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.16 //
|
17 martin 1.15 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.16 //
|
20 martin 1.15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.16 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.15 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.16 //
|
28 martin 1.15 //////////////////////////////////////////////////////////////////////////
|
29 a.dunfey 1.1
30
31 ///////////////////////////////////////////////////////////////////////////////
32 // Interop Provider - This provider services those classes from the
33 // DMTF Interop schema in an implementation compliant with the SMI-S v1.1
34 // Server Profile
35 //
36 // Please see PG_ServerProfile20.mof in the directory
37 // $(PEGASUS_ROOT)/Schemas/Pegasus/InterOp/VER20 for retails regarding the
38 // classes supported by this control provider.
39 //
|
40 kumpf 1.17 // Interop forces all creates to the PEGASUS_NAMESPACENAME_INTEROP
41 // namespace. There is a test on each operation that returns
|
42 a.dunfey 1.1 // the Invalid Class CIMDError
43 // This is a control provider and as such uses the Tracer functions
44 // for data and function traces. Since we do not expect high volume
45 // use we added a number of traces to help diagnostics.
46 ///////////////////////////////////////////////////////////////////////////////
47
48
49 #include <Pegasus/Common/Config.h>
|
50 venkat.puvvada 1.6 #include <Pegasus/Common/HostAddress.h>
|
51 a.dunfey 1.1 #include <Pegasus/Common/PegasusVersion.h>
52
53 #include <cctype>
54 #include <iostream>
55
56 #include "InteropProvider.h"
57 #include "InteropProviderUtils.h"
58 #include "InteropConstants.h"
59 #include "Guid.h"
60
61 #include <Pegasus/Common/StatisticalData.h>
62
63 PEGASUS_USING_STD;
|
64 a.dunfey 1.2 PEGASUS_NAMESPACE_BEGIN
|
65 a.dunfey 1.1
66 const String CIMXMLProtocolVersion = "1.0";
67
68 // Property names for ObjectManager Class
69 //#define OM_PROPERTY_NAME COMMON_PROPERTY_NAME
70 #define OM_PROPERTY_ELEMENTNAME COMMON_PROPERTY_ELEMENTNAME
71 #define OM_PROPERTY_CREATIONCLASSNAME COMMON_PROPERTY_CREATIONCLASSNAME
72 //const CIMName OM_PROPERTY_GATHERSTATISTICALDATA("GatherStatisticalData");
73 const CIMName OM_PROPERTY_DESCRIPTION("Description");
74 const CIMName OM_PROPERTY_COMMUNICATIONMECHANISM("CommunicationMechanism");
75 const CIMName OM_PROPERTY_FUNCTIONALPROFILESSUPPORTED(
76 "FunctionalProfilesSupported");
77 const CIMName OM_PROPERTY_FUNCTIONALPROFILEDESCRIPTIONS(
78 "FunctionalProfileDescriptions");
79 const CIMName OM_PROPERTY_AUTHENTICATIONMECHANISMSSUPPORTED(
80 "AuthenticationMechanismsSupported");
81 const CIMName OM_PROPERTY_AUTHENTICATIONMECHANISMDESCRIPTIONS(
82 "AuthenticationMechanismDescriptions");
83 const CIMName OM_PROPERTY_MULTIPLEOPERATIONSSUPPORTED(
84 "MultipleOperationsSupported");
85 const CIMName OM_PROPERTY_VERSION("Version");
86 a.dunfey 1.1 const CIMName OM_PROPERTY_OPERATIONALSTATUS("OperationalStatus");
87 const CIMName OM_PROPERTY_STARTED("Started");
88
89 // Property Names for CIMXML CommunicationMechanism
90 const CIMName CIMXMLCOMMMECH_PROPERTY_CIMVALIDATED("CIMValidated");
91 const CIMName CIMXMLCOMMMECH_PROPERTY_COMMUNICATIONMECHANISM(
92 "CommunicationMechanism");
93 const CIMName CIMXMLCOMMMECH_PROPERTY_FUNCTIONALPROFILESSUPPORTED(
94 "FunctionalProfilesSupported");
95 const CIMName CIMXMLCOMMMECH_PROPERTY_FUNCTIONALPROFILEDESCRIPTIONS(
96 "FunctionalProfileDescriptions");
97 const CIMName CIMXMLCOMMMECH_PROPERTY_AUTHENTICATIONMECHANISMSSUPPORTED(
98 "AuthenticationMechanismsSupported");
99 const CIMName CIMXMLCOMMMECH_PROPERTY_AUTHENTICATIONMECHANISMDESCRIPTIONS(
100 "AuthenticationMechanismDescriptions");
101 const CIMName CIMXMLCOMMMECH_PROPERTY_MULTIPLEOPERATIONSSUPPORTED(
102 "MultipleOperationsSupported");
103 const CIMName CIMXMLCOMMMECH_PROPERTY_VERSION("Version");
|
104 kumpf 1.17 const CIMName
|
105 s.manicka 1.7 CIMXMLCOMMMECH_PROPERTY_CIMXMLPROTOVERSION("CIMXMLProtocolVersion");
|
106 a.dunfey 1.1 const CIMName CIMXMLCOMMMECH_PROPERTY_NAMESPACETYPE("namespaceType");
107 const CIMName CIMXMLCOMMMECH_PROPERTY_NAMESPACEACCESSPROTOCOL(
108 "namespaceAccessProtocol");
109 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 kumpf 1.17 // features in the CIM Server to determine if certain features are
|
120 a.dunfey 1.1 // 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 // 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 a.dunfey 1.1 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 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 a.dunfey 1.1 }
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 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 a.dunfey 1.1 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_CREATIONCLASSNAME,
184 PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM.getString());
185
186 // Name Property
|
187 s.manicka 1.11 String nameProperty(STRLIT_ARGS("PEGASUSCOMM"));
188 nameProperty.append(namespaceType);
189 nameProperty.append(Char16('+'));
190 nameProperty.append(IPAddress);
191
|
192 a.dunfey 1.1 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAME,
|
193 s.manicka 1.11 nameProperty);
|
194 a.dunfey 1.1
195 // CommunicationMechanism Property - Force to 2.
196 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_COMMUNICATIONMECHANISM,
197 Uint16(2));
198
199 //Functional Profiles Supported Property.
200 Array<Uint16> profiles;
201 Array<String> profileDescriptions;
202 getFunctionalProfiles(profiles, profileDescriptions);
203
204 // Set functional profiles for the instance
205 setPropertyValue(instance,
206 CIMXMLCOMMMECH_PROPERTY_FUNCTIONALPROFILESSUPPORTED, profiles);
207
208 setPropertyValue(instance,
209 CIMXMLCOMMMECH_PROPERTY_FUNCTIONALPROFILEDESCRIPTIONS,
210 profileDescriptions);
211
212 // MultipleOperationsSupported Property
213 setPropertyValue(instance,
214 CIMXMLCOMMMECH_PROPERTY_MULTIPLEOPERATIONSSUPPORTED, false);
215 a.dunfey 1.1
216 // AuthenticationMechanismsSupported Property
217 Array<Uint16> authentications;
218 Array<String> authenticationDescriptions;
219
220 //TODO - get from system.
221 authentications.append(3);
222 authenticationDescriptions.append("Basic");
223
224 setPropertyValue(instance,
225 CIMXMLCOMMMECH_PROPERTY_AUTHENTICATIONMECHANISMSSUPPORTED,
226 authentications);
227
228 setPropertyValue(instance,
229 CIMXMLCOMMMECH_PROPERTY_AUTHENTICATIONMECHANISMDESCRIPTIONS,
230 authenticationDescriptions);
231
232 // Version Property
233 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_VERSION,
234 CIMXMLProtocolVersion);
235
|
236 s.manicka 1.7 //Populate "required" property that's not populated.
237 // CIMXMLProtocolVersion Property
238 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_CIMXMLPROTOVERSION,
239 Uint16(1));
240
|
241 a.dunfey 1.1 // NamespaceType Property
242 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAMESPACETYPE,
243 namespaceType);
244
245 // NamespaceAccessProtocol property
246 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_NAMESPACEACCESSPROTOCOL,
247 accessProtocol);
248
249 // IPAddress property
250 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_IPADDRESS,
251 IPAddress);
252
253 // ElementName property
254 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_ELEMENTNAME,
255 String("Pegasus CIMXML Communication Mechanism"));
256
257 // CIMValidated property
258 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_CIMVALIDATED,
259 Boolean(false));
260
261 // OperationalStatus property
262 a.dunfey 1.1 Array<Uint16> opStatus;
263 opStatus.append(2); // "OK"
264 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_OPERATIONALSTATUS,
265 opStatus);
266
267 // AdvertiseTypes property
268 Array<Uint16> advertiseTypes;
|
269 s.kodali 1.12 if (enableSLP)
|
270 a.dunfey 1.1 {
271 advertiseTypes.append(3); // Advertised via SLP
272 }
273 else
274 {
275 advertiseTypes.append(2); // Not advertised
276 }
277 setPropertyValue(instance, CIMXMLCOMMMECH_PROPERTY_ADVERTISETYPES,
278 advertiseTypes);
279
280 // build the instance path and set into instance
281 CIMObjectPath objPath = instance.buildPath(targetClass);
282 objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
283 objPath.setHost(hostName);
284 instance.setPath(objPath);
285
286 PEG_METHOD_EXIT();
287 return instance;
288 }
289
290 //
291 a.dunfey 1.1 // Retrieves all of the instances of CIMXMLCommunicationMechanism for the
292 // CIMOM.
293 //
294 Array<CIMInstance> InteropProvider::enumCIMXMLCommunicationMechanismInstances()
295 {
296 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
297 "InteropProvider::enumCIMXMLCommunicationMechanismInstances");
298
299 ConfigManager* configManager = ConfigManager::getInstance();
300 Boolean enableHttpConnection = String::equal(
301 configManager->getCurrentValue("enableHttpConnection"), "true");
302 Boolean enableHttpsConnection = String::equal(
303 configManager->getCurrentValue("enableHttpsConnection"), "true");
304
305 Array<CIMInstance> instances;
306 Uint32 namespaceAccessProtocol;
307 String namespaceType;
308
309 CIMClass commMechClass = repository->getClass(
310 PEGASUS_NAMESPACENAME_INTEROP,
311 PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM, false, true, false);
312 a.dunfey 1.1
|
313 venkat.puvvada 1.13 Array<String> ips;
314 #ifdef PEGASUS_ENABLE_IPV6
315 ips = System::getInterfaceAddrs();
316 #endif
|
317 a.dunfey 1.1 if (enableHttpConnection)
318 {
319 // Build the CommunicationMechanism instance for the HTTP protocol
320 namespaceAccessProtocol = 2;
321 namespaceType = "http";
|
322 venkat.puvvada 1.6 CIMInstance instance;
323 for (Uint32 i = 0; i < ips.size() ; ++i)
324 {
325 String addr = ips[i];
326 if (HostAddress::isValidIPV6Address(ips[i]))
327 {
328 addr = "[" + addr + "]";
329 }
330 addr.append(":");
331 addr.append(httpPort);
|
332 kumpf 1.17
|
333 venkat.puvvada 1.6 instance =
334 buildCIMXMLCommunicationMechanismInstance(
335 namespaceType,
336 namespaceAccessProtocol,
337 addr,
338 commMechClass);
339 instances.append(instance);
340 }
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 venkat.puvvada 1.6 CIMInstance instance;
359 for (Uint32 i = 0; i < ips.size() ; ++i)
360 {
361 String addr = ips[i];
362 if (HostAddress::isValidIPV6Address(ips[i]))
363 {
364 addr = "[" + addr + "]";
365 }
|
366 kumpf 1.17 addr.append(":");
367 addr.append(httpsPort);
|
368 venkat.puvvada 1.6 instance =
369 buildCIMXMLCommunicationMechanismInstance(
370 namespaceType,
371 namespaceAccessProtocol,
372 addr,
373 commMechClass);
374 instances.append(instance);
375 }
376 // If System::getInterfaceAddrs() fails add ip4 addr here.
377 if (!ips.size())
378 {
379 instance = buildCIMXMLCommunicationMechanismInstance(
|
380 a.dunfey 1.1 namespaceType,
381 namespaceAccessProtocol,
|
382 kumpf 1.3 getHostAddress(hostName, namespaceAccessProtocol, httpsPort),
383 commMechClass);
|
384 venkat.puvvada 1.6 instances.append(instance);
385 }
|
386 a.dunfey 1.1 }
387
388 PEG_METHOD_EXIT();
389 return instances;
390 }
391
392 //
393 // Get the instance of the CIM_ObjectManager class, creating the instance if it
394 // does not already exist in the repository.
395 //
396 // @param includeQualifiers Boolean
397 // @param includeClassOrigin Boolean
398 // @param propertylist CIMPropertyList
399 //
400 // @return CIMInstance with a single built instance of the class
401 //
402 // @exception repository instances if exception to enumerateInstances
403 // for this class.
404 //
405 CIMInstance InteropProvider::getObjectManagerInstance()
406 {
407 a.dunfey 1.1 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
408 "InteropProvider::getObjectManagerInstance");
409
410 // Try to get the instance from the repository.
411 CIMInstance instance;
412 bool found = false;
413 Array<CIMInstance> tmpInstances = repository->enumerateInstancesForClass(
414 PEGASUS_NAMESPACENAME_INTEROP,
|
415 kumpf 1.18 PEGASUS_CLASSNAME_PG_OBJECTMANAGER, false, false,
|
416 a.dunfey 1.1 CIMPropertyList());
417 Uint32 numInstances = tmpInstances.size();
418 if(numInstances == 1)
419 {
420 instance = tmpInstances[0];
421 }
422 PEGASUS_ASSERT(numInstances <= 1);
423
424
425 if(instance.isUninitialized())
426 {
427 //
428 // No instance in the repository. Build new instance and save it.
429 //
430 CIMClass omClass;
431 instance = buildInstanceSkeleton(PEGASUS_NAMESPACENAME_INTEROP,
|
432 kumpf 1.14 PEGASUS_CLASSNAME_PG_OBJECTMANAGER, false, omClass);
|
433 a.dunfey 1.1
434 // Set the common key properties
435 setCommonKeys(instance);
436
437 setPropertyValue(instance, OM_PROPERTY_CREATIONCLASSNAME,
438 PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString());
439 setPropertyValue(instance, OM_PROPERTY_NAME,
440 String(PEGASUS_INSTANCEID_GLOBAL_PREFIX) + ":" + Guid::getGuid());
441 setPropertyValue(instance, OM_PROPERTY_ELEMENTNAME, String("Pegasus"));
442 Array<Uint16> operationalStatus;
443 operationalStatus.append(2);
444 setPropertyValue(instance, OM_PROPERTY_OPERATIONALSTATUS,
445 operationalStatus);
446 setPropertyValue(instance, OM_PROPERTY_STARTED,
447 CIMValue(Boolean(true)));
448
449 //
450 // Description property this object manager instance.
451 // If PEGASUS_CIMOM_DESCRIPTION is non-zero length, use it.
452 // Otherwise build form the components below, as defined in
453 // PegasusVersion.h.
454 a.dunfey 1.1 String descriptionStatus;
455 String pegasusProductStatus(PEGASUS_PRODUCT_STATUS);
456 if(pegasusProductStatus.size() > 0)
457 descriptionStatus = " " + pegasusProductStatus;
458
459 String description = (String(PEGASUS_CIMOM_DESCRIPTION).size() != 0) ?
460 String(PEGASUS_CIMOM_DESCRIPTION)
461 :
462 String(PEGASUS_CIMOM_GENERIC_NAME) + " " +
463 String(PEGASUS_PRODUCT_NAME) + " Version " +
464 String(PEGASUS_PRODUCT_VERSION) +
465 descriptionStatus;
466
467 setPropertyValue(instance, OM_PROPERTY_DESCRIPTION, description);
468
469 // Property GatherStatisticalData. Initially this is set to false
470 // and can then be modified by a modify instance on the instance.
471 Boolean gatherStatDataFlag = false;
472 setPropertyValue(instance, OM_PROPERTY_GATHERSTATISTICALDATA,
473 gatherStatDataFlag);
474
475 a.dunfey 1.1 // Set the statistics property into the Statisticaldata class so that
476 // it can perform statistics gathering if necessary.
|
477 kumpf 1.5 #ifndef PEGASUS_DISABLE_PERFINST
|
478 a.dunfey 1.1 StatisticalData* sd = StatisticalData::current();
479 sd->setCopyGSD(gatherStatDataFlag);
|
480 kumpf 1.5 #endif
|
481 a.dunfey 1.1
482 // write instance to the repository
483 CIMObjectPath instancePath = repository->createInstance(
484 PEGASUS_NAMESPACENAME_INTEROP, instance);
|
485 kumpf 1.14 // Get an updated copy of the instance that was saved
486 instance = repository->getInstance(
|
487 kumpf 1.18 PEGASUS_NAMESPACENAME_INTEROP, instancePath);
|
488 a.dunfey 1.1 instance.setPath(instancePath);
489 }
490
491 CIMObjectPath currentPath = instance.getPath();
492 currentPath.setHost(hostName);
493 currentPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
494 instance.setPath(currentPath);
495 PEG_METHOD_EXIT();
496 return instance;
497 }
498
499 //
500 // Modify the existing Object Manager instance. Only a single property
501 // modification is allowed, the statistical data setting. Any other change is
502 // rejected with an exception.
503 //
504 void InteropProvider::modifyObjectManagerInstance(
505 const OperationContext & context,
506 const CIMObjectPath & instanceReference,
507 const CIMInstance& modifiedIns,
508 const Boolean includeQualifiers,
509 a.dunfey 1.1 const CIMPropertyList& propertyList)
510 {
511 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
512 "InteropProvider::modifyObjectManagerInstance");
513
514 // Modification only allowed when Performance staticistics are active
515 #ifndef PEGASUS_DISABLE_PERFINST
516 Uint32 propListSize = propertyList.size();
517 if(propListSize == 0 && !propertyList.isNull())
518 return;
519
520 if(propertyList.size() != 1 ||
521 propertyList[0] != OM_PROPERTY_GATHERSTATISTICALDATA)
522 {
523 throw CIMNotSupportedException(String("Only modification of ") +
524 OM_PROPERTY_GATHERSTATISTICALDATA.getString() + " allowed");
525 }
526
527 Boolean statisticsFlag;
528 CIMInstance omInstance;
529
530 a.dunfey 1.1 // We modify only if this property exists.
531 // could either use the property from modifiedIns or simply replace
532 // value in property from object manager.
533 if (modifiedIns.findProperty(OM_PROPERTY_GATHERSTATISTICALDATA) !=
534 PEG_NOT_FOUND)
535 {
536 omInstance = getObjectManagerInstance();
537 if(omInstance.isUninitialized())
538 {
539 throw CIMObjectNotFoundException(instanceReference.toString());
540 }
541 statisticsFlag = getPropertyValue(modifiedIns,
542 OM_PROPERTY_GATHERSTATISTICALDATA, false);
543 // set the changed property into the instance
544 setPropertyValue(omInstance, OM_PROPERTY_GATHERSTATISTICALDATA,
545 statisticsFlag);
546 }
547 else
548 {
549 // if statistics property not in place, simply exit. Nothing to do
550 // not considered an error
551 a.dunfey 1.1 PEG_METHOD_EXIT();
552 return;
553 }
554 // Modify the instance on disk
|
555 kumpf 1.4 repository->modifyInstance(instanceReference.getNameSpace(),
556 omInstance, false, propertyList);
|
557 marek 1.8 PEG_TRACE((
558 TRC_CONTROLPROVIDER,
559 Tracer::LEVEL3,
560 "Interop Provider Set Statistics gathering in CIM_ObjectManager: %s",
561 (statisticsFlag? "true" : "false")));
|
562 a.dunfey 1.1 StatisticalData* sd = StatisticalData::current();
563 sd->setCopyGSD(statisticsFlag);
564 PEG_METHOD_EXIT();
565 return;
566
567 #else
568 PEG_METHOD_EXIT();
569 throw CIMNotSupportedException
|
570 kumpf 1.17 (OM_PROPERTY_GATHERSTATISTICALDATA.getString() +
|
571 a.dunfey 1.1 " modify operation not supported by Interop Provider");
572 #endif
573 }
574
575
576 //
577 // Get an instance of the PG_ComputerSystem class produced by the
578 // ComputerSystem provider in the root/cimv2 namespace.
579 //
580 // @param includeQualifiers Boolean
581 // @param includeClassOrigin Boolean
582 // @param propertylist CIMPropertyList
583 //
584 // @return CIMInstance of PG_ComputerSystem class.
585 //
586 // @exception ObjectNotFound exception if a ComputerSystem instance cannot
587 // be retrieved.
588 //
589 CIMInstance InteropProvider::getComputerSystemInstance()
590 {
591 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
592 a.dunfey 1.1 "InteropProvider::getComputerSystemInstance");
593
594 CIMInstance instance;
595 AutoMutex mut(interopMut);
596 Array<CIMInstance> tmpInstances = cimomHandle.enumerateInstances(
597 OperationContext(),
598 PEGASUS_NAMESPACENAME_CIMV2,
599 PEGASUS_CLASSNAME_PG_COMPUTERSYSTEM, true, false, false, false,
600 CIMPropertyList());
601 Uint32 numInstances = tmpInstances.size();
602 PEGASUS_ASSERT(numInstances <= 1);
603 if(numInstances > 0)
604 {
605 instance = tmpInstances[0];
606 CIMObjectPath tmpPath = instance.getPath();
607 tmpPath.setHost(hostName);
608 tmpPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
609 instance.setPath(tmpPath);
610 }
611
612 if(instance.isUninitialized())
613 a.dunfey 1.1 {
614 PEG_METHOD_EXIT();
615 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND,
616 "Could not find ComputerSystem instance");
617 }
618
619 PEG_METHOD_EXIT();
620 return instance;
621 }
622
623 //
624 // Returns an instance of the HostedObjectManager association linking the
625 // ObjectManager and ComputerSystem instances managed by this provider.
626 //
627 CIMInstance InteropProvider::getHostedObjectManagerInstance()
628 {
629 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
630 "InteropProvider::getHostedObjectManagerInstance");
631
632 // Try to get the current object. If true then it is already created.
633 CIMInstance instance;
634 a.dunfey 1.1 bool found = false;
635
636 CIMObjectPath csPath = getComputerSystemInstance().getPath();
637 CIMObjectPath omPath = getObjectManagerInstance().getPath();
638 String csPathString = csPath.toString();
639 String omPathString = omPath.toString();
640
641 CIMClass hostedOMClass = repository->getClass(
642 PEGASUS_NAMESPACENAME_INTEROP,
643 PEGASUS_CLASSNAME_PG_HOSTEDOBJECTMANAGER,
644 false, true, false);
645
646 instance = hostedOMClass.buildInstance(false, false, CIMPropertyList());
647
648 setPropertyValue(instance, PROPERTY_ANTECEDENT,
649 CIMValue(csPath));
650 setPropertyValue(instance, PROPERTY_DEPENDENT,
651 CIMValue(omPath));
652
653 instance.setPath(instance.buildPath(hostedOMClass));
654
655 a.dunfey 1.1 PEG_METHOD_EXIT();
656 return instance;
657 }
658
659 //
660 // Returns an array containing all of the HostedAccessPoint association
661 // instances for this CIMOM. One will be produced for every instance of
662 // CIMXMLCommunicatiomMechanism managed by this provider.
663 //
664 Array<CIMInstance> InteropProvider::enumHostedAccessPointInstances()
665 {
666 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
667 "InteropProvider::enumHostedAccessPointInstance");
668 Array<CIMInstance> instances;
669
670 CIMObjectPath csPath = getComputerSystemInstance().getPath();
671 Array<CIMInstance> commMechs = enumCIMXMLCommunicationMechanismInstances();
672 CIMClass hapClass = repository->getClass(PEGASUS_NAMESPACENAME_INTEROP,
673 PEGASUS_CLASSNAME_PG_HOSTEDACCESSPOINT, false, true, false);
674 for(Uint32 i = 0, n = commMechs.size(); i < n; ++i)
675 {
676 a.dunfey 1.1 CIMInstance & currentCommMech = commMechs[i];
677 CIMInstance hapInstance = hapClass.buildInstance(false, false,
678 CIMPropertyList());
679 setPropertyValue(hapInstance, PROPERTY_ANTECEDENT, csPath);
680 setPropertyValue(hapInstance, PROPERTY_DEPENDENT,
681 currentCommMech.getPath());
682 hapInstance.setPath(hapInstance.buildPath(hapClass));
683 instances.append(hapInstance);
684 }
685
686 PEG_METHOD_EXIT();
687 return instances;
688 }
689
690
691 //
692 // Returns an array containing all of the CommMechanismForManager association
693 // instances for this CIMOM. One will be produced for every instance of
694 // CIMXMLCommunicatiomMechanism managed by this provider.
695 //
696 Array<CIMInstance> InteropProvider::enumCommMechanismForManagerInstances()
697 a.dunfey 1.1 {
698 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
699 "InteropProvider::enumCommMechanismForManagerInstances");
700
701 Array<CIMInstance> commInstances =
702 enumCIMXMLCommunicationMechanismInstances();
703
704 CIMInstance instanceObjMgr = getObjectManagerInstance();
705
706 CIMObjectPath refObjMgr = instanceObjMgr.getPath();
707
708 Array<CIMInstance> assocInstances;
709 CIMClass targetClass;
710 CIMInstance instanceskel = buildInstanceSkeleton(
|
711 kumpf 1.17 PEGASUS_NAMESPACENAME_INTEROP,
|
712 kumpf 1.14 PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER, true, targetClass);
|
713 a.dunfey 1.1 for (Uint32 i = 0, n = commInstances.size(); i < n; ++i)
714 {
715 CIMInstance instance = instanceskel.clone();
716
717 setPropertyValue(instance, PROPERTY_ANTECEDENT, refObjMgr);
718
719 setPropertyValue(instance, PROPERTY_DEPENDENT,
720 commInstances[i].getPath());
721
722 instance.setPath(instance.buildPath(targetClass));
723 assocInstances.append(instance);
724 }
725
726 PEG_METHOD_EXIT();
727 return assocInstances;
728 }
729
|
730 venkat.puvvada 1.9 #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
731
732 CIMInstance InteropProvider::buildAssociationInstance(
733 const CIMName &className,
734 const CIMName &propName1,
735 const CIMObjectPath &objPath1,
736 const CIMName &propName2,
737 const CIMObjectPath &objPath2)
738 {
739 CIMClass cimClass = repository->getClass(
740 PEGASUS_NAMESPACENAME_INTEROP,
741 className,
742 false,
743 true,
744 true);
745
746 CIMInstance instance = cimClass.buildInstance(
747 true,
748 true,
749 CIMPropertyList());
750
751 venkat.puvvada 1.9 instance.getProperty(instance.findProperty(propName1)).setValue(objPath1);
752 instance.getProperty(instance.findProperty(propName2)).setValue(objPath2);
753 instance.setPath(instance.buildPath(cimClass));
754
755 return instance;
756 }
757
758 Array<CIMInstance> InteropProvider::enumElementCapabilityInstances(
759 const OperationContext &opContext)
760 {
761 // Get CIM_IndicationServiceCapabilities instance
762 Array<CIMObjectPath> capPaths = cimomHandle.enumerateInstanceNames(
763 opContext,
764 PEGASUS_NAMESPACENAME_INTEROP,
765 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES);
766 PEGASUS_ASSERT(capPaths.size() == 1);
767
768 // Get CIM_IndicationService instance
769 Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
770 opContext,
771 PEGASUS_NAMESPACENAME_INTEROP,
772 venkat.puvvada 1.9 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
773 PEGASUS_ASSERT(servicePaths.size() == 1);
774
775 Array<CIMInstance> instances;
776
777 instances.append(
778 buildAssociationInstance(
779 PEGASUS_CLASSNAME_PG_ELEMENTCAPABILITIES,
780 PROPERTY_CAPABILITIES,
781 capPaths[0],
782 PROPERTY_MANAGEDELEMENT,
783 servicePaths[0]));
784
785 return instances;
786 }
787
788 Array<CIMInstance> InteropProvider::enumHostedIndicationServiceInstances(
789 const OperationContext &opContext)
790 {
791 Array<CIMInstance> instances;
792 CIMInstance cInst = getComputerSystemInstance();
793 venkat.puvvada 1.9
794 // Get CIM_IndicationService instance
795 Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
796 opContext,
797 PEGASUS_NAMESPACENAME_INTEROP,
798 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
799
800 PEGASUS_ASSERT(servicePaths.size() == 1);
801
802 instances.append(
803 buildAssociationInstance(
804 PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE,
805 PROPERTY_ANTECEDENT,
806 cInst.getPath(),
807 PROPERTY_DEPENDENT,
808 servicePaths[0]));
809
810 return instances;
811 }
812
813 Array<CIMInstance> InteropProvider::enumServiceAffectsElementInstances(
814 venkat.puvvada 1.9 const OperationContext &opContext)
815 {
816 Array<CIMInstance> instances;
817
818 // Get CIM_IndicationService instance
819 Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
820 opContext,
821 PEGASUS_NAMESPACENAME_INTEROP,
822 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
823 PEGASUS_ASSERT(servicePaths.size() == 1);
824
825 Array<CIMNamespaceName> namespaceNames = repository->enumerateNameSpaces();
826 // Get CIM_IndicationFilter and CIM_ListenerDestination instances in all
827 // namespaces and associate them with CIM_IndicationService instance using
828 // PG_ServiceAffectsElement instance.
829 for (Uint32 i = 0, n = namespaceNames.size() ; i < n ; ++i)
|
830 kumpf 1.17 {
|
831 venkat.puvvada 1.9 Array<CIMObjectPath> filterPaths;
832 try
|
833 kumpf 1.17 {
|
834 venkat.puvvada 1.9 // Get CIM_IndicationFilter instance names
835 filterPaths = cimomHandle.enumerateInstanceNames(
836 opContext,
837 namespaceNames[i],
838 PEGASUS_CLASSNAME_INDFILTER);
839 }
840 catch(CIMException &e)
841 {
842 // Ignore exception with CIM_ERR_INVALID_CLASS code. This will
843 // happen when the class CIM_IndicationFilter can not be found
844 // in this namespace.
845 if (e.getCode() != CIM_ERR_INVALID_CLASS)
846 {
847 PEG_TRACE((
848 TRC_CONTROLPROVIDER,
|
849 marek 1.10 Tracer::LEVEL2,
|
850 venkat.puvvada 1.9 "CIMException while enumerating the "
851 "CIM_IndicationFilter instances"
852 " in the namespace %s: %s.",
853 (const char*)namespaceNames[i].getString().getCString(),
854 (const char*)e.getMessage().getCString()));
855 }
856 }
857 catch(Exception &e)
858 {
859 PEG_TRACE((
860 TRC_CONTROLPROVIDER,
861 Tracer::LEVEL1,
862 "Exception while enumerating the "
863 "CIM_IndicationFilter instances"
864 " in the namespace %s: %s.",
865 (const char*)namespaceNames[i].getString().getCString(),
866 (const char*)e.getMessage().getCString()));
867 }
868 catch(...)
869 {
870 PEG_TRACE((
871 venkat.puvvada 1.9 TRC_CONTROLPROVIDER,
|
872 marek 1.10 Tracer::LEVEL1,
|
873 venkat.puvvada 1.9 "Unknown error occurred while enumerating the "
874 "CIM_IndicationFilter instances in the namespace %s.",
875 (const char*)namespaceNames[i].getString().getCString()));
876 }
877 for (Uint32 f = 0, fn = filterPaths.size(); f < fn ; ++f)
878 {
879 filterPaths[f].setNameSpace(namespaceNames[i]);
880 instances.append(
881 buildAssociationInstance(
882 PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT,
883 PROPERTY_AFFECTEDELEMENT,
884 filterPaths[f],
885 PROPERTY_AFFECTINGELEMENT,
886 servicePaths[0]));
887 }
888
889 Array<CIMObjectPath> handlerPaths;
890 try
891 {
892 // Get CIM_ListenerDestination instance names
893 handlerPaths = cimomHandle.enumerateInstanceNames(
894 venkat.puvvada 1.9 opContext,
895 namespaceNames[i],
896 PEGASUS_CLASSNAME_LSTNRDST);
897 }
898 catch(CIMException &e)
899 {
900 // Ignore exception with CIM_ERR_INVALID_CLASS code. This will
901 // happen when the class CIM_ListenerDestination can not be found
902 // in this namespace.
903 if (e.getCode() != CIM_ERR_INVALID_CLASS)
904 {
905 PEG_TRACE((
906 TRC_CONTROLPROVIDER,
|
907 marek 1.10 Tracer::LEVEL2,
|
908 venkat.puvvada 1.9 "CIMException while enumerating the "
909 "CIM_ListenerDestination instances"
910 " in the namespace %s: %s.",
911 (const char*)namespaceNames[i].getString().getCString(),
912 (const char*)e.getMessage().getCString()));
913 }
914 }
915 catch(Exception &e)
916 {
917 PEG_TRACE((
918 TRC_CONTROLPROVIDER,
919 Tracer::LEVEL1,
920 "Exception while enumerating the "
921 "CIM_ListenerDestination instances"
922 " in the namespace %s: %s.",
923 (const char*)namespaceNames[i].getString().getCString(),
924 (const char*)e.getMessage().getCString()));
925 }
926 catch(...)
927 {
928 PEG_TRACE((
929 venkat.puvvada 1.9 TRC_CONTROLPROVIDER,
|
930 marek 1.10 Tracer::LEVEL1,
|
931 venkat.puvvada 1.9 "Unknown error occurred while enumerating the "
932 "CIM_ListenerDestination instances in the namespace %s.",
933 (const char*)namespaceNames[i].getString().getCString()));
934 }
935 for (Uint32 h = 0, hn = handlerPaths.size(); h < hn ; ++h)
936 {
937 handlerPaths[h].setNameSpace(namespaceNames[i]);
938 instances.append(
939 buildAssociationInstance(
940 PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT,
941 PROPERTY_AFFECTEDELEMENT,
942 handlerPaths[h],
943 PROPERTY_AFFECTINGELEMENT,
944 servicePaths[0]));
945 }
946 }
947 return instances;
948 }
949 #endif
950
|
951 a.dunfey 1.2 PEGASUS_NAMESPACE_END
|
952 a.dunfey 1.1
953 // END OF FILE
|