Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

973 lines
28 KiB

  1. #include "WLBS_Provider.h"
  2. #include "WLBS_clustersetting.h"
  3. #include "ClusterWrapper.h"
  4. #include "ControlWrapper.h"
  5. #include "utils.h"
  6. #include "wlbsutil.h"
  7. #include "WLBS_clustersetting.tmh"
  8. ////////////////////////////////////////////////////////////////////////////////
  9. //
  10. // CWLBS_ClusterSetting::CWLBS_ClusterSetting
  11. //
  12. // Purpose: Constructor
  13. //
  14. ////////////////////////////////////////////////////////////////////////////////
  15. CWLBS_ClusterSetting::CWLBS_ClusterSetting
  16. (
  17. CWbemServices* a_pNameSpace,
  18. IWbemObjectSink* a_pResponseHandler
  19. )
  20. : CWlbs_Root( a_pNameSpace, a_pResponseHandler )
  21. {
  22. }
  23. ////////////////////////////////////////////////////////////////////////////////
  24. //
  25. // CWLBS_ClusterSetting::Create
  26. //
  27. // Purpose: This instantiates this class and is invoked from an array of
  28. // function pointers.
  29. //
  30. ////////////////////////////////////////////////////////////////////////////////
  31. CWlbs_Root* CWLBS_ClusterSetting::Create
  32. (
  33. CWbemServices* a_pNameSpace,
  34. IWbemObjectSink* a_pResponseHandler
  35. )
  36. {
  37. CWlbs_Root* pRoot = new CWLBS_ClusterSetting( a_pNameSpace, a_pResponseHandler );
  38. if( !pRoot )
  39. throw _com_error( WBEM_E_OUT_OF_MEMORY );
  40. return pRoot;
  41. }
  42. ////////////////////////////////////////////////////////////////////////////////
  43. //
  44. // CWLBS_ClusterSetting::GetInstance
  45. //
  46. // Purpose:
  47. //
  48. ////////////////////////////////////////////////////////////////////////////////
  49. HRESULT CWLBS_ClusterSetting::GetInstance
  50. (
  51. const ParsedObjectPath* a_pParsedPath,
  52. long /* a_lFlags */,
  53. IWbemContext* /* a_pIContex */
  54. )
  55. {
  56. IWbemClassObject* pWlbsInstance = NULL;
  57. HRESULT hRes = 0;
  58. TRACE_CRIT("->%!FUNC!");
  59. try {
  60. wstring wstrHostName;
  61. //get the name key property and convert to wstring
  62. //throws _com_error
  63. wstrHostName = (*a_pParsedPath->m_paKeys)->m_vValue.bstrVal;
  64. //get the cluster
  65. CWlbsClusterWrapper* pCluster = GetClusterFromHostName(g_pWlbsControl, wstrHostName);
  66. if (pCluster == NULL)
  67. {
  68. TRACE_CRIT("%!FUNC! GetClusterFromHostName failed for Host name = %ls, Throwing com_error WBEM_E_NOT_FOUND exception",wstrHostName.data());
  69. throw _com_error( WBEM_E_NOT_FOUND );
  70. }
  71. //get the Wbem class instance
  72. SpawnInstance( MOF_CLUSTERSETTING::szName, &pWlbsInstance );
  73. //Convert status to string description
  74. FillWbemInstance( pWlbsInstance, pCluster );
  75. //send the results back to WinMgMt
  76. m_pResponseHandler->Indicate( 1, &pWlbsInstance );
  77. if( pWlbsInstance ) {
  78. pWlbsInstance->Release();
  79. pWlbsInstance = NULL;
  80. }
  81. m_pResponseHandler->SetStatus( 0, WBEM_S_NO_ERROR, NULL, NULL );
  82. hRes = WBEM_S_NO_ERROR;
  83. }
  84. catch(CErrorWlbsControl Err) {
  85. IWbemClassObject* pWbemExtStat = NULL;
  86. TRACE_CRIT("%!FUNC! Caught a Wlbs exception : 0x%x", Err.Error());
  87. CreateExtendedStatus( m_pNameSpace,
  88. &pWbemExtStat,
  89. Err.Error(),
  90. (PWCHAR)(Err.Description()) );
  91. m_pResponseHandler->SetStatus(0, WBEM_E_FAILED, NULL, pWbemExtStat);
  92. if( pWbemExtStat )
  93. pWbemExtStat->Release();
  94. if( pWlbsInstance )
  95. pWlbsInstance->Release();
  96. //do not return WBEM_E_FAILED, this causes a race condition
  97. hRes = WBEM_S_NO_ERROR;
  98. }
  99. catch(_com_error HResErr ) {
  100. TRACE_CRIT("%!FUNC! Caught a com_error exception : 0x%x", HResErr.Error());
  101. m_pResponseHandler->SetStatus(0, HResErr.Error(), NULL, NULL);
  102. if( pWlbsInstance )
  103. pWlbsInstance->Release();
  104. hRes = HResErr.Error();
  105. //transform Win32 error to a WBEM error
  106. if( hRes == ERROR_FILE_NOT_FOUND )
  107. hRes = WBEM_E_NOT_FOUND;
  108. }
  109. catch(...) {
  110. TRACE_CRIT("%!FUNC! Caught an exception");
  111. if( pWlbsInstance )
  112. pWlbsInstance->Release();
  113. TRACE_CRIT("%!FUNC! Rethrowing exception");
  114. TRACE_CRIT("<-%!FUNC!");
  115. throw;
  116. }
  117. TRACE_CRIT("<-%!FUNC! return 0x%x", hRes);
  118. return hRes;
  119. }
  120. ////////////////////////////////////////////////////////////////////////////////
  121. //
  122. // CWLBS_ClusterSetting::EnumInstances
  123. //
  124. // Purpose: This function obtains the clustersetting data for the current host.
  125. // The node does not have to be a member of a cluster for this
  126. // to succeed. However, WLBS must be installed.
  127. //
  128. ////////////////////////////////////////////////////////////////////////////////
  129. HRESULT CWLBS_ClusterSetting::EnumInstances
  130. (
  131. BSTR /* a_bstrClass */,
  132. long /* a_lFlags */,
  133. IWbemContext* /* a_pIContex */
  134. )
  135. {
  136. IWbemClassObject* pWlbsInstance = NULL;
  137. HRESULT hRes = 0;
  138. TRACE_CRIT("->%!FUNC!");
  139. try {
  140. DWORD dwNumClusters = 0;
  141. CWlbsClusterWrapper** ppCluster = NULL;
  142. g_pWlbsControl->EnumClusters(ppCluster, &dwNumClusters);
  143. if (dwNumClusters == 0)
  144. {
  145. TRACE_CRIT("%!FUNC! CWlbsControlWrapper::EnumClusters() returned no clusters, Throwing com_error WBEM_E_NOT_FOUND exception");
  146. throw _com_error( WBEM_E_NOT_FOUND );
  147. }
  148. for (DWORD i=0; i < dwNumClusters; i++)
  149. {
  150. //get the Wbem class instance
  151. SpawnInstance( MOF_CLUSTERSETTING::szName, &pWlbsInstance );
  152. //get the cluster configuration
  153. FillWbemInstance( pWlbsInstance , ppCluster[i]);
  154. //send the results back to WinMgMt
  155. m_pResponseHandler->Indicate( 1, &pWlbsInstance );
  156. if( pWlbsInstance ) {
  157. pWlbsInstance->Release();
  158. pWlbsInstance = NULL;
  159. }
  160. }
  161. m_pResponseHandler->SetStatus( 0, WBEM_S_NO_ERROR, NULL, NULL );
  162. hRes = WBEM_S_NO_ERROR;
  163. }
  164. catch(CErrorWlbsControl Err) {
  165. IWbemClassObject* pWbemExtStat = NULL;
  166. TRACE_CRIT("%!FUNC! Caught a Wlbs exception : 0x%x", Err.Error());
  167. CreateExtendedStatus( m_pNameSpace,
  168. &pWbemExtStat,
  169. Err.Error(),
  170. (PWCHAR)(Err.Description()) );
  171. m_pResponseHandler->SetStatus(0, WBEM_E_FAILED, NULL, pWbemExtStat);
  172. if( pWbemExtStat )
  173. pWbemExtStat->Release();
  174. if( pWlbsInstance )
  175. pWlbsInstance->Release();
  176. //do not return WBEM_E_FAILED, this causes a race condition
  177. hRes = WBEM_S_NO_ERROR;
  178. }
  179. catch(_com_error HResErr ) {
  180. TRACE_CRIT("%!FUNC! Caught a com_error exception : 0x%x", HResErr.Error());
  181. m_pResponseHandler->SetStatus(0, HResErr.Error(), NULL, NULL);
  182. if( pWlbsInstance )
  183. pWlbsInstance->Release();
  184. hRes = HResErr.Error();
  185. //transform Win32 error to a WBEM error
  186. if( hRes == ERROR_FILE_NOT_FOUND )
  187. hRes = WBEM_E_NOT_FOUND ;
  188. }
  189. catch(...) {
  190. TRACE_CRIT("%!FUNC! Caught an exception");
  191. if( pWlbsInstance ) {
  192. pWlbsInstance->Release();
  193. pWlbsInstance = NULL;
  194. }
  195. TRACE_CRIT("%!FUNC! Rethrowing exception");
  196. TRACE_CRIT("<-%!FUNC!");
  197. throw;
  198. }
  199. TRACE_CRIT("<-%!FUNC! return 0x%x", hRes);
  200. return hRes;
  201. }
  202. ////////////////////////////////////////////////////////////////////////////////
  203. //
  204. // CWLBS_ClusterSetting::PutInstance
  205. //
  206. // Purpose: This function updates an instance of a MOF ClusterSetting
  207. // class. The node does not have to be a member of a cluster. However,
  208. // WLBS must be installed for this function to succeed.
  209. //
  210. ////////////////////////////////////////////////////////////////////////////////
  211. HRESULT CWLBS_ClusterSetting::PutInstance
  212. (
  213. IWbemClassObject* a_pInstance,
  214. long /* a_lFlags */,
  215. IWbemContext* /* a_pIContex */
  216. )
  217. {
  218. HRESULT hRes = 0;
  219. VARIANT vHostName;
  220. TRACE_CRIT("->%!FUNC!");
  221. try {
  222. VariantInit( &vHostName );
  223. //get the host name value
  224. hRes = a_pInstance->Get( _bstr_t( MOF_CLUSTERSETTING::pProperties[MOF_CLUSTERSETTING::NAME] ),
  225. 0,
  226. &vHostName,
  227. NULL,
  228. NULL );
  229. if( FAILED( hRes ) )
  230. throw _com_error( hRes );
  231. CWlbsClusterWrapper* pCluster = GetClusterFromHostName(g_pWlbsControl, vHostName.bstrVal);
  232. if (pCluster == NULL)
  233. {
  234. TRACE_CRIT("%!FUNC! GetClusterFromHostName failed for Host name = %ls, Throwing com_error WBEM_E_NOT_FOUND exception",vHostName.bstrVal);
  235. throw _com_error( WBEM_E_NOT_FOUND );
  236. }
  237. //get the cluster IP value
  238. _variant_t vClusterIp;
  239. hRes = a_pInstance->Get( _bstr_t( MOF_CLUSTERSETTING::pProperties[MOF_CLUSTERSETTING::CLUSIPADDRESS] ),
  240. 0,
  241. &vClusterIp,
  242. NULL,
  243. NULL );
  244. DWORD dwClusterIp = IpAddressFromAbcdWsz(vClusterIp.bstrVal);
  245. //
  246. // Make sure the non-zero cluster IP is unique
  247. //
  248. if (dwClusterIp != 0)
  249. {
  250. CWlbsClusterWrapper* pTmpCluster = g_pWlbsControl->GetClusterFromIpOrIndex(dwClusterIp);
  251. if (pTmpCluster && pCluster != pTmpCluster)
  252. {
  253. TRACE_CRIT("%!FUNC! GetClusterFromIpOrIndex failed, Dupilcate Cluster IP (%ls) found, Throwing Wlbs error WLBS_REG_ERROR exception",vClusterIp.bstrVal);
  254. throw CErrorWlbsControl( WLBS_REG_ERROR, CmdWlbsWriteReg );
  255. }
  256. }
  257. UpdateConfiguration( a_pInstance, pCluster );
  258. // CLD: Need to check return code for error
  259. if (S_OK != VariantClear( &vHostName ))
  260. {
  261. TRACE_CRIT("%!FUNC! VariantClear() failed, Throwing WBEM_E_FAILED exception");
  262. throw _com_error( WBEM_E_FAILED );
  263. }
  264. m_pResponseHandler->SetStatus( 0, WBEM_S_NO_ERROR, NULL, NULL );
  265. hRes = WBEM_S_NO_ERROR;
  266. }
  267. catch(CErrorWlbsControl Err) {
  268. IWbemClassObject* pWbemExtStat = NULL;
  269. TRACE_CRIT("%!FUNC! Caught a Wlbs exception : 0x%x", Err.Error());
  270. CreateExtendedStatus( m_pNameSpace,
  271. &pWbemExtStat,
  272. Err.Error(),
  273. (PWCHAR)(Err.Description()) );
  274. m_pResponseHandler->SetStatus(0, WBEM_E_FAILED, NULL, pWbemExtStat);
  275. if( pWbemExtStat )
  276. pWbemExtStat->Release();
  277. // CLD: Need to check return code for error
  278. if (S_OK != VariantClear( &vHostName ))
  279. {
  280. TRACE_CRIT("%!FUNC! VariantClear() failed, Throwing WBEM_E_FAILED exception");
  281. throw _com_error( WBEM_E_FAILED );
  282. }
  283. //do not return WBEM_E_FAILED, this causes a race condition
  284. hRes = WBEM_S_NO_ERROR;
  285. }
  286. catch(_com_error HResErr ) {
  287. TRACE_CRIT("%!FUNC! Caught a com_error exception : 0x%x", HResErr.Error());
  288. m_pResponseHandler->SetStatus(0, HResErr.Error(), NULL, NULL);
  289. // CLD: Need to check return code for error
  290. // No throw here since we are already throwing an exception.
  291. VariantClear( &vHostName );
  292. hRes = HResErr.Error();
  293. }
  294. catch (...) {
  295. TRACE_CRIT("%!FUNC! Caught an exception");
  296. // CLD: Need to check return code for error
  297. // No throw here since we are already throwing an exception.
  298. VariantClear( &vHostName );
  299. TRACE_CRIT("%!FUNC! Rethrowing exception");
  300. TRACE_CRIT("<-%!FUNC!");
  301. throw;
  302. }
  303. TRACE_CRIT("<-%!FUNC! return 0x%x", hRes);
  304. return hRes;
  305. }
  306. ////////////////////////////////////////////////////////////////////////////////
  307. //
  308. // CWLBS_ClusterSetting::ExecMethod
  309. //
  310. // Purpose:
  311. //
  312. ////////////////////////////////////////////////////////////////////////////////
  313. HRESULT CWLBS_ClusterSetting::ExecMethod
  314. (
  315. const ParsedObjectPath* a_pParsedPath,
  316. const BSTR& a_strMethodName,
  317. long /* a_lFlags */,
  318. IWbemContext* /* a_pIContex */,
  319. IWbemClassObject* a_pIInParams
  320. )
  321. {
  322. IWbemClassObject* pOutputInstance = NULL;
  323. VARIANT vValue;
  324. HRESULT hRes = 0;
  325. TRACE_CRIT("->%!FUNC!");
  326. try {
  327. VariantInit( &vValue );
  328. CWlbsClusterWrapper* pCluster = NULL;
  329. if (a_pParsedPath->m_paKeys == NULL)
  330. {
  331. //
  332. // No cluster IP specified
  333. //
  334. TRACE_CRIT("%!FUNC! Key (Clsuter IP) is not specified, Throwing com_error WBEM_E_INVALID_PARAMETER exception");
  335. throw _com_error( WBEM_E_INVALID_PARAMETER );
  336. }
  337. else
  338. {
  339. const wchar_t* wstrRequestedClusterName = (*a_pParsedPath->m_paKeys)->m_vValue.bstrVal;
  340. pCluster = GetClusterFromHostName(g_pWlbsControl, wstrRequestedClusterName);
  341. if (pCluster == NULL)
  342. {
  343. TRACE_CRIT("%!FUNC! GetClusterFromHostName failed for Cluster name = %ls, Throwing com_error WBEM_E_NOT_FOUND exception",wstrRequestedClusterName);
  344. throw _com_error( WBEM_E_NOT_FOUND );
  345. }
  346. }
  347. //determine the method being executed
  348. if( _wcsicmp( a_strMethodName, MOF_CLUSTERSETTING::pMethods[MOF_CLUSTERSETTING::SETPASS] ) == 0 ) {
  349. //get the password
  350. hRes = a_pIInParams->Get
  351. (
  352. _bstr_t( MOF_PARAM::PASSW ),
  353. 0,
  354. &vValue,
  355. NULL,
  356. NULL
  357. );
  358. if( vValue.vt != VT_BSTR )
  359. {
  360. TRACE_CRIT("%!FUNC! Argument %ls for method %ls is NOT of type \"BString\", Throwing com_error WBEM_E_INVALID_PARAMETER exception", MOF_PARAM::PASSW, a_strMethodName);
  361. throw _com_error ( WBEM_E_INVALID_PARAMETER );
  362. }
  363. pCluster->SetPassword( vValue.bstrVal );
  364. } else if( _wcsicmp( a_strMethodName, MOF_CLUSTERSETTING::pMethods[MOF_CLUSTERSETTING::LDSETT] ) == 0 ) {
  365. //
  366. // NOTE:
  367. // NLB, if needed, calls the PnP apis to disable and re-enable the network adapter, for the new NLB settings to take
  368. // effect. Since this operation involves unloading and loading of the device driver, PnP apis, attempt to enable
  369. // the "SeLoadDriverPrivilege" privilege in the impersonation access token. Enabling a privilege is successful only
  370. // when the privilege is present, in the first place to be enabled. When the wmi client and wmi provider are in the
  371. // same machine, it was observed that the "SeLoadDriverPrivilege" privilege was NOT event present in the impersonation
  372. // access token of the server. This is because, only the enabled privileges of the client are passed along to the server.
  373. // So, we now require that the client enable the "SeLoadDriverPrivilege" privilege in its access token before calling
  374. // this method. The following call to Check_Load_Unload_Driver_Privilege() checks if "SeLoadDriverPrivilege" privilege
  375. // is enabled in the impersonation access token. Although the PnP apis only require that this privilege be present,
  376. // we have decided to elevate the requirement to this privilege being present AND enabled. This is because, if the
  377. // privilege is NOT enabled, the operation to enable it may or may not succeed depending on the client's credentials.
  378. // --KarthicN, May 6, 2002.
  379. //
  380. if(!Check_Load_Unload_Driver_Privilege())
  381. {
  382. TRACE_CRIT("%!FUNC! Check_Load_Unload_Driver_Privilege() failed, Throwing WBEM_E_ACCESS_DENIED exception");
  383. throw _com_error( WBEM_E_ACCESS_DENIED );
  384. }
  385. DWORD dwReturnValue = pCluster->Commit(g_pWlbsControl);
  386. //get the output object instance
  387. GetMethodOutputInstance( MOF_CLUSTERSETTING::szName,
  388. a_strMethodName,
  389. &pOutputInstance);
  390. //set the return value
  391. vValue.vt = VT_I4;
  392. vValue.lVal = static_cast<long>(dwReturnValue);
  393. hRes = pOutputInstance->Put(_bstr_t(L"ReturnValue"), 0, &vValue, 0);
  394. if( FAILED( hRes ) ) {
  395. TRACE_CRIT("%!FUNC! IWbemClassObject::Put() returned error : 0x%x, Throwing com_error exception", hRes);
  396. throw _com_error( hRes );
  397. }
  398. if( pOutputInstance ) {
  399. hRes = m_pResponseHandler->Indicate(1, &pOutputInstance);
  400. if( FAILED( hRes ) ) {
  401. TRACE_CRIT("%!FUNC! IWbemObjectSink::Indicate() returned error : 0x%x, Throwing com_error exception", hRes);
  402. throw _com_error( hRes );
  403. }
  404. }
  405. } else if( _wcsicmp( a_strMethodName, MOF_CLUSTERSETTING::pMethods[MOF_CLUSTERSETTING::SETDEF] ) == 0 ) {
  406. pCluster->SetClusterDefaults();
  407. } else {
  408. TRACE_CRIT("%!FUNC! %ls method NOT implemented, Throwing WBEM_E_METHOD_NOT_IMPLEMENTED exception",a_strMethodName);
  409. throw _com_error( WBEM_E_METHOD_NOT_IMPLEMENTED );
  410. }
  411. //get the parameters
  412. //call the underlying API
  413. //set the function return parameter
  414. // CLD: Need to check return code for error
  415. if (S_OK != VariantClear( &vValue ))
  416. {
  417. TRACE_CRIT("%!FUNC! VariantClear() failed, Throwing WBEM_E_FAILED exception");
  418. throw _com_error( WBEM_E_FAILED );
  419. }
  420. if( pOutputInstance ) {
  421. pOutputInstance->Release();
  422. pOutputInstance = NULL;
  423. }
  424. m_pResponseHandler->SetStatus( 0, WBEM_S_NO_ERROR, NULL, NULL );
  425. hRes = WBEM_S_NO_ERROR;
  426. }
  427. catch(CErrorWlbsControl Err) {
  428. IWbemClassObject* pWbemExtStat = NULL;
  429. TRACE_CRIT("%!FUNC! Caught a Wlbs exception : 0x%x", Err.Error());
  430. CreateExtendedStatus( m_pNameSpace,
  431. &pWbemExtStat,
  432. Err.Error(),
  433. (PWCHAR)(Err.Description()) );
  434. m_pResponseHandler->SetStatus(0, WBEM_E_FAILED, NULL, pWbemExtStat);
  435. if( pWbemExtStat )
  436. pWbemExtStat->Release();
  437. // CLD: Need to check return code for error
  438. // No throw here since we are already throwing an exception.
  439. VariantClear( &vValue );
  440. if( pOutputInstance ) {
  441. pOutputInstance->Release();
  442. pOutputInstance = NULL;
  443. }
  444. //do not return WBEM_E_FAILED, this causes a race condition
  445. hRes = WBEM_S_NO_ERROR;
  446. }
  447. catch(_com_error HResErr ) {
  448. TRACE_CRIT("%!FUNC! Caught a com_error exception : 0x%x", HResErr.Error());
  449. m_pResponseHandler->SetStatus(0, HResErr.Error(), NULL, NULL);
  450. // CLD: Need to check return code for error
  451. // No throw here since we are already throwing an exception.
  452. VariantClear( &vValue );
  453. if( pOutputInstance ) {
  454. pOutputInstance->Release();
  455. }
  456. hRes = HResErr.Error();
  457. }
  458. catch ( ... ) {
  459. TRACE_CRIT("%!FUNC! Caught an exception");
  460. // CLD: Need to check return code for error
  461. // No throw here since we are already throwing an exception.
  462. VariantClear( &vValue );
  463. if( pOutputInstance ) {
  464. pOutputInstance->Release();
  465. }
  466. TRACE_CRIT("%!FUNC! Rethrowing exception");
  467. TRACE_CRIT("<-%!FUNC!");
  468. throw;
  469. }
  470. TRACE_CRIT("<-%!FUNC! return 0x%x", hRes);
  471. return hRes;
  472. }
  473. ////////////////////////////////////////////////////////////////////////////////
  474. //
  475. // CWLBS_ClusterSetting::FillWbemInstance
  476. //
  477. // Purpose: This function copies all of the data from a cluster configuration
  478. // structure to a WBEM instance.
  479. //
  480. ////////////////////////////////////////////////////////////////////////////////
  481. void CWLBS_ClusterSetting::FillWbemInstance( IWbemClassObject* a_pWbemInstance,
  482. CWlbsClusterWrapper* pCluster)
  483. {
  484. namespace CLUSTER = MOF_CLUSTERSETTING;
  485. TRACE_VERB("->%!FUNC!");
  486. ASSERT( a_pWbemInstance );
  487. ASSERT(pCluster );
  488. CClusterConfiguration ClusterConfig;
  489. pCluster->GetClusterConfig( ClusterConfig );
  490. wstring wstrHostName;
  491. ConstructHostName( wstrHostName, pCluster->GetClusterIpOrIndex(g_pWlbsControl),
  492. pCluster->GetHostID() );
  493. //NAME
  494. a_pWbemInstance->Put
  495. (
  496. _bstr_t( CLUSTER::pProperties[CLUSTER::NAME] ) ,
  497. 0 ,
  498. &_variant_t(wstrHostName.c_str()),
  499. NULL
  500. );
  501. //CLUSNAME
  502. a_pWbemInstance->Put
  503. (
  504. _bstr_t( CLUSTER::pProperties[CLUSTER::CLUSNAME] ),
  505. 0 ,
  506. &_variant_t(ClusterConfig.szClusterName.c_str()),
  507. NULL
  508. );
  509. //CLUSIPADDRESS
  510. a_pWbemInstance->Put
  511. (
  512. _bstr_t( CLUSTER::pProperties[CLUSTER::CLUSIPADDRESS] ),
  513. 0 ,
  514. &_variant_t(ClusterConfig.szClusterIPAddress.c_str()),
  515. NULL
  516. );
  517. //CLUSNETMASK
  518. a_pWbemInstance->Put
  519. (
  520. _bstr_t( CLUSTER::pProperties[CLUSTER::CLUSNETMASK] ),
  521. 0 ,
  522. &_variant_t(ClusterConfig.szClusterNetworkMask.c_str()),
  523. NULL
  524. );
  525. //CLUSMAC
  526. a_pWbemInstance->Put
  527. (
  528. _bstr_t( CLUSTER::pProperties[CLUSTER::CLUSMAC] ),
  529. 0 ,
  530. &_variant_t(ClusterConfig.szClusterMACAddress.c_str()),
  531. NULL
  532. );
  533. //MULTIENABLE
  534. a_pWbemInstance->Put
  535. (
  536. _bstr_t( CLUSTER::pProperties[CLUSTER::MULTIENABLE] ),
  537. 0 ,
  538. &_variant_t(ClusterConfig.bMulticastSupportEnable),
  539. NULL
  540. );
  541. //REMCNTEN
  542. a_pWbemInstance->Put
  543. (
  544. _bstr_t( CLUSTER::pProperties[CLUSTER::REMCNTEN] ),
  545. 0 ,
  546. &_variant_t(ClusterConfig.bRemoteControlEnabled),
  547. NULL
  548. );
  549. //IGMPSUPPORT
  550. a_pWbemInstance->Put
  551. (
  552. _bstr_t( CLUSTER::pProperties[CLUSTER::IGMPSUPPORT] ),
  553. 0 ,
  554. &_variant_t(ClusterConfig.bIgmpSupport),
  555. NULL
  556. );
  557. //CLUSTERIPTOMULTICASTIP
  558. a_pWbemInstance->Put
  559. (
  560. _bstr_t( CLUSTER::pProperties[CLUSTER::CLUSTERIPTOMULTICASTIP] ),
  561. 0 ,
  562. &_variant_t(ClusterConfig.bClusterIPToMulticastIP),
  563. NULL
  564. );
  565. //MULTICASTIPADDRESS
  566. a_pWbemInstance->Put
  567. (
  568. _bstr_t( CLUSTER::pProperties[CLUSTER::MULTICASTIPADDRESS] ),
  569. 0 ,
  570. &_variant_t(ClusterConfig.szMulticastIPAddress.c_str()),
  571. NULL
  572. );
  573. //ADAPTERGUID
  574. GUID AdapterGuid = pCluster->GetAdapterGuid();
  575. WCHAR szAdapterGuid[128];
  576. StringFromGUID2(AdapterGuid, szAdapterGuid,
  577. sizeof(szAdapterGuid)/sizeof(szAdapterGuid[0]) );
  578. a_pWbemInstance->Put
  579. (
  580. _bstr_t( CLUSTER::pProperties[CLUSTER::ADAPTERGUID] ),
  581. 0 ,
  582. &_variant_t(szAdapterGuid),
  583. NULL
  584. );
  585. //BDA Team Active
  586. a_pWbemInstance->Put
  587. (
  588. _bstr_t( CLUSTER::pProperties[CLUSTER::BDATEAMACTIVE] ),
  589. 0 ,
  590. &_variant_t(ClusterConfig.bBDATeamActive),
  591. NULL
  592. );
  593. if (ClusterConfig.bBDATeamActive)
  594. {
  595. //BDA Team Id
  596. a_pWbemInstance->Put
  597. (
  598. _bstr_t( CLUSTER::pProperties[CLUSTER::BDATEAMID] ),
  599. 0 ,
  600. &_variant_t(ClusterConfig.szBDATeamId.c_str()),
  601. NULL
  602. );
  603. //BDA Team Master
  604. a_pWbemInstance->Put
  605. (
  606. _bstr_t( CLUSTER::pProperties[CLUSTER::BDATEAMMASTER] ),
  607. 0 ,
  608. &_variant_t(ClusterConfig.bBDATeamMaster),
  609. NULL
  610. );
  611. //BDA Reverse Hash
  612. a_pWbemInstance->Put
  613. (
  614. _bstr_t( CLUSTER::pProperties[CLUSTER::BDAREVERSEHASH] ),
  615. 0 ,
  616. &_variant_t(ClusterConfig.bBDAReverseHash),
  617. NULL
  618. );
  619. }
  620. //IDHBENAB
  621. a_pWbemInstance->Put
  622. (
  623. _bstr_t( CLUSTER::pProperties[CLUSTER::IDHBENAB] ),
  624. 0 ,
  625. &_variant_t(ClusterConfig.bIdentityHeartbeatEnabled),
  626. NULL
  627. );
  628. TRACE_VERB("<-%!FUNC!");
  629. }
  630. ////////////////////////////////////////////////////////////////////////////////
  631. //
  632. // CWLBS_ClusterSetting::UpdateConfiguration
  633. //
  634. // Purpose: This function updates the configuration data for a member node or a
  635. // potential WLBS cluster node.
  636. //
  637. ////////////////////////////////////////////////////////////////////////////////
  638. void CWLBS_ClusterSetting::UpdateConfiguration
  639. (
  640. IWbemClassObject* a_pInstance,
  641. CWlbsClusterWrapper* pCluster
  642. )
  643. {
  644. namespace CLUSTER = MOF_CLUSTERSETTING;
  645. CClusterConfiguration NewConfiguration;
  646. CClusterConfiguration OldConfiguration;
  647. TRACE_VERB("->%!FUNC!");
  648. pCluster->GetClusterConfig( OldConfiguration );
  649. //Cluster Name
  650. UpdateConfigProp
  651. (
  652. NewConfiguration.szClusterName,
  653. OldConfiguration.szClusterName,
  654. CLUSTER::pProperties[CLUSTER::CLUSNAME],
  655. a_pInstance
  656. );
  657. //Cluster IP
  658. UpdateConfigProp
  659. (
  660. NewConfiguration.szClusterIPAddress,
  661. OldConfiguration.szClusterIPAddress,
  662. CLUSTER::pProperties[CLUSTER::CLUSIPADDRESS],
  663. a_pInstance
  664. );
  665. //Cluster Network Mask
  666. UpdateConfigProp
  667. (
  668. NewConfiguration.szClusterNetworkMask,
  669. OldConfiguration.szClusterNetworkMask,
  670. CLUSTER::pProperties[CLUSTER::CLUSNETMASK],
  671. a_pInstance
  672. );
  673. //Cluster enable remote control
  674. UpdateConfigProp
  675. (
  676. NewConfiguration.bRemoteControlEnabled,
  677. OldConfiguration.bRemoteControlEnabled,
  678. CLUSTER::pProperties[CLUSTER::REMCNTEN],
  679. a_pInstance
  680. );
  681. //Cluster enable multicast support
  682. UpdateConfigProp
  683. (
  684. NewConfiguration.bMulticastSupportEnable,
  685. OldConfiguration.bMulticastSupportEnable,
  686. CLUSTER::pProperties[CLUSTER::MULTIENABLE],
  687. a_pInstance
  688. );
  689. //IGMPSUPPORT
  690. UpdateConfigProp
  691. (
  692. NewConfiguration.bIgmpSupport,
  693. OldConfiguration.bIgmpSupport,
  694. CLUSTER::pProperties[CLUSTER::IGMPSUPPORT],
  695. a_pInstance
  696. );
  697. //CLUSTERIPTOMULTICASTIP
  698. UpdateConfigProp
  699. (
  700. NewConfiguration.bClusterIPToMulticastIP,
  701. OldConfiguration.bClusterIPToMulticastIP,
  702. CLUSTER::pProperties[CLUSTER::CLUSTERIPTOMULTICASTIP],
  703. a_pInstance
  704. );
  705. //MULTICASTIPADDRESS
  706. UpdateConfigProp
  707. (
  708. NewConfiguration.szMulticastIPAddress,
  709. OldConfiguration.szMulticastIPAddress,
  710. CLUSTER::pProperties[CLUSTER::MULTICASTIPADDRESS],
  711. a_pInstance
  712. );
  713. //BDA Teaming Active ?
  714. UpdateConfigProp
  715. (
  716. NewConfiguration.bBDATeamActive,
  717. OldConfiguration.bBDATeamActive,
  718. CLUSTER::pProperties[CLUSTER::BDATEAMACTIVE],
  719. a_pInstance
  720. );
  721. // Set the other BDA properties only if the "Active" property is set
  722. if (NewConfiguration.bBDATeamActive)
  723. {
  724. //BDA Team ID
  725. UpdateConfigProp
  726. (
  727. NewConfiguration.szBDATeamId,
  728. OldConfiguration.szBDATeamId,
  729. CLUSTER::pProperties[CLUSTER::BDATEAMID],
  730. a_pInstance
  731. );
  732. //BDA Team Master
  733. UpdateConfigProp
  734. (
  735. NewConfiguration.bBDATeamMaster,
  736. OldConfiguration.bBDATeamMaster,
  737. CLUSTER::pProperties[CLUSTER::BDATEAMMASTER],
  738. a_pInstance
  739. );
  740. //BDA Team Reverse Hash
  741. UpdateConfigProp
  742. (
  743. NewConfiguration.bBDAReverseHash,
  744. OldConfiguration.bBDAReverseHash,
  745. CLUSTER::pProperties[CLUSTER::BDAREVERSEHASH],
  746. a_pInstance
  747. );
  748. }
  749. //Cluster enable identity heartbeats
  750. UpdateConfigProp
  751. (
  752. NewConfiguration.bIdentityHeartbeatEnabled,
  753. OldConfiguration.bIdentityHeartbeatEnabled,
  754. CLUSTER::pProperties[CLUSTER::IDHBENAB],
  755. a_pInstance
  756. );
  757. pCluster->PutClusterConfig( NewConfiguration );
  758. TRACE_VERB("<-%!FUNC!");
  759. }