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