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.

622 lines
14 KiB

  1. #ifndef _MNLBMACHINE_H
  2. #define _MNLBMACHINE_H
  3. //
  4. // Copyright (c) Microsoft. All Rights Reserved
  5. //
  6. // THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Microsoft.
  7. // The copyright notice above does not evidence any
  8. // actual or intended publication of such source code.
  9. //
  10. // OneLiner : MNLBMachine interface.
  11. // DevUnit : wlbstest
  12. // Author : Murtaza Hakim
  13. //
  14. // Description:
  15. // -----------
  16. // Include Files
  17. #include "MNLBPortRule.h"
  18. #include "Common.h"
  19. #include "MWmiObject.h"
  20. #include "MWmiInstance.h"
  21. #include <vector>
  22. #include <memory>
  23. #include <comdef.h>
  24. using namespace std;
  25. class MNLBMachine
  26. {
  27. public:
  28. enum MNLBMachine_Error
  29. {
  30. MNLBMachine_SUCCESS = 0,
  31. };
  32. struct HostInfo
  33. {
  34. _bstr_t dedicatedIP;
  35. long hostID;
  36. };
  37. //
  38. // Description:
  39. // -----------
  40. // constructor.
  41. //
  42. // Parameters:
  43. // ----------
  44. // ip IN : ip address or machine name of machine to configure/admin nlbs on.
  45. // clusterIP IN : cluster ip on machine to configure.
  46. //
  47. // Returns:
  48. // -------
  49. // none.
  50. //
  51. MNLBMachine( const _bstr_t& ip,
  52. const _bstr_t& clusterIP );
  53. // for local machine.
  54. MNLBMachine( const _bstr_t& clusterIP );
  55. // NOT IMPLEMENTED.
  56. //
  57. //
  58. // Description:
  59. // -----------
  60. // default constructor.
  61. //
  62. // Parameters:
  63. // ----------
  64. // none.
  65. //
  66. // Returns:
  67. // -------
  68. // none.
  69. MNLBMachine();
  70. //
  71. // Description:
  72. // -----------
  73. // copy constructor.
  74. //
  75. // Parameters:
  76. // ----------
  77. // objToCopy IN : object to copy.
  78. //
  79. // Returns:
  80. // -------
  81. // none.
  82. MNLBMachine(const MNLBMachine& objToCopy );
  83. //
  84. // Description:
  85. // -----------
  86. // assignment operator
  87. //
  88. // Parameters:
  89. // ----------
  90. // rhs IN : object to assign.
  91. //
  92. // Returns:
  93. // -------
  94. // self
  95. MNLBMachine&
  96. operator=( const MNLBMachine& rhs );
  97. //
  98. // Description:
  99. // -----------
  100. // destructor
  101. //
  102. // Parameters:
  103. // ----------
  104. // none
  105. //
  106. // Returns:
  107. // -------
  108. // none.
  109. ~MNLBMachine();
  110. //
  111. // Description:
  112. // -----------
  113. // nlb host properties for machine.
  114. //
  115. // Parameters:
  116. // ----------
  117. // hp OUT : host properties.
  118. //
  119. // Returns:
  120. // -------
  121. // SUCCESS else error code.
  122. MNLBMachine_Error
  123. getHostProperties( HostProperties* hp );
  124. //
  125. // Description:
  126. // -----------
  127. // nlb cluster properties.
  128. //
  129. // Parameters:
  130. // ----------
  131. // cp OUT : cluster properties.
  132. //
  133. // Returns:
  134. // -------
  135. // SUCCESS else error code.
  136. MNLBMachine_Error
  137. getClusterProperties( ClusterProperties* cp );
  138. //
  139. // Description:
  140. // -----------
  141. // information of all hosts part of cluster
  142. //
  143. // Parameters:
  144. // ----------
  145. // cp OUT : cluster properties.
  146. //
  147. // Returns:
  148. // -------
  149. // SUCCESS else error code.
  150. MNLBMachine_Error
  151. getPresentHostsInfo( vector< HostInfo >* hostInfo );
  152. //
  153. // Description:
  154. // -----------
  155. // sets the nlbs host properties.
  156. //
  157. // Parameters:
  158. // ----------
  159. // hp IN : host properties to set.
  160. // retVal OUT : return value of method ran.
  161. //
  162. // Returns:
  163. // -------
  164. // SUCCESS else error code.
  165. MNLBMachine_Error
  166. setHostProperties( const HostProperties& hp,
  167. unsigned long* retVal );
  168. //
  169. // Description:
  170. // -----------
  171. // sets the nlbs cluster properties.
  172. //
  173. // Parameters:
  174. // ----------
  175. // cp IN : cluster properties to set.
  176. // retVal OUT : return value of method ran.
  177. //
  178. // Returns:
  179. // -------
  180. // SUCCESS else error code.
  181. MNLBMachine_Error
  182. setClusterProperties( const ClusterProperties& cp,
  183. unsigned long* retVal );
  184. //
  185. // Description:
  186. // -----------
  187. // get the load balanced port rules associated with this machine.
  188. //
  189. // Parameters:
  190. // ----------
  191. // portsLB OUT : load balanced port rules associated with this machine.
  192. //
  193. // Returns:
  194. // -------
  195. // SUCCESS else error code.
  196. MNLBMachine_Error
  197. getPortRulesLoadBalanced( vector<MNLBPortRuleLoadBalanced>* portsLB );
  198. //
  199. // Description:
  200. // -----------
  201. // get the failover port rules associated with this machine.
  202. //
  203. // Parameters:
  204. // ----------
  205. // portsF OUT : failover port rules associated with this machine.
  206. //
  207. // Returns:
  208. // -------
  209. // SUCCESS else error code.
  210. MNLBMachine_Error
  211. getPortRulesFailover( vector<MNLBPortRuleFailover>* portsF );
  212. //
  213. // Description:
  214. // -----------
  215. // get the disabled port rules associated with this machine.
  216. //
  217. // Parameters:
  218. // ----------
  219. // portsD OUT : failover port rules associated with this machine.
  220. //
  221. // Returns:
  222. // -------
  223. // SUCCESS else error code.
  224. MNLBMachine_Error
  225. getPortRulesDisabled( vector<MNLBPortRuleDisabled>* portsD );
  226. //
  227. // Description:
  228. // -----------
  229. // adds a load balanced port rule to the machine.
  230. //
  231. // Parameters:
  232. // ----------
  233. // portRuleLB IN : load balanced port rule to add.
  234. //
  235. // Returns:
  236. // -------
  237. // SUCCESS else error code.
  238. MNLBMachine_Error
  239. addPortRuleLoadBalanced( const MNLBPortRuleLoadBalanced& portRuleLB );
  240. //
  241. // Description:
  242. // -----------
  243. // adds a failover port rule to the machine.
  244. //
  245. // Parameters:
  246. // ----------
  247. // portRuleF IN : failover port rule to add.
  248. //
  249. // Returns:
  250. // -------
  251. // SUCCESS else error code.
  252. MNLBMachine_Error
  253. addPortRuleFailover( const MNLBPortRuleFailover& portRuleF );
  254. //
  255. // Description:
  256. // -----------
  257. // adds a disabled port rule to the machine.
  258. //
  259. // Parameters:
  260. // ----------
  261. // portRuleD IN : disabled port rule to add.
  262. //
  263. // Returns:
  264. // -------
  265. // SUCCESS else error code.
  266. MNLBMachine_Error
  267. addPortRuleDisabled( const MNLBPortRuleDisabled& portRuleD );
  268. //
  269. // Description:
  270. // -----------
  271. // removes a load balanced port rule to the machine.
  272. //
  273. // Parameters:
  274. // ----------
  275. // portRuleLB IN : load balanced port rule to remove.
  276. //
  277. // Returns:
  278. // -------
  279. // SUCCESS else error code.
  280. MNLBMachine_Error
  281. removePortRuleLoadBalanced( const MNLBPortRuleLoadBalanced& portRuleLB );
  282. //
  283. // Description:
  284. // -----------
  285. // removes a failover port rule to the machine.
  286. //
  287. // Parameters:
  288. // ----------
  289. // portRuleF IN : failover port rule to remove.
  290. //
  291. // Returns:
  292. // -------
  293. // SUCCESS else error code.
  294. MNLBMachine_Error
  295. removePortRuleFailover( const MNLBPortRuleFailover& portRuleF );
  296. //
  297. // Description:
  298. // -----------
  299. // removes a disabled port rule to the machine.
  300. //
  301. // Parameters:
  302. // ----------
  303. // portRuleD IN : disabled port rule to remove.
  304. //
  305. // Returns:
  306. // -------
  307. // SUCCESS else error code.
  308. MNLBMachine_Error
  309. removePortRuleDisabled( const MNLBPortRuleDisabled& portRuleD );
  310. //
  311. // Description:
  312. // -----------
  313. // starts host/cluster operations.
  314. //
  315. // Parameters:
  316. // ----------
  317. // hostID IN : host id or Common::ALL_HOSTS for cluster wide
  318. // or Common::THIS_HOST for connected machine.
  319. // retVal OUT : return value of method ran.
  320. //
  321. // Returns:
  322. // -------
  323. // SUCCESS else error code.
  324. MNLBMachine_Error
  325. start( int hostID, unsigned long* retVal );
  326. //
  327. // Description:
  328. // -----------
  329. // stops host/cluster operations.
  330. //
  331. // Parameters:
  332. // ----------
  333. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  334. // Common::THIS_HOST for connected machine.
  335. // retVal OUT : return value of method ran.
  336. //
  337. // Returns:
  338. // -------
  339. // SUCCESS else error code.
  340. MNLBMachine_Error
  341. stop( int hostID, unsigned long* retVal );
  342. //
  343. // Description:
  344. // -----------
  345. // resume control over host/cluster operations.
  346. //
  347. // Parameters:
  348. // ----------
  349. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  350. // Common::THIS_HOST for connected machine.
  351. // retVal OUT : return value of method ran.
  352. //
  353. // Returns:
  354. // -------
  355. // SUCCESS else error code.
  356. MNLBMachine_Error
  357. resume( int hostID, unsigned long* retVal );
  358. //
  359. // Description:
  360. // -----------
  361. // suspend control over host/cluster operations.
  362. //
  363. // Parameters:
  364. // ----------
  365. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  366. // Common::THIS_HOST for connected machine.
  367. // retVal OUT : return value of method ran.
  368. //
  369. // Returns:
  370. // -------
  371. // SUCCESS else error code.
  372. MNLBMachine_Error
  373. suspend( int hostID, unsigned long* retVal );
  374. //
  375. // Description:
  376. // -----------
  377. // finishes all existing connections and
  378. // stops host/cluster operations.
  379. //
  380. // Parameters:
  381. // ----------
  382. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  383. // Common::THIS_HOST for connected machine.
  384. // retVal OUT : return value of method ran.
  385. //
  386. // Returns:
  387. // -------
  388. // SUCCESS else error code.
  389. MNLBMachine_Error
  390. drainstop( int hostID, unsigned long* retVal );
  391. //
  392. // Description:
  393. // -----------
  394. // enables traffic for port rule for host/cluster.
  395. //
  396. // Parameters:
  397. // ----------
  398. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  399. // Common::THIS_HOST for connected machine.
  400. // retVal OUT : return value of method ran.
  401. // port IN : port to affect or default is all ports.
  402. //
  403. // Returns:
  404. // -------
  405. // SUCCESS else error code.
  406. MNLBMachine_Error
  407. enable( int hostID,
  408. unsigned long* retVal,
  409. unsigned long port = Common::ALL_PORTS );
  410. //
  411. // Description:
  412. // -----------
  413. // disables ALL traffic for port rule for host/cluster.
  414. //
  415. // Parameters:
  416. // ----------
  417. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  418. // Common::THIS_HOST for connected machine.
  419. // retVal OUT : return value of method ran.
  420. // port IN : port to affect or default is all ports.
  421. //
  422. // Returns:
  423. // -------
  424. // SUCCESS else error code.
  425. MNLBMachine_Error
  426. disable( int hostID, unsigned long* retVal, unsigned long port = Common::ALL_PORTS);
  427. //
  428. // Description:
  429. // -----------
  430. // disables NEW traffic for port rule for host/cluster.
  431. //
  432. // Parameters:
  433. // ----------
  434. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  435. // Common::THIS_HOST for connected machine.
  436. // retVal OUT : return value of method ran.
  437. // port IN : port to affect or default is all ports.
  438. //
  439. // Returns:
  440. // -------
  441. // SUCCESS else error code.
  442. MNLBMachine_Error
  443. drain( int hostID, unsigned long* retVal, unsigned long port = Common::ALL_PORTS );
  444. //
  445. // Description:
  446. // -----------
  447. // syncs the driver with the parameters in the registry.
  448. // this method is generally not required, but is provided
  449. // if somehow the driver and the registry where parameters
  450. // are stored are out of sync.
  451. //
  452. // Parameters:
  453. // ----------
  454. // retVal OUT : return value of method ran.
  455. //
  456. // Returns:
  457. // -------
  458. // SUCCESS else error code.
  459. MNLBMachine_Error
  460. reload( unsigned long* retVal );
  461. //
  462. // Description:
  463. // -----------
  464. // sets the nlbs remote control password.
  465. //
  466. // Parameters:
  467. // ----------
  468. // password IN : password to set.
  469. //
  470. // Returns:
  471. // -------
  472. // SUCCESS else error code.
  473. MNLBMachine_Error
  474. setPassword( const _bstr_t& password,
  475. unsigned long* retVal );
  476. //
  477. // Description:
  478. // -----------
  479. // refreshes the wmi connection to the host
  480. //
  481. // Parameters:
  482. // ----------
  483. // none
  484. //
  485. // Returns:
  486. // -------
  487. // SUCCESS else error code.
  488. MNLBMachine_Error
  489. refreshConnection();
  490. private:
  491. // data
  492. auto_ptr<MWmiObject> p_machine;
  493. _bstr_t mIP;
  494. _bstr_t mClusterIP;
  495. _bstr_t mHostID;
  496. // functions
  497. MNLBMachine_Error
  498. connectToMachine();
  499. MNLBMachine_Error
  500. checkClusterIPAndSetHostID();
  501. MNLBMachine_Error
  502. getInstanceToRunMethodOn( int hostID, vector <MWmiInstance>* instanceStore );
  503. MNLBMachine::MNLBMachine_Error
  504. MNLBMachine::getPortRulesLoadBalanced_private( vector<MNLBPortRuleLoadBalanced>* portsLB,
  505. vector<MWmiInstance>* instances );
  506. MNLBMachine::MNLBMachine_Error
  507. MNLBMachine::getPortRulesFailover_private( vector<MNLBPortRuleFailover>* portsF,
  508. vector<MWmiInstance>* instances );
  509. MNLBMachine::MNLBMachine_Error
  510. MNLBMachine::getPortRulesDisabled_private( vector<MNLBPortRuleDisabled>* portsD,
  511. vector<MWmiInstance>* instances );
  512. };
  513. // ensure type safety
  514. typedef class MNLBMachine MNLBMachine;
  515. #endif