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