(file) Return to Namespace.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ControlProviders / InteropProvider

  1 martin 1.13 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.14 //
  3 martin 1.13 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.14 //
 10 martin 1.13 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.14 //
 17 martin 1.13 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.14 //
 20 martin 1.13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.14 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.13 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.14 //
 28 martin 1.13 //////////////////////////////////////////////////////////////////////////
 29 kumpf  1.5  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31 a.dunfey 1.1  
 32               ///////////////////////////////////////////////////////////////////////////////
 33               //  Interop Provider - This provider services those classes from the
 34               //  DMTF Interop schema in an implementation compliant with the SMI-S v1.1
 35               //  Server Profile
 36               //
 37               //  Please see PG_ServerProfile20.mof in the directory
 38               //  $(PEGASUS_ROOT)/Schemas/Pegasus/InterOp/VER20 for retails regarding the
 39               //  classes supported by this control provider.
 40               //
 41 kumpf    1.5  //  Interop forces all creates to the PEGASUS_NAMESPACENAME_INTEROP
 42               //  namespace. There is a test on each operation that returns
 43 a.dunfey 1.1  //  the Invalid Class CIMDError
 44               //  This is a control provider and as such uses the Tracer functions
 45               //  for data and function traces.  Since we do not expect high volume
 46               //  use we added a number of traces to help diagnostics.
 47               ///////////////////////////////////////////////////////////////////////////////
 48               
 49               #include "InteropProvider.h"
 50               #include "InteropProviderUtils.h"
 51               #include "InteropConstants.h"
 52 sahana.prabhakar 1.15 #include <Pegasus/Common/ArrayIterator.h>
 53 a.dunfey         1.1  
 54                       PEGASUS_USING_STD;
 55 a.dunfey         1.2  PEGASUS_NAMESPACE_BEGIN
 56 a.dunfey         1.1  
 57                       //
 58                       // Property names for CIM_Namespace Class
 59                       //
 60                       #define CIM_NAMESPACE_PROPERTY_NAME  COMMON_PROPERTY_NAME
 61                       #define CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME \
 62                           COMMON_PROPERTY_CREATIONCLASSNAME
 63                       #define CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME \
 64                           COMMON_PROPERTY_SYSTEMCREATIONCLASSNAME
 65                       #define CIM_NAMESPACE_PROPERTY_SYSTEMNAME COMMON_PROPERTY_SYSTEMNAME
 66                       static const CIMName CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME(
 67                           "ObjectManagerCreationClassName");
 68                       static const CIMName CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME(
 69                           "ObjectManagerName");
 70                       static const CIMName CIM_NAMESPACE_PROPERTY_CLASSINFO(
 71                           "ClassInfo");
 72                       static const CIMName CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO(
 73                           "DescriptionOfClassInfo");
 74                       static const CIMName CIM_NAMESPACE_PROPERTY_CLASSTYPE("ClassType");
 75                       
 76                       // Additional Property names for PG_Namespace Class
 77 a.dunfey         1.1  
 78                       static const CIMName PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED(
 79                           "SchemaUpdatesAllowed");
 80                       static const CIMName PG_NAMESPACE_PROPERTY_ISSHAREABLE(
 81                           "IsShareable");
 82                       static const CIMName PG_NAMESPACE_PROPERTY_PARENTNAMESPACE(
 83                           "ParentNamespace");
 84                       #define PG_NAMESPACE_PROPERTY_NAME COMMON_PROPERTY_NAME
 85                       
 86                       //
 87                       // Get the instances of CIM_Namespace. Gets all instances of the namespace from
 88                       // the repository namespace management functions. Builds instances that
 89                       // match all of the request attributes.
 90                       //
 91                       Array<CIMInstance> InteropProvider::enumNamespaceInstances()
 92                       {
 93                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 94 ouyang.jian      1.7          "InteropProvider::enumNamespaceInstances()");
 95 a.dunfey         1.1  
 96                           Array<CIMNamespaceName> namespaceNames = repository->enumerateNameSpaces();
 97                           Array<CIMInstance> instanceArray;
 98                       
 99                           // Build instances of PG namespace since that is the leaf class
100                           for (Uint32 i = 0, n = namespaceNames.size(); i < n; i++)
101                           {
102                              instanceArray.append(
103                                  buildNamespaceInstance(namespaceNames[i].getString()));
104                           }
105                       
106                           PEG_METHOD_EXIT();
107                           return instanceArray;
108                       }
109                       
110                       //
111                       // Returns an array of all of the NamespaceInManager association instances
112                       // for this CIMOM. One instance will be produced for every namespace present
113                       // in the CIMOM/repository.
114                       //
115                       Array<CIMInstance> InteropProvider::enumNamespaceInManagerInstances()
116 a.dunfey         1.1  {
117                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
118 ouyang.jian      1.7          "InteropProvider::enumNamespaceInManagerInstances()");
119 a.dunfey         1.1  
120                           Array<CIMInstance> namespaceInstances = enumNamespaceInstances();
121                       
122                           CIMObjectPath objectManagerPath = getObjectManagerInstance().getPath();
123                       
124                           Array<CIMInstance> assocInstances;
125                           CIMClass targetClass;
126                       
127                           CIMInstance instanceskel = buildInstanceSkeleton(
128                               PEGASUS_NAMESPACENAME_INTEROP,
129 kumpf            1.11         PEGASUS_CLASSNAME_PG_NAMESPACEINMANAGER, true, targetClass);
130 a.dunfey         1.1      // Build and instance for each namespace instance.
131                           for (Uint32 i = 0 ; i < namespaceInstances.size() ; i++)
132                           {
133                               CIMInstance instance = instanceskel.clone();
134                               setPropertyValue(instance, PROPERTY_ANTECEDENT, objectManagerPath);
135                               setPropertyValue(instance, PROPERTY_DEPENDENT,
136 kumpf            1.5              namespaceInstances[i].getPath());
137 a.dunfey         1.1  
138                               CIMObjectPath objPath = instance.buildPath(targetClass);
139                               objPath.setHost(hostName);
140                               objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
141                               instance.setPath(objPath);
142                               assocInstances.append(instance);
143                           }
144                           PEG_METHOD_EXIT();
145                           return assocInstances;
146                       }
147                       
148                       
149                       //
150                       // Generates one instance of the PG_Namespace class for the specified
151                       // namespace.
152                       //
153                       CIMInstance InteropProvider::buildNamespaceInstance(
154                           const String & nameSpace)
155                       {
156                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
157 ouyang.jian      1.7          "InteropProvider::buildNamespaceInstance()");
158 a.dunfey         1.1  
159                           CIMClass targetClass;
160                           CIMInstance instance = buildInstanceSkeleton(
161                               PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PGNAMESPACE,
162 kumpf            1.11         true, targetClass);
163 a.dunfey         1.1  
164                           setCommonKeys(instance);
165                       
166                           // ObjectManagerCreationClassName
167                           setPropertyValue(instance,
168                               CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME,
169                               PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString());
170                       
171                           // ObjectManagerName
172                           setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME,
173                               objectManagerName);
174                       
175                           // CreationClassName
176                           setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
177                               PEGASUS_CLASSNAME_PGNAMESPACE.getString());
178                           // Name
179                           // This is the namespace name itself
180                           setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME,
181                               nameSpace);
182                       
183                           // ClassInfo
184 a.dunfey         1.1      // Set the classinfo to unknown and the description to namespace.
185                           setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CLASSINFO, Uint16(0));
186                       
187                           // DescriptionOfClassInfo
188                           setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO,
189                               String("namespace"));
190                       
191                           // ClassType
192                           setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CLASSTYPE,
193                               Uint16(2));
194                       
195                       
196                           //
197                           //  Everything above was commmon to CIM Namespace.  The following are
198                           //  PG_Namespace Properties
199                           //
200                           CIMRepository::NameSpaceAttributes attributes;
201                           repository->getNameSpaceAttributes(nameSpace, attributes);
202 kumpf            1.4      String parent;
203                           String name;
204 a.dunfey         1.1      Boolean shareable = false;
205                           Boolean updatesAllowed = true;
206                           for (CIMRepository::NameSpaceAttributes::Iterator i = attributes.start();
207                               i; i++)
208                           {
209                               String key=i.key();
210                               String value = i.value();
211                               if(String::equalNoCase(key,"shareable"))
212                               {
213                                   if (String::equalNoCase(value,"true"))
214                                       shareable=true;
215                               }
216                               else if(String::equalNoCase(key,"updatesAllowed"))
217                               {
218                                   if (String::equalNoCase(value,"false"))
219                                       updatesAllowed=false;
220                               }
221                               // Test to be sure we are returning proper namespace name
222                               else if (String::equalNoCase(key,"name"))
223                               {
224                                   if (!String::equalNoCase(value, nameSpace))
225 a.dunfey         1.1              {
226                                       PEG_METHOD_EXIT();
227                                       // This is poor exception since it reflects internal error. Do
228                                       // error log
229                                       throw CIMNotSupportedException(
230                                           "Namespace attribute rtnd error for key " + key +
231                                           "expected " + nameSpace + value + " in " +
232                                           String(thisProvider));
233                                   }
234                       
235                                   name = value;
236                               }
237                               else if (String::equalNoCase(key,"parent"))
238                               {
239                                   parent=value;
240                               }
241 venkat.puvvada   1.12 #ifdef PEGASUS_ENABLE_REMOTE_CMPI
242                               else if (String::equalNoCase(key,"remoteInfo"))
243                               {
244                                   //ATTN: remoteInfo property is not part of PG_Namespace class,
245                                   // add the property to PG_Namespace instance once avilable.
246                               }
247                       #endif
248 a.dunfey         1.1          else
249                               {
250                                   PEG_METHOD_EXIT();
251                                   // Poor error definition since it reflects internal error. do error
252                                   // log
253                                   throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, nameSpace +
254                                       " namespace attribute " + key + " option not supported in" +
255                                       String(thisProvider));
256                               }
257                           }
258                       
259                           // SchemaUpdatesAllowed
260                           setPropertyValue(instance, PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED,
261                               updatesAllowed);
262                       
263                           // IsShareable
264                           setPropertyValue(instance, PG_NAMESPACE_PROPERTY_ISSHAREABLE, shareable);
265                       
266                           // ParentNamespace
267                           setPropertyValue(instance, PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, parent);
268 kumpf            1.5      setPropertyValue(instance, PG_NAMESPACE_PROPERTY_NAME, name);
269 a.dunfey         1.1  
270                           CIMObjectPath objPath = instance.buildPath(targetClass);
271                           objPath.setHost(hostName);
272                           objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP);
273                           instance.setPath(objPath);
274                           PEG_METHOD_EXIT();
275                           return instance;
276                       }
277                       
278 sahana.prabhakar 1.15 CIMInstance InteropProvider::getNameSpaceInstance(
279                           const CIMObjectPath & ref)
280                       {
281                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
282                               "getNameSpaceInstance()");
283                           Array<CIMKeyBinding> keyBindings = ref.getKeyBindings();
284                           ConstArrayIterator<CIMKeyBinding> keyIter(keyBindings);
285                           String name;
286                       
287                           for (Uint32 i = 0; i < keyIter.size(); i++)
288                           {
289                               if (keyIter[i].getName().equal(CIM_NAMESPACE_PROPERTY_NAME))
290                               {
291                                   name = keyIter[i].getValue();
292                                   break;
293                               }
294                           }
295                       
296                           if(repository->nameSpaceExists(name)) 
297                           {
298                               CIMInstance newInst = buildNamespaceInstance(name);
299 sahana.prabhakar 1.15         if( newInst.getPath() != ref )
300                               {
301                                   throw CIMObjectNotFoundException(ref.toString());
302                               }
303                               PEG_METHOD_EXIT();
304                               return newInst;
305                           }
306                       
307                           PEG_METHOD_EXIT();
308                           throw CIMObjectNotFoundException(ref.toString());
309                       }
310                       
311 a.dunfey         1.1  //
312                       // Function that takes an instance of the CIM_Namespace class, checks whether
313 kumpf            1.5  // the key properties are present,
314 a.dunfey         1.1  //
315                       String buildNamespacePath(
316                           CIMObjectPath & namespacePath,
317                           const CIMInstance& instance,
318                           const String & objectManagerName)
319                       {
320                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
321 ouyang.jian      1.7          "buildNamespacePath()");
322 a.dunfey         1.1  
323                           unsigned int propIndex = PEG_NOT_FOUND;
324                           CIMName propertyName;
325                       
326                           if(instance.findProperty(CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME)
327                               == PEG_NOT_FOUND)
328                           {
329                               propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME;
330                           }
331                           else if(instance.findProperty(CIM_NAMESPACE_PROPERTY_SYSTEMNAME)
332                               == PEG_NOT_FOUND)
333                           {
334                               propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME;
335                           }
336                           else if(instance.findProperty(
337                               CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME)
338                               == PEG_NOT_FOUND)
339                           {
340                               propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME;
341                           }
342                           else if(instance.findProperty(
343 a.dunfey         1.1          CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME)
344                               == PEG_NOT_FOUND)
345                           {
346                               propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME;
347                           }
348                           else if(instance.findProperty(
349                               CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME)
350                               == PEG_NOT_FOUND)
351                           {
352                               propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME;
353                           }
354                           else if((propIndex = instance.findProperty(CIM_NAMESPACE_PROPERTY_NAME))
355                               == PEG_NOT_FOUND)
356                           {
357                               propertyName = CIM_NAMESPACE_PROPERTY_NAME;
358                           }
359                       
360                           if(propIndex == PEG_NOT_FOUND)
361                           {
362 thilo.boehm      1.10         PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL1,
363                                   "Invalid CIM_Namespace Key Property %s",
364                                   (const char*)propertyName.getString().getCString()));
365 a.dunfey         1.1          PEG_METHOD_EXIT();
366                               throw CIMInvalidParameterException(
367                                   "Invalid CIM_Namespace key property: " + propertyName.getString());
368                           }
369                       
370 marek            1.3      PEG_TRACE_CSTRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
371 a.dunfey         1.1          "CIM_Namespace Keys Valid");
372                       
373                           Array<CIMKeyBinding> keyBindings;
374                       
375                           String newNamespaceName;
376                           instance.getProperty(propIndex).getValue().get(newNamespaceName);
377                           keyBindings.append(CIMKeyBinding(
378                               CIM_NAMESPACE_PROPERTY_NAME,
379                               newNamespaceName, CIMKeyBinding::STRING));
380                       
381                           keyBindings.append(CIMKeyBinding(
382                               CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
383                               PEGASUS_CLASSNAME_PGNAMESPACE.getString(), CIMKeyBinding::STRING));
384                       
385                           keyBindings.append(CIMKeyBinding(
386                               CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
387                               System::getSystemCreationClassName(), CIMKeyBinding::STRING));
388                       
389                           String hostName = System::getFullyQualifiedHostName();
390                           keyBindings.append(CIMKeyBinding(
391                               CIM_NAMESPACE_PROPERTY_SYSTEMNAME,
392 a.dunfey         1.1          hostName, CIMKeyBinding::STRING));
393                       
394                           keyBindings.append(CIMKeyBinding(
395                               CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME,
396                               PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString(),
397                               CIMKeyBinding::STRING));
398                       
399                           keyBindings.append(CIMKeyBinding(
400                               CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME,
401                               objectManagerName, CIMKeyBinding::STRING));
402                       
403                           namespacePath = CIMObjectPath(hostName, PEGASUS_NAMESPACENAME_INTEROP,
404                               PEGASUS_CLASSNAME_PGNAMESPACE, keyBindings);
405                           return newNamespaceName;
406                       }
407                       
408                       //
409                       // Validates the keys for the ObjectPath representing an instance of
410                       // PG_Namespace. Having this function should be more efficient than creating an
411                       // instance of PG_Namespace and then comparing the object paths.
412                       //
413 a.dunfey         1.1  CIMNamespaceName validateNamespaceKeys(
414                           const CIMObjectPath& objectPath,
415                           const String & objectManagerName)
416                       {
417                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
418 ouyang.jian      1.7          "validateNamespaceKeys()");
419 a.dunfey         1.1  
420                           CIMName propertyName;
421                           if(!validateRequiredProperty(
422                               objectPath,
423                               CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
424                               PEGASUS_CLASSNAME_PG_COMPUTERSYSTEM.getString()))
425                           {
426                               propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME;
427                           }
428                           else if(!validateRequiredProperty(
429                               objectPath,
430                               CIM_NAMESPACE_PROPERTY_SYSTEMNAME,
431                               System::getFullyQualifiedHostName()))
432                           {
433                               propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME;
434                           }
435                           else if(!validateRequiredProperty(
436                               objectPath,
437                               CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME,
438                               PEGASUS_CLASSNAME_PG_OBJECTMANAGER.getString()))
439                           {
440 a.dunfey         1.1          propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME;
441                           }
442                           else if(!validateRequiredProperty(
443                               objectPath,
444                               CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME,
445                               objectManagerName))
446                           {
447                               propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME;
448                           }
449                           else if(!validateRequiredProperty(
450                               objectPath,
451                               CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
452                               PEGASUS_CLASSNAME_PGNAMESPACE.getString()))
453                           {
454                               propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME;
455                           }
456                           else if(!validateRequiredProperty(objectPath,
457                               CIM_NAMESPACE_PROPERTY_NAME,
458                               String::EMPTY))
459                           {
460                               propertyName = CIM_NAMESPACE_PROPERTY_NAME;
461 a.dunfey         1.1      }
462                       
463                           if(!propertyName.isNull())
464                           {
465                               PEG_METHOD_EXIT();
466                               throw CIMInvalidParameterException(
467                                   "Invalid key property: " + propertyName.getString());
468                           }
469                       
470                           PEG_METHOD_EXIT();
471 kumpf            1.5      return CIMNamespaceName(
472                               getKeyValue(objectPath, CIM_NAMESPACE_PROPERTY_NAME));
473 a.dunfey         1.1  }
474                       
475                       void InteropProvider::deleteNamespace(
476                           const CIMObjectPath & instanceName)
477                       {
478                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
479                               "InteropProvider::deleteNamespace()");
480                           // Validate requred keys and retrieve namespace name. An exception
481                           // will be thrown if the object path is not valid.
482                           CIMNamespaceName deleteNamespaceName =
483                               validateNamespaceKeys(instanceName, objectManagerName);
484                       
485                           if (deleteNamespaceName.equal(PEGASUS_NAMESPACENAME_ROOT))
486                           {
487                               PEG_METHOD_EXIT();
488                               throw CIMNotSupportedException("root namespace cannot be deleted.");
489                           }
490                       
491                           repository->deleteNameSpace(deleteNamespaceName);
492                       
493 thilo.boehm      1.10     PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
494                               "Namespace = %s successfully deleted.",
495                               (const char*)deleteNamespaceName.getString().getCString()));
496 a.dunfey         1.1  
497                           PEG_METHOD_EXIT();
498                       }
499                       
500                       CIMObjectPath InteropProvider::createNamespace(
501                           const CIMInstance & namespaceInstance)
502                       {
503                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
504                               "InteropProvider::createNamespace()");
505                           // The buildNamespacePath method performs some validation on the
506                           // namespace instance, creates a valid object path that can be used
507                           // by the client to access the instance later, and retrieves the
508                           // namespace to be created.
509                           CIMObjectPath newInstanceReference;
510                           CIMNamespaceName newNamespaceName = buildNamespacePath(
511                               newInstanceReference, namespaceInstance, objectManagerName);
512                       
513                           // Create the new namespace
514 kumpf            1.6  
515 thilo.boehm      1.10     PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
516                               "Namespace = %s to be created.",
517                               (const char*)newNamespaceName.getString().getCString()));
518 kumpf            1.6  
519                           CIMRepository::NameSpaceAttributes attributes;
520                       
521                           // Set shareable attribute to "false" if property is not present
522                           Boolean shareable = false;
523                           if (getPropertyValue(namespaceInstance,
524                               PG_NAMESPACE_PROPERTY_ISSHAREABLE, false))
525                           {
526                               attributes.insert("shareable", "true");
527                           }
528                           else
529 a.dunfey         1.1      {
530 kumpf            1.6          attributes.insert("shareable", "false");
531                           }
532 a.dunfey         1.1  
533 kumpf            1.6      // Set updatesAllowed attribute to "false" if property is not present
534                           Boolean updatesAllowed = false;
535                           if (getPropertyValue(namespaceInstance,
536                               PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, false))
537 a.dunfey         1.1      {
538 kumpf            1.6          attributes.insert("updatesAllowed", "true");
539 a.dunfey         1.1      }
540 kumpf            1.6      else
541 a.dunfey         1.1      {
542 kumpf            1.6          attributes.insert("updatesAllowed", "false");
543 a.dunfey         1.1      }
544                       
545 kumpf            1.6      // Set the parent attribute if the property is present, but don't set
546                           // it at all otherwise.
547                           String parent = getPropertyValue(namespaceInstance,
548                               PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, String::EMPTY);
549                           if (parent != String::EMPTY)
550                               attributes.insert("parent",parent);
551                       
552                           //
553                           // Create the namespace with the retrieved attributes.
554                           //
555                           repository->createNameSpace(newNamespaceName, attributes);
556                       
557 marek            1.8      PEG_TRACE((
558                               TRC_CONTROLPROVIDER,
559                               Tracer::LEVEL4,
560                               "Namespace %s: Shareable = %s, Updates allowed: %s, Parent: %s"
561                                   "  successfully created.",
562                               (const char*) newNamespaceName.getString().getCString(),
563 kumpf            1.6          shareable? "true" : "false",
564                               updatesAllowed? "true" : "false",
565 marek            1.8          (const char*) parent.getCString()));
566 kumpf            1.6  
567 a.dunfey         1.1      return newInstanceReference;
568                       }
569                       
570 a.dunfey         1.2  PEGASUS_NAMESPACE_END
571 a.dunfey         1.1  
572                       // END OF FILE

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2