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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2