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.

782 lines
22 KiB

  1. #include <crtdbg.h>
  2. #include <comdef.h>
  3. #include <iostream>
  4. #include <memory>
  5. #include <string>
  6. #include <wbemprov.h>
  7. #include <genlex.h> //for wmi object path parser
  8. #include <objbase.h>
  9. #include <wlbsconfig.h>
  10. #include <ntrkcomm.h>
  11. using namespace std;
  12. #include "objpath.h"
  13. #include "debug.h"
  14. #include "controlwrapper.h"
  15. #include "clusterwrapper.h"
  16. #include "utils.h"
  17. #include "wlbsparm.h"
  18. #include "control.h"
  19. #include "controlwrapper.tmh"
  20. #define NLB_DEFAULT_TIMEOUT 10
  21. void CWlbsControlWrapper::Initialize()
  22. {
  23. TRACE_CRIT("->%!FUNC!");
  24. DWORD dwRet = m_WlbsControl.Initialize();
  25. if( dwRet != WLBS_PRESENT && dwRet != WLBS_LOCAL_ONLY)
  26. {
  27. TRACE_CRIT("%!FUNC! CWlbsControl::Initialize failed : 0x%x, Throwing Wlbs error exception", dwRet);
  28. TRACE_CRIT("<-%!FUNC!");
  29. throw CErrorWlbsControl( dwRet, CmdWlbsInit );
  30. }
  31. m_WlbsControl.WlbsTimeoutSet( WLBS_ALL_CLUSTERS, NLB_DEFAULT_TIMEOUT );
  32. CWlbsCluster** ppCluster;
  33. DWORD dwNumClusters = 0;
  34. //
  35. // Use the local password for local query
  36. //
  37. m_WlbsControl.EnumClusterObjects( ppCluster, &dwNumClusters);
  38. for (int i=0;i<dwNumClusters;i++)
  39. {
  40. m_WlbsControl.WlbsCodeSet( ppCluster[i]->GetClusterIp(),
  41. ppCluster[i]->GetPassword() );
  42. }
  43. TRACE_CRIT("<-%!FUNC!");
  44. }
  45. void CWlbsControlWrapper::ReInitialize()
  46. {
  47. TRACE_CRIT("->%!FUNC!");
  48. m_WlbsControl.ReInitialize();
  49. CWlbsCluster** ppCluster;
  50. DWORD dwNumClusters = 0;
  51. //
  52. // In case pasword is changed, use the local password for local query
  53. //
  54. m_WlbsControl.EnumClusterObjects( ppCluster, &dwNumClusters);
  55. for (int i=0;i<dwNumClusters;i++)
  56. {
  57. //
  58. // If the change is not commited, the driver will still has the old password
  59. //
  60. if (!ppCluster[i]->IsCommitPending())
  61. {
  62. m_WlbsControl.WlbsCodeSet( ppCluster[i]->GetClusterIp(),
  63. ppCluster[i]->GetPassword() );
  64. }
  65. }
  66. TRACE_CRIT("<-%!FUNC!");
  67. }
  68. void CWlbsControlWrapper::EnumClusters(CWlbsClusterWrapper** & ppCluster, DWORD* pdwNumClusters)
  69. {
  70. TRACE_VERB("->%!FUNC!");
  71. m_WlbsControl.EnumClusterObjects( (CWlbsCluster** &) ppCluster, pdwNumClusters);
  72. TRACE_VERB("<-%!FUNC!");
  73. }
  74. ////////////////////////////////////////////////////////////////////////////////
  75. //
  76. // CWlbsControlWrapper::Disable
  77. //
  78. // Purpose: Disable ALL traffic handling for the rule containing the
  79. // specified port on specified host or all cluster hosts. Only rules
  80. // that are set for multiple host filtering mode are affected.
  81. //
  82. //
  83. ////////////////////////////////////////////////////////////////////////////////
  84. DWORD CWlbsControlWrapper::Disable
  85. (
  86. DWORD a_dwCluster ,
  87. DWORD a_dwHost ,
  88. WLBS_RESPONSE* a_pResponse ,
  89. DWORD& a_dwNumHosts ,
  90. DWORD a_dwVip ,
  91. DWORD a_dwPort
  92. )
  93. {
  94. DWORD dwRet;
  95. BOOL bClusterWide = ( a_dwHost == WLBS_ALL_HOSTS );
  96. DWORD dwNumHosts = a_dwNumHosts;
  97. TRACE_VERB("->%!FUNC!");
  98. dwRet = m_WlbsControl.WlbsDisable( a_dwCluster ,
  99. a_dwHost ,
  100. a_pResponse ,
  101. &dwNumHosts ,
  102. a_dwVip ,
  103. a_dwPort
  104. );
  105. //check for Winsock errors
  106. if( dwRet > 10000 )
  107. {
  108. TRACE_CRIT("%!FUNC! CWlbsControl::WlbsDisable failed : 0x%x, Throwing Wlbs error exception", dwRet);
  109. TRACE_VERB("<-%!FUNC!");
  110. throw CErrorWlbsControl( dwRet, CmdWlbsQuery, bClusterWide );
  111. }
  112. //check the return value and throw if an error occurred
  113. switch( dwRet ) {
  114. case WLBS_INIT_ERROR:
  115. case WLBS_BAD_PASSW:
  116. case WLBS_TIMEOUT:
  117. case WLBS_LOCAL_ONLY:
  118. case WLBS_REMOTE_ONLY:
  119. case WLBS_IO_ERROR:
  120. TRACE_CRIT("%!FUNC! Throwing Wlbs error exception : 0x%x", dwRet);
  121. TRACE_VERB("<-%!FUNC!");
  122. throw CErrorWlbsControl( dwRet, CmdWlbsDisable, bClusterWide );
  123. break;
  124. }
  125. a_dwNumHosts = dwNumHosts;
  126. TRACE_VERB("<-%!FUNC! return = 0x%x", dwRet);
  127. return dwRet;
  128. }
  129. ////////////////////////////////////////////////////////////////////////////////
  130. //
  131. // CWlbsControlWrapper::Enable
  132. //
  133. // Purpose: Enable traffic handling for rule containing the
  134. // specified port on specified host or all cluster hosts. Only rules
  135. // that are set for multiple host filtering mode are affected.
  136. //
  137. //
  138. //
  139. ////////////////////////////////////////////////////////////////////////////////
  140. DWORD CWlbsControlWrapper::Enable
  141. (
  142. DWORD a_dwCluster ,
  143. DWORD a_dwHost ,
  144. WLBS_RESPONSE* a_pResponse ,
  145. DWORD& a_dwNumHosts ,
  146. DWORD a_dwVip ,
  147. DWORD a_dwPort
  148. )
  149. {
  150. DWORD dwRet;
  151. BOOL bClusterWide = ( a_dwHost == WLBS_ALL_HOSTS );
  152. DWORD dwNumHosts = a_dwNumHosts;
  153. TRACE_VERB("->%!FUNC!");
  154. dwRet = m_WlbsControl.WlbsEnable( a_dwCluster ,
  155. a_dwHost ,
  156. a_pResponse ,
  157. &dwNumHosts ,
  158. a_dwVip ,
  159. a_dwPort
  160. );
  161. //check for Winsock errors
  162. if( dwRet > 10000 )
  163. {
  164. TRACE_CRIT("%!FUNC! CWlbsControl::WlbsEnable failed : 0x%x, Throwing Wlbs error exception", dwRet);
  165. TRACE_VERB("<-%!FUNC!");
  166. throw CErrorWlbsControl( dwRet, CmdWlbsQuery, bClusterWide );
  167. }
  168. //check the return value and throw if an error occurred
  169. switch(dwRet) {
  170. case WLBS_INIT_ERROR:
  171. case WLBS_BAD_PASSW:
  172. case WLBS_TIMEOUT:
  173. case WLBS_LOCAL_ONLY:
  174. case WLBS_REMOTE_ONLY:
  175. case WLBS_IO_ERROR:
  176. TRACE_CRIT("%!FUNC! Throwing Wlbs error exception : 0x%x", dwRet);
  177. TRACE_VERB("<-%!FUNC!");
  178. throw CErrorWlbsControl( dwRet, CmdWlbsEnable, bClusterWide );
  179. break;
  180. }
  181. a_dwNumHosts = dwNumHosts;
  182. TRACE_VERB("<-%!FUNC! return = 0x%x", dwRet);
  183. return dwRet;
  184. }
  185. ////////////////////////////////////////////////////////////////////////////////
  186. //
  187. // CWlbsControlWrapper::Drain
  188. //
  189. // Purpose: Disable NEW traffic handling for rule containing the specified
  190. // port on specified host or all cluster hosts. Only rules that are
  191. // set for multiple host filtering mode are affected.
  192. //
  193. //
  194. ////////////////////////////////////////////////////////////////////////////////
  195. DWORD CWlbsControlWrapper::Drain
  196. (
  197. DWORD a_dwCluster ,
  198. DWORD a_dwHost ,
  199. WLBS_RESPONSE* a_pResponse ,
  200. DWORD& a_dwNumHosts ,
  201. DWORD a_dwVip ,
  202. DWORD a_dwPort
  203. )
  204. {
  205. DWORD dwRet;
  206. BOOL bClusterWide = ( a_dwHost == WLBS_ALL_HOSTS );
  207. DWORD dwNumHosts = a_dwNumHosts;
  208. TRACE_VERB("->%!FUNC!");
  209. dwRet = m_WlbsControl.WlbsDrain( a_dwCluster ,
  210. a_dwHost ,
  211. a_pResponse ,
  212. &dwNumHosts ,
  213. a_dwVip ,
  214. a_dwPort
  215. );
  216. //check for Winsock errors
  217. if( dwRet > 10000 )
  218. {
  219. TRACE_CRIT("%!FUNC! CWlbsControl::WlbsDrain failed : 0x%x, Throwing Wlbs error exception", dwRet);
  220. TRACE_VERB("<-%!FUNC!");
  221. throw CErrorWlbsControl( dwRet, CmdWlbsQuery, bClusterWide );
  222. }
  223. //check the return value and throw if an error occurred
  224. switch(dwRet) {
  225. case WLBS_INIT_ERROR:
  226. case WLBS_BAD_PASSW:
  227. case WLBS_TIMEOUT:
  228. case WLBS_LOCAL_ONLY:
  229. case WLBS_REMOTE_ONLY:
  230. case WLBS_IO_ERROR:
  231. TRACE_CRIT("%!FUNC! Throwing Wlbs error exception : 0x%x", dwRet);
  232. TRACE_VERB("<-%!FUNC!");
  233. throw CErrorWlbsControl( dwRet, CmdWlbsDrain, bClusterWide );
  234. break;
  235. }
  236. a_dwNumHosts = dwNumHosts;
  237. TRACE_VERB("<-%!FUNC! return = 0x%x", dwRet);
  238. return dwRet;
  239. }
  240. ////////////////////////////////////////////////////////////////////////////////
  241. //
  242. // CWlbsControlWrapper::DrainStop
  243. //
  244. // Purpose: Enter draining mode on specified host or all cluster hosts.
  245. // New connections will not be accepted. Cluster mode will be stopped
  246. // when all existing connections finish. While draining, host will
  247. // participate in convergence and remain part of the cluster.
  248. //
  249. //
  250. ////////////////////////////////////////////////////////////////////////////////
  251. DWORD CWlbsControlWrapper::DrainStop
  252. (
  253. DWORD a_dwCluster ,
  254. DWORD a_dwHost ,
  255. WLBS_RESPONSE* a_pResponse ,
  256. DWORD& a_dwNumHosts
  257. )
  258. {
  259. DWORD dwRet;
  260. BOOL bClusterWide = ( a_dwHost == WLBS_ALL_HOSTS );
  261. DWORD dwNumHosts = a_dwNumHosts;
  262. TRACE_VERB("->%!FUNC!");
  263. dwRet = m_WlbsControl.WlbsDrainStop( a_dwCluster ,
  264. a_dwHost ,
  265. a_pResponse ,
  266. &dwNumHosts
  267. );
  268. //check for Winsock errors
  269. if( dwRet > 10000 )
  270. {
  271. TRACE_CRIT("%!FUNC! CWlbsControl::WlbsDrainStop failed : 0x%x, Throwing Wlbs error exception", dwRet);
  272. TRACE_VERB("<-%!FUNC!");
  273. throw CErrorWlbsControl( dwRet, CmdWlbsQuery, bClusterWide );
  274. }
  275. //check the return value and throw if an error occurred
  276. switch(dwRet) {
  277. case WLBS_INIT_ERROR:
  278. case WLBS_BAD_PASSW:
  279. case WLBS_TIMEOUT:
  280. case WLBS_LOCAL_ONLY:
  281. case WLBS_REMOTE_ONLY:
  282. case WLBS_IO_ERROR:
  283. TRACE_CRIT("%!FUNC! Throwing Wlbs error exception : 0x%x", dwRet);
  284. TRACE_VERB("<-%!FUNC!");
  285. throw CErrorWlbsControl( dwRet, CmdWlbsDrainStop, bClusterWide );
  286. break;
  287. }
  288. a_dwNumHosts = dwNumHosts;
  289. TRACE_VERB("<-%!FUNC! return = 0x%x", dwRet);
  290. return dwRet;
  291. }
  292. ////////////////////////////////////////////////////////////////////////////////
  293. //
  294. // CWlbsControlWrapper::Resume
  295. //
  296. // Purpose: Resume cluster operation control on specified host or all
  297. // cluster hosts.
  298. //
  299. //
  300. ////////////////////////////////////////////////////////////////////////////////
  301. DWORD CWlbsControlWrapper::Resume
  302. (
  303. DWORD a_dwCluster ,
  304. DWORD a_dwHost ,
  305. WLBS_RESPONSE* a_pResponse ,
  306. DWORD& a_dwNumHosts
  307. )
  308. {
  309. DWORD dwRet;
  310. BOOL bClusterWide = ( a_dwHost == WLBS_ALL_HOSTS );
  311. DWORD dwNumHosts = a_dwNumHosts;
  312. TRACE_VERB("->%!FUNC!");
  313. dwRet = m_WlbsControl.WlbsResume(
  314. a_dwCluster ,
  315. a_dwHost ,
  316. a_pResponse ,
  317. &dwNumHosts
  318. );
  319. //check for Winsock errors
  320. if( dwRet > 10000 )
  321. {
  322. TRACE_CRIT("%!FUNC! CWlbsControl::WlbsResume failed : 0x%x, Throwing Wlbs error exception", dwRet);
  323. TRACE_VERB("<-%!FUNC!");
  324. throw CErrorWlbsControl( dwRet, CmdWlbsQuery, bClusterWide );
  325. }
  326. //check the return value and throw if an error occurred
  327. switch(dwRet) {
  328. case WLBS_INIT_ERROR:
  329. case WLBS_BAD_PASSW:
  330. case WLBS_TIMEOUT:
  331. case WLBS_LOCAL_ONLY:
  332. case WLBS_REMOTE_ONLY:
  333. case WLBS_IO_ERROR:
  334. TRACE_CRIT("%!FUNC! Throwing Wlbs error exception : 0x%x", dwRet);
  335. TRACE_VERB("<-%!FUNC!");
  336. throw CErrorWlbsControl( dwRet, CmdWlbsResume, bClusterWide );
  337. break;
  338. }
  339. a_dwNumHosts = dwNumHosts;
  340. TRACE_VERB("<-%!FUNC! return = 0x%x", dwRet);
  341. return dwRet;
  342. }
  343. ////////////////////////////////////////////////////////////////////////////////
  344. //
  345. // CWlbsControlWrapper::Start
  346. //
  347. // Purpose: Start cluster operations on specified host or all cluster hosts.
  348. //
  349. //
  350. ////////////////////////////////////////////////////////////////////////////////
  351. DWORD CWlbsControlWrapper::Start
  352. (
  353. DWORD a_dwCluster ,
  354. DWORD a_dwHost ,
  355. WLBS_RESPONSE* a_pResponse ,
  356. DWORD& a_dwNumHosts
  357. )
  358. {
  359. DWORD dwRet;
  360. BOOL bClusterWide = ( a_dwHost == WLBS_ALL_HOSTS );
  361. DWORD dwNumHosts = a_dwNumHosts;
  362. TRACE_VERB("->%!FUNC!");
  363. dwRet = m_WlbsControl.WlbsStart( a_dwCluster ,
  364. a_dwHost ,
  365. a_pResponse ,
  366. &dwNumHosts
  367. );
  368. //check for Winsock errors
  369. if( dwRet > 10000 )
  370. {
  371. TRACE_CRIT("%!FUNC! CWlbsControl::WlbsStart failed : 0x%x, Throwing Wlbs error exception", dwRet);
  372. TRACE_VERB("<-%!FUNC!");
  373. throw CErrorWlbsControl( dwRet, CmdWlbsQuery, bClusterWide );
  374. }
  375. //check the return value and throw if an error occurred
  376. switch(dwRet) {
  377. case WLBS_INIT_ERROR:
  378. case WLBS_BAD_PASSW:
  379. case WLBS_TIMEOUT:
  380. case WLBS_LOCAL_ONLY:
  381. case WLBS_REMOTE_ONLY:
  382. case WLBS_IO_ERROR:
  383. TRACE_CRIT("%!FUNC! Throwing Wlbs error exception : 0x%x", dwRet);
  384. TRACE_VERB("<-%!FUNC!");
  385. throw CErrorWlbsControl( dwRet, CmdWlbsStart, bClusterWide );
  386. break;
  387. }
  388. a_dwNumHosts = dwNumHosts;
  389. TRACE_VERB("<-%!FUNC! return = 0x%x", dwRet);
  390. return dwRet;
  391. }
  392. ////////////////////////////////////////////////////////////////////////////////
  393. //
  394. // CWlbsControlWrapper::Stop
  395. //
  396. // Purpose: Stop cluster operations on specified host or all cluster hosts.
  397. //
  398. //
  399. ////////////////////////////////////////////////////////////////////////////////
  400. DWORD CWlbsControlWrapper::Stop
  401. (
  402. DWORD a_dwCluster ,
  403. DWORD a_dwHost ,
  404. WLBS_RESPONSE* a_pResponse ,
  405. DWORD& a_dwNumHosts
  406. )
  407. {
  408. DWORD dwRet;
  409. BOOL bClusterWide = ( a_dwHost == WLBS_ALL_HOSTS );
  410. DWORD dwNumHosts = a_dwNumHosts;
  411. TRACE_VERB("->%!FUNC!");
  412. dwRet = m_WlbsControl.WlbsStop(
  413. a_dwCluster ,
  414. a_dwHost ,
  415. a_pResponse ,
  416. &dwNumHosts
  417. );
  418. //check for Winsock errors
  419. if( dwRet > 10000 )
  420. {
  421. TRACE_CRIT("%!FUNC! CWlbsControl::WlbsStop failed : 0x%x, Throwing Wlbs error exception", dwRet);
  422. TRACE_VERB("<-%!FUNC!");
  423. throw CErrorWlbsControl( dwRet, CmdWlbsQuery, bClusterWide );
  424. }
  425. //check the return value and throw if an error occurred
  426. switch(dwRet) {
  427. case WLBS_INIT_ERROR:
  428. case WLBS_BAD_PASSW:
  429. case WLBS_TIMEOUT:
  430. case WLBS_LOCAL_ONLY:
  431. case WLBS_REMOTE_ONLY:
  432. case WLBS_IO_ERROR:
  433. TRACE_CRIT("%!FUNC! Throwing Wlbs error exception : 0x%x", dwRet);
  434. TRACE_VERB("<-%!FUNC!");
  435. throw CErrorWlbsControl( dwRet, CmdWlbsStop, bClusterWide );
  436. break;
  437. }
  438. a_dwNumHosts = dwNumHosts;
  439. TRACE_VERB("<-%!FUNC! return = 0x%x", dwRet);
  440. return dwRet;
  441. }
  442. ////////////////////////////////////////////////////////////////////////////////
  443. //
  444. // CWlbsControlWrapper::Suspend
  445. //
  446. // Purpose: Suspend cluster operation control on specified host or
  447. // all cluster hosts.
  448. //
  449. //
  450. ////////////////////////////////////////////////////////////////////////////////
  451. DWORD CWlbsControlWrapper::Suspend
  452. (
  453. DWORD a_dwCluster ,
  454. DWORD a_dwHost ,
  455. WLBS_RESPONSE* a_pResponse ,
  456. DWORD& a_dwNumHosts
  457. )
  458. {
  459. DWORD dwRet;
  460. BOOL bClusterWide = ( a_dwHost == WLBS_ALL_HOSTS );
  461. DWORD dwNumHosts = a_dwNumHosts;
  462. TRACE_VERB("->%!FUNC!");
  463. dwRet = m_WlbsControl.WlbsSuspend( a_dwCluster ,
  464. a_dwHost ,
  465. a_pResponse ,
  466. &dwNumHosts
  467. );
  468. //check for Winsock errors
  469. if( dwRet > 10000 )
  470. {
  471. TRACE_CRIT("%!FUNC! CWlbsControl::WlbsSuspend failed : 0x%x, Throwing Wlbs error exception", dwRet);
  472. TRACE_VERB("<-%!FUNC!");
  473. throw CErrorWlbsControl( dwRet, CmdWlbsQuery, bClusterWide );
  474. }
  475. //check the return value and throw if an error occurred
  476. switch(dwRet) {
  477. case WLBS_INIT_ERROR:
  478. case WLBS_BAD_PASSW:
  479. case WLBS_TIMEOUT:
  480. case WLBS_LOCAL_ONLY:
  481. case WLBS_REMOTE_ONLY:
  482. case WLBS_IO_ERROR:
  483. TRACE_CRIT("%!FUNC! Throwing Wlbs error exception : 0x%x", dwRet);
  484. TRACE_VERB("<-%!FUNC!");
  485. throw CErrorWlbsControl( dwRet, CmdWlbsSuspend, bClusterWide );
  486. break;
  487. }
  488. a_dwNumHosts = dwNumHosts;
  489. TRACE_VERB("<-%!FUNC! return = 0x%x", dwRet);
  490. return dwRet;
  491. }
  492. ////////////////////////////////////////////////////////////////////////////////
  493. //
  494. // CWlbsControlWrapper::Query
  495. //
  496. // Purpose: This invokes WlbsQuery and returns a response structure along
  497. // with other parameters if requested.
  498. //
  499. // Errors: The function throws CErrorWlbsControl.
  500. //
  501. // Return: Status value returned by the target host
  502. //
  503. ////////////////////////////////////////////////////////////////////////////////
  504. DWORD CWlbsControlWrapper::Query
  505. (
  506. CWlbsClusterWrapper * pCluster,
  507. DWORD a_dwHost,
  508. WLBS_RESPONSE * a_pResponse,
  509. WLBS_RESPONSE * a_pComputerNameResponse,
  510. PDWORD a_pdwNumHosts,
  511. PDWORD a_pdwHostMap
  512. )
  513. {
  514. TRACE_VERB("->%!FUNC!");
  515. DWORD dwRet;
  516. BOOL bClusterWide = 0;
  517. bClusterWide = ( a_dwHost == WLBS_ALL_HOSTS );
  518. // The below check is present only to take care of the
  519. // condition where a junk pointer was passed, but the
  520. // a_pdwNumHosts is set to NULL or zero. This check
  521. // is NOT necessitated by WlbsQuery, but by the check
  522. // at the end of this function where we fill in the DIP
  523. // into the zero-th entry of the array.
  524. if ((a_pdwNumHosts == NULL) || (*a_pdwNumHosts == 0))
  525. {
  526. a_pResponse = NULL;
  527. }
  528. dwRet = m_WlbsControl.WlbsQuery(
  529. (CWlbsCluster*)pCluster ,
  530. a_dwHost ,
  531. a_pResponse ,
  532. a_pdwNumHosts,
  533. a_pdwHostMap,
  534. NULL
  535. );
  536. string strOut;
  537. //check for Winsock errors
  538. if( dwRet > 10000 )
  539. {
  540. TRACE_CRIT("%!FUNC! CWlbsControl::WlbsQuery failed : 0x%x, Throwing Wlbs error exception", dwRet);
  541. TRACE_VERB("<-%!FUNC!");
  542. throw CErrorWlbsControl( dwRet, CmdWlbsQuery, bClusterWide );
  543. }
  544. //check the return value and throw if an error occurred
  545. switch( dwRet ) {
  546. case WLBS_INIT_ERROR:
  547. case WLBS_BAD_PASSW:
  548. case WLBS_TIMEOUT:
  549. case WLBS_LOCAL_ONLY:
  550. case WLBS_REMOTE_ONLY:
  551. case WLBS_IO_ERROR:
  552. TRACE_CRIT("%!FUNC! Throwing Wlbs error exception : 0x%x", dwRet);
  553. TRACE_VERB("<-%!FUNC!");
  554. throw CErrorWlbsControl( dwRet, CmdWlbsQuery, bClusterWide );
  555. }
  556. //local queries do not return the dedicated IP
  557. //get the dedicated IP and fill the structure
  558. if(( a_dwHost == WLBS_LOCAL_HOST ) && (a_pResponse != NULL))
  559. {
  560. a_pResponse[0].address = pCluster->GetDedicatedIp();
  561. // If the local computer's fqdn is to be queried from the nlb driver, do it.
  562. if(a_pComputerNameResponse)
  563. {
  564. GUID AdapterGuid;
  565. AdapterGuid = pCluster->GetAdapterGuid();
  566. WlbsGetSpecifiedClusterMember(&AdapterGuid, pCluster->GetHostID(), a_pComputerNameResponse);
  567. }
  568. }
  569. TRACE_VERB("<-%!FUNC! return = 0x%x", dwRet);
  570. return dwRet;
  571. }
  572. ////////////////////////////////////////////////////////////////////////////////
  573. //
  574. // CWlbsClusterWrapper::CheckMembership
  575. //
  576. // Purpose: This verifies that the local host is a member of the cluster
  577. // specified by the Cluster IP in the registry. At the time this
  578. // was written, there was a remote chance that a user can modify the
  579. // IP address in the registry prior to the load of this DLL.
  580. //
  581. // Note, this call is only required for the Node, Cluster and linked
  582. // associations and should not be invoked for any of the Setting classes.
  583. //
  584. ////////////////////////////////////////////////////////////////////////////////
  585. void CWlbsControlWrapper::CheckMembership()
  586. {
  587. // todo: make sure the host is in at least one cluster
  588. /*
  589. WLBS_RESPONSE WlbsResponse;
  590. DWORD dwResSize = 1;
  591. //get the cluster and HostID
  592. DWORD dwRes = pControl->Query( m_pWlbsCluster->GetClusterIp(),
  593. WLBS_LOCAL_HOST,
  594. &WlbsResponse,
  595. &dwResSize,
  596. NULL);
  597. switch( dwRes ) {
  598. case WLBS_SUSPENDED:
  599. case WLBS_STOPPED:
  600. case WLBS_CONVERGING:
  601. case WLBS_DRAINING:
  602. case WLBS_CONVERGED:
  603. case WLBS_DEFAULT:
  604. break;
  605. default:
  606. throw CErrorWlbsControl( dwRes, CmdWlbsQuery );
  607. }
  608. */
  609. // DWORD dwClusterIP;
  610. // GetClusterIP( &dwClusterIP );
  611. //if( dwClusterIP == 0 )
  612. //throw _com_error( WBEM_E_NOT_FOUND );
  613. //*******************************
  614. //this section does not work when the remote control is disabled
  615. //on the local host
  616. //*******************************
  617. //call the query function
  618. // dwRes = WlbsQuery( dwClusterIP,
  619. // WlbsResponse.id,
  620. // NULL,
  621. // NULL,
  622. // NULL,
  623. // NULL );
  624. //analyze query results for errors
  625. // switch( dwRes ) {
  626. // case WLBS_OK:
  627. // case WLBS_STOPPED:
  628. // case WLBS_CONVERGING:
  629. // case WLBS_CONVERGED:
  630. // case WLBS_DEFAULT:
  631. // case WLBS_DRAINING:
  632. // case WLBS_SUSPENDED:
  633. // return;
  634. // default:
  635. // throw CErrorWlbsControl( dwRes, CmdWlbsQuery );
  636. // }
  637. //*******************************
  638. //this section does not work when the remote control is disabled
  639. //on the local host
  640. //*******************************
  641. }
  642. DWORD CWlbsControlWrapper::WlbsQueryState
  643. (
  644. DWORD cluster,
  645. DWORD host,
  646. DWORD operation,
  647. PNLB_OPTIONS pOptions,
  648. PWLBS_RESPONSE pResponse,
  649. PDWORD pcResponses
  650. )
  651. {
  652. return m_WlbsControl.WlbsQueryState(cluster, host, operation, pOptions, pResponse, pcResponses);
  653. }