47 mreddy 1.1.2.1
48 //property names
49
50 static const String PROP_ELEMENTNAME = "ElementName";
51 static const String PROP_DESCRIPTION = "Description";
52 static const String PROP_NAME = "Name";
53 static const String PROP_CLASSINFO = "Classinfo";
54 static const String PROP_COMMUNICATIONMECHANISM = "CommunicationMechanism";
55 static const String PROP_OTHERCOMMUNICATIONMECHANISMDESCRIPTION = "OtherCommunicationMechanismDescription";
56 static const String PROP_INTEROPSCHEMANAMESPACE = "InteropSchemaNamespace";
57 static const String PROP_VERSION = "Version";
58 static const String PROP_FUNCTIONALPROFILESSUPPORTED = "FunctionalProfilesSupported";
59 static const String PROP_FUNCTIONALPROFILEDESCRIPTIONS = "FunctionalProfileDescriptions";
60 static const String PROP_MULTIPLEOPERATIONSSUPPORTED = "MultipleOperationsSupported";
61 static const String PROP_AUTHENTICATIONMECHANISMSSUPPORTED = "AuthenticationMechanismsSupported";
62 static const String PROP_AUTHENTICATIONMECHANISMDESCRIPTIONS = "AuthenticationMechanismDescriptions";
63 static const String PROP_NAMESPACETYPE = "namespaceType";
64 static const String PROP_IPADDRESS = "IPAddress";
65
66 static const String CIM_CLASSNAME_REGISTEREDPROFILE = "CIM_RegisteredProfile";
67 static const String PROP_OTHERREGISTEREDORGANIZATION = "OtherRegisteredOrganization";
68 mreddy 1.1.2.1 static const String PROP_REGISTEREDNAME = "RegisteredName";
69 static const String PROP_ADVERTISETYPES = "AdvertiseTypes";
70
71 //constructor
72 SLPAttrib::SLPAttrib():serviceType(SERVICE_TYPE)
73 {
74 }
75
76 SLPAttrib::~SLPAttrib()
77 {
78 }
79
80 String SLPAttrib::getAttributes(void) const
81 {
82 return attributes;
83 }
84
85 String SLPAttrib::getServiceType(void) const
86 {
87 return serviceType;
88 }
89 mreddy 1.1.2.1
90 String SLPAttrib::getServiceUrl(void) const
91 {
92 return serviceUrl;
93 }
94
95 // fill all data required for SLP.
96 void SLPAttrib::fillData(String protocol)
97 {
98 CIMClient client;
99 CIMClass cimClass;
100 //
101 // open connection to CIMOM
102 //
103 String hostStr = System::getHostName();
104
105 try
106 {
107 //
108 client.connectLocal();
109
110 mreddy 1.1.2.1 //
111 Array <CIMInstance> instances;
112 CIMValue val;
113 Uint32 pos;
114 Boolean localOnly=true;
115 Boolean includeQualifiers=true;
116 Boolean includeClassOrigin=false;
117 Boolean deepInheritance=true;
118 Uint32 len = 0;
119
120 // set to true if there is "Other" property value in FunctionsProfilesSupported value.
121 Boolean functionaProfileDescriptions = false;
122
123 instances = client.enumerateInstances
124 (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_OBJECTMANAGER,deepInheritance,localOnly,includeQualifiers,includeClassOrigin);
125
126 PEGASUS_ASSERT (instances.size () == 1);
127
128 pos = instances[0].findProperty(PROP_ELEMENTNAME);
129 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
130 val = instances[0].getProperty(pos).getValue ();
131 mreddy 1.1.2.1 serviceHiName = val.toString();
132
133 pos = instances[0].findProperty (PROP_DESCRIPTION);
134 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
135 val = instances[0].getProperty(pos).getValue ();
136 serviceHiDescription = val.toString();
137
138 pos = instances[0].findProperty (PROP_NAME);
139 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
140 val = instances[0].getProperty(pos).getValue ();
141 serviceId = val.toString();
142
143 instances = client.enumerateInstances
144 (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM,deepInheritance,localOnly,includeQualifiers,includeClassOrigin);
145
146 for (Uint32 n=instances.size(),i=0 ; i<n; i++)
147 {
148 pos = instances[i].findProperty (PROP_NAMESPACETYPE);
149 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
150 val = instances[i].getProperty(pos).getValue ();
151 if (val.toString() == protocol)
152 mreddy 1.1.2.1 {
153 pos = instances[i].findProperty (PROP_IPADDRESS);
154 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
155 val = instances[i].getProperty(pos).getValue ();
156 serviceUrl="service:wbem:";
157 serviceUrl.append(protocol);
158 serviceUrl.append("://");
159 serviceUrl.append(val.toString());
160 break;
161 }
162 }
163
164 cimClass = client.getClass(PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_CIMNAMESPACE);
165 instances = client.enumerateInstances
166 (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_CIMNAMESPACE,deepInheritance,localOnly,includeQualifiers,includeClassOrigin);
167
168 for (Uint32 n=instances.size(),i=0 ; i<n; i++)
169 {
170 pos = instances[i].findProperty (PROP_NAME);
171 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
172 val = instances[i].getProperty(pos).getValue();
173 mreddy 1.1.2.1 nameSpaces.append(val.toString());
174 nameSpaces.append(",");
175
176 pos = instances[i].findProperty (PROP_CLASSINFO);
177 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
178 val = instances[i].getProperty(pos).getValue();
179 pos = cimClass.findProperty(PROP_CLASSINFO);
180 classes.append(getMappedValue(cimClass.getProperty(pos),val));
181 classes.append(",");
182 }
183
184 len = nameSpaces.size();
185 if (len > 0)
186 nameSpaces.remove( len-1,1);
187
188 len = classes.size();
189 if (len > 0)
190 classes.remove( len-1,1);
191
192 cimClass = client.getClass
193 (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_OBJECTMANAGERCOMMUNICATIONMECHANISM);
194 mreddy 1.1.2.1 instances = client.enumerateInstances
195 (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_OBJECTMANAGERCOMMUNICATIONMECHANISM,deepInheritance,localOnly,includeQualifiers,includeClassOrigin);
196
197 pos = instances[0].findProperty (PROP_COMMUNICATIONMECHANISM);
198 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
199 val = instances[0].getProperty(pos).getValue();
200 pos = cimClass.findProperty(PROP_COMMUNICATIONMECHANISM);
201 communicationMechanism = getMappedValue(cimClass.getProperty(pos),val);
202 pos = instances[0].findProperty (PROP_OTHERCOMMUNICATIONMECHANISMDESCRIPTION);
203 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
204 val = instances[0].getProperty(pos).getValue ();
205 otherCommunicationMechanismDescription = val.toString();
206
207 interopSchemaNamespace = PG_INTEROP_NAMESPACE;
208
209 pos = instances[0].findProperty (PROP_VERSION);
210 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
211 val = instances[0].getProperty(pos).getValue();
212 pos = cimClass.findProperty(PROP_VERSION);
213 protocolVersion = getMappedValue(cimClass.getProperty(pos),val);
214
215 mreddy 1.1.2.1 pos = instances[0].findProperty (PROP_FUNCTIONALPROFILESSUPPORTED);
216 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
217 CIMConstProperty constProperty;
218 constProperty = instances[0].getProperty(pos);
219 val = constProperty.getValue();
220 Array<Uint16> arrayValFPS;
221 val.get(arrayValFPS);
222 pos = cimClass.findProperty(PROP_FUNCTIONALPROFILESSUPPORTED);
223 for (Uint32 n=arrayValFPS.size(),i=0; i<n; i++)
224 {
225 String profileValue = getMappedValue(cimClass.getProperty(pos),CIMValue(arrayValFPS[i]));
226 if (profileValue == "Other")
227 functionaProfileDescriptions = true;
228 functionalProfilesSupported.append(profileValue);
229 functionalProfilesSupported.append(",");
230 }
231 len = functionalProfilesSupported.size();
232 if (len > 0)
233 functionalProfilesSupported.remove( len-1,1);
234
235 if (functionalProfileDescriptions == true)
236 mreddy 1.1.2.1 {
237 pos = instances[0].findProperty (PROP_FUNCTIONALPROFILEDESCRIPTIONS);
238 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
239 val = instances[0].getProperty(pos).getValue();
240 Array<String> arrayValFPD;
241 val.get(arrayValFPD);
242 for (Uint32 n=arrayValFPD.size(),i=0; i<n; i++)
243 {
244 functionalProfileDescriptions.append(arrayValFPD[i]);
245 functionalProfileDescriptions.append(",");
246 }
247 len = functionalProfileDescriptions.size();
248 if (len > 0)
249 functionalProfileDescriptions.remove( len-1,1);
250 }
251 pos = instances[0].findProperty (PROP_MULTIPLEOPERATIONSSUPPORTED);
252 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
253 val = instances[0].getProperty(pos).getValue();
254 Boolean value;
255 val.get(value);
256 if (value == true)
257 mreddy 1.1.2.1 multipleOperationsSupported.append("TRUE");
258 else
259 multipleOperationsSupported.append("FALSE");
260
261 pos = instances[0].findProperty (PROP_AUTHENTICATIONMECHANISMSSUPPORTED);
262 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
263 val = instances[0].getProperty(pos).getValue();
264 Array<Uint16> arrayValAMS;
265 val.get(arrayValAMS);
266 pos = cimClass.findProperty (PROP_AUTHENTICATIONMECHANISMSSUPPORTED);
267 for (Uint32 n=arrayValAMS.size(),i=0; i<n; i++)
268 {
269 authenticationMechanismsSupported.append(getMappedValue(cimClass.getProperty(pos),CIMValue(arrayValAMS[i])));
270 authenticationMechanismsSupported.append(",");
271 }
272 len = authenticationMechanismsSupported.size();
273 if (len > 0)
274 authenticationMechanismsSupported.remove( len-1,1);
275
276 pos = instances[0].findProperty (PROP_AUTHENTICATIONMECHANISMDESCRIPTIONS);
277 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
278 mreddy 1.1.2.1 val = instances[0].getProperty(pos).getValue();
279 Array<String> arrayValAMD;
280 val.get(arrayValAMD);
281 for (Uint32 n=arrayValAMD.size(),i=0; i<n; i++)
282 {
283 authenticationMechanismDescriptions.append(arrayValAMD[i]);
284 authenticationMechanismDescriptions.append(",");
285 }
286 len = authenticationMechanismDescriptions.size();
287 if (len > 0)
288 authenticationMechanismDescriptions.remove( len-1,1);
289 instances = client.enumerateInstances
290 (PEGASUS_NAMESPACENAME_INTEROP, CIM_CLASSNAME_REGISTEREDPROFILE,deepInheritance,localOnly,includeQualifiers,includeClassOrigin);
291
292 for (Uint32 n=instances.size(),i=0 ; i<n; i++)
293 {
294 pos = instances[i].findProperty (PROP_ADVERTISETYPES);
295 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
296 CIMValue cAdvTypes = instances[i].getProperty(pos).getValue();
297 Array<Uint16> advTypes;
298 cAdvTypes.get(advTypes);
299 mreddy 1.1.2.1 for (Uint32 n=advTypes.size(),j = 0; j < n; j++)
300 {
301 if(advTypes[j] == 3)
302 {
303 pos = instances[i].findProperty (PROP_OTHERREGISTEREDORGANIZATION);
304 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
305 registeredProfiles.append(instances[i].getProperty(pos).getValue().toString());
306 registeredProfiles.append(":");
307 pos = instances[i].findProperty (PROP_REGISTEREDNAME);
308 PEGASUS_ASSERT (pos != PEG_NOT_FOUND);
309 registeredProfiles.append(instances[i].getProperty(pos).getValue().toString());
310 registeredProfiles.append(",");
311 break;
312 }
313 }
314 }
315
316 if (instances.size() > 0)
317 {
318 len = registeredProfiles.size();
319 registeredProfiles.remove( len-1,1);
320 mreddy 1.1.2.1 }
321 else
322 registeredProfiles.append("");
323 }
324
325 catch(CIMException& e)
326 {
327 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
328 "SLP Registration Failed. CIMException. $0", e.getMessage());
329 }
330
331 catch(Exception& e)
332 {
333 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
334 "SLP Registration Failed Startup: CIMException exception. $0", e.getMessage());
335 }
336 client.disconnect();
337 return;
338 }
339
340 // Map Values to ValueMap
341 mreddy 1.1.2.1 String SLPAttrib::getMappedValue(const CIMProperty& cimProperty, CIMValue value)
342 {
343 String retValue;
344 Uint16 localValue;
345
346 if (strcmp(cimTypeToString(value.getType()),"string") == 0)
347 value.get(retValue);
348 else
349 {
350 value.get(localValue);
351 retValue = Formatter::format("$0",localValue);
352 }
353
354 Uint32 posValueMap;
355
356 if ((posValueMap = cimProperty.findQualifier(CIMName("ValueMap"))) == PEG_NOT_FOUND)
357 {
358 return retValue;
359 }
360 CIMConstQualifier qValueMap = cimProperty.getQualifier(posValueMap);
361 if (!qValueMap.isArray() || (qValueMap.getType() != CIMTYPE_STRING))
362 mreddy 1.1.2.1 {
363 return retValue;
364 }
365
366 CIMValue q1 = qValueMap.getValue();
367 Array<String> val;
368 q1.get(val);
369
370 Uint32 posValue;
371 if ((posValue = cimProperty.findQualifier("Values")) == PEG_NOT_FOUND)
372 {
373 return retValue;
374 }
375
376 CIMConstQualifier qValue = cimProperty.getQualifier(posValue);
377 if (!qValue.isArray() || (qValue.getType() != CIMTYPE_STRING))
378 {
379 return retValue;
380 }
381
382 CIMValue q2 = qValue.getValue();
383 mreddy 1.1.2.1 Array<String> va2;
384 q2.get(va2);
385
386 if (va2.size() != val.size())
387 {
388 return retValue;
389 }
390
391 for (Uint32 n=val.size(),i = 0; i < n; i++)
392 {
393 if(retValue == val[i])
394 {
395 return (va2[i]);
396 }
397 }
398 return retValue;
399 }
400
401 // Form the attributes String.
402 void SLPAttrib::formAttributes()
403 {
404 mreddy 1.1.2.1
405 attributes.append(Formatter::format(
406 "(template-url-syntax=$0),(service-hi-name=$1),(service-hi-description=$2),(service-id=$3),(Namespace=$4),(Classinfo=$5),(CommunicationMechanism=$6),(OtherCommunicationMechanismDescription=$7),(InteropSchemaNamespace=$8),(ProtocolVersion=$9),",
407 serviceUrl,serviceHiName,
408 serviceHiDescription,serviceId,
409 nameSpaces,classes,
410 communicationMechanism,
411 otherCommunicationMechanismDescription,
412 interopSchemaNamespace,
413 protocolVersion));
414
415 attributes.append(Formatter::format(
416 "(FunctionalProfilesSupported=$0),(FunctionalProfileDescriptions=$1),(MultipleOperationsSupported=$2),(AuthenticationMechanismsSupported=$3),(AuthenticationMechanismDescriptions=$4),(RegisteredProfilesSupported=$5)",
417 functionalProfilesSupported,
418 functionalProfileDescriptions,
419 multipleOperationsSupported,
420 authenticationMechanismsSupported,
421 authenticationMechanismDescriptions,
422 registeredProfiles));
423
424 if (attributes.size() > 7900)
425 mreddy 1.1.2.1 {
426 //truncate the attributes
427 attributes = attributes.subString(0,7900);
428 Uint32 index = attributes.reverseFind(')');
429 attributes= attributes.subString(0,index+1);
430 }
431 return;
432 }
433 PEGASUS_NAMESPACE_END
|