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