Source code of Windows XP (NT5)
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.

955 lines
24 KiB

  1. #include "WLBS_Provider.h"
  2. #include "WLBS_NodeSetting.h"
  3. #include "ClusterWrapper.h"
  4. #include "ControlWrapper.h"
  5. #include "utils.h"
  6. #include "wlbsutil.h"
  7. ////////////////////////////////////////////////////////////////////////////////
  8. //
  9. // CWLBS_NodeSetting::CWLBS_NodeSetting
  10. //
  11. // Purpose: Constructor
  12. //
  13. ////////////////////////////////////////////////////////////////////////////////
  14. CWLBS_NodeSetting::CWLBS_NodeSetting
  15. (
  16. CWbemServices* a_pNameSpace,
  17. IWbemObjectSink* a_pResponseHandler
  18. )
  19. : CWlbs_Root( a_pNameSpace, a_pResponseHandler )
  20. {
  21. }
  22. ////////////////////////////////////////////////////////////////////////////////
  23. //
  24. // CWLBS_NodeSetting::Create
  25. //
  26. // Purpose: This instantiates this class and is invoked from an array of
  27. // function pointers.
  28. //
  29. ////////////////////////////////////////////////////////////////////////////////
  30. CWlbs_Root* CWLBS_NodeSetting::Create
  31. (
  32. CWbemServices* a_pNameSpace,
  33. IWbemObjectSink* a_pResponseHandler
  34. )
  35. {
  36. CWlbs_Root* pRoot = new CWLBS_NodeSetting( a_pNameSpace, a_pResponseHandler );
  37. if( !pRoot )
  38. throw _com_error( WBEM_E_OUT_OF_MEMORY );
  39. return pRoot;
  40. }
  41. ////////////////////////////////////////////////////////////////////////////////
  42. //
  43. // CWLBS_NodeSetting::GetInstance
  44. //
  45. // Purpose: This function retrieves an instance of a MOF NodeSetting
  46. // class. The node does not have to be a member of a cluster. However,
  47. // WLBS must be installed for this function to succeed.
  48. //
  49. ////////////////////////////////////////////////////////////////////////////////
  50. HRESULT CWLBS_NodeSetting::GetInstance
  51. (
  52. const ParsedObjectPath* a_pParsedPath,
  53. long /* a_lFlags */,
  54. IWbemContext* /* a_pIContex */
  55. )
  56. {
  57. IWbemClassObject* pWlbsInstance = NULL;
  58. HRESULT hRes = 0;
  59. try {
  60. //get the name key property and convert to wstring
  61. const wchar_t* wstrHostName = (*a_pParsedPath->m_paKeys)->m_vValue.bstrVal;
  62. CWlbsClusterWrapper* pCluster = GetClusterFromHostName(g_pWlbsControl, wstrHostName);
  63. DWORD dwHostID = ExtractHostID( wstrHostName );
  64. if (pCluster == NULL || (DWORD)-1 == dwHostID || pCluster->GetHostID() != dwHostID)
  65. throw _com_error( WBEM_E_NOT_FOUND );
  66. //get the Wbem class instance
  67. SpawnInstance( MOF_NODESETTING::szName, &pWlbsInstance );
  68. //Convert status to string description
  69. FillWbemInstance(pCluster, pWlbsInstance );
  70. //send the results back to WinMgMt
  71. m_pResponseHandler->Indicate( 1, &pWlbsInstance );
  72. if( pWlbsInstance ) {
  73. pWlbsInstance->Release();
  74. pWlbsInstance = NULL;
  75. }
  76. m_pResponseHandler->SetStatus( 0, WBEM_S_NO_ERROR, NULL, NULL );
  77. hRes = WBEM_S_NO_ERROR;
  78. }
  79. catch(CErrorWlbsControl Err) {
  80. IWbemClassObject* pWbemExtStat = NULL;
  81. CreateExtendedStatus( m_pNameSpace,
  82. &pWbemExtStat,
  83. Err.Error(),
  84. (PWCHAR)(Err.Description()) );
  85. m_pResponseHandler->SetStatus(0, WBEM_E_FAILED, NULL, pWbemExtStat);
  86. //if( pWbemExtStat )
  87. //pWbemExtStat->Release();
  88. if( pWlbsInstance )
  89. pWlbsInstance->Release();
  90. //do not return WBEM_E_FAILED, this causes a race condition
  91. hRes = WBEM_S_NO_ERROR;
  92. }
  93. catch(_com_error HResErr ) {
  94. m_pResponseHandler->SetStatus(0, HResErr.Error(), NULL, NULL);
  95. if( pWlbsInstance )
  96. pWlbsInstance->Release();
  97. hRes = HResErr.Error();
  98. if( hRes == ERROR_FILE_NOT_FOUND )
  99. hRes = WBEM_E_NOT_FOUND;
  100. }
  101. catch(...) {
  102. if( pWlbsInstance )
  103. pWlbsInstance->Release();
  104. throw;
  105. }
  106. return hRes;
  107. }
  108. ////////////////////////////////////////////////////////////////////////////////
  109. //
  110. // CWLBS_NodeSetting::EnumInstances
  111. //
  112. // Purpose: This function obtains the NodeSetting data for the current host.
  113. // The node does not have to be a member of a cluster for this
  114. // to succeed.
  115. //
  116. ////////////////////////////////////////////////////////////////////////////////
  117. HRESULT CWLBS_NodeSetting::EnumInstances
  118. (
  119. BSTR /*a_bstrClass*/,
  120. long /* a_lFlags */,
  121. IWbemContext* /* a_pIContex */
  122. )
  123. {
  124. IWbemClassObject* pWlbsInstance = NULL;
  125. HRESULT hRes = 0;
  126. try {
  127. DWORD dwNumClusters = 0;
  128. CWlbsClusterWrapper** ppCluster = NULL;
  129. g_pWlbsControl->EnumClusters(ppCluster, &dwNumClusters);
  130. if (dwNumClusters == 0)
  131. {
  132. throw _com_error( WBEM_E_NOT_FOUND );
  133. }
  134. for (DWORD i=0; i<dwNumClusters; i++)
  135. {
  136. //get the Wbem class instance
  137. SpawnInstance( MOF_NODESETTING::szName, &pWlbsInstance );
  138. //Convert status to string description
  139. FillWbemInstance(ppCluster[i], pWlbsInstance );
  140. //send the results back to WinMgMt
  141. m_pResponseHandler->Indicate( 1, &pWlbsInstance );
  142. }
  143. if( pWlbsInstance ) {
  144. pWlbsInstance->Release();
  145. pWlbsInstance = NULL;
  146. }
  147. m_pResponseHandler->SetStatus( 0, WBEM_S_NO_ERROR, NULL, NULL );
  148. hRes = WBEM_S_NO_ERROR;
  149. }
  150. catch(CErrorWlbsControl Err) {
  151. IWbemClassObject* pWbemExtStat = NULL;
  152. CreateExtendedStatus( m_pNameSpace,
  153. &pWbemExtStat,
  154. Err.Error(),
  155. (PWCHAR)(Err.Description()) );
  156. m_pResponseHandler->SetStatus(0, WBEM_E_FAILED, NULL, pWbemExtStat);
  157. if( pWbemExtStat )
  158. pWbemExtStat->Release();
  159. if( pWlbsInstance )
  160. pWlbsInstance->Release();
  161. //do not return WBEM_E_FAILED, this causes a race condition
  162. hRes = WBEM_S_NO_ERROR;
  163. }
  164. catch(_com_error HResErr ) {
  165. m_pResponseHandler->SetStatus(0, HResErr.Error(), NULL, NULL);
  166. if( pWlbsInstance )
  167. pWlbsInstance->Release();
  168. hRes = HResErr.Error();
  169. if( hRes == ERROR_FILE_NOT_FOUND )
  170. hRes = WBEM_E_NOT_FOUND;
  171. }
  172. catch(...) {
  173. if( pWlbsInstance )
  174. pWlbsInstance->Release();
  175. throw;
  176. }
  177. return hRes;
  178. }
  179. ////////////////////////////////////////////////////////////////////////////////
  180. //
  181. // CWLBS_NodeSetting::PutInstance
  182. //
  183. // Purpose: This function updates an instance of a MOF NodeSetting
  184. // class. The node does not have to be a member of a cluster.
  185. //
  186. ////////////////////////////////////////////////////////////////////////////////
  187. HRESULT CWLBS_NodeSetting::PutInstance
  188. (
  189. IWbemClassObject* a_pInstance,
  190. long /* a_lFlags */,
  191. IWbemContext* /* a_pIContex */
  192. )
  193. {
  194. VARIANT vHostName;
  195. HRESULT hRes = 0;
  196. try {
  197. VariantInit( &vHostName );
  198. //get the host name value
  199. hRes = a_pInstance->Get( _bstr_t( MOF_NODESETTING::pProperties[MOF_NODESETTING::NAME] ),
  200. 0,
  201. &vHostName,
  202. NULL,
  203. NULL );
  204. if( FAILED( hRes ) )
  205. throw _com_error( hRes );
  206. wstring wstrHostName( vHostName.bstrVal );
  207. DWORD dwClustIpOrIndex = ExtractClusterIP( wstrHostName );
  208. DWORD dwHostID = ExtractHostID( wstrHostName );
  209. CWlbsClusterWrapper* pCluster = g_pWlbsControl->GetClusterFromIpOrIndex(dwClustIpOrIndex);
  210. if( pCluster == NULL || (DWORD)-1 == dwHostID || pCluster->GetHostID() != dwHostID)
  211. throw _com_error( WBEM_E_NOT_FOUND );
  212. UpdateConfiguration(pCluster, a_pInstance );
  213. // CLD: Need to check return code for error
  214. if (S_OK != VariantClear( &vHostName ))
  215. throw _com_error( WBEM_E_FAILED );
  216. m_pResponseHandler->SetStatus( 0, WBEM_S_NO_ERROR, NULL, NULL );
  217. hRes = WBEM_S_NO_ERROR;
  218. }
  219. catch(CErrorWlbsControl Err) {
  220. IWbemClassObject* pWbemExtStat = NULL;
  221. CreateExtendedStatus( m_pNameSpace,
  222. &pWbemExtStat,
  223. Err.Error(),
  224. (PWCHAR)(Err.Description()) );
  225. m_pResponseHandler->SetStatus(0, WBEM_E_FAILED, NULL, pWbemExtStat);
  226. if( pWbemExtStat )
  227. pWbemExtStat->Release();
  228. // CLD: Need to check return code for error
  229. // No throw here since we are already throwing an exception.
  230. VariantClear( &vHostName );
  231. //do not return WBEM_E_FAILED, this causes a race condition
  232. hRes = WBEM_S_NO_ERROR;
  233. }
  234. catch(_com_error HResErr ) {
  235. m_pResponseHandler->SetStatus(0, HResErr.Error(), NULL, NULL);
  236. // CLD: Need to check return code for error
  237. // No throw here since we are already throwing an exception.
  238. VariantClear( &vHostName );
  239. hRes = HResErr.Error();
  240. }
  241. catch (...) {
  242. // CLD: Need to check return code for error
  243. // No throw here since we are already throwing an exception.
  244. VariantClear( &vHostName );
  245. throw;
  246. }
  247. return hRes;
  248. }
  249. ////////////////////////////////////////////////////////////////////////////////
  250. //
  251. // CWLBS_NodeSetting::ExecMethod
  252. //
  253. // Purpose:
  254. //
  255. ////////////////////////////////////////////////////////////////////////////////
  256. HRESULT CWLBS_NodeSetting::ExecMethod
  257. (
  258. const ParsedObjectPath* a_pParsedPath ,
  259. const BSTR& a_strMethodName,
  260. long /* a_lFlags */,
  261. IWbemContext* /* a_pIContex */,
  262. IWbemClassObject* a_pIInParams
  263. )
  264. {
  265. IWbemClassObject* pOutputInstance = NULL;
  266. IWbemClassObject* pWbemPortRule = NULL;
  267. HRESULT hRes = 0;
  268. CNodeConfiguration NodeConfig;
  269. VARIANT vValue ;
  270. try {
  271. VariantInit( &vValue );
  272. VARIANT vHostName ;
  273. VariantInit( &vHostName );
  274. if (a_pParsedPath->m_paKeys == NULL)
  275. {
  276. //
  277. // No name specified
  278. //
  279. throw _com_error( WBEM_E_INVALID_PARAMETER );
  280. }
  281. wstring wstrHostName = (*a_pParsedPath->m_paKeys)->m_vValue.bstrVal;
  282. DWORD dwClustIpOrIndex = ExtractClusterIP( wstrHostName );
  283. DWORD dwHostID = ExtractHostID( wstrHostName );
  284. CWlbsClusterWrapper* pCluster = g_pWlbsControl->GetClusterFromIpOrIndex(dwClustIpOrIndex);
  285. if( pCluster == NULL || (DWORD)-1 == dwHostID || pCluster->GetHostID() != dwHostID)
  286. throw _com_error( WBEM_E_NOT_FOUND );
  287. //determine the method being executed
  288. if( _wcsicmp( a_strMethodName, MOF_NODESETTING::pMethods[MOF_NODESETTING::GETPORT] ) == 0 ) {
  289. WLBS_PORT_RULE PortRule;
  290. // The GetPort method does NOT take vip as a parameter, so, if there is any port rule
  291. // that is specific to a vip (other than the "all vip"), we fail this method.
  292. // The "EffectiveVersion" registry value is checked for a value of CVY_VERSION_FULL to
  293. // see of there is any port rule that is specific to a vip
  294. pCluster->GetNodeConfig(NodeConfig);
  295. if(NodeConfig.dwEffectiveVersion == CVY_VERSION_FULL)
  296. throw _com_error( WBEM_E_INVALID_OPERATION );
  297. //get the output object instance
  298. GetMethodOutputInstance( MOF_NODESETTING::szName,
  299. a_strMethodName,
  300. &pOutputInstance);
  301. //get the Port
  302. hRes = a_pIInParams->Get
  303. (
  304. _bstr_t( MOF_PARAM::PORT_NUMBER ),
  305. 0,
  306. &vValue,
  307. NULL,
  308. NULL
  309. );
  310. if( vValue.vt != VT_I4 )
  311. throw _com_error ( WBEM_E_INVALID_PARAMETER );
  312. // Get the "All Vip" port rule for this vip
  313. pCluster->GetPortRule(IpAddressFromAbcdWsz(CVY_DEF_ALL_VIP), static_cast<DWORD>( vValue.lVal ), &PortRule );
  314. //create the appropriate port rule class
  315. switch( PortRule.mode ) {
  316. case WLBS_SINGLE:
  317. SpawnInstance( MOF_CLASSES::g_szMOFClassList[MOF_CLASSES::PRFAIL], &pWbemPortRule );
  318. CWLBS_PortRule::FillWbemInstance(pCluster, pWbemPortRule, &PortRule );
  319. break;
  320. case WLBS_MULTI:
  321. SpawnInstance( MOF_CLASSES::g_szMOFClassList[MOF_CLASSES::PRLOADB], &pWbemPortRule );
  322. CWLBS_PortRule::FillWbemInstance(pCluster, pWbemPortRule, &PortRule );
  323. break;
  324. case WLBS_NEVER:
  325. SpawnInstance( MOF_CLASSES::g_szMOFClassList[MOF_CLASSES::PRDIS], &pWbemPortRule );
  326. CWLBS_PortRule::FillWbemInstance(pCluster, pWbemPortRule, &PortRule );
  327. break;
  328. }
  329. vValue.vt = VT_UNKNOWN;
  330. vValue.punkVal = pWbemPortRule;
  331. pWbemPortRule->AddRef();
  332. hRes = pOutputInstance->Put( _bstr_t(MOF_PARAM::PORTRULE),
  333. 0,
  334. &vValue,
  335. 0 );
  336. // CLD: Need to check return code for error
  337. if (S_OK != VariantClear( &vValue ))
  338. throw _com_error( WBEM_E_FAILED );
  339. if( FAILED( hRes ) )
  340. throw _com_error( hRes );
  341. if( pOutputInstance ) {
  342. hRes = m_pResponseHandler->Indicate(1, &pOutputInstance);
  343. if( FAILED( hRes ) )
  344. throw _com_error( hRes );
  345. }
  346. } else if( _wcsicmp( a_strMethodName, MOF_NODESETTING::pMethods[MOF_NODESETTING::LDSETT] ) == 0 ) {
  347. DWORD dwReturnValue = pCluster->Commit(g_pWlbsControl);
  348. vValue.vt = VT_I4;
  349. vValue.lVal = static_cast<long>(dwReturnValue);
  350. //get the output object instance
  351. GetMethodOutputInstance( MOF_NODESETTING::szName,
  352. a_strMethodName,
  353. &pOutputInstance);
  354. hRes = pOutputInstance->Put(_bstr_t(L"ReturnValue"), 0, &vValue, 0);
  355. // CLD: Need to check return code for error
  356. if (S_OK != VariantClear( &vValue ))
  357. throw _com_error( WBEM_E_FAILED );
  358. if( FAILED( hRes ) )
  359. throw _com_error( hRes );
  360. if( pOutputInstance ) {
  361. hRes = m_pResponseHandler->Indicate(1, &pOutputInstance);
  362. if( FAILED( hRes ) )
  363. throw _com_error( hRes );
  364. }
  365. } else if( _wcsicmp( a_strMethodName, MOF_NODESETTING::pMethods[MOF_NODESETTING::SETDEF] ) == 0 ) {
  366. pCluster->SetNodeDefaults();
  367. } else {
  368. throw _com_error( WBEM_E_METHOD_NOT_IMPLEMENTED );
  369. }
  370. //send the results back to WinMgMt
  371. //set the return value
  372. //release resources
  373. // CLD: Need to check return code for error
  374. if (S_OK != VariantClear( &vValue ))
  375. throw _com_error( WBEM_E_FAILED );
  376. if( pOutputInstance ) {
  377. pOutputInstance->Release();
  378. pOutputInstance = NULL;
  379. }
  380. m_pResponseHandler->SetStatus( 0, WBEM_S_NO_ERROR, NULL, NULL );
  381. hRes = WBEM_S_NO_ERROR;
  382. }
  383. catch(CErrorWlbsControl Err) {
  384. IWbemClassObject* pWbemExtStat = NULL;
  385. CreateExtendedStatus( m_pNameSpace,
  386. &pWbemExtStat,
  387. Err.Error(),
  388. (PWCHAR)(Err.Description()) );
  389. m_pResponseHandler->SetStatus(0, WBEM_E_FAILED, NULL, pWbemExtStat);
  390. if( pWbemExtStat )
  391. pWbemExtStat->Release();
  392. // CLD: Need to check return code for error
  393. // No throw here since we are already throwing an exception.
  394. VariantClear( &vValue );
  395. if( pOutputInstance )
  396. pOutputInstance->Release();
  397. //do not return WBEM_E_FAILED, this causes a race condition
  398. hRes = WBEM_S_NO_ERROR;
  399. }
  400. catch(_com_error HResErr ) {
  401. m_pResponseHandler->SetStatus(0, HResErr.Error(), NULL, NULL);
  402. // CLD: Need to check return code for error
  403. // No throw here since we are already throwing an exception.
  404. VariantClear( &vValue );
  405. if( pOutputInstance )
  406. pOutputInstance->Release();
  407. hRes = HResErr.Error();
  408. }
  409. catch ( ... ) {
  410. // CLD: Need to check return code for error
  411. // No throw here since we are already throwing an exception.
  412. VariantClear( &vValue );
  413. if( pOutputInstance )
  414. pOutputInstance->Release();
  415. throw;
  416. }
  417. return hRes;
  418. }
  419. ////////////////////////////////////////////////////////////////////////////////
  420. //
  421. // CWLBS_NodeSetting::FillWbemInstance
  422. //
  423. // Purpose: This function copies all of the data from a node configuration
  424. // structure to a WBEM instance.
  425. //
  426. ////////////////////////////////////////////////////////////////////////////////
  427. void CWLBS_NodeSetting::FillWbemInstance(CWlbsClusterWrapper* pCluster,
  428. IWbemClassObject* a_pWbemInstance )
  429. {
  430. namespace NODE = MOF_NODESETTING;
  431. ASSERT( a_pWbemInstance );
  432. CNodeConfiguration NodeConfig;
  433. pCluster->GetNodeConfig( NodeConfig );
  434. wstring wstrHostName;
  435. ConstructHostName( wstrHostName, pCluster->GetClusterIpOrIndex(g_pWlbsControl),
  436. pCluster->GetHostID() );
  437. //NAME
  438. HRESULT hRes = a_pWbemInstance->Put
  439. (
  440. _bstr_t( NODE::pProperties[NODE::NAME] ) ,
  441. 0 ,
  442. &_variant_t(wstrHostName.c_str()),
  443. NULL
  444. );
  445. if( FAILED( hRes ) )
  446. throw _com_error( hRes );
  447. //DEDIPADDRESS
  448. hRes = a_pWbemInstance->Put
  449. (
  450. _bstr_t( NODE::pProperties[NODE::DEDIPADDRESS] ),
  451. 0 ,
  452. &_variant_t(NodeConfig.szDedicatedIPAddress.c_str()),
  453. NULL
  454. );
  455. if( FAILED( hRes ) )
  456. throw _com_error( hRes );
  457. //DEDNETMASK
  458. hRes = a_pWbemInstance->Put
  459. (
  460. _bstr_t( NODE::pProperties[NODE::DEDNETMASK] ),
  461. 0 ,
  462. &_variant_t(NodeConfig.szDedicatedNetworkMask.c_str()),
  463. NULL
  464. );
  465. if( FAILED( hRes ) )
  466. throw _com_error( hRes );
  467. //NUMRULES
  468. hRes = a_pWbemInstance->Put
  469. (
  470. _bstr_t( NODE::pProperties[NODE::NUMRULES] ),
  471. 0 ,
  472. &_variant_t((long)NodeConfig.dwNumberOfRules),
  473. NULL
  474. );
  475. if( FAILED( hRes ) )
  476. throw _com_error( hRes );
  477. //HOSTPRI
  478. hRes = a_pWbemInstance->Put
  479. (
  480. _bstr_t( NODE::pProperties[NODE::HOSTPRI] ),
  481. 0 ,
  482. &_variant_t((long)NodeConfig.dwHostPriority),
  483. NULL
  484. );
  485. if( FAILED( hRes ) )
  486. throw _com_error( hRes );
  487. //MSGPERIOD
  488. hRes = a_pWbemInstance->Put
  489. (
  490. _bstr_t( NODE::pProperties[NODE::MSGPERIOD] ),
  491. 0 ,
  492. &_variant_t((long)NodeConfig.dwAliveMsgPeriod),
  493. NULL
  494. );
  495. if( FAILED( hRes ) )
  496. throw _com_error( hRes );
  497. //MSGTOLER
  498. hRes = a_pWbemInstance->Put
  499. (
  500. _bstr_t( NODE::pProperties[NODE::MSGTOLER] ),
  501. 0 ,
  502. &_variant_t((long)NodeConfig.dwAliveMsgTolerance),
  503. NULL
  504. );
  505. if( FAILED( hRes ) )
  506. throw _com_error( hRes );
  507. //CLUSMODEONSTART
  508. hRes = a_pWbemInstance->Put
  509. (
  510. _bstr_t( NODE::pProperties[NODE::CLUSMODEONSTART] ),
  511. 0 ,
  512. &_variant_t(NodeConfig.bClusterModeOnStart),
  513. NULL
  514. );
  515. if( FAILED( hRes ) )
  516. throw _com_error( hRes );
  517. //NBTENABLE
  518. // hRes = a_pWbemInstance->Put
  519. // (
  520. // _bstr_t( NODE::pProperties[NODE::NBTENABLE] ),
  521. // 0 ,
  522. // &( _variant_t( NodeConfig.bNBTSupportEnable ) ) ,
  523. // NULL
  524. // );
  525. if( FAILED( hRes ) )
  526. throw _com_error( hRes );
  527. //REMOTEUDPPORT
  528. hRes = a_pWbemInstance->Put
  529. (
  530. _bstr_t( NODE::pProperties[NODE::REMOTEUDPPORT] ),
  531. 0 ,
  532. &_variant_t((long)NodeConfig.dwRemoteControlUDPPort),
  533. NULL
  534. );
  535. if( FAILED( hRes ) )
  536. throw _com_error( hRes );
  537. //MASKSRCMAC
  538. hRes = a_pWbemInstance->Put
  539. (
  540. _bstr_t( NODE::pProperties[NODE::MASKSRCMAC] ),
  541. 0 ,
  542. &_variant_t(NodeConfig.bMaskSourceMAC),
  543. NULL
  544. );
  545. if( FAILED( hRes ) )
  546. throw _com_error( hRes );
  547. //DESCPERALLOC
  548. hRes = a_pWbemInstance->Put
  549. (
  550. _bstr_t( NODE::pProperties[NODE::DESCPERALLOC] ),
  551. 0 ,
  552. &_variant_t((long)NodeConfig.dwDescriptorsPerAlloc),
  553. NULL
  554. );
  555. if( FAILED( hRes ) )
  556. throw _com_error( hRes );
  557. //MAXDESCALLOCS
  558. hRes = a_pWbemInstance->Put
  559. (
  560. _bstr_t( NODE::pProperties[NODE::MAXDESCALLOCS] ),
  561. 0 ,
  562. &_variant_t((long)NodeConfig.dwMaxDescriptorAllocs),
  563. NULL
  564. );
  565. if( FAILED( hRes ) )
  566. throw _com_error( hRes );
  567. //NUMACTIONS
  568. hRes = a_pWbemInstance->Put
  569. (
  570. _bstr_t( NODE::pProperties[NODE::NUMACTIONS] ),
  571. 0 ,
  572. &_variant_t((long)NodeConfig.dwNumActions),
  573. NULL
  574. );
  575. if( FAILED( hRes ) )
  576. throw _com_error( hRes );
  577. //NUMPACKETS
  578. hRes = a_pWbemInstance->Put
  579. (
  580. _bstr_t( NODE::pProperties[NODE::NUMPACKETS] ),
  581. 0 ,
  582. &_variant_t((long)NodeConfig.dwNumPackets),
  583. NULL
  584. );
  585. if( FAILED( hRes ) )
  586. throw _com_error( hRes );
  587. //NUMALIVEMSGS
  588. hRes = a_pWbemInstance->Put
  589. (
  590. _bstr_t( NODE::pProperties[NODE::NUMALIVEMSGS] ),
  591. 0 ,
  592. &_variant_t((long)NodeConfig.dwNumAliveMsgs),
  593. NULL
  594. );
  595. if( FAILED( hRes ) )
  596. throw _com_error( hRes );
  597. //ADAPTERGUID
  598. GUID AdapterGuid = pCluster->GetAdapterGuid();
  599. WCHAR szAdapterGuid[128];
  600. StringFromGUID2(AdapterGuid, szAdapterGuid,
  601. sizeof(szAdapterGuid)/sizeof(szAdapterGuid[0]) );
  602. hRes = a_pWbemInstance->Put
  603. (
  604. _bstr_t( NODE::pProperties[NODE::ADAPTERGUID] ),
  605. 0 ,
  606. &_variant_t(szAdapterGuid),
  607. NULL
  608. );
  609. if( FAILED( hRes ) )
  610. throw _com_error( hRes );
  611. }
  612. ////////////////////////////////////////////////////////////////////////////////
  613. //
  614. // CWLBS_NodeSetting::UpdateConfiguration
  615. //
  616. // Purpose: This function updates the configuration data for a member node or a
  617. // potential WLBS cluster node.
  618. //
  619. ////////////////////////////////////////////////////////////////////////////////
  620. void CWLBS_NodeSetting::UpdateConfiguration
  621. (
  622. CWlbsClusterWrapper* pCluster,
  623. IWbemClassObject* a_pInstance
  624. )
  625. {
  626. namespace NODE = MOF_NODESETTING;
  627. CNodeConfiguration NewConfiguration;
  628. CNodeConfiguration OldConfiguration;
  629. pCluster->GetNodeConfig( OldConfiguration );
  630. //Dedicated IP
  631. UpdateConfigProp
  632. (
  633. NewConfiguration.szDedicatedIPAddress,
  634. OldConfiguration.szDedicatedIPAddress,
  635. NODE::pProperties[NODE::DEDIPADDRESS],
  636. a_pInstance
  637. );
  638. //Dedicate Network Mask
  639. UpdateConfigProp
  640. (
  641. NewConfiguration.szDedicatedNetworkMask,
  642. OldConfiguration.szDedicatedNetworkMask,
  643. NODE::pProperties[NODE::DEDNETMASK],
  644. a_pInstance
  645. );
  646. //HostPriority
  647. UpdateConfigProp
  648. (
  649. NewConfiguration.dwHostPriority,
  650. OldConfiguration.dwHostPriority,
  651. NODE::pProperties[NODE::HOSTPRI],
  652. a_pInstance
  653. );
  654. //AliveMsgPeriod
  655. UpdateConfigProp
  656. (
  657. NewConfiguration.dwAliveMsgPeriod,
  658. OldConfiguration.dwAliveMsgPeriod,
  659. NODE::pProperties[NODE::MSGPERIOD],
  660. a_pInstance
  661. );
  662. //AliveMsgTolerance
  663. UpdateConfigProp
  664. (
  665. NewConfiguration.dwAliveMsgTolerance,
  666. OldConfiguration.dwAliveMsgTolerance,
  667. NODE::pProperties[NODE::MSGTOLER],
  668. a_pInstance
  669. );
  670. //ClusterModeOnStart
  671. UpdateConfigProp
  672. (
  673. NewConfiguration.bClusterModeOnStart,
  674. OldConfiguration.bClusterModeOnStart,
  675. NODE::pProperties[NODE::CLUSMODEONSTART],
  676. a_pInstance
  677. );
  678. //NBTSupportEnable
  679. // UpdateConfigProp
  680. // (
  681. // NewConfiguration.bNBTSupportEnable,
  682. // OldConfiguration.bNBTSupportEnable,
  683. // NODE::pProperties[NODE::NBTENABLE],
  684. // a_pInstance
  685. // );
  686. //RemoteControlUDPPort
  687. UpdateConfigProp
  688. (
  689. NewConfiguration.dwRemoteControlUDPPort,
  690. OldConfiguration.dwRemoteControlUDPPort,
  691. NODE::pProperties[NODE::REMOTEUDPPORT],
  692. a_pInstance
  693. );
  694. //MaskSourceMAC
  695. UpdateConfigProp
  696. (
  697. NewConfiguration.bMaskSourceMAC,
  698. OldConfiguration.bMaskSourceMAC,
  699. NODE::pProperties[NODE::MASKSRCMAC],
  700. a_pInstance
  701. );
  702. //DescriptorsPerAlloc
  703. UpdateConfigProp
  704. (
  705. NewConfiguration.dwDescriptorsPerAlloc,
  706. OldConfiguration.dwDescriptorsPerAlloc,
  707. NODE::pProperties[NODE::DESCPERALLOC],
  708. a_pInstance
  709. );
  710. //MaxDescriptorAllocs
  711. UpdateConfigProp
  712. (
  713. NewConfiguration.dwMaxDescriptorAllocs,
  714. OldConfiguration.dwMaxDescriptorAllocs,
  715. NODE::pProperties[NODE::MAXDESCALLOCS],
  716. a_pInstance
  717. );
  718. //NumActions
  719. UpdateConfigProp
  720. (
  721. NewConfiguration.dwNumActions,
  722. OldConfiguration.dwNumActions,
  723. NODE::pProperties[NODE::NUMACTIONS],
  724. a_pInstance
  725. );
  726. //NumPackets
  727. UpdateConfigProp
  728. (
  729. NewConfiguration.dwNumPackets,
  730. OldConfiguration.dwNumPackets,
  731. NODE::pProperties[NODE::NUMPACKETS],
  732. a_pInstance
  733. );
  734. //NumAliveMsgs
  735. UpdateConfigProp
  736. (
  737. NewConfiguration.dwNumAliveMsgs,
  738. OldConfiguration.dwNumAliveMsgs,
  739. NODE::pProperties[NODE::NUMALIVEMSGS],
  740. a_pInstance
  741. );
  742. pCluster->PutNodeConfig( NewConfiguration );
  743. }