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.

1023 lines
27 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(MOF_CLASSES::g_szMOFClassList[MOF_CLASSES::PRFAIL], pCluster, pWbemPortRule, &PortRule );
  319. break;
  320. case WLBS_MULTI:
  321. SpawnInstance( MOF_CLASSES::g_szMOFClassList[MOF_CLASSES::PRLOADB], &pWbemPortRule );
  322. CWLBS_PortRule::FillWbemInstance(MOF_CLASSES::g_szMOFClassList[MOF_CLASSES::PRLOADB], pCluster, pWbemPortRule, &PortRule );
  323. break;
  324. case WLBS_NEVER:
  325. SpawnInstance( MOF_CLASSES::g_szMOFClassList[MOF_CLASSES::PRDIS], &pWbemPortRule );
  326. CWLBS_PortRule::FillWbemInstance(MOF_CLASSES::g_szMOFClassList[MOF_CLASSES::PRDIS], 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::GETPORT_EX] ) == 0 ) {
  347. WLBS_PORT_RULE PortRule;
  348. DWORD dwPort, dwVip;
  349. //get the output object instance
  350. GetMethodOutputInstance( MOF_NODESETTING::szName,
  351. a_strMethodName,
  352. &pOutputInstance);
  353. //get the vip
  354. hRes = a_pIInParams->Get
  355. (
  356. _bstr_t( MOF_PARAM::VIP ),
  357. 0,
  358. &vValue,
  359. NULL,
  360. NULL
  361. );
  362. if( vValue.vt != VT_BSTR )
  363. throw _com_error ( WBEM_E_INVALID_PARAMETER );
  364. dwVip = IpAddressFromAbcdWsz( vValue.bstrVal );
  365. //get the Port
  366. hRes = a_pIInParams->Get
  367. (
  368. _bstr_t( MOF_PARAM::PORT_NUMBER ),
  369. 0,
  370. &vValue,
  371. NULL,
  372. NULL
  373. );
  374. if( vValue.vt != VT_I4 )
  375. throw _com_error ( WBEM_E_INVALID_PARAMETER );
  376. dwPort = vValue.lVal;
  377. // Get the port rule for this vip & this port
  378. pCluster->GetPortRule(dwVip, dwPort, &PortRule );
  379. //create the vip port rule class
  380. SpawnInstance( MOF_CLASSES::g_szMOFClassList[MOF_CLASSES::PRVIP], &pWbemPortRule );
  381. CWLBS_PortRule::FillWbemInstance(MOF_CLASSES::g_szMOFClassList[MOF_CLASSES::PORTRULE_EX], pCluster, pWbemPortRule, &PortRule );
  382. vValue.vt = VT_UNKNOWN;
  383. vValue.punkVal = pWbemPortRule;
  384. pWbemPortRule->AddRef();
  385. hRes = pOutputInstance->Put( _bstr_t(MOF_PARAM::PORTRULE_EX),
  386. 0,
  387. &vValue,
  388. 0 );
  389. VariantClear( &vValue );
  390. if( FAILED( hRes ) )
  391. throw _com_error( hRes );
  392. if( pOutputInstance ) {
  393. hRes = m_pResponseHandler->Indicate(1, &pOutputInstance);
  394. if( FAILED( hRes ) )
  395. throw _com_error( hRes );
  396. }
  397. } else if( _wcsicmp( a_strMethodName, MOF_NODESETTING::pMethods[MOF_NODESETTING::LDSETT] ) == 0 ) {
  398. DWORD dwReturnValue = pCluster->Commit(g_pWlbsControl);
  399. vValue.vt = VT_I4;
  400. vValue.lVal = static_cast<long>(dwReturnValue);
  401. //get the output object instance
  402. GetMethodOutputInstance( MOF_NODESETTING::szName,
  403. a_strMethodName,
  404. &pOutputInstance);
  405. hRes = pOutputInstance->Put(_bstr_t(L"ReturnValue"), 0, &vValue, 0);
  406. // CLD: Need to check return code for error
  407. if (S_OK != VariantClear( &vValue ))
  408. throw _com_error( WBEM_E_FAILED );
  409. if( FAILED( hRes ) )
  410. throw _com_error( hRes );
  411. if( pOutputInstance ) {
  412. hRes = m_pResponseHandler->Indicate(1, &pOutputInstance);
  413. if( FAILED( hRes ) )
  414. throw _com_error( hRes );
  415. }
  416. } else if( _wcsicmp( a_strMethodName, MOF_NODESETTING::pMethods[MOF_NODESETTING::SETDEF] ) == 0 ) {
  417. pCluster->SetNodeDefaults();
  418. } else {
  419. throw _com_error( WBEM_E_METHOD_NOT_IMPLEMENTED );
  420. }
  421. //send the results back to WinMgMt
  422. //set the return value
  423. //release resources
  424. // CLD: Need to check return code for error
  425. if (S_OK != VariantClear( &vValue ))
  426. throw _com_error( WBEM_E_FAILED );
  427. if( pOutputInstance ) {
  428. pOutputInstance->Release();
  429. pOutputInstance = NULL;
  430. }
  431. m_pResponseHandler->SetStatus( 0, WBEM_S_NO_ERROR, NULL, NULL );
  432. hRes = WBEM_S_NO_ERROR;
  433. }
  434. catch(CErrorWlbsControl Err) {
  435. IWbemClassObject* pWbemExtStat = NULL;
  436. CreateExtendedStatus( m_pNameSpace,
  437. &pWbemExtStat,
  438. Err.Error(),
  439. (PWCHAR)(Err.Description()) );
  440. m_pResponseHandler->SetStatus(0, WBEM_E_FAILED, NULL, pWbemExtStat);
  441. if( pWbemExtStat )
  442. pWbemExtStat->Release();
  443. // CLD: Need to check return code for error
  444. // No throw here since we are already throwing an exception.
  445. VariantClear( &vValue );
  446. if( pOutputInstance )
  447. pOutputInstance->Release();
  448. //do not return WBEM_E_FAILED, this causes a race condition
  449. hRes = WBEM_S_NO_ERROR;
  450. }
  451. catch(_com_error HResErr ) {
  452. m_pResponseHandler->SetStatus(0, HResErr.Error(), NULL, NULL);
  453. // CLD: Need to check return code for error
  454. // No throw here since we are already throwing an exception.
  455. VariantClear( &vValue );
  456. if( pOutputInstance )
  457. pOutputInstance->Release();
  458. hRes = HResErr.Error();
  459. }
  460. catch ( ... ) {
  461. // CLD: Need to check return code for error
  462. // No throw here since we are already throwing an exception.
  463. VariantClear( &vValue );
  464. if( pOutputInstance )
  465. pOutputInstance->Release();
  466. throw;
  467. }
  468. return hRes;
  469. }
  470. ////////////////////////////////////////////////////////////////////////////////
  471. //
  472. // CWLBS_NodeSetting::FillWbemInstance
  473. //
  474. // Purpose: This function copies all of the data from a node configuration
  475. // structure to a WBEM instance.
  476. //
  477. ////////////////////////////////////////////////////////////////////////////////
  478. void CWLBS_NodeSetting::FillWbemInstance(CWlbsClusterWrapper* pCluster,
  479. IWbemClassObject* a_pWbemInstance )
  480. {
  481. namespace NODE = MOF_NODESETTING;
  482. ASSERT( a_pWbemInstance );
  483. CNodeConfiguration NodeConfig;
  484. pCluster->GetNodeConfig( NodeConfig );
  485. wstring wstrHostName;
  486. ConstructHostName( wstrHostName, pCluster->GetClusterIpOrIndex(g_pWlbsControl),
  487. pCluster->GetHostID() );
  488. //NAME
  489. HRESULT hRes = a_pWbemInstance->Put
  490. (
  491. _bstr_t( NODE::pProperties[NODE::NAME] ) ,
  492. 0 ,
  493. &_variant_t(wstrHostName.c_str()),
  494. NULL
  495. );
  496. if( FAILED( hRes ) )
  497. throw _com_error( hRes );
  498. //DEDIPADDRESS
  499. hRes = a_pWbemInstance->Put
  500. (
  501. _bstr_t( NODE::pProperties[NODE::DEDIPADDRESS] ),
  502. 0 ,
  503. &_variant_t(NodeConfig.szDedicatedIPAddress.c_str()),
  504. NULL
  505. );
  506. if( FAILED( hRes ) )
  507. throw _com_error( hRes );
  508. //DEDNETMASK
  509. hRes = a_pWbemInstance->Put
  510. (
  511. _bstr_t( NODE::pProperties[NODE::DEDNETMASK] ),
  512. 0 ,
  513. &_variant_t(NodeConfig.szDedicatedNetworkMask.c_str()),
  514. NULL
  515. );
  516. if( FAILED( hRes ) )
  517. throw _com_error( hRes );
  518. //NUMRULES
  519. hRes = a_pWbemInstance->Put
  520. (
  521. _bstr_t( NODE::pProperties[NODE::NUMRULES] ),
  522. 0 ,
  523. &_variant_t((long)NodeConfig.dwNumberOfRules),
  524. NULL
  525. );
  526. if( FAILED( hRes ) )
  527. throw _com_error( hRes );
  528. //HOSTPRI
  529. hRes = a_pWbemInstance->Put
  530. (
  531. _bstr_t( NODE::pProperties[NODE::HOSTPRI] ),
  532. 0 ,
  533. &_variant_t((long)NodeConfig.dwHostPriority),
  534. NULL
  535. );
  536. if( FAILED( hRes ) )
  537. throw _com_error( hRes );
  538. //MSGPERIOD
  539. hRes = a_pWbemInstance->Put
  540. (
  541. _bstr_t( NODE::pProperties[NODE::MSGPERIOD] ),
  542. 0 ,
  543. &_variant_t((long)NodeConfig.dwAliveMsgPeriod),
  544. NULL
  545. );
  546. if( FAILED( hRes ) )
  547. throw _com_error( hRes );
  548. //MSGTOLER
  549. hRes = a_pWbemInstance->Put
  550. (
  551. _bstr_t( NODE::pProperties[NODE::MSGTOLER] ),
  552. 0 ,
  553. &_variant_t((long)NodeConfig.dwAliveMsgTolerance),
  554. NULL
  555. );
  556. if( FAILED( hRes ) )
  557. throw _com_error( hRes );
  558. //CLUSMODEONSTART
  559. hRes = a_pWbemInstance->Put
  560. (
  561. _bstr_t( NODE::pProperties[NODE::CLUSMODEONSTART] ),
  562. 0 ,
  563. &_variant_t(NodeConfig.bClusterModeOnStart),
  564. NULL
  565. );
  566. if( FAILED( hRes ) )
  567. throw _com_error( hRes );
  568. //NBTENABLE
  569. // hRes = a_pWbemInstance->Put
  570. // (
  571. // _bstr_t( NODE::pProperties[NODE::NBTENABLE] ),
  572. // 0 ,
  573. // &( _variant_t( NodeConfig.bNBTSupportEnable ) ) ,
  574. // NULL
  575. // );
  576. if( FAILED( hRes ) )
  577. throw _com_error( hRes );
  578. //REMOTEUDPPORT
  579. hRes = a_pWbemInstance->Put
  580. (
  581. _bstr_t( NODE::pProperties[NODE::REMOTEUDPPORT] ),
  582. 0 ,
  583. &_variant_t((long)NodeConfig.dwRemoteControlUDPPort),
  584. NULL
  585. );
  586. if( FAILED( hRes ) )
  587. throw _com_error( hRes );
  588. //MASKSRCMAC
  589. hRes = a_pWbemInstance->Put
  590. (
  591. _bstr_t( NODE::pProperties[NODE::MASKSRCMAC] ),
  592. 0 ,
  593. &_variant_t(NodeConfig.bMaskSourceMAC),
  594. NULL
  595. );
  596. if( FAILED( hRes ) )
  597. throw _com_error( hRes );
  598. //DESCPERALLOC
  599. hRes = a_pWbemInstance->Put
  600. (
  601. _bstr_t( NODE::pProperties[NODE::DESCPERALLOC] ),
  602. 0 ,
  603. &_variant_t((long)NodeConfig.dwDescriptorsPerAlloc),
  604. NULL
  605. );
  606. if( FAILED( hRes ) )
  607. throw _com_error( hRes );
  608. //MAXDESCALLOCS
  609. hRes = a_pWbemInstance->Put
  610. (
  611. _bstr_t( NODE::pProperties[NODE::MAXDESCALLOCS] ),
  612. 0 ,
  613. &_variant_t((long)NodeConfig.dwMaxDescriptorAllocs),
  614. NULL
  615. );
  616. if( FAILED( hRes ) )
  617. throw _com_error( hRes );
  618. //NUMACTIONS
  619. hRes = a_pWbemInstance->Put
  620. (
  621. _bstr_t( NODE::pProperties[NODE::NUMACTIONS] ),
  622. 0 ,
  623. &_variant_t((long)NodeConfig.dwNumActions),
  624. NULL
  625. );
  626. if( FAILED( hRes ) )
  627. throw _com_error( hRes );
  628. //NUMPACKETS
  629. hRes = a_pWbemInstance->Put
  630. (
  631. _bstr_t( NODE::pProperties[NODE::NUMPACKETS] ),
  632. 0 ,
  633. &_variant_t((long)NodeConfig.dwNumPackets),
  634. NULL
  635. );
  636. if( FAILED( hRes ) )
  637. throw _com_error( hRes );
  638. //NUMALIVEMSGS
  639. hRes = a_pWbemInstance->Put
  640. (
  641. _bstr_t( NODE::pProperties[NODE::NUMALIVEMSGS] ),
  642. 0 ,
  643. &_variant_t((long)NodeConfig.dwNumAliveMsgs),
  644. NULL
  645. );
  646. if( FAILED( hRes ) )
  647. throw _com_error( hRes );
  648. //ADAPTERGUID
  649. GUID AdapterGuid = pCluster->GetAdapterGuid();
  650. WCHAR szAdapterGuid[128];
  651. StringFromGUID2(AdapterGuid, szAdapterGuid,
  652. sizeof(szAdapterGuid)/sizeof(szAdapterGuid[0]) );
  653. hRes = a_pWbemInstance->Put
  654. (
  655. _bstr_t( NODE::pProperties[NODE::ADAPTERGUID] ),
  656. 0 ,
  657. &_variant_t(szAdapterGuid),
  658. NULL
  659. );
  660. if( FAILED( hRes ) )
  661. throw _com_error( hRes );
  662. }
  663. ////////////////////////////////////////////////////////////////////////////////
  664. //
  665. // CWLBS_NodeSetting::UpdateConfiguration
  666. //
  667. // Purpose: This function updates the configuration data for a member node or a
  668. // potential WLBS cluster node.
  669. //
  670. ////////////////////////////////////////////////////////////////////////////////
  671. void CWLBS_NodeSetting::UpdateConfiguration
  672. (
  673. CWlbsClusterWrapper* pCluster,
  674. IWbemClassObject* a_pInstance
  675. )
  676. {
  677. namespace NODE = MOF_NODESETTING;
  678. CNodeConfiguration NewConfiguration;
  679. CNodeConfiguration OldConfiguration;
  680. pCluster->GetNodeConfig( OldConfiguration );
  681. //Dedicated IP
  682. UpdateConfigProp
  683. (
  684. NewConfiguration.szDedicatedIPAddress,
  685. OldConfiguration.szDedicatedIPAddress,
  686. NODE::pProperties[NODE::DEDIPADDRESS],
  687. a_pInstance
  688. );
  689. //Dedicate Network Mask
  690. UpdateConfigProp
  691. (
  692. NewConfiguration.szDedicatedNetworkMask,
  693. OldConfiguration.szDedicatedNetworkMask,
  694. NODE::pProperties[NODE::DEDNETMASK],
  695. a_pInstance
  696. );
  697. //HostPriority
  698. UpdateConfigProp
  699. (
  700. NewConfiguration.dwHostPriority,
  701. OldConfiguration.dwHostPriority,
  702. NODE::pProperties[NODE::HOSTPRI],
  703. a_pInstance
  704. );
  705. //AliveMsgPeriod
  706. UpdateConfigProp
  707. (
  708. NewConfiguration.dwAliveMsgPeriod,
  709. OldConfiguration.dwAliveMsgPeriod,
  710. NODE::pProperties[NODE::MSGPERIOD],
  711. a_pInstance
  712. );
  713. //AliveMsgTolerance
  714. UpdateConfigProp
  715. (
  716. NewConfiguration.dwAliveMsgTolerance,
  717. OldConfiguration.dwAliveMsgTolerance,
  718. NODE::pProperties[NODE::MSGTOLER],
  719. a_pInstance
  720. );
  721. //ClusterModeOnStart
  722. UpdateConfigProp
  723. (
  724. NewConfiguration.bClusterModeOnStart,
  725. OldConfiguration.bClusterModeOnStart,
  726. NODE::pProperties[NODE::CLUSMODEONSTART],
  727. a_pInstance
  728. );
  729. //NBTSupportEnable
  730. // UpdateConfigProp
  731. // (
  732. // NewConfiguration.bNBTSupportEnable,
  733. // OldConfiguration.bNBTSupportEnable,
  734. // NODE::pProperties[NODE::NBTENABLE],
  735. // a_pInstance
  736. // );
  737. //RemoteControlUDPPort
  738. UpdateConfigProp
  739. (
  740. NewConfiguration.dwRemoteControlUDPPort,
  741. OldConfiguration.dwRemoteControlUDPPort,
  742. NODE::pProperties[NODE::REMOTEUDPPORT],
  743. a_pInstance
  744. );
  745. //MaskSourceMAC
  746. UpdateConfigProp
  747. (
  748. NewConfiguration.bMaskSourceMAC,
  749. OldConfiguration.bMaskSourceMAC,
  750. NODE::pProperties[NODE::MASKSRCMAC],
  751. a_pInstance
  752. );
  753. //DescriptorsPerAlloc
  754. UpdateConfigProp
  755. (
  756. NewConfiguration.dwDescriptorsPerAlloc,
  757. OldConfiguration.dwDescriptorsPerAlloc,
  758. NODE::pProperties[NODE::DESCPERALLOC],
  759. a_pInstance
  760. );
  761. //MaxDescriptorAllocs
  762. UpdateConfigProp
  763. (
  764. NewConfiguration.dwMaxDescriptorAllocs,
  765. OldConfiguration.dwMaxDescriptorAllocs,
  766. NODE::pProperties[NODE::MAXDESCALLOCS],
  767. a_pInstance
  768. );
  769. //NumActions
  770. UpdateConfigProp
  771. (
  772. NewConfiguration.dwNumActions,
  773. OldConfiguration.dwNumActions,
  774. NODE::pProperties[NODE::NUMACTIONS],
  775. a_pInstance
  776. );
  777. //NumPackets
  778. UpdateConfigProp
  779. (
  780. NewConfiguration.dwNumPackets,
  781. OldConfiguration.dwNumPackets,
  782. NODE::pProperties[NODE::NUMPACKETS],
  783. a_pInstance
  784. );
  785. //NumAliveMsgs
  786. UpdateConfigProp
  787. (
  788. NewConfiguration.dwNumAliveMsgs,
  789. OldConfiguration.dwNumAliveMsgs,
  790. NODE::pProperties[NODE::NUMALIVEMSGS],
  791. a_pInstance
  792. );
  793. pCluster->PutNodeConfig( NewConfiguration );
  794. }