1 karl 1.18 //%2005////////////////////////////////////////////////////////////////////////
|
2 karl 1.1 //
|
3 karl 1.12 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.3 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.12 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.18 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.1 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
|
18 karl 1.3 //
|
19 karl 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Karl Schopmeyer (k.schopmeyer@opengroup.org)
31 //
32 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
33 // (carolann_graves@hp.com)
|
34 karl 1.8 // Karl Schopmeyer - Created Cim_Namespace capabilities.
35 // Karl Schopmeyer - added objectmanager and communication classes
|
36 karl 1.1 //
37 //%////////////////////////////////////////////////////////////////////////////
38
39
40 ///////////////////////////////////////////////////////////////////////////////
|
41 karl 1.5 // Interop Provider - This provider services those classes from the
42 // DMTF Interop schema association with the CIMOM itself
|
43 karl 1.1 //
|
44 karl 1.5 // This provider services the following classes:
45 // CIMObjectManager
46 // CIM_ObjectManagerCommunicationMechanism
47 // CIM_CIMXMLCommunicationMechanism
|
48 karl 1.19 // CIM_ProtocolAdapter (Note: Removed because deprecated class in cim 2.9)
|
49 karl 1.8 // CIM_Namespace (Effective Pegasus 2.4 we use PG_Namespace which
50 // is a subclass of CIM_Namespace with additional properties for
51 // shared namespaces.
|
52 karl 1.5 //
53 // It also services the Interop associations tied to these classes
54 // including:
55 // CIM_NamespaceInManager
56 // ...
|
57 karl 1.11 // This is a control provider and as such uses the Tracer functions
58 // for data and function traces. Since we do not expect high volume
59 // use we added a number of traces to help diagnostics.
|
60 karl 1.1 ///////////////////////////////////////////////////////////////////////////////
|
61 karl 1.11 /* TODO LIST:
62 1. Finish the association functions
63
64 2. UUID generation should become a system function since it will be used
65 by many providers, etc. as part of id generation.
66
67 3. Review the key parameters on create, etc. to be sort out which are
68 required from user and which we can supply. I think we are asking too
69 much of the user right now.
|
70 tony 1.6 */
|
71 karl 1.1
72 #include <Pegasus/Common/Config.h>
73 #include <Pegasus/Common/PegasusVersion.h>
74
75 #include <cctype>
76 #include <iostream>
77
78 #include "InteropProvider.h"
|
79 tony 1.6 #include "Guid.h"
|
80 karl 1.1 #include <Pegasus/Common/String.h>
81 #include <Pegasus/Common/System.h>
82 #include <Pegasus/Common/ArrayInternal.h>
83 #include <Pegasus/Common/CIMName.h>
84 #include <Pegasus/Common/CIMType.h>
85 #include <Pegasus/Common/CIMInstance.h>
86 #include <Pegasus/Common/CIMObjectPath.h>
87 #include <Pegasus/Common/InternalException.h>
88 #include <Pegasus/Common/CIMStatusCode.h>
89 #include <Pegasus/Common/Tracer.h>
90 #include <Pegasus/Common/OperationContext.h>
91 #include <Pegasus/Config/ConfigManager.h>
|
92 tony 1.6 #include <Pegasus/Common/XmlWriter.h>
93 #include <Pegasus/Config/ConfigManager.h>
|
94 karl 1.8 #include <Pegasus/Common/StatisticalData.h>
95 #include <Pegasus/Common/HashTable.h>
|
96 karl 1.1
97
|
98 tony 1.6 #include <stdlib.h>
|
99 karl 1.1
|
100 tony 1.6 //The following include is needed for gethostbyname
101 #if defined(PEGASUS_OS_TYPE_WINDOWS)
102 #include <objbase.h>
103 #else
104 #include <netdb.h>
105 #include <arpa/inet.h>
106 #endif
|
107 karl 1.1
108 PEGASUS_USING_STD;
109
110 PEGASUS_NAMESPACE_BEGIN
111
|
112 tony 1.6 #define CDEBUG(X)
|
113 karl 1.11 #define LDEBUG()
|
114 tony 1.6 //#define CDEBUG(X) PEGASUS_STD(cout) << "InteropProvider " << X << PEGASUS_STD(endl)
|
115 karl 1.11 //#define LDEBUG(X) Logger::put (Logger::DEBUG_LOG, "InteropProvider", Logger::INFORMATION, "$0", X)
116 // The following is attempt to use the tracer for CDEBUG. Not working. 1 sept 2004
117 //#include <cstring>
118 //#include <stdcxx/stream/strstream>
119 // This one sucks because not applicable to separate executables.
120 // looks like we use trace for the externals.
121 // requires using PEGASUS_USING_PEGASUS
122 //#define CDEBUG(X) {ostrstream os; os << X; char* tmp = os.str(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, String(tmp));delete tmp;}
123 //#define CDEBUG(X) {stringstream os; os << X;string os_str = os.str(); const char* tmp = os_str.c_str(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, String(tmp); }
|
124 tony 1.6
125 //**************************************************************************
126 //
127 // Constants representing the class names processed
128 //
129 //**************************************************************************
130
|
131 karl 1.10 const char * thisProvider = "InteropProvider";
|
132 tony 1.6 // The following should be moved to somewhere like constants.
|
133 karl 1.5 static const String PegasusInstanceIDGlobalPrefix = "PEG";
|
134 karl 1.1
135 /**
136 The constants representing the class names we process
137 */
|
138 karl 1.8 // ATTN DELETE: static const CIMName __NAMESPACE_CLASSNAME = CIMName ("__Namespace");
|
139 karl 1.1 static const CIMName CIM_NAMESPACE_CLASSNAME = CIMName ("CIM_Namespace");
|
140 karl 1.8 static const CIMName PG_NAMESPACE_CLASSNAME = CIMName ("PG_Namespace");
141
|
142 karl 1.1 static const CIMName CIM_OBJECTMANAGER_CLASSNAME = CIMName ("CIM_ObjectManager");
143 static const CIMName CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME =
144 CIMName ("CIM_ObjectManagerCommunicationMechanism");
|
145 tony 1.6 static const CIMName PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME =
146 CIMName ("PG_CIMXMLCommunicationMechanism");
147 static const CIMName CIM_COMMMECHANISMFORMANAGER_CLASSNAME =
148 CIMName ("CIM_CommMechanismForManager");
149 static const CIMName CIM_NAMESPACEINMANAGER_CLASSNAME =
150 CIMName ("CIM_NamespaceInManager");
|
151 karl 1.1
152 // Property Names for __Namespace Class
153 static const CIMName NAMESPACE_PROPERTYNAME = CIMName ("Name");
154 static const CIMNamespaceName ROOTNS = CIMNamespaceName ("root");
155
156
157 // Property names for CIM_ObjectManager Class
158 static const CIMName OM_GATHERSTATISTICALDATA =
159 CIMName ("GatherStatisticalData");
|
160 tony 1.6 // Property for the slp template.
161 static const CIMName OM_DESCRIPTIONPROPERTY =
162 CIMName("Description");
|
163 karl 1.1
164 // Property Names for ObjectManagerCommunicationMechanism Class
165 static const CIMName OM_COMMUNICATIONMECHANISM =
166 CIMName ("CommunicationMechanism");
167 static const CIMName OM_FUNCTIONALPROFILESSUPPORTED =
168 CIMName ("FunctionalProfilesSupported");
169 static const CIMName OM_FUNCTIONALPROFILEDESCRIPTIONS =
170 CIMName ("FunctionalProfileDescriptions");
171 static const CIMName OM_AUTHENTICATIONMECHANISMSSUPPORTED =
172 CIMName ("AuthenticationMechanismsSupported");
173 static const CIMName OM_AUTHENTICATIONMECHANISMDESCRIPTIONS =
174 CIMName ("AuthenticationMechanismDescriptions");
175 static const CIMName OM_MULTIPLEOPERATIONSSUPPORTED =
176 CIMName ("MultipleOperationsSupported");
177 static const CIMName OM_VERSION =
178 CIMName ("Version");
179
180 // Property Names for CIMXML CommunicationMechanism
181
182 static const CIMName CIMVALIDATED =
183 CIMName ("CIMValidated");
184 karl 1.1
185 static const String CIMXMLProtocolVersion = "1.0";
186
|
187 karl 1.5 // Property names for CIM_Namespace Class
|
188 karl 1.1
189 static const CIMName CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME =
190 CIMName ("SystemCreationClassName");
191 static const CIMName CIM_NAMESPACE_PROPERTY_SYSTEMNAME =
192 CIMName ("SystemName");
193 static const CIMName CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME =
194 CIMName ("ObjectManagerCreationClassName");
195 static const CIMName CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME =
196 CIMName ("ObjectManagerName");
197 static const CIMName CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME =
198 CIMName ("CreationClassName");
199 static const CIMName CIM_NAMESPACE_PROPERTY_NAME = CIMName ("Name");
200 static const CIMName CIM_NAMESPACE_PROPERTY_CLASSINFO =
201 CIMName ("ClassInfo");
202 static const CIMName CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO =
203 CIMName ("DescriptionOfClassInfo");
204
|
205 karl 1.8 // Additional Property names for PG_Namespace Class
206
207 static const CIMName PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED =
208 CIMName ("SchemaUpdatesAllowed");
209 static const CIMName PG_NAMESPACE_PROPERTY_ISSHAREABLE =
210 CIMName ("IsShareable");
211 static const CIMName PG_NAMESPACE_PROPERTY_PARENTNAMESPACE =
212 CIMName ("ParentNamespace");
|
213 karl 1.11 static const CIMName PG_NAMESPACE_PROPERTY_NAME =
214 CIMName ("Name");
|
215 karl 1.8
|
216 karl 1.5 // Defines to serve as the ENUM for class selection for instance
217 // operations.
218
219 enum targetClass{
|
220 karl 1.11 //__NAMESPACE = 1,
221 PG_NAMESPACE = 1,
222 CIM_OBJECTMANAGER = 2,
223 PG_CIMXMLCOMMUNICATIONMECHANISM = 3,
224 CIM_NAMESPACEINMANAGERINST =4,
|
225 karl 1.19 CIM_COMMMECHANISMFORMANAGERINST=5,
226 CIM_NAMESPACEINMANAGER=6
|
227 karl 1.11 };
228
|
229 tony 1.6 enum targetAssocClass{
|
230 karl 1.19 CIM_NAMESPACEINMANAGERASSOC = 1,
231 CIM_COMMMECHANISMFORMANAGERASSOC=2
|
232 tony 1.6 };
|
233 karl 1.5
|
234 karl 1.1 //***************************************************************
|
235 karl 1.5 // Provider Utility Functions
|
236 karl 1.1 //***************************************************************
|
237 tony 1.6
|
238 karl 1.8 /** get one string property from an instance. Note that these functions simply
239 return the default value if the property cannot be found or is of the wrong
240 type thus, in reality being a maintenance problem since there is no
241 error indication.
|
242 tony 1.6 @param instance CIMInstance from which we get property value
243 @param propertyName String name of the property containing the value
244 @param default String optional parameter that is substituted if the property does
245 not exist, is Null, or is not a string type. The substitute is String::EMPTY
246 @return String value found or defaultValue.
247 */
|
248 karl 1.10 String _getPropertyValue(const CIMInstance& instance, const CIMName& propertyName, const String& defaultValue)
|
249 tony 1.6 {
|
250 karl 1.8 String output = defaultValue;
|
251 tony 1.6 Uint32 pos;
252 if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
253 {
254 CIMConstProperty p1 = instance.getProperty(pos);
255 if (p1.getType() == CIMTYPE_STRING)
256 {
257 CIMValue v1 = p1.getValue();
258
259 if (!v1.isNull())
260 v1.get(output);
261 }
262 }
|
263 karl 1.8 return(output);
264 }
265
266 // Overload of _getPropertyValue for boolean type
|
267 karl 1.10 Boolean _getPropertyValue(const CIMInstance& instance, const CIMName& propertyName, const Boolean defaultValue)
|
268 karl 1.8 {
269 Boolean output = defaultValue;
270 Uint32 pos;
271 if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
272 {
273 CIMConstProperty p1 = instance.getProperty(pos);
274 if (p1.getType() == CIMTYPE_BOOLEAN)
275 {
276 CIMValue v1 = p1.getValue();
277
278 if (!v1.isNull())
279 v1.get(output);
280 }
281 }
|
282 tony 1.6 return(output);
283 }
|
284 karl 1.11
|
285 tony 1.6 /** get Host IP address from host name. If the
286 host name is not provided, uses internal function.
287 If everything fails, gets the definition normally
288 used for localhost (127.0.0.1).
289
290 @param hostName String with the name of the host
291 @return String with the IP address to be used
292 NOTE: This code should not be in slpprovider. This
293 should be in the Interop classes but for the moment
294 it is not.
295 */
296 String _getHostAddress(String hostName)
|
297 marek 1.14 {
298 String ipAddress;
|
299 tony 1.6
300 if (hostName == String::EMPTY)
301 hostName = System::getHostName();
302
|
303 marek 1.14 if ((ipAddress = System::getHostIP(hostName)) == String::EMPTY)
304 {
305 // set default address if everything else failed
306 ipAddress = String("127.0.0.1");
307 }
|
308 tony 1.6 return ipAddress;
309 }
310
|
311 karl 1.19 Array<String> _getFunctionalProfiles(Array<Uint16> & profiles)
|
312 tony 1.6 {
313 Array<String> profileDescriptions;
314 profiles.append(2); profileDescriptions.append("Basic Read");
315 profiles.append(3); profileDescriptions.append("Basic Write");
316 profiles.append(4); profileDescriptions.append("Schema Manipulation");
317 profiles.append(5); profileDescriptions.append("Instance Manipulation");
318 profiles.append(6); profileDescriptions.append("Association Traversal");
319 profiles.append(8); profileDescriptions.append("Qualifier Declaration");
320 profiles.append(9); profileDescriptions.append("Indications");
321 return(profileDescriptions);
322 }
323
324 /* get the prefix that will be part of the cimom identification
325 This can be either the default PEG or if the environment
326 variable PEGASUS_TRADEMARK_PREFIX is defined this is used.
327 NOTE: getting from the environment variable is a hack until
328 we can come up with a better source.
329 @return String containing the unique name for the CIMOM ID
330 */
331
332 String getTrademarkCIMOMIDPrefix()
333 tony 1.6 {
334
335 char * trademark;
336 trademark = getenv("PEGASUS_TRADEMARK_PREFIX");
337 return((trademark)? trademark : PegasusInstanceIDGlobalPrefix);
338 }
339 /** Builds the UUID string for this CIMOM.
340 **/
341 String getUUIDString()
342 {
343 return(Guid::getGuid());
344 }
|
345 karl 1.1
346 /* Test the keys in the CIM_Namespace for valid values
347 This includes all of the keys above the name key.
348 THis is a dummy for now.
349 ATTN: KS Extend and finish this function.
350 */
|
351 karl 1.5 Boolean _validateProperties(const CIMObjectPath& path)
|
352 karl 1.1 {
353 return true;
354 }
|
355 karl 1.5 Boolean _validateProperties(const CIMInstance& instance)
|
356 karl 1.1 {
357 return true;
358 }
359
|
360 tony 1.6 /* Validate that the property exists, is string type and
|
361 karl 1.5 optionally the value itself. Note processes only String
|
362 tony 1.6 properties.
363 @param Instance to search for property.
364 @param CIMName containing property Name
365 @value String containing value. If not String::EMPTY, compare to
|
366 karl 1.5 value in the property
|
367 tony 1.6 @return True if passes all tests
|
368 karl 1.5 */
369 Boolean _validateRequiredProperty(const CIMInstance& instance,
370 const CIMName& propertyName,
371 const String& value)
372 {
|
373 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
374 "InteropProvider::_validateRequiredProperty()");
|
375 karl 1.5 Uint32 pos;
|
376 tony 1.6
|
377 karl 1.5 if ((pos = instance.findProperty (propertyName)) == PEG_NOT_FOUND)
|
378 tony 1.6 {
379 PEG_METHOD_EXIT();
|
380 karl 1.5 return(false);
|
381 tony 1.6 }
|
382 karl 1.5 //
383 // Get the property
384 //
385 CIMConstProperty theProperty = instance.getProperty(pos);
386 const CIMValue theValue = theProperty.getValue ();
387 //
|
388 tony 1.6 // ATTN: Required property must have a non-null value
|
389 karl 1.5 //
|
390 tony 1.6 if ((theValue.getType() != CIMTYPE_STRING) || (theValue.isNull()))
391 {
392 PEG_METHOD_EXIT();
|
393 karl 1.5 return(false);
|
394 tony 1.6 }
395
396 String valueField;
397 theValue.get(valueField);
398 if ((value == String::EMPTY) || (valueField == value))
|
399 karl 1.5 {
|
400 tony 1.6 PEG_METHOD_EXIT();
401 return(true);
|
402 karl 1.5 }
|
403 tony 1.6 PEG_METHOD_EXIT();
404 return(false);
|
405 karl 1.5 }
406
407 Boolean _validateRequiredProperty(const CIMInstance& instance,
408 const CIMName& propertyName,
409 const Uint16& value)
410 {
|
411 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
412 "InteropProvider::_validateRequiredProperty()");
413
414 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "Validate "
415 + propertyName.getString());
416
|
417 karl 1.5 Uint32 pos;
418 if ((pos = instance.findProperty (propertyName)) == PEG_NOT_FOUND)
|
419 tony 1.6 {
420 PEG_METHOD_EXIT();
|
421 karl 1.5 return(false);
|
422 tony 1.6 }
|
423 karl 1.5 //
424 // Get the property
425 //
426 CIMConstProperty theProperty = instance.getProperty(pos);
427 CIMValue theValue = theProperty.getValue ();
428 //
|
429 tony 1.6 // ATTN:Required property must have a non-null value
|
430 karl 1.5 //
|
431 tony 1.6 if ((theValue.getType() != CIMTYPE_UINT16)
432 || (theValue.isNull()) )
433 {
434 PEG_METHOD_EXIT();
|
435 karl 1.5 return(false);
|
436 tony 1.6 }
437 PEG_METHOD_EXIT();
|
438 karl 1.5 return(true);
439 }
440 Boolean _validateRequiredProperty(const CIMObjectPath& objectPath,
441 const CIMName& propertyName,
442 const String value)
443 {
|
444 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
445 "InteropProvider::_validateRequiedProperty()");
|
446 karl 1.5 Array<CIMKeyBinding> kbArray = objectPath.getKeyBindings();
447
448 // find the correct key binding
449 for (Uint32 i = 0; i < kbArray.size(); i++)
450 {
451 if (kbArray[i].getName() == propertyName)
452 {
453 if (value != String::EMPTY)
454 {
455 if (value !=kbArray[i].getValue())
456 {
|
457 tony 1.6 PEG_METHOD_EXIT();
|
458 karl 1.5 return(true);
459 }
460 }
461 }
462 }
|
463 tony 1.6 PEG_METHOD_EXIT();
|
464 karl 1.5 return(true);
465 }
|
466 karl 1.1
467 /* Query the repository for array of all namespacenames
|
468 tony 1.6 @return Array<CIMNamespaceName> with all namespaces
469 @exception Passes all exception that repository may generate.
|
470 karl 1.1 */
471 Array<CIMNamespaceName> InteropProvider::_enumerateNameSpaces()
472 {
473 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
474 "InteropProvider::_enumerateNameSpaces()");
|
475 tony 1.6
|
476 karl 1.1 Array<CIMNamespaceName> namespaceNames;
477
|
478 tony 1.6 namespaceNames = _repository->enumerateNameSpaces();
|
479 karl 1.1
480 PEG_METHOD_EXIT();
481 return(namespaceNames);
482 }
483
|
484 tony 1.6 /* get a class defintion. Gets the class defined by
485 the parameters. Generates exception of class not defined.
|
486 karl 1.1 @param namespace in which to look for the class.
487 @param name of class to get.
488 @return the CIMClass object
489 @Exceptions any repository exceptions if class not found.
490 */
491 CIMClass InteropProvider::_getClass(const CIMNamespaceName& nameSpace,
|
492 tony 1.6 const CIMName& className)
|
493 karl 1.1 {
494 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
|
495 tony 1.6 "InteropProvider::_getClass");
496
497 CIMClass myClass = _repository->getClass(nameSpace, className,
498 false,true,true);
|
499 karl 1.1 PEG_METHOD_EXIT();
500 return myClass;
501 }
502
503 /* Verify that this is one of the legal classnames and
504 return indicator which.
505 @param - Classname
506 @return - Uint32 indicating type
507 @Exceptions - throws CIMNotSupportedException if invalid class.
508 */
|
509 kumpf 1.17 static targetClass _verifyValidClassInput(const CIMName& className)
|
510 karl 1.1 {
|
511 karl 1.10 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
512 "InteropProvider::_verifyValidClassInput");
|
513 karl 1.1 if (className.equal(CIM_OBJECTMANAGER_CLASSNAME))
514 return CIM_OBJECTMANAGER;
515
|
516 tony 1.6 if (className.equal(PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME))
517 return PG_CIMXMLCOMMUNICATIONMECHANISM;
|
518 karl 1.1
|
519 karl 1.19 if (className.equal(CIM_NAMESPACEINMANAGER_CLASSNAME))
520 return CIM_NAMESPACEINMANAGER;
521
|
522 karl 1.10 // Last entry, reverse test and return OK if PG_Namespace
|
523 karl 1.8 // Note: Changed to PG_Namespace for CIM 2.4
524 if (!className.equal(PG_NAMESPACE_CLASSNAME))
|
525 karl 1.1 throw CIMNotSupportedException
526 (className.getString() + " not supported by Interop Provider");
527
|
528 karl 1.10 PEG_METHOD_EXIT();
|
529 karl 1.8 return PG_NAMESPACE;
|
530 karl 1.1 }
531
|
532 kumpf 1.17 static targetAssocClass _verifyValidAssocClassInput(const CIMName& className)
|
533 tony 1.6 {
|
534 karl 1.10 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
535 "InteropProvider::_verifyValidAssocClassInput");
|
536 tony 1.6 if (className.equal(CIM_NAMESPACEINMANAGER_CLASSNAME))
|
537 karl 1.19 return CIM_NAMESPACEINMANAGERASSOC;
538
|
539 karl 1.8 // Last entry, reverse test and return OK if CIM_CommMech....
|
540 tony 1.6 if (!className.equal(CIM_COMMMECHANISMFORMANAGER_CLASSNAME))
541 throw CIMNotSupportedException
542 (className.getString() + " not supported by Interop Provider");
543
|
544 karl 1.10 PEG_METHOD_EXIT();
|
545 karl 1.19 return CIM_COMMMECHANISMFORMANAGERASSOC;
|
546 tony 1.6 }
547
|
548 karl 1.1 /* validate the authorization of the user name against the namespace.
549 */
550 String _validateUserID(const OperationContext & context)
551 {
|
552 karl 1.10 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
553 "InteropProvider::_validateUserID");
|
554 karl 1.1 //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER
555 String userName;
556 try
557 {
558 IdentityContainer container = context.get(IdentityContainer::NAME);
559 userName = container.getUserName();
560 }
|
561 karl 1.10
|
562 karl 1.1 catch (...)
563 {
564 userName = String::EMPTY;
565 }
|
566 karl 1.10
567 PEG_METHOD_EXIT();
|
568 karl 1.1 return userName;
569 }
570
|
571 karl 1.11 /** Set the value of a property defined by property name in the instance provided.
|
572 tony 1.6 Sets a String into the value field unless the property name cannot be found.
573 If the property cannot be found, it simply returns.
574 ATTN: This function does not pass an error back if property not found.
575 @param instance CIMInstance in which to set property value
576 @param propertyName CIMName of property in which value will be set.
577 @param value String value to set into property
578
579 */
580 void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const String& value)
581 {
582 Uint32 pos;
583 if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
584 instance.getProperty(pos).setValue(CIMValue(value));
585 }
586
587 void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Boolean& value)
588 {
589 Uint32 pos;
590 if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
591 instance.getProperty(pos).setValue(CIMValue(value));
592 }
|
593 karl 1.1
|
594 tony 1.6 void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Uint16& value)
595 {
596 Uint32 pos;
597 if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
598 instance.getProperty(pos).setValue(CIMValue(value));
599 }
600
601 void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Array<String>& value)
602 {
603 Uint32 pos;
604 if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
605 instance.getProperty(pos).setValue(CIMValue(value));
606 }
607
608 void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Array<Uint16>& value)
609 {
610 Uint32 pos;
611 if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
612 instance.getProperty(pos).setValue(CIMValue(value));
613 }
614
615 tony 1.6 void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const CIMObjectPath& value)
616 {
617 Uint32 pos;
618 if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
619 instance.getProperty(pos).setValue(CIMValue(value));
620 }
621
622 /** add the correct values to the common keys defined for all of the classes. This is
623 systemcreationclassname and systemname
624 Note that if the properties do not exist, we simply ignore them.
625 */
626 void _fixInstanceCommonKeys(CIMInstance& instance)
|
627 karl 1.1 {
628 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
|
629 tony 1.6 "InteropProvider::_fixInstanceCommonKeys()");
|
630 karl 1.1 String SystemCreationClassName = System::getSystemCreationClassName ();
631 if (SystemCreationClassName == String::EMPTY)
632 {
|
633 tony 1.6 //Attn: Get this globally. For now This in place because global is often Empty
|
634 karl 1.1 SystemCreationClassName = "CIM_ComputerSystem";
635 }
636
|
637 tony 1.6 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,SystemCreationClassName);
|
638 karl 1.1
|
639 karl 1.5 // Add property SystemName
|
640 tony 1.6
641 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMNAME,System::getHostName());
|
642 karl 1.1 PEG_METHOD_EXIT();
643 }
644
|
645 tony 1.6 /** builds one instance of the class named className. Gets Class defintion and f
646 fills in the correct properties from the class. This requires a repository
647 getclass request for each instance built. The skeleton is built by
648 creating the instance and copying qualifiers and properties from
649 the class. Finally the instance is cloned to separate it from the
650 original objects.
651 NOTE: This is very inefficient for anything larger than a few instances.
652 We should separate the get from the createSkeleton.
653 @param className CIMName of the class for which the instance is to be built
654 @return CIMInstance of this class with properties complete.
655 @exception passes on any exceptions received from the repository request.
656 */
657 CIMInstance InteropProvider::_buildInstanceSkeleton(const CIMName& className)
|
658 karl 1.1 {
659 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
|
660 tony 1.6 "InteropProvider::_buildInstanceSkeleton()");
|
661 karl 1.10 CIMClass myClass;
|
662 karl 1.1
|
663 tony 1.6 CIMInstance skeleton(className);
664 myClass = _repository->getClass(_operationNamespace, className, false, true, true);
|
665 karl 1.1
|
666 tony 1.6 // copy the qualifiers
667 for (Uint32 i = 0 ; i < myClass.getQualifierCount() ; i++)
668 skeleton.addQualifier(myClass.getQualifier(i));
669
670 // copy the properties
671 for (Uint32 i = 0 ; i < myClass.getPropertyCount() ; i++)
672 skeleton.addProperty(myClass.getProperty(i));
|
673 karl 1.1
674 PEG_METHOD_EXIT();
|
675 tony 1.6 return(skeleton.clone());
|
676 karl 1.1 }
677
|
678 tony 1.6 /* build a single instance of the cimxmlcommunicationmechanism class
679 using the parameter provided as the name property
680 @parm name String representing the name to be used for this object.
681 @return CIMInstance of the class
|
682 karl 1.5 */
|
683 tony 1.6 CIMInstance InteropProvider::_buildInstancePGCIMXMLCommunicationMechanism(
684 const String& namespaceType,
685 const String& IPAddress,
686 const Boolean& includeQualifiers,
687 const Boolean& includeClassOrigin,
688 const CIMPropertyList& propertyList)
|
689 karl 1.1 {
690 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
|
691 tony 1.6 "InteropProvider::_buildInstancePGCIMXMLCommunicationMechanism()");
|
692 karl 1.1
|
693 tony 1.6 CIMInstance instance = _buildInstanceSkeleton(PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME);
|
694 karl 1.1
|
695 tony 1.6 _fixInstanceCommonKeys(instance);
|
696 karl 1.1
|
697 tony 1.6 //CreationClassName
698 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME.getString());
|
699 karl 1.1
|
700 karl 1.19 //Name, this CommunicationMechanism. We need to make it unique. To do this
701 // we simply append the commtype to the classname since we have max of two right
702 // now.
703 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, (String("PEGASUSCOMM") + namespaceType));
|
704 karl 1.1
|
705 karl 1.19 // CommunicationMechanism Property - Force to 2.
|
706 tony 1.6 _setPropertyValue(instance, OM_COMMUNICATIONMECHANISM, Uint16(2));
|
707 karl 1.1
708 //Functional Profiles Supported Property.
709 Array<Uint16> profiles;
|
710 tony 1.6 Array<String> profileDescriptions = _getFunctionalProfiles(profiles);
|
711 karl 1.1
|
712 tony 1.6 // Set functional profiles in instance
713 _setPropertyValue(instance, OM_FUNCTIONALPROFILESSUPPORTED, profiles);
714
715 _setPropertyValue(instance, OM_FUNCTIONALPROFILEDESCRIPTIONS, profileDescriptions);
|
716 karl 1.1
717 // Multiple OperationsSupported Property
|
718 tony 1.6 _setPropertyValue(instance, OM_MULTIPLEOPERATIONSSUPPORTED, false);
|
719 karl 1.5
720 // AuthenticationMechanismsSupported Property
|
721 karl 1.1 Array<Uint16> authentications;
722 Array<String> authenticationDescriptions;
|
723 karl 1.5
|
724 karl 1.19 // Note that we have fixed authentication here.
|
725 tony 1.7 authentications.append(3); authenticationDescriptions.append("Basic");
|
726 karl 1.5
|
727 tony 1.6 _setPropertyValue(instance, OM_AUTHENTICATIONMECHANISMSSUPPORTED, authentications);
728
729 _setPropertyValue(instance, OM_AUTHENTICATIONMECHANISMDESCRIPTIONS, authenticationDescriptions);
|
730 karl 1.1
|
731 tony 1.6 _setPropertyValue(instance, OM_VERSION, CIMXMLProtocolVersion);
732
|
733 karl 1.19 // Obsolete function _setPropertyValue(instance, "namespaceType", namespaceType);
|
734 tony 1.6
735 _setPropertyValue(instance, "IPAddress", IPAddress);
|
736 karl 1.1
737 PEG_METHOD_EXIT();
738 return(instance);
739 }
|
740 tony 1.6
741 Array<CIMInstance> InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanism(
742 const Boolean includeQualifiers,
743 const Boolean includeClassOrigin,
744 const CIMPropertyList& propertyList)
745 {
|
746 karl 1.10 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
747 "InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanism");
748
|
749 tony 1.6 // This is a temporary hack to get the multiple connections.
750 ConfigManager* configManager = ConfigManager::getInstance();
751 Boolean enableHttpConnection = String::equal(
752 configManager->getCurrentValue("enableHttpConnection"), "true");
753 Boolean enableHttpsConnection = String::equal(
754 configManager->getCurrentValue("enableHttpsConnection"), "true");
755
756 String IPAddress = _getHostAddress(System::getHostName());
757 Array<CIMInstance> instances;
758
759 if (enableHttpConnection)
760 {
761 CDEBUG("building pgcimxmlinstances 1");
762 CIMInstance instance = _buildInstancePGCIMXMLCommunicationMechanism(
763 "http", IPAddress,
764 includeQualifiers,
765 includeClassOrigin,
766 propertyList);
767 instances.append(instance);
768 }
769
770 tony 1.6 if (enableHttpsConnection)
771 {
772 CDEBUG("building pgcimxmlinstances 2");
773 CIMInstance instance = _buildInstancePGCIMXMLCommunicationMechanism(
774 "https", IPAddress,
775 includeQualifiers,
776 includeClassOrigin,
777 propertyList);
778 instances.append(instance);
779 }
|
780 karl 1.10 PEG_METHOD_EXIT();
|
781 tony 1.6 return(instances);
782 }
783 /* Gets the value for the CIMObjectManager name. This is a key
784 property with the following characteristics.
785 1. It is persistent. This must be persistent through CIMOM
786 restarts. We will save it in the instance database to achieve this.
787 2. It must be unique. We cannot create duplicate CIMOM names
788 3. It is based on the DMTF description of how unique InstanceIds
789 are defined (Trademark/etc followed by unique identification.
790 Use the Global constant PegasusInstanceIDGlobalPrefix as the
791 prefix allowing this to be changed.
792 */
793 String buildObjectManagerName()
794 {
795 return(getTrademarkCIMOMIDPrefix() + ":" + getUUIDString());
|
796 karl 1.1 }
797
|
798 karl 1.10 /** get either the local or disk CIMObjectmanager instance.
799 @return Boolean true if already exists. False if
800 not initialized. Also returns with the current version set
801 into local parameter.
802 ATTN: Probably should get rid of the local parameter since
803 this is used so infrequently, waste of space.
804 */
805 Boolean InteropProvider::_getInstanceCIMObjectManager(
806 const Boolean includeQualifiers,
807 const Boolean includeClassOrigin,
808 const CIMPropertyList& propertyList)
809 {
810
811 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
812 "InteropProvider::_getInstanceCIMObjectManager");
813 // If there is already an instance of this class local use it.
814 if (!instanceOfCIMObjectManager.isUninitialized())
815 {
816 PEG_METHOD_EXIT();
817 return(true);
818 }
819 karl 1.10 // Try to get persistent instance from repository
820 Array<CIMInstance> instances;
821 try
822 {
823 instances = _repository->enumerateInstances(_operationNamespace,
824 CIM_OBJECTMANAGER_CLASSNAME, true, false, includeQualifiers,
825 includeClassOrigin, propertyList);
826
827 if (instances.size() >= 1)
828 {
829 // set this instance into global variable.
830 instanceOfCIMObjectManager = instances[0];
831
832 // log entry if there is more than one instance.
833 // Some day we may support multiple entries to see other CIMOMs but
834 // for now this should be illegal and represent an internal error.
835 // but we will still continue to use the first entry.
836 if (instances.size() > 1)
837 {
838 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
839 "Error. Multiple definitons of : $0", CIM_OBJECTMANAGER_CLASSNAME.getString());
840 karl 1.10 }
841 return(true);
842 }
843 else
844 return(false);
845 }
846 catch(CIMException& e)
847 {
848 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
849 "Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString());
850 PEG_METHOD_EXIT();
851 throw e;
852 }
853 catch(Exception& e)
854 {
855 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
856 "Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString());
857 PEG_METHOD_EXIT();
858 throw e;
859 }
860 }
861 karl 1.10
862
|
863 tony 1.6 /** build an instance of the CIM_ObjectManager class filling out
864 the required properties
865 @param includeQualifiers Boolean
866 @param includeClassOrigin Boolean
867 @param propertylist CIMPropertyList
868 @return CIMInstance with a single built instance of the class
869 @exception repository instances if exception to enumerateInstances
870 for this class.
871 */
872 CIMInstance InteropProvider::_buildInstanceCIMObjectManager(
873 const Boolean includeQualifiers,
874 const Boolean includeClassOrigin,
875 const CIMPropertyList& propertyList)
|
876 karl 1.1 {
877 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
|
878 karl 1.10 "InteropProvider::_buildInstanceCIMObjectManager");
|
879 karl 1.1
|
880 karl 1.10 // Try to get the current object. If true then it is already created.
881 if (_getInstanceCIMObjectManager(includeQualifiers,includeClassOrigin,propertyList))
|
882 karl 1.5 {
883 PEG_METHOD_EXIT();
884 return(instanceOfCIMObjectManager);
885 }
886 //
|
887 karl 1.8 // No instance in the repository. Build new instance and save it.
|
888 karl 1.5 //
|
889 tony 1.6 CIMInstance instance = _buildInstanceSkeleton(CIM_OBJECTMANAGER_CLASSNAME);
890
891 _fixInstanceCommonKeys(instance);
|
892 karl 1.1
|
893 tony 1.6 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,CIM_OBJECTMANAGER_CLASSNAME.getString());
|
894 karl 1.1
|
895 tony 1.6 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME,buildObjectManagerName());
896
897 _setPropertyValue(instance, CIMName("ElementName"), String("Pegasus"));
898
|
899 karl 1.8 //
|
900 tony 1.6 //Description property this object manager instance
|
901 karl 1.10 // default is Pegasus CIM_Server Version.
902 // Provided undocumented option to get this from the environment.
903 // This should probably be removed or documented.
|
904 karl 1.8 //
|
905 tony 1.6 String description;
906 char * envDescription;
907 envDescription = getenv("PEGASUS_CIMOM_DESCRIPTION");
908
|
909 karl 1.10 description = (envDescription) ?
910 envDescription :
|
911 kumpf 1.15 "Pegasus " + String(PEGASUS_PRODUCT_NAME) + " Version " +
|
912 kumpf 1.13 String(PEGASUS_PRODUCT_VERSION);
|
913 tony 1.6
914 _setPropertyValue(instance, CIMName("Description"), description);
|
915 karl 1.1
|
916 karl 1.8 //Property GatherStatisticalData. Initially this is set to false
917 // and can then be modified by a modify instance on the instance.
918
|
919 karl 1.10 Boolean gatherStatDataFlag = false;
920
921 _setPropertyValue(instance, OM_GATHERSTATISTICALDATA, Boolean(gatherStatDataFlag));
922
923 // ATTN: This one is a problem KS rethink this.
924 // the following is a temporary hack to set the value of the statistics
925 // gathering function dynamically. We simply get the correct value
926 // and call the internal method to set it each time this object is
927 // built.
|
928 karl 1.16 #ifndef PEGASUS_DISABLE_PERFINST
|
929 karl 1.10 StatisticalData* sd = StatisticalData::current();
930 sd->setCopyGSD(gatherStatDataFlag);
931 #endif
|
932 tony 1.6
|
933 karl 1.20 // write instance to the repository
|
934 karl 1.10 CIMObjectPath instancePath;
935 // Add the instance path to this if necessary ATTN ATTN:
|
936 karl 1.5 try
937 {
|
938 karl 1.10 instancePath = _repository->createInstance(_operationNamespace,
939 instance );
|
940 karl 1.5 }
941 catch(CIMException& e)
942 {
|
943 tony 1.6 // ATTN: KS generate log error if this not possible
|
944 karl 1.5 PEG_METHOD_EXIT();
945 throw e;
946 }
947 catch(Exception& e)
948 {
|
949 karl 1.10 // ATTN: Generate log error.
950 PEG_METHOD_EXIT();
|
951 karl 1.5 throw e;
952 }
|
953 karl 1.10 instance.setPath(instancePath);
954 CDEBUG("CIMObjectMgr path = " << instancePath.toString());
955 // Save this instance for other requests
|
956 a.dunfey 1.21 instanceOfCIMObjectManager = instance.clone();
|
957 karl 1.20 instance.filter(includeQualifiers, includeClassOrigin, propertyList);
|
958 karl 1.5 PEG_METHOD_EXIT();
|
959 karl 1.20 return(instance);
|
960 karl 1.1 }
961
|
962 karl 1.8 /** Get the instances of CIM_Namespace. Gets all instances of the namespace from
963 the repository namespace management functions
964 Pegasus 2.4 - This now gets CIM_Namespace and its subclass PG_Namespace
|
965 tony 1.6 */
966 Array<CIMInstance> InteropProvider::_getInstancesCIMNamespace(const Boolean& includeQualifiers,
967 const Boolean& includeClassOrigin,
968 const CIMPropertyList& propertyList)
969 {
970 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
971 "InteropProvider::_getInstancesCIMNamespace()");
|
972 karl 1.8
973 CDEBUG("_getinstancesPGNamespace");
|
974 tony 1.6 Array<CIMNamespaceName> namespaceNames = _enumerateNameSpaces();
|
975 karl 1.10 CDEBUG("_getInstancesCIMNamespace. count = " << namespaceNames.size());
|
976 tony 1.6 Array<CIMInstance> instanceArray;
977
|
978 karl 1.8 // We build instances of PG namespace since that is the leaf class
|
979 tony 1.6 for (Uint32 i = 0; i < namespaceNames.size(); i++)
980 {
|
981 karl 1.8 instanceArray.append( _buildInstancePGNamespace(namespaceNames[i]));
|
982 tony 1.6 }
|
983 karl 1.10 CDEBUG("Build this many PG_Namespace Instances. count= " << instanceArray.size());
|
984 tony 1.6 PEG_METHOD_EXIT();
985 return(instanceArray);
986 }
987
988 /** get the instance of namespace defined by the input parameter which is the object path
989 for the instance required.
990 ATTN: Note that this is incorrect. We are supplying the namespace name and need to supply
991 the objectpath
992 @param TBD
993 @return CIMInstance with the found instance or CIMInstance() if nothing found.
994 */
995 CIMInstance InteropProvider::_getInstanceCIMNamespace(const CIMNamespaceName & nameSpace)
996 {
997 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
998 "InteropProvider::_getInstancesCIMNamespace()");
999
1000 CDEBUG("_getinstanceCIMNamespace Gets ONE only from Namespace=" << nameSpace.getString());
1001 Array<CIMInstance> instances = _getInstancesCIMNamespace(true, true, CIMPropertyList());
1002
|
1003 karl 1.8 // search the instances for one with the name property value = input parameter.
|
1004 tony 1.6 for (Uint32 i = 0 ; i < instances.size() ; i++)
1005 {
|
1006 karl 1.8 if (_getPropertyValue(instances[i], CIMName("name"), String::EMPTY) == nameSpace.getString())
|
1007 tony 1.6 {
1008 PEG_METHOD_EXIT();
1009 return(instances[i]);
1010 }
1011 }
1012 PEG_METHOD_EXIT();
1013 CIMInstance nullInstance;
1014 return(nullInstance);
1015 }
1016
1017 CIMObjectPath InteropProvider::_buildReference(const CIMInstance& instance, const CIMName& className)
1018 {
1019 return(_buildObjectPath(_operationNamespace,className, instance));
1020 }
1021
1022 Array<CIMInstance> InteropProvider::_buildInstancesNamespaceInManager()
1023 {
|
1024 karl 1.10 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1025 "InteropProvider::_buildInstancesNamespaceInManager");
|
1026 tony 1.6
1027 Array<CIMInstance> namespaceInstances = _getInstancesCIMNamespace(false,
1028 false, CIMPropertyList());
1029
1030 CIMInstance instanceObjMgr = _buildInstanceCIMObjectManager( true, true, CIMPropertyList());
1031
1032 CIMObjectPath refObjMgr = _buildReference(instanceObjMgr, CIM_OBJECTMANAGER_CLASSNAME);
1033
1034 Array<CIMInstance> assocInstances;
1035
1036 for (Uint32 i = 0 ; i < namespaceInstances.size() ; i++)
1037 {
1038 CIMInstance instance = _buildInstanceSkeleton(CIM_NAMESPACEINMANAGER_CLASSNAME);
1039
1040 _setPropertyValue(instance, CIMName("Antecdent"), refObjMgr);
1041 //ATTNATTN: this is weak qualifier.
1042 _setPropertyValue(instance, CIMName("Dependent"), _buildReference(namespaceInstances[i],
1043 CIM_NAMESPACEINMANAGER_CLASSNAME));
1044 assocInstances.append(instance);
1045 }
|
1046 karl 1.10
1047 PEG_METHOD_EXIT();
|
1048 tony 1.6 return(assocInstances);
1049 }
1050
1051 Array<CIMInstance> InteropProvider::_buildInstancesCommMechanismForManager()
1052 {
|
1053 karl 1.10 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1054 "InteropProvider::_buildInstancesCommMechanismForManager");
|
1055 tony 1.6
1056 Array<CIMInstance> commInstances = _buildInstancesPGCIMXMLCommunicationMechanism(true,
1057 true, CIMPropertyList());
1058
1059 CIMInstance instanceObjMgr = _buildInstanceCIMObjectManager( true, true, CIMPropertyList());
1060
1061 CIMObjectPath refObjMgr = _buildReference(instanceObjMgr, CIM_OBJECTMANAGER_CLASSNAME);
1062 Array<CIMInstance> assocInstances;
1063
1064 for (Uint32 i = 0 ; i < commInstances.size() ; i++)
1065 {
1066
1067 CIMInstance instance = _buildInstanceSkeleton(CIM_COMMMECHANISMFORMANAGER_CLASSNAME);
1068
1069 _setPropertyValue(instance,CIMName("Antecdent"), refObjMgr);
1070 //ATTNATTN: this is weak qualifier.
1071 _setPropertyValue(instance,CIMName("Dependent"), _buildReference(commInstances[i],CIM_COMMMECHANISMFORMANAGER_CLASSNAME));
1072 assocInstances.append(instance);
1073 }
|
1074 karl 1.10
1075 PEG_METHOD_EXIT();
|
1076 tony 1.6 return(assocInstances);
1077 }
1078
|
1079 karl 1.1 /* generate one instance of the CIM_Namespace class with the
1080 properties
|
1081 karl 1.8 NOTE: CIM 2.4 - Changed to build PG namespace
|
1082 karl 1.1 @param namespace name to put into the class
1083 @exceptions - exceptions carried forward from create instance
1084 and addProperty.
1085 */
|
1086 karl 1.8 CIMInstance InteropProvider::_buildInstancePGNamespace(const CIMNamespaceName & nameSpace)
|
1087 karl 1.1 {
1088 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
|
1089 karl 1.10 "InteropProvider::_buildInstancePGNamespace");
|
1090 tony 1.6
1091 // ATTN: KS need to get the real objectManager name from elsewhere. the only place
1092 // this exists is through the objectmanager object.
1093 // ATTN: Should we be saving the objectmanager name somewhere internally either in
1094 // interop or more generally somewhere within the system for common access.
|
1095 karl 1.1 String ObjectManagerName = "ObjectManagerNameValue";
1096
|
1097 karl 1.8 CIMInstance instance = _buildInstanceSkeleton(PG_NAMESPACE_CLASSNAME);
|
1098 karl 1.1
|
1099 tony 1.6 _fixInstanceCommonKeys(instance);
|
1100 karl 1.1
1101 //ObjectManagerCreationClassName
|
1102 tony 1.6 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, CIM_OBJECTMANAGER_CLASSNAME.getString());
1103
|
1104 karl 1.1 //ObjectManagerName
|
1105 tony 1.6 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, ObjectManagerName);
1106
|
1107 karl 1.1 //CreationClassName
|
1108 tony 1.6 // Class in which this was created,
1109 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, CIM_NAMESPACE_CLASSNAME.getString());
|
1110 karl 1.1 //Name
|
1111 tony 1.6 // This is the namespace name itself
1112 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, nameSpace.getString());
|
1113 karl 1.1
1114 //ClassInfo
|
1115 tony 1.6 // Set the classinfo to unknown and the description to namespace.
1116 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CLASSINFO, Uint16(0));
1117 _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO, String("namespace"));
1118
|
1119 karl 1.8 //
1120 // Everything above was commmon to CIM Namespace. The following is PG_Namespace Properties
1121 //
1122 // ATTN: KS Get the correct values for these entities from repository interface.
|
1123 karl 1.10 CDEBUG("_buildPGNS Instance get namespace attributes for namespace= " << nameSpace.getString());
|
1124 karl 1.8 CIMRepository::NameSpaceAttributes attributes;
1125 _repository->getNameSpaceAttributes(nameSpace.getString(), attributes);
1126 String parent="";
|
1127 karl 1.11 String name = "";
|
1128 karl 1.8 Boolean shareable=false;
1129 Boolean updatesAllowed=true;
1130 for (CIMRepository::NameSpaceAttributes::Iterator i = attributes.start(); i; i++)
1131 {
1132 String key=i.key();
|
1133 karl 1.10 String value = i.value();
1134 CDEBUG("Show Attributes. key= " << key << " value= " << value);
|
1135 karl 1.8 if (String::equalNoCase(key,"shareable"))
|
1136 karl 1.11 {
|
1137 karl 1.10 if (String::equalNoCase(value,"true"))
1138 shareable=true;
|
1139 karl 1.11 }
|
1140 karl 1.8 else if (String::equalNoCase(key,"updatesAllowed"))
|
1141 karl 1.11 {
|
1142 karl 1.10 if (String::equalNoCase(value,"false"))
1143 updatesAllowed=false;
|
1144 karl 1.11 }
|
1145 karl 1.10 // Test to be sure we are returning proper namespace name
1146 else if (String::equalNoCase(key,"name"))
|
1147 karl 1.8 {
|
1148 karl 1.10 if (!String::equalNoCase(value, nameSpace.getString()))
1149 {
1150 PEG_METHOD_EXIT();
1151 // This is poor exception since it reflects internal error. Do error log
1152 throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED,
1153 "Namespace attribute rtnd error for key " + key + "expected " +
1154 nameSpace.getString()+ value + " in " + String(thisProvider));
1155 }
|
1156 karl 1.11
1157 name = value;
|
1158 karl 1.8 }
1159 else if (String::equalNoCase(key,"parent"))
|
1160 karl 1.11 {
|
1161 karl 1.10 parent=value;
|
1162 karl 1.11 }
|
1163 karl 1.8 else
1164 {
1165 PEG_METHOD_EXIT();
|
1166 karl 1.10 // Poor error definition since it reflects internal error. do error log
|
1167 karl 1.8 throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, nameSpace.getString()+
|
1168 karl 1.10 " namespace attribute " + key + " option not supported in"+ String(thisProvider));
|
1169 karl 1.8 }
1170 }
1171 _setPropertyValue(instance, PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, updatesAllowed);
1172 _setPropertyValue(instance, PG_NAMESPACE_PROPERTY_ISSHAREABLE, shareable);
1173 _setPropertyValue(instance, PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, parent);
|
1174 karl 1.11 _setPropertyValue(instance, PG_NAMESPACE_PROPERTY_NAME, name);
|
1175 karl 1.8
|
1176 karl 1.1 PEG_METHOD_EXIT();
1177 return(instance);
1178 }
|
1179 karl 1.5 void _validateCIMNamespaceKeys(const CIMObjectPath& objectPath)
1180 {
|
1181 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1182 "InteropProvider::_validateCIMNamespaceKeys");
1183
|
1184 karl 1.5 Boolean valid = true;
1185 CIMName propertyName;
1186 if (!_validateRequiredProperty(objectPath,
1187 CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
1188 System::getSystemCreationClassName ()))
1189 {
1190 propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME;
1191 valid = false;
1192 }
1193 if (!_validateRequiredProperty(objectPath,
1194 CIM_NAMESPACE_PROPERTY_SYSTEMNAME,
1195 System::getHostName()))
1196 {
1197 propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME;
1198 valid = false;
1199 }
1200 if (!_validateRequiredProperty(objectPath,
1201 CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME,
1202 CIM_OBJECTMANAGER_CLASSNAME.getString()))
1203 {
1204 propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME;
1205 karl 1.5 valid = false;
1206 }
1207
1208 // ATTN: This one still a problem. We have to get the name first
1209 if (!_validateRequiredProperty(objectPath,
1210 CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME,
1211 String::EMPTY))
1212 {
1213 propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME;
1214 valid = false;
1215 }
1216 if (!_validateRequiredProperty(objectPath,
1217 CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
1218 System::getHostName()))
1219 {
1220 propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME;
1221 valid = false;
1222 }
1223
1224 if (!_validateRequiredProperty(objectPath,
1225 CIM_NAMESPACE_PROPERTY_NAME,
1226 karl 1.5 String::EMPTY))
1227 {
1228 propertyName = CIM_NAMESPACE_PROPERTY_NAME;
1229 valid = false;
1230 }
1231
1232 if (false)
1233 {
|
1234 tony 1.6 PEG_METHOD_EXIT();
|
1235 karl 1.5 throw CIMInvalidParameterException(
1236 "Invalid key property: " + propertyName.getString());
1237 }
|
1238 tony 1.6 PEG_METHOD_EXIT();
1239 }
|
1240 karl 1.5
|
1241 karl 1.11 /** completes a property in the defined instance either
1242 by adding the complete property if it does not exist
1243 or by adding the value if the property does exist.
1244 Used to make sure that key properties for things
1245 like systemcreationclass are included in the
1246 creation of new instances and that the
1247 values are logical for the CIMOM.
1248 */
1249 Boolean _completeProperty(CIMInstance& instance,
1250 const CIMName& propertyName,
1251 const String& value)
1252 {
1253
1254 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1255 "InteropProvider::_completeProperty()");
1256
1257 Uint32 pos;
1258
1259 if (!_validateRequiredProperty(instance,
1260 propertyName,
1261 value))
1262 karl 1.11 {
1263 if ((pos = instance.findProperty (propertyName)) == PEG_NOT_FOUND)
1264 {
1265 // Add the property. Should be from the class.
1266 PEG_METHOD_EXIT();
1267 return(false);
1268 }
1269 else
1270 {
1271 //
1272 _setPropertyValue(instance, propertyName, value);
1273 }
1274 }
1275
1276 PEG_METHOD_EXIT();
1277 return(true);
1278 }
1279 Boolean _completeCIMNamespaceKeys(CIMInstance& instance)
1280 {
1281
1282 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1283 karl 1.11 "InteropProvider::_completeCIMNamespaceKeys");
1284
1285 Boolean valid = true;
1286 CIMName propertyName;
1287
1288 if (!_completeProperty(instance,
1289 CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
1290 System::getSystemCreationClassName ()))
1291 {
1292
1293 propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME;
1294 valid = false;
1295 }
1296
1297 if (!_completeProperty(instance,
1298 CIM_NAMESPACE_PROPERTY_SYSTEMNAME,
1299 System::getHostName()))
1300 {
1301 propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME;
1302 valid = false;
1303 }
1304 karl 1.11
1305 if (!_completeProperty(instance,
1306 CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME,
1307 CIM_OBJECTMANAGER_CLASSNAME.getString()))
1308 {
1309 propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME;
1310 valid = false;
1311 }
1312
1313 if (!_completeProperty(instance,
1314 CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME,
1315 String::EMPTY))
1316 {
1317 propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME;
1318 valid = false;
1319 }
1320 if (!_completeProperty(instance,
1321 CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
1322 System::getHostName()))
1323 {
1324 propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME;
1325 karl 1.11 valid = false;
1326 }
1327
1328 if (!_completeProperty(instance,
1329 CIM_NAMESPACE_PROPERTY_NAME,
1330 String::EMPTY))
1331 {
1332 propertyName = CIM_NAMESPACE_PROPERTY_NAME;
1333 valid = false;
1334 }
1335
1336 if (!valid)
1337 {
1338 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1339 "Invalid CIM_Namespace Key Property " + propertyName.getString());
1340 PEG_METHOD_EXIT();
1341 throw CIMInvalidParameterException(
1342 "Invalid CIM_Namespace key property: " + propertyName.getString());
1343 }
1344 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "CIM_Namespace Keys Valid");
1345 PEG_METHOD_EXIT();
1346 karl 1.11 return(valid);
1347 }
1348
1349
|
1350 karl 1.5 void _validateCIMNamespaceKeys(const CIMInstance& instance)
1351 {
|
1352 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1353 "InteropProvider::_validateCIMNamespaceKeys");
|
1354 karl 1.5 Boolean valid = true;
1355 CIMName propertyName;
1356 if (!_validateRequiredProperty(instance,
1357 CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
1358 System::getSystemCreationClassName ()))
1359 {
1360 propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME;
1361 valid = false;
1362 }
1363
1364 if (!_validateRequiredProperty(instance,
1365 CIM_NAMESPACE_PROPERTY_SYSTEMNAME,
1366 System::getHostName()))
1367 {
1368 propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME;
1369 valid = false;
1370 }
1371
1372 if (!_validateRequiredProperty(instance,
1373 CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME,
1374 CIM_OBJECTMANAGER_CLASSNAME.getString()))
1375 karl 1.5 {
1376 propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME;
1377 valid = false;
1378 }
1379
1380 // ATTN: This one still a problem. We have to get the name first
1381 if (!_validateRequiredProperty(instance,
1382 CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME,
1383 String::EMPTY))
1384 {
1385 propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME;
1386 valid = false;
1387 }
1388 if (!_validateRequiredProperty(instance,
1389 CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
1390 System::getHostName()))
1391 {
1392 propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME;
1393 valid = false;
1394 }
1395
1396 karl 1.5 if (!_validateRequiredProperty(instance,
1397 CIM_NAMESPACE_PROPERTY_NAME,
1398 String::EMPTY))
1399 {
1400 propertyName = CIM_NAMESPACE_PROPERTY_NAME;
1401 valid = false;
1402 }
1403
1404 if (false)
1405 {
|
1406 tony 1.6 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1407 "Invalid CIM_Namespace Key Property " + propertyName.getString());
1408 PEG_METHOD_EXIT();
|
1409 karl 1.5 throw CIMInvalidParameterException(
|
1410 tony 1.6 "Invalid CIM_Namespace key property: " + propertyName.getString());
|
1411 karl 1.5 }
|
1412 tony 1.6 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "CIM_Namespace Keys Valid");
1413 PEG_METHOD_EXIT();
1414 }
1415
1416 /** builds complete object path from instance and classinfo by building the full path
1417 with host and namespace names included.
1418 */
1419 CIMObjectPath InteropProvider::_buildObjectPath(const CIMNamespaceName& name,
1420 const CIMName& className,
1421 const CIMInstance& instance)
1422 {
|
1423 karl 1.10 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1424 "InteropProvider::_buildObjectPath");
1425
|
1426 tony 1.6 CIMObjectPath objectPath;
1427 objectPath = _buildInstancePath(name,className,instance);
1428
1429 objectPath.setHost(System::getHostName());
1430
1431 objectPath.setNameSpace(name);
|
1432 karl 1.10
1433 PEG_METHOD_EXIT();
|
1434 tony 1.6 return(objectPath);
|
1435 karl 1.5 }
1436
|
1437 tony 1.6 /* Given a class and instance build the instance path for a
|
1438 karl 1.1 the object. This builds all components of the path
1439 @param namespace name to build
1440 @return CIMObjectPath containing namespace, class and keybinding
1441 components of path
|
1442 tony 1.6 @exceptions - Passes repository exceptions.
|
1443 karl 1.1 */
1444
1445 CIMObjectPath InteropProvider::_buildInstancePath(const CIMNamespaceName& name,
|
1446 tony 1.6 const CIMName& className,
|
1447 karl 1.1 const CIMInstance& instance)
1448 {
1449 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
|
1450 tony 1.6 "InteropProvider::_buildInstancePath");
|
1451 karl 1.1
1452 // get the class CIM_Namespace class to use in building path
|
1453 tony 1.6 // Exception out if Class does not exist in this namespace
1454 CIMClass thisClass = _getClass(name, className);
|
1455 karl 1.1
1456 CIMObjectPath ref = instance.buildPath(thisClass);
1457
1458 PEG_METHOD_EXIT();
1459 return(ref);
1460 }
1461
1462 /* _isNamespace determines if the namespace in the second
1463 parameter is in the array in the first parameter.
1464 @param array of possible namespaces
1465 @param canidate namespace
1466 @return - true if found
1467 */
|
1468 carson.hovey 1.22 static Boolean _isNamespace(
|
1469 tony 1.6 Array<CIMNamespaceName>& namespaceNames,
1470 CIMNamespaceName& namespaceName)
|
1471 karl 1.1 {
|
1472 karl 1.10 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1473 "InteropProvider::_isNamespace");
1474
|
1475 karl 1.1 Boolean found = false;
1476 for(Uint32 i = 0; i < namespaceNames.size(); i++)
1477 {
|
1478 tony 1.6 if(namespaceNames[i].equal ( namespaceName ))
|
1479 karl 1.1 return true;
1480 }
|
1481 karl 1.10
1482 PEG_METHOD_EXIT();
|
1483 karl 1.1 return false;
1484 }
1485
1486 //**************************************************************
1487 // Overloaded functions to get key value with different params
1488 //**************************************************************
1489
|
1490 tony 1.6 /* find the name key in the keybindings and return the value.
|
1491 karl 1.1 Executes exception if the key not found
1492 @param object path we will search
1493 @param keyName - Name of the key to find.
1494 @return value of name property
1495 @exceptions CIMInvalidParameterException
1496 */
1497 String _getKeyValue(const CIMObjectPath& instanceName, const CIMName& keyName)
1498 {
1499 Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings();
1500
1501 // find the correct key binding
1502 for (Uint32 i = 0; i < kbArray.size(); i++)
1503 {
1504 if (kbArray[i].getName() == keyName)
1505 return (kbArray[i].getValue());
1506 }
|
1507 tony 1.6
|
1508 karl 1.1 throw CIMInvalidParameterException("Invalid key property: " + keyName.getString());
1509 }
1510
1511 String _getKeyValue(const CIMInstance& instance, const CIMName& keyName)
1512 {
1513 Uint32 pos;
1514 CIMValue propertyValue;
1515
1516 pos = instance.findProperty(keyName);
1517 if (pos == PEG_NOT_FOUND)
1518 throw CIMPropertyNotFoundException
1519 (NAMESPACE_PROPERTYNAME.getString());
1520
1521 propertyValue = instance.getProperty(pos).getValue();
1522 if (propertyValue.getType() != CIMTYPE_STRING)
1523 throw CIMInvalidParameterException("Invalid type for property: "
1524 + NAMESPACE_PROPERTYNAME.getString());
1525 String name;
1526 propertyValue.get(name);
1527 return(name);
1528 //ATTN: KS Returns String whereas below returns CIMNamespaceName.
1529 karl 1.1 }
1530
1531 //***************************************************************************
1532 // The following section is the Instance Operation processors
1533 //***************************************************************************
1534 // createInstance
1535 //***************************************************************************
1536 void InteropProvider::createInstance(
1537 const OperationContext & context,
1538 const CIMObjectPath & instanceReference,
1539 const CIMInstance& myInstance,
1540 ObjectPathResponseHandler & handler)
1541 {
1542 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::createInstance()");
1543
|
1544 karl 1.11 handler.processing();
|
1545 karl 1.1 CIMNamespaceName newNamespaceName;
1546 CDEBUG("CreateInstance " << instanceReference.toString());
1547 // operation namespace needed internally to get class.
1548 _operationNamespace = instanceReference.getNameSpace();
1549
1550 // Verify that ClassName is correct and get value
|
1551 karl 1.11 targetClass classEnum = _verifyValidClassInput(instanceReference.getClassName());
1552
|
1553 karl 1.1 String userName = _validateUserID(context);
1554 CIMObjectPath newInstanceReference;
|
1555 karl 1.11
|
1556 karl 1.5 if ((classEnum == CIM_OBJECTMANAGER) ||
|
1557 tony 1.6 (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM))
|
1558 karl 1.5 throw CIMNotSupportedException("InteropProvider, Create Not allowed");
|
1559 karl 1.1
|
1560 karl 1.8 if (classEnum == PG_NAMESPACE)
|
1561 karl 1.1 {
|
1562 humberto 1.23 #ifdef PEGASUS_OS_OS400
1563 MessageLoaderParms mparms("ControlProviders.InteropProvider.CREATE_INSTANCE_NOT_ALLOWED",
1564 "Create instance operation not allowed by Interop Provider for class $0.",
1565 PG_NAMESPACE_CLASSNAME.getString());
1566 throw CIMNotSupportedException(mparms);
1567 #else
|
1568 karl 1.11 // Create local instance to complete any keys.
1569 CIMInstance localInstance = myInstance.clone();
1570
1571 _completeCIMNamespaceKeys(localInstance);
|
1572 tony 1.6 // Validate that keys are as required. Does its own exception.
|
1573 karl 1.11 newNamespaceName = _getKeyValue(myInstance, CIM_NAMESPACE_PROPERTY_NAME);
1574
1575 newInstanceReference = _buildInstancePath(_operationNamespace,
1576 PG_NAMESPACE_CLASSNAME, localInstance);
|
1577 humberto 1.23 #endif
|
1578 karl 1.1 }
|
1579 tony 1.6
|
1580 karl 1.11 else // Invalid class for the create functions.
|
1581 karl 1.1 {
|
1582 karl 1.10 PEGASUS_ASSERT(false);
|
1583 karl 1.1 }
|
1584 karl 1.10
|
1585 karl 1.1 // Create the new namespace
1586 try
1587 {
|
1588 tony 1.6 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1589 "Namespace = " + newNamespaceName.getString() +
1590 " to be created.");
|
1591 karl 1.10 Boolean updatesAllowed = false;
1592 Boolean shareable = false;
1593 String parent = String::EMPTY;
|
1594 karl 1.11
|
1595 karl 1.8 CIMRepository::NameSpaceAttributes attributes;
|
1596 karl 1.10 // optional property. Set false if not found.
1597 // ATTN: Should set to class default.
|
1598 karl 1.8 if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_ISSHAREABLE) != PEG_NOT_FOUND)
1599 {
1600 if (_getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_ISSHAREABLE, false))
|
1601 karl 1.10 {
|
1602 karl 1.8 attributes.insert("shareable","true");
|
1603 karl 1.10 shareable = true;
1604 }
|
1605 karl 1.8 else
|
1606 karl 1.10 attributes.insert("shareable", "false");
|
1607 karl 1.8 }
1608 else
|
1609 karl 1.10 attributes.insert("shareable", "false");
|
1610 karl 1.8
|
1611 karl 1.10 // Optional property. Set false if not found.
|
1612 karl 1.8 if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED) != PEG_NOT_FOUND)
1613 {
1614 if (_getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, false))
|
1615 karl 1.10 {
|
1616 karl 1.8 attributes.insert("updatesAllowed","true");
|
1617 karl 1.10 updatesAllowed = true;
1618 }
|
1619 karl 1.8 else
1620 attributes.insert("updatesAllowed", "false");
1621 }
1622 else
1623 attributes.insert("updatesAllowed", "false");
1624
|
1625 karl 1.10 // ATTN: Need to reflect and dependencies between these properties. Right now
1626 // this lets anything happen.
|
1627 karl 1.8 if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_PARENTNAMESPACE) != PEG_NOT_FOUND)
1628 {
1629 String parent = _getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, String::EMPTY);
1630 if (parent != String::EMPTY)
|
1631 karl 1.10 attributes.insert("parent",parent);
|
1632 karl 1.8 }
1633 _repository->createNameSpace(newNamespaceName, attributes);
|
1634 karl 1.1
1635 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1636 "Namespace = " + newNamespaceName.getString() +
1637 " successfully created.");
|
1638 karl 1.10 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1639 "Create Namespace: Shareable = $0, Updates allows: $1, Parent: $2",
1640 newNamespaceName.getString(), shareable? "true" : "false", shareable? "true" : "false", parent );
|
1641 karl 1.11
|
1642 karl 1.1 }
1643 catch(CIMException& e)
1644 {
1645 PEG_METHOD_EXIT();
1646 throw e;
1647 }
1648 catch(Exception& e)
1649 {
1650 PEG_METHOD_EXIT();
1651 throw e;
1652 }
1653
1654 // begin processing the request
1655
1656 handler.deliver(newInstanceReference);
1657
1658 // complete processing the request
1659 handler.complete();
1660
1661 PEG_METHOD_EXIT();
1662 return;
1663 karl 1.1 }
1664
1665 //***************************************************************************
1666 // deleteInstance
1667 //***************************************************************************
1668 void InteropProvider::deleteInstance(
1669 const OperationContext & context,
1670 const CIMObjectPath & instanceName,
1671 ResponseHandler & handler)
1672 {
1673 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::deleteInstance");
|
1674 tony 1.6
|
1675 karl 1.1 CIMNamespaceName childNamespaceName;
1676 CIMNamespaceName deleteNamespaceName;
1677
|
1678 tony 1.6 _operationNamespace = instanceName.getNameSpace();
1679 handler.processing();
|
1680 karl 1.1 // Verify that ClassName is correct and get value
|
1681 karl 1.5 targetClass classEnum = _verifyValidClassInput(instanceName.getClassName());
|
1682 karl 1.1
1683 String userName = _validateUserID(context);
|
1684 tony 1.6
1685
1686 if ((classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM))
1687 throw CIMNotSupportedException("Delete Not allowed");
1688
1689 // Delete the instance since it may be in persistent storage
1690 if ((classEnum == CIM_OBJECTMANAGER))
1691 {
1692 CIMInstance instance;
1693 try
1694 {
1695 instance = _repository->getInstance(_operationNamespace, instanceName);
1696
1697 // If instance found, then delete it.
1698 _repository->deleteInstance(_operationNamespace,instanceName);
1699
1700 PEG_METHOD_EXIT();
1701 handler.complete();
1702 return;
1703 }
1704 catch(CIMException& e)
1705 tony 1.6 {
1706 PEG_METHOD_EXIT();
1707 throw e;
1708 }
1709 }
|
1710 karl 1.1
1711 Array<CIMNamespaceName> namespaceNames;
1712 namespaceNames = _enumerateNameSpaces();
|
1713 karl 1.8 if (classEnum == PG_NAMESPACE)
|
1714 karl 1.1 {
|
1715 humberto 1.23 #ifdef PEGASUS_OS_OS400
1716 MessageLoaderParms mparms("ControlProviders.InteropProvider.DELETE_INSTANCE_NOT_ALLOWED",
1717 "Delete instance operation not allowed by Interop Provider for class $0.",
1718 PG_NAMESPACE_CLASSNAME.getString());
1719 throw CIMNotSupportedException(mparms);
1720 #else
|
1721 karl 1.5 // validate requred keys. Exception out if not valid
1722 _validateCIMNamespaceKeys(instanceName);
1723
|
1724 karl 1.1 deleteNamespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME);
1725 CDEBUG("Delete namespace = " << deleteNamespaceName );
|
1726 humberto 1.23 #endif
|
1727 karl 1.1 }
1728
1729 // ATTN: KS Why THis???
1730 if (deleteNamespaceName.equal (ROOTNS))
1731 {
1732 throw CIMNotSupportedException("root namespace cannot be deleted.");
1733 }
1734
1735 _repository->deleteNameSpace(deleteNamespaceName);
1736
1737 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1738 "Namespace = " + deleteNamespaceName.getString() +
1739 " successfully deleted.");
|
1740 karl 1.5
1741 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1742 "Interop Provider Delete Namespace: $0",
1743 deleteNamespaceName.getString());
1744
|
1745 karl 1.1 handler.processing();
1746
1747 // complete processing the request
1748 handler.complete();
1749
1750 PEG_METHOD_EXIT();
1751 return ;
1752 }
1753
1754 //***************************************************************************
1755 // getInstance
1756 //***************************************************************************
1757 void InteropProvider::getInstance(
1758 const OperationContext & context,
1759 const CIMObjectPath & instanceName,
1760 const Boolean includeQualifiers,
1761 const Boolean includeClassOrigin,
|
1762 tony 1.6 const CIMPropertyList & propertyList,
|
1763 karl 1.1 InstanceResponseHandler & handler)
1764 {
1765 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::getInstance");
1766
1767 // Verify that ClassName is correct and get value
|
1768 karl 1.5 targetClass classEnum = _verifyValidClassInput(instanceName.getClassName());
|
1769 karl 1.1
1770 String userName = _validateUserID(context);
1771
1772 // begin processing the request
1773 handler.processing();
1774 if (classEnum == CIM_OBJECTMANAGER)
1775 {
|
1776 tony 1.6 CIMInstance instance = _buildInstanceCIMObjectManager(includeQualifiers,
1777 includeClassOrigin, propertyList);
|
1778 karl 1.1 handler.deliver(instance);
1779 handler.complete();
1780 PEG_METHOD_EXIT();
1781 return;
1782 }
1783
|
1784 tony 1.6 if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
|
1785 karl 1.1 {
|
1786 tony 1.6 // ATTN: test for correct instance KS: Priority 1
1787 Array <CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism(
1788 includeQualifiers,
1789 includeClassOrigin, propertyList);
1790 handler.deliver(instances[0]);
|
1791 karl 1.1 handler.complete();
1792 PEG_METHOD_EXIT();
1793 return;
1794 }
1795
|
1796 karl 1.19 if (classEnum == CIM_NAMESPACEINMANAGER)
1797 {
1798 handler.complete();
1799 PEG_METHOD_EXIT();
1800 return;
1801 }
1802
|
1803 karl 1.1 // Get List of namespaces
1804 Array<CIMNamespaceName> namespaceNames;
1805 namespaceNames = _enumerateNameSpaces();
1806 CIMInstance instance;
1807
|
1808 karl 1.8 if (classEnum == PG_NAMESPACE)
|
1809 karl 1.1 {
1810 // Not clear what we have to take into account here.
1811 // get the namespace from the name value.
1812 // should check the other keys to see if valid.
1813 CIMNamespaceName namespaceName;
1814 namespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME);
|
1815 tony 1.6
|
1816 karl 1.1 // ATTN: Why this CIMNamespaceName parentNamespaceName = instanceName.getNameSpace();
1817 if (!_isNamespace(namespaceNames, namespaceName))
1818 {
1819 throw CIMObjectNotFoundException("Namespace does not exist: "
1820 + namespaceName.getString());
1821 }
1822 PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1823 "Namespace = " + namespaceName.getString() + " successfully found.");
|
1824 tony 1.6
1825 instance = _getInstanceCIMNamespace(namespaceName);
|
1826 karl 1.1 }
1827 else // processing for __Namespace
1828 {
|
1829 karl 1.10 PEGASUS_ASSERT(false);
|
1830 karl 1.8 }
|
1831 karl 1.1
1832 handler.deliver(instance);
1833
1834 // complete processing the request
1835 handler.complete();
1836
1837 PEG_METHOD_EXIT();
1838 return ;
1839 }
1840
1841 //***************************************************************************
1842 // enumerateInstances
1843 //***************************************************************************
1844 void InteropProvider::enumerateInstances(
1845 const OperationContext & context,
1846 const CIMObjectPath & ref,
1847 const Boolean includeQualifiers,
1848 const Boolean includeClassOrigin,
1849 const CIMPropertyList& propertyList,
1850 InstanceResponseHandler & handler)
1851 {
1852 karl 1.1 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::enumerateInstances()");
1853 // Verify that ClassName is correct and get value
|
1854 tony 1.6
|
1855 karl 1.5 targetClass classEnum = _verifyValidClassInput(ref.getClassName());
|
1856 karl 1.1
|
1857 tony 1.6 // operation namespace needed internally to get class.
1858 _operationNamespace = ref.getNameSpace();
1859 //String userName = _validateUserID(context);
|
1860 karl 1.1
1861 // The following 3 classes deliver a single instance because
1862 // that is all there is today.
1863 if (classEnum == CIM_OBJECTMANAGER)
1864 {
|
1865 tony 1.6 CIMInstance instance = _buildInstanceCIMObjectManager(includeQualifiers,
1866 includeClassOrigin,
1867 propertyList);
|
1868 karl 1.10
1869 //Array<Sint8> tmp;
1870 ///XmlWriter::appendInstanceElement(tmp, instance);
1871 //tmp.append('\0');
1872 //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
1873 // "Instance - XML content: $0", tmp.getData());
1874 ///XmlWriter::printInstanceElement(instance);
|
1875 karl 1.1 handler.deliver(instance);
1876 handler.complete();
1877 PEG_METHOD_EXIT();
1878 return;
1879 }
1880
|
1881 tony 1.6 if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
|
1882 karl 1.1 {
|
1883 tony 1.6 Array<CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism(includeQualifiers,
1884 includeClassOrigin, propertyList);
1885 CDEBUG("Build instances of PGCIMXML. count= " << instances.size());
1886 handler.deliver(instances);
|
1887 karl 1.1 handler.complete();
1888 PEG_METHOD_EXIT();
1889 return;
1890 }
1891
|
1892 karl 1.19 if (classEnum == CIM_NAMESPACEINMANAGER)
1893 {
1894 handler.complete();
1895 PEG_METHOD_EXIT();
1896 return;
1897 }
1898
|
1899 karl 1.8 if (classEnum == PG_NAMESPACE)
|
1900 karl 1.1 {
|
1901 tony 1.6 Array<CIMInstance> instances = _getInstancesCIMNamespace(includeQualifiers,
1902 includeClassOrigin, propertyList);
1903
1904 handler.deliver(instances);
|
1905 karl 1.1 handler.complete();
1906 PEG_METHOD_EXIT();
1907 return;
1908 }
1909
1910 handler.complete();
1911
1912 PEG_METHOD_EXIT();
1913 }
1914
|
1915 karl 1.10 void InteropProvider::modifyObjectManagerInstance(const OperationContext & context,
1916 const CIMObjectPath & instanceReference,
1917 const CIMInstance& modifiedIns,
1918 const Boolean includeQualifiers,
1919 const CIMPropertyList& propertyList,
1920 ResponseHandler & handler)
1921 {
1922 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1923 "InteropProvider::modifyInstanceManagerInstance");
1924 // the only allowed modification is this one property, statistical data
1925 if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND)
1926 {
|
1927 karl 1.11 // ATTN: This function is a design problem.
1928 // ATTN: Should the ifdef include everything????
|
1929 karl 1.10 // the following is a temporary hack to set the value of the statistics
1930 // gathering function dynamically. We simply get the value from input
1931 // and call the internal method to set it each time this object is
1932 // built.
|
1933 karl 1.16 #ifndef PEGASUS_DISABLE_PERFINST
|
1934 karl 1.10 StatisticalData* sd = StatisticalData::current();
1935 Boolean statisticsFlag = _getPropertyValue(modifiedIns, OM_GATHERSTATISTICALDATA, false);
1936 sd->setCopyGSD(statisticsFlag);
1937 if ( ! _getInstanceCIMObjectManager(false, false, CIMPropertyList()))
1938 {
1939 _buildInstanceCIMObjectManager(true, true, CIMPropertyList());
1940 }
1941
1942 // ATTN: Think we need to clone here to avoid any issues of overwriting.
1943 _setPropertyValue(instanceOfCIMObjectManager, OM_GATHERSTATISTICALDATA, statisticsFlag);
1944 CIMObjectPath instancePath;
|
1945 karl 1.11
1946 // Modify the object on disk
|
1947 karl 1.10 try
1948 {
1949 _repository->modifyInstance(_operationNamespace,
1950 instanceOfCIMObjectManager );
1951 }
1952 catch(CIMException& e)
1953 {
1954 // ATTN: KS generate log error if this not possible
1955 PEG_METHOD_EXIT();
1956 throw e;
1957 }
1958 catch(Exception& e)
1959 {
1960 // ATTN: Generate log error.
1961 PEG_METHOD_EXIT();
1962 throw e;
1963 }
1964 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1965 "Interop Provider Set Statistics gathering in CIM_ObjectManager: $0",
1966 (statisticsFlag? "true" : "false"));
|
1967 karl 1.11 // modify returns nothing normally.
|
1968 karl 1.10 return;
1969 #endif
|
1970 karl 1.8
|
1971 karl 1.10 }
1972 PEG_METHOD_EXIT();
|
1973 karl 1.11 // ATTN Expand this defintion to be more precise since it allows only mod of
1974 // one property and that property MUST be in the instance to be modifiable.
|
1975 karl 1.10 throw CIMNotSupportedException
1976 (OM_GATHERSTATISTICALDATA.getString() + " modify operation not supported by Interop Provider");
1977 }
|
1978 karl 1.1 //***************************************************************************
|
1979 karl 1.10 // modifyInstance
|
1980 karl 1.1 //***************************************************************************
|
1981 karl 1.8 void InteropProvider::modifyInstance(const OperationContext & context,
1982 const CIMObjectPath & instanceReference,
1983 const CIMInstance& modifiedIns,
1984 const Boolean includeQualifiers,
1985 const CIMPropertyList& propertyList,
1986 ResponseHandler & handler)
1987 {
1988
1989 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
|
1990 karl 1.10 "InteropProvider::modifyInstance");
|
1991 karl 1.8
1992 // operation namespace needed internally to get class.
|
1993 karl 1.10
1994 // ATTN: KS 31 August 2004. This must test for privileged user.
|
1995 karl 1.8 _operationNamespace = instanceReference.getNameSpace();
1996 CIMName className = instanceReference.getClassName();
1997 targetClass classEnum = _verifyValidClassInput(instanceReference.getClassName());
1998
1999 String userName = _validateUserID(context);
2000 // begin processing the request
2001 handler.processing();
2002
2003 if (classEnum == CIM_OBJECTMANAGER)
2004 {
|
2005 karl 1.10 modifyObjectManagerInstance(context, instanceReference,modifiedIns,
2006 includeQualifiers, propertyList, handler);
|
2007 karl 1.8 // for the moment allow modification of the statistics property only
2008 }
2009
|
2010 karl 1.10 else if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
|
2011 karl 1.8 {
2012
2013 PEG_METHOD_EXIT();
2014 throw CIMNotSupportedException
2015 (className.getString() + " not supported by Interop Provider");
2016 }
|
2017 karl 1.10 else if (classEnum == PG_NAMESPACE)
|
2018 karl 1.8 {
|
2019 humberto 1.23 #ifdef PEGASUS_OS_OS400
2020 MessageLoaderParms mparms("ControlProviders.InteropProvider.MODIFY_INSTANCE_NOT_ALLOWED",
2021 "Modify instance operation not allowed by Interop Provider for class $0.",
2022 PG_NAMESPACE_CLASSNAME.getString());
2023 throw CIMNotSupportedException(mparms);
2024 #else
|
2025 karl 1.10 // for the moment allow modification of the statistics property only
|
2026 karl 1.8 PEG_METHOD_EXIT();
2027 throw CIMNotSupportedException
2028 (className.getString() + " not supported by Interop Provider");
|
2029 humberto 1.23 #endif
|
2030 karl 1.8 }
|
2031 karl 1.10 else
2032 {
2033 PEGASUS_ASSERT(false); // should never get here.
2034 }
|
2035 karl 1.8
|
2036 karl 1.10 handler.complete();
|
2037 karl 1.8 PEG_METHOD_EXIT();
2038 return;
2039 }
2040
|
2041 karl 1.10 //***************************************************************************
2042 // enumerateInstanceNames
2043 //***************************************************************************
|
2044 karl 1.1 void InteropProvider::enumerateInstanceNames(
2045 const OperationContext & context,
2046 const CIMObjectPath & classReference,
2047 ObjectPathResponseHandler & handler)
2048 {
2049 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
2050 "InteropProvider::enumerateInstanceNames()");
2051
2052 // operation namespace needed internally to get class.
2053 _operationNamespace = classReference.getNameSpace();
2054
|
2055 karl 1.5 targetClass classEnum = _verifyValidClassInput(classReference.getClassName());
|
2056 karl 1.1
|
2057 tony 1.6 String userName = _validateUserID(context);
|
2058 karl 1.11
|
2059 karl 1.1 // begin processing the request
2060 handler.processing();
2061
|
2062 karl 1.11 // Deliver a single instance because there should only be one instance.
|
2063 karl 1.1 if (classEnum == CIM_OBJECTMANAGER)
2064 {
|
2065 tony 1.6 CIMInstance instance = _buildInstanceCIMObjectManager( true, true, CIMPropertyList());
2066 CIMObjectPath ref = _buildInstancePath(_operationNamespace,
|
2067 karl 1.1 CIM_OBJECTMANAGER_CLASSNAME, instance);
2068 handler.deliver(ref);
2069 handler.complete();
2070 PEG_METHOD_EXIT();
2071 return;
2072 }
|
2073 karl 1.11
2074 // Deliver all possible instances of this class
|
2075 tony 1.6 if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
|
2076 karl 1.1 {
|
2077 tony 1.6 Array<CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism(true,
2078 true, CIMPropertyList());
2079
2080 for (Uint32 i = 0 ; i < instances.size() ; i++)
2081 {
2082 CIMObjectPath ref = _buildInstancePath(_operationNamespace,
2083 PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME, instances[i]);
2084 handler.deliver(ref);
2085 }
|
2086 karl 1.1 handler.complete();
2087 PEG_METHOD_EXIT();
2088 return;
2089 }
2090
|
2091 karl 1.19 if (classEnum == CIM_NAMESPACEINMANAGER)
2092 {
2093 handler.complete();
2094 PEG_METHOD_EXIT();
2095 return;
2096 }
2097
|
2098 karl 1.8 if (classEnum == PG_NAMESPACE)
|
2099 tony 1.6 {
2100 Array<CIMInstance> instances = _getInstancesCIMNamespace(false,
2101 false, CIMPropertyList());
2102 CDEBUG("EvalNames. Found instances. Count= " << instances.size());
2103 for (Uint32 i = 0 ; i < instances.size() ; i++)
2104 {
2105 CIMObjectPath ref = _buildInstancePath(_operationNamespace,
2106 CIM_NAMESPACE_CLASSNAME, instances[i]);
2107 handler.deliver(ref);
2108 }
|
2109 karl 1.1
2110 handler.complete();
2111 PEG_METHOD_EXIT();
2112 return;
2113 }
2114
|
2115 karl 1.11 if (classEnum == CIM_COMMMECHANISMFORMANAGERINST)
2116 {
2117 Array<CIMInstance> instances = _buildInstancesCommMechanismForManager();
2118 for (Uint32 i = 0 ; i < instances.size() ; i++ )
2119 {
2120 CIMObjectPath ref = _buildObjectPath(_operationNamespace,
2121 CIM_COMMMECHANISMFORMANAGER_CLASSNAME, instances[i]);
2122 handler.deliver(ref);
2123 }
2124 }
2125
2126 if (classEnum == CIM_NAMESPACEINMANAGERINST)
2127 {
2128 Array<CIMInstance> instances = _buildInstancesNamespaceInManager();
2129 for (Uint32 i = 0 ; i < instances.size() ; i++ )
2130 {
2131 CIMObjectPath ref = _buildObjectPath(_operationNamespace,
2132 CIM_NAMESPACEINMANAGER_CLASSNAME, instances[i]);
2133 handler.deliver(ref);
2134 }
2135 }
2136 karl 1.11
2137
|
2138 karl 1.8 // ATTN: Exception response because of error
|
2139 karl 1.1 PEG_METHOD_EXIT();
2140 }
2141
2142 //**************************************************************
2143 //**************************************************************
2144 // Association Functions
2145 //**************************************************************
2146 //**************************************************************
2147
2148 void InteropProvider::associators(
2149 const OperationContext & context,
2150 const CIMObjectPath & objectName,
2151 const CIMName & associationClass,
2152 const CIMName & resultClass,
2153 const String & role,
2154 const String & resultRole,
2155 const Boolean includeQualifiers,
2156 const Boolean includeClassOrigin,
2157 const CIMPropertyList & propertyList,
2158 ObjectResponseHandler & handler)
2159 {
|
2160 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
2161 "InteropProvider::associatorNames()");
|
2162 karl 1.16 //throw CIMNotSupportedException("AssociationProvider::associators");
|
2163 karl 1.1 }
2164
2165 void InteropProvider::associatorNames(
2166 const OperationContext & context,
2167 const CIMObjectPath & objectName,
2168 const CIMName & associationClass,
2169 const CIMName & resultClass,
2170 const String & role,
2171 const String & resultRole,
2172 ObjectPathResponseHandler & handler)
2173 {
|
2174 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
2175 "InteropProvider::associatorNames()");
|
2176 karl 1.16 //throw CIMNotSupportedException("AssociationProvider::associatorNames");
|
2177 karl 1.1 }
2178
2179 void InteropProvider::references(
2180 const OperationContext & context,
2181 const CIMObjectPath & objectName,
2182 const CIMName & resultClass,
2183 const String & role,
2184 const Boolean includeQualifiers,
2185 const Boolean includeClassOrigin,
2186 const CIMPropertyList & propertyList,
2187 ObjectResponseHandler & handler)
2188 {
|
2189 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
2190 "InteropProvider::references()");
|
2191 karl 1.16 //throw CIMNotSupportedException("AssociationProvider::references");
|
2192 karl 1.1 }
2193
|
2194 tony 1.6 void _filterAssocInstances(Array<CIMInstance>& instances,
2195 CIMName assocClassName,
2196 String assocRole,
2197 CIMName resultClassName = CIMName(),
2198 String resultRole = String::EMPTY)
2199 {
2200 return;
2201 }
|
2202 karl 1.11
|
2203 karl 1.1 void InteropProvider::referenceNames(
2204 const OperationContext & context,
2205 const CIMObjectPath & objectName,
2206 const CIMName & resultClass,
2207 const String & role,
2208 ObjectPathResponseHandler & handler)
2209 {
|
2210 tony 1.6 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
2211 "InteropProvider::referenceNames()");
2212 CDEBUG("::referenceNames(): object= " << objectName.toString() << " result Class= " << resultClass.getString());
2213
2214 // operation namespace needed internally to get class.
2215 _operationNamespace = objectName.getNameSpace();
2216 String userName = _validateUserID(context);
2217 // begin processing the request
2218 handler.processing();
2219
2220 // determine if valid class result class
2221
2222 CIMName targetAssocClassName = resultClass;
2223
2224 CIMName targetClassName = objectName.getClassName();
2225
2226 targetAssocClass classEnum = _verifyValidAssocClassInput(targetAssocClassName);
2227
2228 Array<CIMInstance> assocInstances;
2229
|
2230 karl 1.19 if (classEnum == CIM_COMMMECHANISMFORMANAGERASSOC)
|
2231 tony 1.6 assocInstances = _buildInstancesCommMechanismForManager();
2232
|
2233 karl 1.19 if (classEnum == CIM_NAMESPACEINMANAGERASSOC)
|
2234 tony 1.6 assocInstances = _buildInstancesNamespaceInManager();
2235
2236 _filterAssocInstances(assocInstances, resultClass, role);
2237
2238 for (Uint32 i = 0 ; i < assocInstances.size() ; i++ )
2239 {
2240 CIMObjectPath ref = _buildObjectPath(_operationNamespace,
2241 targetAssocClassName, assocInstances[i]);
2242 CDEBUG("referenceNames returns: " << ref.toString());
2243 handler.deliver(ref);
|
2244 karl 1.11 }
|
2245 tony 1.6
2246 handler.complete();
2247
2248 PEG_METHOD_EXIT();
2249 // Convert the instances to referenceNames response
|
2250 karl 1.1 }
2251
2252 PEGASUS_NAMESPACE_END
2253 // END_OF_FILE
|