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