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.

586 lines
13 KiB

  1. #ifndef _MNLBSETTING_H
  2. #define _MNLBSETTING_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 : MNLBSetting 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 MNLBSetting
  26. {
  27. public:
  28. enum MNLBSetting_Error
  29. {
  30. MNLBSetting_SUCCESS = 0,
  31. COM_FAILURE = 1,
  32. UNCONSTRUCTED = 2,
  33. MACHINE_FAILURE = 3,
  34. BOUND = 4,
  35. UNBOUND = 5,
  36. NO_SUCH_NIC = 6,
  37. NLBS_NOT_INSTALLED = 7,
  38. NO_SUCH_IP = 8,
  39. INVALID_RULE = 9,
  40. };
  41. //
  42. // Description:
  43. // -----------
  44. // constructor.
  45. //
  46. // Parameters:
  47. // ----------
  48. // ip IN : ip address of machine to configure/admin nlbs on.
  49. // fullNICName IN : full name of nic to use.
  50. //
  51. // Returns:
  52. // -------
  53. // none.
  54. //
  55. MNLBSetting( _bstr_t ip,
  56. _bstr_t fullNICName );
  57. // for local machine.
  58. MNLBSetting( _bstr_t fullNICName );
  59. // NOT IMPLEMENTED.
  60. //
  61. //
  62. // Description:
  63. // -----------
  64. // default constructor.
  65. //
  66. // Parameters:
  67. // ----------
  68. // none.
  69. //
  70. // Returns:
  71. // -------
  72. // none.
  73. MNLBSetting();
  74. //
  75. // Description:
  76. // -----------
  77. // copy constructor.
  78. //
  79. // Parameters:
  80. // ----------
  81. // objToCopy IN : object to copy.
  82. //
  83. // Returns:
  84. // -------
  85. // none.
  86. MNLBSetting(const MNLBSetting& objToCopy );
  87. //
  88. // Description:
  89. // -----------
  90. // assignment operator
  91. //
  92. // Parameters:
  93. // ----------
  94. // rhs IN : object to assign.
  95. //
  96. // Returns:
  97. // -------
  98. // self
  99. MNLBSetting&
  100. operator=( const MNLBSetting& rhs );
  101. //
  102. // Description:
  103. // -----------
  104. // destructor
  105. //
  106. // Parameters:
  107. // ----------
  108. // none
  109. //
  110. // Returns:
  111. // -------
  112. // none.
  113. ~MNLBSetting();
  114. //
  115. // Description:
  116. // -----------
  117. // gets the nlbs host properties.
  118. //
  119. // Parameters:
  120. // ----------
  121. // hp OUT : host properties.
  122. //
  123. // Returns:
  124. // -------
  125. // SUCCESS else error code.
  126. MNLBSetting_Error
  127. getHostProperties( HostProperties* hp );
  128. //
  129. // Description:
  130. // -----------
  131. // gets the nlbs cluster properties.
  132. //
  133. // Parameters:
  134. // ----------
  135. // cp OUT : cluster properties.
  136. //
  137. // Returns:
  138. // -------
  139. // SUCCESS else error code.
  140. MNLBSetting_Error
  141. getClusterProperties( ClusterProperties* cp );
  142. //
  143. // Description:
  144. // -----------
  145. // sets the nlbs host properties.
  146. //
  147. // Parameters:
  148. // ----------
  149. // hp IN : host properties to set.
  150. // retVal OUT : return value of method ran.
  151. //
  152. // Returns:
  153. // -------
  154. // SUCCESS else error code.
  155. MNLBSetting_Error
  156. setHostProperties( const HostProperties& hp,
  157. unsigned long* retVal );
  158. //
  159. // Description:
  160. // -----------
  161. // sets the nlbs cluster properties.
  162. //
  163. // Parameters:
  164. // ----------
  165. // cp IN : cluster properties to set.
  166. // retVal OUT : return value of method ran.
  167. //
  168. // Returns:
  169. // -------
  170. // SUCCESS else error code.
  171. MNLBSetting_Error
  172. setClusterProperties( const ClusterProperties& cp,
  173. unsigned long* retVal );
  174. //
  175. // Description:
  176. // -----------
  177. // get the load balanced port rules associated with this machine.
  178. //
  179. // Parameters:
  180. // ----------
  181. // portsLB OUT : load balanced port rules associated with this machine.
  182. //
  183. // Returns:
  184. // -------
  185. // SUCCESS else error code.
  186. MNLBSetting_Error
  187. getPortRulesLoadBalanced( vector<MNLBPortRuleLoadBalanced>* portsLB );
  188. //
  189. // Description:
  190. // -----------
  191. // get the failover port rules associated with this machine.
  192. //
  193. // Parameters:
  194. // ----------
  195. // portsF OUT : failover port rules associated with this machine.
  196. //
  197. // Returns:
  198. // -------
  199. // SUCCESS else error code.
  200. MNLBSetting_Error
  201. getPortRulesFailover( vector<MNLBPortRuleFailover>* portsF );
  202. //
  203. // Description:
  204. // -----------
  205. // get the disabled port rules associated with this machine.
  206. //
  207. // Parameters:
  208. // ----------
  209. // portsD OUT : failover port rules associated with this machine.
  210. //
  211. // Returns:
  212. // -------
  213. // SUCCESS else error code.
  214. MNLBSetting_Error
  215. getPortRulesDisabled( vector<MNLBPortRuleDisabled>* portsD );
  216. //
  217. // Description:
  218. // -----------
  219. // adds a load balanced port rule to the machine.
  220. //
  221. // Parameters:
  222. // ----------
  223. // portRuleLB IN : load balanced port rule to add.
  224. //
  225. // Returns:
  226. // -------
  227. // SUCCESS else error code.
  228. MNLBSetting_Error
  229. addPortRuleLoadBalanced( const MNLBPortRuleLoadBalanced& portRuleLB );
  230. //
  231. // Description:
  232. // -----------
  233. // adds a failover port rule to the machine.
  234. //
  235. // Parameters:
  236. // ----------
  237. // portRuleF IN : failover port rule to add.
  238. //
  239. // Returns:
  240. // -------
  241. // SUCCESS else error code.
  242. MNLBSetting_Error
  243. addPortRuleFailover( const MNLBPortRuleFailover& portRuleF );
  244. //
  245. // Description:
  246. // -----------
  247. // adds a disabled port rule to the machine.
  248. //
  249. // Parameters:
  250. // ----------
  251. // portRuleD IN : disabled port rule to add.
  252. //
  253. // Returns:
  254. // -------
  255. // SUCCESS else error code.
  256. MNLBSetting_Error
  257. addPortRuleDisabled( const MNLBPortRuleDisabled& portRuleD );
  258. //
  259. // Description:
  260. // -----------
  261. // removes a load balanced port rule to the machine.
  262. //
  263. // Parameters:
  264. // ----------
  265. // portRuleLB IN : load balanced port rule to remove.
  266. //
  267. // Returns:
  268. // -------
  269. // SUCCESS else error code.
  270. MNLBSetting_Error
  271. removePortRuleLoadBalanced( const MNLBPortRuleLoadBalanced& portRuleLB );
  272. //
  273. // Description:
  274. // -----------
  275. // removes a failover port rule to the machine.
  276. //
  277. // Parameters:
  278. // ----------
  279. // portRuleF IN : failover port rule to remove.
  280. //
  281. // Returns:
  282. // -------
  283. // SUCCESS else error code.
  284. MNLBSetting_Error
  285. removePortRuleFailover( const MNLBPortRuleFailover& portRuleF );
  286. //
  287. // Description:
  288. // -----------
  289. // removes a disabled port rule to the machine.
  290. //
  291. // Parameters:
  292. // ----------
  293. // portRuleD IN : disabled port rule to remove.
  294. //
  295. // Returns:
  296. // -------
  297. // SUCCESS else error code.
  298. MNLBSetting_Error
  299. removePortRuleDisabled( const MNLBPortRuleDisabled& portRuleD );
  300. //
  301. // Description:
  302. // -----------
  303. // starts host/cluster operations.
  304. //
  305. // Parameters:
  306. // ----------
  307. // hostID IN : host id or Common::ALL_HOSTS for cluster wide
  308. // or Common::THIS_HOST for connected machine.
  309. // retVal OUT : return value of method ran.
  310. //
  311. // Returns:
  312. // -------
  313. // SUCCESS else error code.
  314. MNLBSetting_Error
  315. start( int hostID, unsigned long* retVal );
  316. //
  317. // Description:
  318. // -----------
  319. // stops host/cluster operations.
  320. //
  321. // Parameters:
  322. // ----------
  323. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  324. // Common::THIS_HOST for connected machine.
  325. // retVal OUT : return value of method ran.
  326. //
  327. // Returns:
  328. // -------
  329. // SUCCESS else error code.
  330. MNLBSetting_Error
  331. stop( int hostID, unsigned long* retVal );
  332. //
  333. // Description:
  334. // -----------
  335. // resume control over host/cluster operations.
  336. //
  337. // Parameters:
  338. // ----------
  339. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  340. // Common::THIS_HOST for connected machine.
  341. // retVal OUT : return value of method ran.
  342. //
  343. // Returns:
  344. // -------
  345. // SUCCESS else error code.
  346. MNLBSetting_Error
  347. resume( int hostID, unsigned long* retVal );
  348. //
  349. // Description:
  350. // -----------
  351. // suspend control over host/cluster operations.
  352. //
  353. // Parameters:
  354. // ----------
  355. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  356. // Common::THIS_HOST for connected machine.
  357. // retVal OUT : return value of method ran.
  358. //
  359. // Returns:
  360. // -------
  361. // SUCCESS else error code.
  362. MNLBSetting_Error
  363. suspend( int hostID, unsigned long* retVal );
  364. //
  365. // Description:
  366. // -----------
  367. // finishes all existing connections and
  368. // stops host/cluster operations.
  369. //
  370. // Parameters:
  371. // ----------
  372. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  373. // Common::THIS_HOST for connected machine.
  374. // retVal OUT : return value of method ran.
  375. //
  376. // Returns:
  377. // -------
  378. // SUCCESS else error code.
  379. MNLBSetting_Error
  380. drainstop( int hostID, unsigned long* retVal );
  381. //
  382. // Description:
  383. // -----------
  384. // enables traffic for port rule for host/cluster.
  385. //
  386. // Parameters:
  387. // ----------
  388. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  389. // Common::THIS_HOST for connected machine.
  390. // retVal OUT : return value of method ran.
  391. // port IN : port to affect or default is all ports.
  392. //
  393. // Returns:
  394. // -------
  395. // SUCCESS else error code.
  396. MNLBSetting_Error
  397. enable( int hostID, unsigned long* retVal, unsigned long port = Common::ALL_PORTS );
  398. //
  399. // Description:
  400. // -----------
  401. // disables ALL traffic for port rule for host/cluster.
  402. //
  403. // Parameters:
  404. // ----------
  405. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  406. // Common::THIS_HOST for connected machine.
  407. // retVal OUT : return value of method ran.
  408. // port IN : port to affect or default is all ports.
  409. //
  410. // Returns:
  411. // -------
  412. // SUCCESS else error code.
  413. MNLBSetting_Error
  414. disable( int hostID, unsigned long* retVal, unsigned long port = Common::ALL_PORTS);
  415. //
  416. // Description:
  417. // -----------
  418. // disables NEW traffic for port rule for host/cluster.
  419. //
  420. // Parameters:
  421. // ----------
  422. // hostID IN : host id or Common::ALL_HOSTS for cluster wide or
  423. // Common::THIS_HOST for connected machine.
  424. // retVal OUT : return value of method ran.
  425. // port IN : port to affect or default is all ports.
  426. //
  427. // Returns:
  428. // -------
  429. // SUCCESS else error code.
  430. MNLBSetting_Error
  431. drain( int hostID, unsigned long* retVal, unsigned long port = Common::ALL_PORTS );
  432. //
  433. // Description:
  434. // -----------
  435. // refreshes the wmi connection to the host
  436. //
  437. // Parameters:
  438. // ----------
  439. // none
  440. //
  441. // Returns:
  442. // -------
  443. // SUCCESS else error code.
  444. MNLBSetting_Error
  445. refreshConnection();
  446. MNLBSetting_Error
  447. reload( unsigned long* retVal );
  448. private:
  449. // data
  450. auto_ptr<MWmiObject> p_machine;
  451. _bstr_t mIP;
  452. _bstr_t nic;
  453. // functions
  454. MNLBSetting_Error
  455. connectToMachine();
  456. MNLBSetting_Error
  457. checkNicBinding(_bstr_t& guid );
  458. MNLBSetting_Error
  459. getInstanceToRunMethodOn( int hostID, vector <MWmiInstance>* instanceStore );
  460. MNLBSetting::MNLBSetting_Error
  461. MNLBSetting::getPortRulesLoadBalanced_private( vector<MNLBPortRuleLoadBalanced>* portsLB,
  462. vector<MWmiInstance>* instances );
  463. MNLBSetting::MNLBSetting_Error
  464. MNLBSetting::getPortRulesFailover_private( vector<MNLBPortRuleFailover>* portsF,
  465. vector<MWmiInstance>* instances );
  466. MNLBSetting::MNLBSetting_Error
  467. MNLBSetting::getPortRulesDisabled_private( vector<MNLBPortRuleDisabled>* portsD,
  468. vector<MWmiInstance>* instances );
  469. MNLBSetting_Error
  470. getClusterIPAndHostID( _bstr_t& clusterIP,
  471. _bstr_t& hostID );
  472. };
  473. // ensure type safety
  474. typedef class MNLBSetting MNLBSetting;
  475. #endif