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

  1 martin 1.9 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.10 //
  3 martin 1.9  // 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.10 //
 10 martin 1.9  // 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.10 //
 17 martin 1.9  // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.10 //
 20 martin 1.9  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.10 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.9  // 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.10 //
 28 martin 1.9  //////////////////////////////////////////////////////////////////////////
 29 a.dunfey 1.1  
 30               #ifndef InteropProviderUtils_h
 31               #define InteropProviderUtils_h
 32               
 33               #include <Pegasus/Common/Array.h>
 34               #include <Pegasus/Common/CIMClass.h>
 35               #include <Pegasus/Common/CIMInstance.h>
 36               #include <Pegasus/Common/CIMObjectPath.h>
 37               #include <Pegasus/Common/CIMPropertyList.h>
 38               #include <Pegasus/Common/String.h>
 39               
 40 a.dunfey 1.2  PEGASUS_NAMESPACE_BEGIN
 41 a.dunfey 1.1  
 42               // Enum for class selection for instance operations.
 43 kumpf    1.8  enum TARGET_CLASS
 44               {
 45                   PG_NAMESPACE,
 46                   PG_OBJECTMANAGER,
 47                   PG_CIMXMLCOMMUNICATIONMECHANISM,
 48                   PG_NAMESPACEINMANAGER,
 49                   PG_COMMMECHANISMFORMANAGER,
 50                   PG_REGISTEREDPROFILE,
 51                   PG_REGISTEREDSUBPROFILE,
 52                   PG_REFERENCEDPROFILE,
 53                   PG_ELEMENTCONFORMSTOPROFILE,
 54                   PG_SUBPROFILEREQUIRESPROFILE,
 55                   PG_SOFTWAREIDENTITY,
 56                   PG_ELEMENTSOFTWAREIDENTITY,
 57                   PG_INSTALLEDSOFTWAREIDENTITY,
 58                   PG_COMPUTERSYSTEM,
 59                   PG_HOSTEDOBJECTMANAGER,
 60                   PG_HOSTEDACCESSPOINT,
 61                   PG_ELEMENTCONFORMSTOPROFILE_RP_RP,
 62                   CIM_NAMESPACE,
 63                   PG_PROVIDERPROFILECAPABILITIES,
 64 kumpf    1.8      PG_PROVIDERREFERENCEDPROFILES
 65 venkat.puvvada 1.7  #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
 66 kumpf          1.8      ,PG_ELEMENTCAPABILITIES,
 67                         PG_HOSTEDINDICATIONSERVICE,
 68                         PG_SERVICEAFFECTSELEMENT
 69 venkat.puvvada 1.7  #endif
 70 a.dunfey       1.1  };
 71                     
 72                     /***************************************************************
 73                      *                                                             *
 74                      *               Provider Utility Functions                    *
 75                      *                                                             *
 76                      ***************************************************************/
 77                     
 78                     const char * boolToString(Boolean x);
 79                     
 80                     //
 81                     // Utility function used to produce trace/logging statements
 82                     //
 83                     String propertyListToString(const CIMPropertyList& pl);
 84                     
 85                     //
 86                     // Helper function that constructs an the InstanceId property out of its
 87                     // constituent pieces.
 88                     //
 89                     String buildProfileInstanceId(
 90                         const String & organization,
 91 a.dunfey       1.1      const String & name,
 92                         const String & version);
 93                     
 94                     //
 95                     // function that creates an object path given a class definition, an
 96                     // instance of that class, the host name, and the namespace.
 97                     //
 98                     CIMObjectPath buildInstancePath(
 99                         const CIMClass & cimClass,
100                         const String & hostName,
101                         const CIMNamespaceName & nameSpace,
102                         const CIMInstance & instance);
103                     
104                     //
105                     // Template function that retrieves the value of a property. The template
106                     // type determines the type that should be contained within the CIMValue object
107                     // of the property (specified by the propName parameter) in the supplied
108                     // instance. This is used particularly for Required properties, so if the
109                     // property is not found or is NULL, an exception will be thrown.
110                     //
111                     template <class RetClass>
112 a.dunfey       1.1  RetClass getRequiredValue(const CIMInstance & instance,
113                                               const CIMName & propName)
114                     {
115                         RetClass retVal;
116                         Uint32 index = instance.findProperty(propName);
117                         if(index == PEG_NOT_FOUND)
118                         {
119                             throw CIMOperationFailedException("Instance " +
120                                 instance.getPath().toString() +
121                                 " missing expected property " + propName.getString());
122                         }
123                         const CIMValue & tmpVal = instance.getProperty(index).getValue();
124                         if(tmpVal.isNull())
125                         {
126                             throw CIMOperationFailedException("Instance " +
127                                 instance.getPath().toString() +
128                                 " has unexpected NULL value for property " + propName.getString());
129                         }
130                     
131                         tmpVal.get(retVal);
132                     
133 a.dunfey       1.1      return retVal;
134                     }
135                     
136                     //
137                     // Determines if the namespace is allowable for this operation.
138                     // This provider is designed to accept either all namespaces or
139                     // limit itself to just one for operations.  In all cases, it
140                     // will provide the required answers and use the correct namespace
141                     // for any persistent information.  However, it may be configured
142                     // to either accept input operations from any namespace or simply
143                     // from one (normally the interop namespace).
144                     // @ objectReference for the operation.  This must include the
145                     // namespace and class name for the operation.
146                     // @return Returns normally if the namespace test is passed. Otherwise
147                     // it generates a CIMException (CIM_ERR_NOT_SUPPORTED)
148                     // @exception CIMException(CIM_ERR_NOT_SUPPORTED)
149                     //
150                     // NOTE:This function is commented out because the routing tables will always
151                     // do the right thing and that's the only way requests get here. If this
152                     // changes, then this function should be reinstated along with the various
153                     // locations where calls to the function are also commented out.
154 a.dunfey       1.1  //
155                     /*
156                     bool namespaceSupported(const CIMObjectPath & path);
157                     */
158                     
159                     //
160                     // Normalize the instance by setting the complete path for the instance and
161                     // executing the instance filter to set the qualifiers, classorigin, and
162                     // property list in accordance with the input.  Note that this can only remove
163                     // characteristics, except for the path completion, so that it expects
164                     // instances with qualifiers, class origin, and a complete set of properties
165                     // already present in the instance.
166                     //
167                     void normalizeInstance(CIMInstance& instance, const CIMObjectPath& path,
168                                            Boolean includeQualifiers, Boolean includeClassOrigin,
169                                            const CIMPropertyList& propertyList);
170                     
171                     //
172                     // Get one string property from an instance. Note that these functions simply
173                     // return the default value if the property cannot be found or is of the wrong
174                     // type.
175 a.dunfey       1.1  // @param instance CIMInstance from which we get property value
176                     // @param propertyName String name of the property containing the value
177                     // @param default String optional parameter that is substituted if the property
178                     // does not exist or is NULL.
179                     // @return String value found or defaultValue.
180                     //
181                     String getPropertyValue(const CIMInstance & instance,
182                         const CIMName & propertyName, const String & defaultValue);
183                     
184                     //
185                     // Overload of getPropertyValue for boolean type
186                     //
187                     Boolean getPropertyValue(const CIMInstance & instance,
188                         const CIMName & propertyName, const Boolean defaultValue);
189                     
190                     //
191                     // Get Host IP address from host name. If the host name is not provided,
192                     // uses internal function. If everything fails, gets the definition normally
193                     // used for localhost (127.0.0.1).
194                     //
195                     // @param hostName String with the name of the host. Allows String:EMPTY and
196 a.dunfey       1.1  //     in that case, gets it directly from system.
197                     // @param namespaceType - Uint32 representing the access protocol for this
198                     //     request.  This is exactly the definition in the
199                     //     PG_CIMXMLCommunicationMechanism mof for the property
200                     //     namespaceAccessProtocol.
201 kumpf          1.3  // @param port String defining the port to be used.
202 a.dunfey       1.1  //
203                     // @return String with the IP address to be used. This must be the complete
204                     //     address sufficient to access the IP address. Therefore, it includes the
205                     //     port number.
206                     //
207 kumpf          1.3  String getHostAddress(
208                         const String& hostName,
209                         Uint32 namespaceType,
210                         const String& port);
211 a.dunfey       1.1  
212                     //
213                     // Validate that the property exists, is string type and optionally the value
214                     // itself. NOTE: This function processes only String properties.
215                     //
216                     // @param Instance to search for property.
217                     // @param CIMName containing property Name
218                     // @param String containing value. If not String::EMPTY, compare to value
219                     //     in the property
220                     // @return True if passes all tests
221                     //
222                     Boolean validateRequiredProperty(
223                         const CIMInstance & instance,
224                         const CIMName & propertyName,
225                         const String & value);
226                     
227                     //
228                     // Same as above, overloaded to check key properties in CIMObjectPath objects
229                     // against a string value.
230                     //
231                     Boolean validateRequiredProperty(
232 a.dunfey       1.1      const CIMObjectPath & objectPath,
233                         const CIMName & propertyName,
234                         const String & value);
235                     
236                     //
237                     // Verify that this is one of the legal classnames for instance operations and
238                     // return an indicator as to which one it is.
239                     // @param - Classname
240                     // @return - Enum value indicating type
241                     // @Exceptions - throws CIMNotSupportedException if invalid class.
242                     //
243                     TARGET_CLASS translateClassInput(const CIMName& className);
244                     
245                     //
246                     // Same as method above, but used specifically for association classes.
247                     //
248                     TARGET_CLASS translateAssocClassInput(const CIMName & className);
249                     
250                     //
251                     // Set the value of a property defined by property name in the instance
252                     // provided. If the property cannot be found, it simply returns.
253 a.dunfey       1.1  //
254                     // @param instance CIMInstance in which to set property value
255                     // @param propertyName CIMName of property in which value will be set.
256                     // @param value CIMValue value to set into property
257                     //
258                     // @return true if property value was set, false if the property was not found
259                     //
260                     void setPropertyValue(CIMInstance& instance, const CIMName& propertyName,
261                         const CIMValue & value);
262                     
263                     //
264                     // Sets the correct values to the common keys defined for all of the classes.
265                     // This is SystemCreationClassName and SystemName. Note that if the properties
266                     // do not exist, we simply ignore them.
267                     //
268                     void setCommonKeys(CIMInstance& instance);
269                     
270                     //
271                     // Retrieves the key binding given by the keyName parameter from the supplied
272                     // object path.
273                     //
274 a.dunfey       1.1  String getKeyValue(const CIMObjectPath& instanceName, const CIMName& keyName);
275                     
276                     //
277                     // Retrieves the key binding given by the keyName parameter from the supplied
278                     // instance.
279                     //
280                     String getKeyValue(const CIMInstance& instance, const CIMName& keyName);
281                     
282                     //
283                     // The following method is used to translate a string based on the
284                     // Value/ValueMap qualifiers of a property. Note that the method is written
285                     // in such a way that the translation could be done in either direction
286                     // (from Value value to ValueMap value or vice versa) or with another pair
287                     // of qualifiers with a relationship similar to the Value/ValueMap pair.
288                     //
289                     String translateValue(
290                         const String & value,
291                         const CIMName & propName,
292                         const CIMName & sourceQualifier,
293                         const CIMName & targetQualifier,
294                         const CIMClass & classDef);
295 a.dunfey       1.1  
296                     //
297                     // Same as above, but converts an integral value into a string first so that
298                     // it can be found when searching the Values qualifier (or some similar
299                     // qualifier).
300                     //
301                     String translateValue(Uint16 value, const CIMName & propName,
302                         const CIMName & sourceQualifier, const CIMName & targetQualifier,
303                         const CIMClass & classDef);
304                     
305                     //
306                     // helper function for building a reference ObjectPath for an instance
307                     // of CIM_Dependency.
308                     //
309                     CIMObjectPath buildDependencyReference(
310                         const String & hostName,
311                         const String & instanceId,
312                         const CIMName & instanceClass);
313                     
314                     //
315                     // helper function for building an instance of CIM_Dependency given
316 a.dunfey       1.1  // the antecedent and dependent references and the concrete subclass for which
317                     // the instance will be created.
318                     //
319                     CIMInstance buildDependencyInstanceFromPaths(
320                         const CIMObjectPath & antecedent,
321                         const CIMObjectPath & dependent,
322                         const CIMClass & dependencyClass);
323                     
324                     //
325                     // Given an instance of PG_ProviderProfileCapabilities, this method retrieves
326                     // the values necessary for constructing instances of PG_RegisteredProfile,
327                     // PG_RegisteredSubProfile, and all of their associations.
328                     // NOTE: This function is implemented in RegisteredProfile.cpp but declared
329                     //       here so that it can be accessed by ElementConformsToProfile.cpp and
330                     //       Software.cpp.
331                     //
332                     String extractProfileInfo(
333                         const CIMInstance & profileCapabilities,
334                         const CIMClass & capabilitiesClass,
335                         const CIMClass & profileClass,
336                         String & name,
337 a.dunfey       1.1      String & version,
338                         Uint16 & organization,
339                         String & organizationName,
340                         Array<String> & subprofileNames,
341                         Array<String> & subprofileVersions,
342                         Array<Uint16> & subprofileOrganizations,
343                         Array<String> & subprofileOrganizationNames,
344 venkat.puvvada 1.6      Array<String> & subProfileProviderModuleNames,
345                         Array<String> & subProfileProviderNames,
346 a.dunfey       1.1      bool noSubProfileInfo = true);
347                     
348 a.dunfey       1.2  PEGASUS_NAMESPACE_END
349 a.dunfey       1.1  
350                     #endif // InteropProviderUtils_h

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2