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
60 #include <Pegasus/Common/StatisticalData.h>
|
61 venkat.puvvada 1.20 #include <Pegasus/General/Guid.h>
|
62 a.dunfey 1.1
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 kavita.gupta 1.19 if (ConfigManager::parseBooleanValue(
145 configManager->getCurrentValue("enableAssociationTraversal")))
|
146 a.dunfey 1.1 {
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 kavita.gupta 1.19 if (ConfigManager::parseBooleanValue(
158 configManager->getCurrentValue("enableIndicationService")))
|
159 a.dunfey 1.1 {
160 profiles.append(9);
161 profileDescriptions.append("Indications");
162 }
163 }
164
165 //
166 // Build a single instance of the CIMXMLCommunicationMechanism class using the
167 // parameters provided. Builds the complete instance and sets its object path.
168 //
169 CIMInstance InteropProvider::buildCIMXMLCommunicationMechanismInstance(
170 const String& namespaceType,
171 const Uint16& accessProtocol,
172 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 a.dunfey 1.1 setCommonKeys(instance);
181
182 // CreationClassName property
183 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 kavita.gupta 1.19 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
301 configManager->getCurrentValue("enableHttpConnection"));
302 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
303 configManager->getCurrentValue("enableHttpsConnection"));
|
304 a.dunfey 1.1
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
|
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 s.kodali 1.21 #ifdef PEGASUS_FLAVOR
442 String elementName(PEGASUS_FLAVOR);
443 elementName.append(Char16('-'));
444 elementName.append("pegasus");
445 setPropertyValue(instance, OM_PROPERTY_ELEMENTNAME, elementName);
446 #else
|
447 a.dunfey 1.1 setPropertyValue(instance, OM_PROPERTY_ELEMENTNAME, String("Pegasus"));
|
448 s.kodali 1.21 #endif
|
449 a.dunfey 1.1 Array<Uint16> operationalStatus;
450 operationalStatus.append(2);
451 setPropertyValue(instance, OM_PROPERTY_OPERATIONALSTATUS,
452 operationalStatus);
453 setPropertyValue(instance, OM_PROPERTY_STARTED,
454 CIMValue(Boolean(true)));
455
456 //
457 // Description property this object manager instance.
458 // If PEGASUS_CIMOM_DESCRIPTION is non-zero length, use it.
459 // Otherwise build form the components below, as defined in
460 // PegasusVersion.h.
461 String descriptionStatus;
462 String pegasusProductStatus(PEGASUS_PRODUCT_STATUS);
463 if(pegasusProductStatus.size() > 0)
464 descriptionStatus = " " + pegasusProductStatus;
465
466 String description = (String(PEGASUS_CIMOM_DESCRIPTION).size() != 0) ?
467 String(PEGASUS_CIMOM_DESCRIPTION)
468 :
469 String(PEGASUS_CIMOM_GENERIC_NAME) + " " +
470 a.dunfey 1.1 String(PEGASUS_PRODUCT_NAME) + " Version " +
471 String(PEGASUS_PRODUCT_VERSION) +
472 descriptionStatus;
473
474 setPropertyValue(instance, OM_PROPERTY_DESCRIPTION, description);
475
476 // Property GatherStatisticalData. Initially this is set to false
477 // and can then be modified by a modify instance on the instance.
478 Boolean gatherStatDataFlag = false;
479 setPropertyValue(instance, OM_PROPERTY_GATHERSTATISTICALDATA,
480 gatherStatDataFlag);
481
482 // Set the statistics property into the Statisticaldata class so that
483 // it can perform statistics gathering if necessary.
|
484 kumpf 1.5 #ifndef PEGASUS_DISABLE_PERFINST
|
485 a.dunfey 1.1 StatisticalData* sd = StatisticalData::current();
486 sd->setCopyGSD(gatherStatDataFlag);
|
487 kumpf 1.5 #endif
|
488 a.dunfey 1.1
489 // write instance to the repository
490 CIMObjectPath instancePath = repository->createInstance(
491 PEGASUS_NAMESPACENAME_INTEROP, instance);
|
492 kumpf 1.14 // Get an updated copy of the instance that was saved
493 instance = repository->getInstance(
|
494 kumpf 1.18 PEGASUS_NAMESPACENAME_INTEROP, instancePath);
|
495 a.dunfey 1.1 instance.setPath(instancePath);
496 }
497
498 CIMObjectPath currentPath = instance.getPath();
499 currentPath.setHost(hostName);
500 currentPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
501 instance.setPath(currentPath);
502 PEG_METHOD_EXIT();
503 return instance;
504 }
505
506 //
507 // Modify the existing Object Manager instance. Only a single property
508 // modification is allowed, the statistical data setting. Any other change is
509 // rejected with an exception.
510 //
511 void InteropProvider::modifyObjectManagerInstance(
512 const OperationContext & context,
513 const CIMObjectPath & instanceReference,
514 const CIMInstance& modifiedIns,
515 const Boolean includeQualifiers,
516 a.dunfey 1.1 const CIMPropertyList& propertyList)
517 {
518 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
519 "InteropProvider::modifyObjectManagerInstance");
520
521 // Modification only allowed when Performance staticistics are active
522 #ifndef PEGASUS_DISABLE_PERFINST
523 Uint32 propListSize = propertyList.size();
524 if(propListSize == 0 && !propertyList.isNull())
525 return;
526
527 if(propertyList.size() != 1 ||
528 propertyList[0] != OM_PROPERTY_GATHERSTATISTICALDATA)
529 {
530 throw CIMNotSupportedException(String("Only modification of ") +
531 OM_PROPERTY_GATHERSTATISTICALDATA.getString() + " allowed");
532 }
533
534 Boolean statisticsFlag;
535 CIMInstance omInstance;
536
537 a.dunfey 1.1 // We modify only if this property exists.
538 // could either use the property from modifiedIns or simply replace
539 // value in property from object manager.
540 if (modifiedIns.findProperty(OM_PROPERTY_GATHERSTATISTICALDATA) !=
541 PEG_NOT_FOUND)
542 {
543 omInstance = getObjectManagerInstance();
544 if(omInstance.isUninitialized())
545 {
546 throw CIMObjectNotFoundException(instanceReference.toString());
547 }
548 statisticsFlag = getPropertyValue(modifiedIns,
549 OM_PROPERTY_GATHERSTATISTICALDATA, false);
550 // set the changed property into the instance
551 setPropertyValue(omInstance, OM_PROPERTY_GATHERSTATISTICALDATA,
552 statisticsFlag);
553 }
554 else
555 {
556 // if statistics property not in place, simply exit. Nothing to do
557 // not considered an error
558 a.dunfey 1.1 PEG_METHOD_EXIT();
559 return;
560 }
561 // Modify the instance on disk
|
562 kumpf 1.4 repository->modifyInstance(instanceReference.getNameSpace(),
563 omInstance, false, propertyList);
|
564 marek 1.8 PEG_TRACE((
565 TRC_CONTROLPROVIDER,
566 Tracer::LEVEL3,
567 "Interop Provider Set Statistics gathering in CIM_ObjectManager: %s",
568 (statisticsFlag? "true" : "false")));
|
569 a.dunfey 1.1 StatisticalData* sd = StatisticalData::current();
570 sd->setCopyGSD(statisticsFlag);
571 PEG_METHOD_EXIT();
572 return;
573
574 #else
575 PEG_METHOD_EXIT();
576 throw CIMNotSupportedException
|
577 kumpf 1.17 (OM_PROPERTY_GATHERSTATISTICALDATA.getString() +
|
578 a.dunfey 1.1 " modify operation not supported by Interop Provider");
579 #endif
580 }
581
582
583 //
584 // Get an instance of the PG_ComputerSystem class produced by the
585 // ComputerSystem provider in the root/cimv2 namespace.
586 //
|
587 thilo.boehm 1.22 // @param opContext Operation context.
|
588 a.dunfey 1.1 //
589 // @return CIMInstance of PG_ComputerSystem class.
590 //
591 // @exception ObjectNotFound exception if a ComputerSystem instance cannot
592 // be retrieved.
593 //
|
594 thilo.boehm 1.22 CIMInstance InteropProvider::getComputerSystemInstance(
595 const OperationContext &opContext)
|
596 a.dunfey 1.1 {
597 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
598 "InteropProvider::getComputerSystemInstance");
599
600 CIMInstance instance;
601 AutoMutex mut(interopMut);
602 Array<CIMInstance> tmpInstances = cimomHandle.enumerateInstances(
|
603 thilo.boehm 1.22 opContext,
|
604 a.dunfey 1.1 PEGASUS_NAMESPACENAME_CIMV2,
605 PEGASUS_CLASSNAME_PG_COMPUTERSYSTEM, true, false, false, false,
606 CIMPropertyList());
607 Uint32 numInstances = tmpInstances.size();
608 PEGASUS_ASSERT(numInstances <= 1);
609 if(numInstances > 0)
610 {
611 instance = tmpInstances[0];
612 CIMObjectPath tmpPath = instance.getPath();
613 tmpPath.setHost(hostName);
614 tmpPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
615 instance.setPath(tmpPath);
616 }
617
618 if(instance.isUninitialized())
619 {
620 PEG_METHOD_EXIT();
621 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND,
622 "Could not find ComputerSystem instance");
623 }
624
625 a.dunfey 1.1 PEG_METHOD_EXIT();
626 return instance;
627 }
628
629 //
630 // Returns an instance of the HostedObjectManager association linking the
631 // ObjectManager and ComputerSystem instances managed by this provider.
632 //
|
633 thilo.boehm 1.22 CIMInstance InteropProvider::getHostedObjectManagerInstance(
634 const OperationContext &opContext)
|
635 a.dunfey 1.1 {
636 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
637 "InteropProvider::getHostedObjectManagerInstance");
638
639 // Try to get the current object. If true then it is already created.
640 CIMInstance instance;
641 bool found = false;
642
|
643 thilo.boehm 1.22 CIMObjectPath csPath = getComputerSystemInstance(opContext).getPath();
|
644 a.dunfey 1.1 CIMObjectPath omPath = getObjectManagerInstance().getPath();
645 String csPathString = csPath.toString();
646 String omPathString = omPath.toString();
647
648 CIMClass hostedOMClass = repository->getClass(
649 PEGASUS_NAMESPACENAME_INTEROP,
650 PEGASUS_CLASSNAME_PG_HOSTEDOBJECTMANAGER,
651 false, true, false);
652
653 instance = hostedOMClass.buildInstance(false, false, CIMPropertyList());
654
655 setPropertyValue(instance, PROPERTY_ANTECEDENT,
656 CIMValue(csPath));
657 setPropertyValue(instance, PROPERTY_DEPENDENT,
658 CIMValue(omPath));
659
660 instance.setPath(instance.buildPath(hostedOMClass));
661
662 PEG_METHOD_EXIT();
663 return instance;
664 }
665 a.dunfey 1.1
666 //
667 // Returns an array containing all of the HostedAccessPoint association
668 // instances for this CIMOM. One will be produced for every instance of
669 // CIMXMLCommunicatiomMechanism managed by this provider.
670 //
|
671 thilo.boehm 1.22 Array<CIMInstance> InteropProvider::enumHostedAccessPointInstances(
672 const OperationContext &opContext)
|
673 a.dunfey 1.1 {
674 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
675 "InteropProvider::enumHostedAccessPointInstance");
676 Array<CIMInstance> instances;
677
|
678 thilo.boehm 1.22 CIMObjectPath csPath = getComputerSystemInstance(opContext).getPath();
|
679 a.dunfey 1.1 Array<CIMInstance> commMechs = enumCIMXMLCommunicationMechanismInstances();
680 CIMClass hapClass = repository->getClass(PEGASUS_NAMESPACENAME_INTEROP,
681 PEGASUS_CLASSNAME_PG_HOSTEDACCESSPOINT, false, true, false);
682 for(Uint32 i = 0, n = commMechs.size(); i < n; ++i)
683 {
684 CIMInstance & currentCommMech = commMechs[i];
685 CIMInstance hapInstance = hapClass.buildInstance(false, false,
686 CIMPropertyList());
687 setPropertyValue(hapInstance, PROPERTY_ANTECEDENT, csPath);
688 setPropertyValue(hapInstance, PROPERTY_DEPENDENT,
689 currentCommMech.getPath());
690 hapInstance.setPath(hapInstance.buildPath(hapClass));
691 instances.append(hapInstance);
692 }
693
694 PEG_METHOD_EXIT();
695 return instances;
696 }
697
698
699 //
700 a.dunfey 1.1 // Returns an array containing all of the CommMechanismForManager association
701 // instances for this CIMOM. One will be produced for every instance of
702 // CIMXMLCommunicatiomMechanism managed by this provider.
703 //
704 Array<CIMInstance> InteropProvider::enumCommMechanismForManagerInstances()
705 {
706 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
707 "InteropProvider::enumCommMechanismForManagerInstances");
708
709 Array<CIMInstance> commInstances =
710 enumCIMXMLCommunicationMechanismInstances();
711
712 CIMInstance instanceObjMgr = getObjectManagerInstance();
713
714 CIMObjectPath refObjMgr = instanceObjMgr.getPath();
715
716 Array<CIMInstance> assocInstances;
717 CIMClass targetClass;
718 CIMInstance instanceskel = buildInstanceSkeleton(
|
719 kumpf 1.17 PEGASUS_NAMESPACENAME_INTEROP,
|
720 kumpf 1.14 PEGASUS_CLASSNAME_PG_COMMMECHANISMFORMANAGER, true, targetClass);
|
721 a.dunfey 1.1 for (Uint32 i = 0, n = commInstances.size(); i < n; ++i)
722 {
723 CIMInstance instance = instanceskel.clone();
724
725 setPropertyValue(instance, PROPERTY_ANTECEDENT, refObjMgr);
726
727 setPropertyValue(instance, PROPERTY_DEPENDENT,
728 commInstances[i].getPath());
729
730 instance.setPath(instance.buildPath(targetClass));
731 assocInstances.append(instance);
732 }
733
734 PEG_METHOD_EXIT();
735 return assocInstances;
736 }
737
|
738 venkat.puvvada 1.9 #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
739
740 CIMInstance InteropProvider::buildAssociationInstance(
741 const CIMName &className,
742 const CIMName &propName1,
743 const CIMObjectPath &objPath1,
744 const CIMName &propName2,
745 const CIMObjectPath &objPath2)
746 {
747 CIMClass cimClass = repository->getClass(
748 PEGASUS_NAMESPACENAME_INTEROP,
749 className,
750 false,
751 true,
752 true);
753
754 CIMInstance instance = cimClass.buildInstance(
755 true,
756 true,
757 CIMPropertyList());
758
759 venkat.puvvada 1.9 instance.getProperty(instance.findProperty(propName1)).setValue(objPath1);
760 instance.getProperty(instance.findProperty(propName2)).setValue(objPath2);
761 instance.setPath(instance.buildPath(cimClass));
762
763 return instance;
764 }
765
766 Array<CIMInstance> InteropProvider::enumElementCapabilityInstances(
767 const OperationContext &opContext)
768 {
769 // Get CIM_IndicationServiceCapabilities instance
770 Array<CIMObjectPath> capPaths = cimomHandle.enumerateInstanceNames(
771 opContext,
772 PEGASUS_NAMESPACENAME_INTEROP,
773 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES);
774 PEGASUS_ASSERT(capPaths.size() == 1);
775
776 // Get CIM_IndicationService instance
777 Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
778 opContext,
779 PEGASUS_NAMESPACENAME_INTEROP,
780 venkat.puvvada 1.9 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
781 PEGASUS_ASSERT(servicePaths.size() == 1);
782
783 Array<CIMInstance> instances;
784
785 instances.append(
786 buildAssociationInstance(
787 PEGASUS_CLASSNAME_PG_ELEMENTCAPABILITIES,
788 PROPERTY_CAPABILITIES,
789 capPaths[0],
790 PROPERTY_MANAGEDELEMENT,
791 servicePaths[0]));
792
793 return instances;
794 }
795
796 Array<CIMInstance> InteropProvider::enumHostedIndicationServiceInstances(
797 const OperationContext &opContext)
798 {
799 Array<CIMInstance> instances;
|
800 thilo.boehm 1.22 CIMInstance cInst = getComputerSystemInstance(opContext);
|
801 venkat.puvvada 1.9
802 // Get CIM_IndicationService instance
803 Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
804 opContext,
805 PEGASUS_NAMESPACENAME_INTEROP,
806 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
807
808 PEGASUS_ASSERT(servicePaths.size() == 1);
809
810 instances.append(
811 buildAssociationInstance(
812 PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE,
813 PROPERTY_ANTECEDENT,
814 cInst.getPath(),
815 PROPERTY_DEPENDENT,
816 servicePaths[0]));
817
818 return instances;
819 }
820
821 Array<CIMInstance> InteropProvider::enumServiceAffectsElementInstances(
822 venkat.puvvada 1.9 const OperationContext &opContext)
823 {
824 Array<CIMInstance> instances;
825
826 // Get CIM_IndicationService instance
827 Array<CIMObjectPath> servicePaths = cimomHandle.enumerateInstanceNames(
828 opContext,
829 PEGASUS_NAMESPACENAME_INTEROP,
830 PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
831 PEGASUS_ASSERT(servicePaths.size() == 1);
832
833 Array<CIMNamespaceName> namespaceNames = repository->enumerateNameSpaces();
834 // Get CIM_IndicationFilter and CIM_ListenerDestination instances in all
835 // namespaces and associate them with CIM_IndicationService instance using
836 // PG_ServiceAffectsElement instance.
837 for (Uint32 i = 0, n = namespaceNames.size() ; i < n ; ++i)
|
838 kumpf 1.17 {
|
839 venkat.puvvada 1.9 Array<CIMObjectPath> filterPaths;
840 try
|
841 kumpf 1.17 {
|
842 venkat.puvvada 1.9 // Get CIM_IndicationFilter instance names
843 filterPaths = cimomHandle.enumerateInstanceNames(
844 opContext,
845 namespaceNames[i],
846 PEGASUS_CLASSNAME_INDFILTER);
847 }
848 catch(CIMException &e)
849 {
850 // Ignore exception with CIM_ERR_INVALID_CLASS code. This will
851 // happen when the class CIM_IndicationFilter can not be found
852 // in this namespace.
853 if (e.getCode() != CIM_ERR_INVALID_CLASS)
854 {
855 PEG_TRACE((
856 TRC_CONTROLPROVIDER,
|
857 marek 1.10 Tracer::LEVEL2,
|
858 venkat.puvvada 1.9 "CIMException while enumerating the "
859 "CIM_IndicationFilter instances"
860 " in the namespace %s: %s.",
861 (const char*)namespaceNames[i].getString().getCString(),
862 (const char*)e.getMessage().getCString()));
863 }
864 }
865 catch(Exception &e)
866 {
867 PEG_TRACE((
868 TRC_CONTROLPROVIDER,
869 Tracer::LEVEL1,
870 "Exception while enumerating the "
871 "CIM_IndicationFilter instances"
872 " in the namespace %s: %s.",
873 (const char*)namespaceNames[i].getString().getCString(),
874 (const char*)e.getMessage().getCString()));
875 }
876 catch(...)
877 {
878 PEG_TRACE((
879 venkat.puvvada 1.9 TRC_CONTROLPROVIDER,
|
880 marek 1.10 Tracer::LEVEL1,
|
881 venkat.puvvada 1.9 "Unknown error occurred while enumerating the "
882 "CIM_IndicationFilter instances in the namespace %s.",
883 (const char*)namespaceNames[i].getString().getCString()));
884 }
885 for (Uint32 f = 0, fn = filterPaths.size(); f < fn ; ++f)
886 {
887 filterPaths[f].setNameSpace(namespaceNames[i]);
888 instances.append(
889 buildAssociationInstance(
890 PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT,
891 PROPERTY_AFFECTEDELEMENT,
892 filterPaths[f],
893 PROPERTY_AFFECTINGELEMENT,
894 servicePaths[0]));
895 }
896
897 Array<CIMObjectPath> handlerPaths;
898 try
899 {
900 // Get CIM_ListenerDestination instance names
901 handlerPaths = cimomHandle.enumerateInstanceNames(
902 venkat.puvvada 1.9 opContext,
903 namespaceNames[i],
904 PEGASUS_CLASSNAME_LSTNRDST);
905 }
906 catch(CIMException &e)
907 {
908 // Ignore exception with CIM_ERR_INVALID_CLASS code. This will
909 // happen when the class CIM_ListenerDestination can not be found
910 // in this namespace.
911 if (e.getCode() != CIM_ERR_INVALID_CLASS)
912 {
913 PEG_TRACE((
914 TRC_CONTROLPROVIDER,
|
915 marek 1.10 Tracer::LEVEL2,
|
916 venkat.puvvada 1.9 "CIMException while enumerating the "
917 "CIM_ListenerDestination instances"
918 " in the namespace %s: %s.",
919 (const char*)namespaceNames[i].getString().getCString(),
920 (const char*)e.getMessage().getCString()));
921 }
922 }
923 catch(Exception &e)
924 {
925 PEG_TRACE((
926 TRC_CONTROLPROVIDER,
927 Tracer::LEVEL1,
928 "Exception while enumerating the "
929 "CIM_ListenerDestination instances"
930 " in the namespace %s: %s.",
931 (const char*)namespaceNames[i].getString().getCString(),
932 (const char*)e.getMessage().getCString()));
933 }
934 catch(...)
935 {
936 PEG_TRACE((
937 venkat.puvvada 1.9 TRC_CONTROLPROVIDER,
|
938 marek 1.10 Tracer::LEVEL1,
|
939 venkat.puvvada 1.9 "Unknown error occurred while enumerating the "
940 "CIM_ListenerDestination instances in the namespace %s.",
941 (const char*)namespaceNames[i].getString().getCString()));
942 }
943 for (Uint32 h = 0, hn = handlerPaths.size(); h < hn ; ++h)
944 {
945 handlerPaths[h].setNameSpace(namespaceNames[i]);
946 instances.append(
947 buildAssociationInstance(
948 PEGASUS_CLASSNAME_PG_SERVICEAFFECTSELEMENT,
949 PROPERTY_AFFECTEDELEMENT,
950 handlerPaths[h],
951 PROPERTY_AFFECTINGELEMENT,
952 servicePaths[0]));
953 }
954 }
955 return instances;
956 }
957 #endif
958
|
959 a.dunfey 1.2 PEGASUS_NAMESPACE_END
|
960 a.dunfey 1.1
961 // END OF FILE
|