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.

2986 lines
103 KiB

  1. #include "LeftView.h"
  2. #include "ClusterConnectPage.h"
  3. #include "ClusterConnectIndirectPage.h"
  4. #include "ManageVirtualIPSPage.h"
  5. #include "MachineConnectPage.h"
  6. #include "PortsControlPage.h"
  7. #include "HostPage.h"
  8. #include "ClusterPage.h"
  9. #include "ResourceString.h"
  10. #include "PortsPage.h"
  11. #include "CommonNLB.h"
  12. #include "MNLBUIData.h"
  13. #include "MNLBNetCfg.h"
  14. #include "MWmiError.h"
  15. #include "MIPAddress.h"
  16. #include "MIPAddressAdmin.h"
  17. #include "resource.h"
  18. #include <vector>
  19. #include <algorithm>
  20. using namespace std;
  21. IMPLEMENT_DYNCREATE( LeftView, CTreeView )
  22. BEGIN_MESSAGE_MAP( LeftView, CTreeView )
  23. ON_WM_RBUTTONDOWN()
  24. ON_COMMAND( ID_WORLD_CONNECT, OnWorldConnect )
  25. ON_COMMAND( ID_WORLD_CONNECT_INDIRECT, OnWorldConnectIndirect )
  26. ON_COMMAND( ID_WORLD_NEW, OnWorldNewCluster )
  27. ON_COMMAND( ID_REFRESH, OnRefresh )
  28. ON_COMMAND( ID_CLUSTER_PROPERTIES, OnClusterProperties )
  29. ON_COMMAND( ID_CLUSTER_MANAGE_VIPS, OnClusterManageVIPS )
  30. ON_COMMAND( ID_CLUSTER_REMOVE, OnClusterRemove )
  31. ON_COMMAND( ID_CLUSTER_UNMANAGE, OnClusterUnmanage )
  32. ON_COMMAND( ID_CLUSTER_ADD_HOST, OnClusterAddHost )
  33. ON_COMMAND_RANGE( ID_CLUSTER_EXE_QUERY, ID_CLUSTER_EXE_SUSPEND,
  34. OnClusterControl )
  35. ON_COMMAND_RANGE( ID_CLUSTER_EXE_ENABLE, ID_CLUSTER_EXE_DRAIN,
  36. OnClusterPortControl )
  37. ON_COMMAND( ID_HOST_PROPERTIES, OnHostProperties )
  38. ON_COMMAND( ID_HOST_REMOVE, OnHostRemove )
  39. ON_COMMAND_RANGE( ID_HOST_EXE_QUERY, ID_HOST_EXE_SUSPEND,
  40. OnHostControl )
  41. ON_COMMAND_RANGE( ID_HOST_EXE_ENABLE, ID_HOST_EXE_DRAIN,
  42. OnHostPortControl )
  43. ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
  44. END_MESSAGE_MAP()
  45. // Sort the item in reverse alphabetical order.
  46. LeftView::LeftView()
  47. {
  48. // This is a hack as when ::dataSink calls
  49. // SetWindowText it sets both the caption
  50. // and the edit control. Thus what is written
  51. // in the log pane also comes in caption. By
  52. // making the caption initially very big
  53. // this hack ensures that the caption only shows
  54. // the title and nothing else.
  55. // This is crazy stuff, but that is what you get
  56. // when you work with mfc and its very poor doc.
  57. // One disadvantage of this is that the bottom
  58. // pane will now show a horizontal scroll bar
  59. // when it really is not required, but that is
  60. // a tradeoff if a message pane title is required.
  61. title = GETRESOURCEIDSTRING( IDS_BOTTOM_PANE_TITLE ) +
  62. L" " +
  63. GETRESOURCEIDSTRING( IDS_INFO_NEWLINE );
  64. }
  65. LeftView::~LeftView()
  66. {
  67. }
  68. Document*
  69. LeftView::GetDocument()
  70. {
  71. return ( Document *) m_pDocument;
  72. }
  73. void
  74. LeftView::OnInitialUpdate()
  75. {
  76. CTreeView::OnInitialUpdate();
  77. // get present style.
  78. LONG presentStyle;
  79. presentStyle = GetWindowLong( m_hWnd, GWL_STYLE );
  80. // Set the last error to zero to avoid confusion. See sdk for SetWindowLong.
  81. SetLastError(0);
  82. // set new style.
  83. LONG rcLong;
  84. rcLong = SetWindowLong( m_hWnd,
  85. GWL_STYLE,
  86. presentStyle | TVS_HASLINES | TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_LINESATROOT );
  87. //
  88. // Get and set the image list which is used by this
  89. // tree view from document.
  90. //
  91. GetTreeCtrl().SetImageList( GetDocument()->m_images48x48,
  92. TVSIL_NORMAL );
  93. // insert root icon which is world
  94. const _bstr_t& worldLevel = GETRESOURCEIDSTRING( IDS_WORLD_NAME );
  95. rootItem.hParent = TVI_ROOT;
  96. rootItem.hInsertAfter = TVI_FIRST;
  97. rootItem.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  98. rootItem.item.pszText = worldLevel;
  99. rootItem.item.cchTextMax= worldLevel.length() + 1;
  100. rootItem.item.iImage = 0;
  101. rootItem.item.iSelectedImage = 0;
  102. rootItem.item.lParam = 0;
  103. rootItem.item.cChildren = 1;
  104. GetTreeCtrl().InsertItem( &rootItem );
  105. //
  106. // we will register
  107. // with the document class,
  108. // as we are the left pane
  109. //
  110. GetDocument()->registerLeftPane( this );
  111. }
  112. void
  113. LeftView::OnRButtonDown( UINT nFlags, CPoint point )
  114. {
  115. // do a hit test
  116. // here we are checking that right button is down on
  117. // a tree view item or icon.
  118. TVHITTESTINFO hitTest;
  119. hitTest.pt = point;
  120. GetTreeCtrl().HitTest( &hitTest );
  121. if( !(hitTest.flags == TVHT_ONITEMLABEL )
  122. &&
  123. !(hitTest.flags == TVHT_ONITEMICON )
  124. )
  125. {
  126. return;
  127. }
  128. // make the item right clicked on the
  129. // selected item.
  130. GetTreeCtrl().SelectItem( hitTest.hItem );
  131. LRESULT result;
  132. OnSelchanged( NULL, &result );
  133. HTREEITEM hdlSelItem = hitTest.hItem;
  134. // get the image of the item which
  135. // has been selected. From this we can make out it it is
  136. // world level, cluster level or host level.
  137. TVITEM selItem;
  138. selItem.hItem = hdlSelItem;
  139. selItem.mask = TVIF_IMAGE ;
  140. GetTreeCtrl().GetItem( &selItem );
  141. /// Depending upon item selected show the pop up menu.
  142. int menuIndex;
  143. switch( selItem.iImage )
  144. {
  145. case 0: // this is world level.
  146. menuIndex = 0;
  147. break;
  148. case 1: // this is some cluster
  149. menuIndex = 1;
  150. break;
  151. case 2: // this has to be host.
  152. menuIndex = 2;
  153. break;
  154. default: // don't know how to handle this image.
  155. return;
  156. }
  157. CMenu menu;
  158. menu.LoadMenu( IDR_POPUP );
  159. CMenu* pContextMenu = menu.GetSubMenu( menuIndex );
  160. ClientToScreen( &point );
  161. pContextMenu->TrackPopupMenu( TPM_RIGHTBUTTON,
  162. point.x,
  163. point.y,
  164. this );
  165. CTreeView::OnRButtonDown(nFlags, point);
  166. }
  167. void
  168. LeftView::OnRefresh()
  169. {
  170. // Refresh is the following steps:
  171. //
  172. // * Remove the present cluster being refreshed from view.
  173. //
  174. // * Connect direct if cluster has connectedDirect = true, else indirect.
  175. // find tree view cluster member which has been selected.
  176. //
  177. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  178. TVITEM selectedItem;
  179. selectedItem.hItem = hdlSelectedItem;
  180. selectedItem.mask = TVIF_PARAM;
  181. GetTreeCtrl().GetItem( &selectedItem );
  182. ClusterData* p_clusterData = (ClusterData *) selectedItem.lParam;
  183. if( p_clusterData->connectedDirect == true )
  184. {
  185. RefreshDirect();
  186. }
  187. else
  188. {
  189. RefreshIndirect();
  190. }
  191. }
  192. void
  193. LeftView::RefreshDirect()
  194. {
  195. // Refresh is the following steps:
  196. // * Remove the present cluster being refreshed from view.
  197. // * Connect direct back to the cluster.
  198. // find tree view cluster member which has been selected.
  199. //
  200. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  201. TVITEM selectedItem;
  202. selectedItem.hItem = hdlSelectedItem;
  203. selectedItem.mask = TVIF_PARAM;
  204. GetTreeCtrl().GetItem( &selectedItem );
  205. ClusterData* p_clusterData = (ClusterData *) selectedItem.lParam;
  206. // now reconnect.
  207. //
  208. ClusterConnectPage clusterConnect( p_clusterData );
  209. _bstr_t tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_REFRESH_CLUSTER );
  210. CPropertySheet tabbedDlg( tabbedDlgCaption );
  211. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  212. tabbedDlg.AddPage( &clusterConnect );
  213. int rc = tabbedDlg.DoModal();
  214. if( rc != IDOK )
  215. {
  216. return;
  217. }
  218. else
  219. {
  220. // connection successful, thus remove old item.
  221. //
  222. GetTreeCtrl().DeleteItem( hdlSelectedItem );
  223. // deleting memory of host needs to be done.
  224. // TODO
  225. // form the tree
  226. //
  227. TVINSERTSTRUCT item;
  228. item.hParent = GetTreeCtrl().GetRootItem();
  229. item.hInsertAfter = TVI_LAST;
  230. item.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  231. item.item.pszText = p_clusterData->cp.cIP;
  232. item.item.cchTextMax= p_clusterData->cp.cIP.length() + 1;
  233. item.item.iImage = 1;
  234. item.item.iSelectedImage = 1;
  235. item.item.lParam = (LPARAM ) p_clusterData;
  236. item.item.cChildren = 1;
  237. HTREEITEM clusterParent = GetTreeCtrl().InsertItem( &item );
  238. GetTreeCtrl().Expand( GetTreeCtrl().GetRootItem(), TVE_EXPAND );
  239. map<_bstr_t, HostData>::iterator topHostData;
  240. for( topHostData = p_clusterData->hosts.begin(); topHostData != p_clusterData->hosts.end(); ++topHostData )
  241. {
  242. item.hParent = clusterParent;
  243. item.hInsertAfter = TVI_LAST;
  244. item.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  245. item.item.pszText = (*topHostData).second.hp.machineName;
  246. item.item.cchTextMax= (*topHostData).second.hp.machineName.length() + 1;
  247. item.item.iImage = 2;
  248. item.item.iSelectedImage = 2;
  249. item.item.lParam = (LPARAM ) new _bstr_t((*topHostData).second.hp.machineName );
  250. item.item.cChildren = 0;
  251. GetTreeCtrl().InsertItem( &item );
  252. }
  253. GetTreeCtrl().Expand( clusterParent, TVE_EXPAND );
  254. }
  255. LRESULT result;
  256. OnSelchanged( NULL, &result );
  257. }
  258. void
  259. LeftView::RefreshIndirect()
  260. {
  261. // Refresh is the following steps:
  262. // Remove the present cluster being refreshed from view.
  263. // Connect direct or indirectly back to the cluster.
  264. // find tree view cluster member which has been selected.
  265. //
  266. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  267. TVITEM selectedItem;
  268. selectedItem.hItem = hdlSelectedItem;
  269. selectedItem.mask = TVIF_PARAM;
  270. GetTreeCtrl().GetItem( &selectedItem );
  271. ClusterData* p_clusterData = (ClusterData *) selectedItem.lParam;
  272. // now reconnect.
  273. //
  274. ClusterConnectIndirectPage clusterConnect( p_clusterData );
  275. _bstr_t tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_REFRESH_CLUSTER );
  276. CPropertySheet tabbedDlg( tabbedDlgCaption );
  277. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  278. tabbedDlg.AddPage( &clusterConnect );
  279. int rc = tabbedDlg.DoModal();
  280. if( rc != IDOK )
  281. {
  282. return;
  283. }
  284. else
  285. {
  286. // connection successful, thus remove old item.
  287. //
  288. GetTreeCtrl().DeleteItem( hdlSelectedItem );
  289. // deleting memory of host needs to be done.
  290. // TODO
  291. // form the tree
  292. //
  293. TVINSERTSTRUCT item;
  294. item.hParent = GetTreeCtrl().GetRootItem();
  295. item.hInsertAfter = TVI_LAST;
  296. item.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  297. item.item.pszText = p_clusterData->cp.cIP;
  298. item.item.cchTextMax= p_clusterData->cp.cIP.length() + 1;
  299. item.item.iImage = 1;
  300. item.item.iSelectedImage = 1;
  301. item.item.lParam = (LPARAM ) p_clusterData;
  302. item.item.cChildren = 1;
  303. HTREEITEM clusterParent = GetTreeCtrl().InsertItem( &item );
  304. GetTreeCtrl().Expand( GetTreeCtrl().GetRootItem(), TVE_EXPAND );
  305. map<_bstr_t, HostData>::iterator topHostData;
  306. for( topHostData = p_clusterData->hosts.begin(); topHostData != p_clusterData->hosts.end(); ++topHostData )
  307. {
  308. item.hParent = clusterParent;
  309. item.hInsertAfter = TVI_LAST;
  310. item.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  311. item.item.pszText = (*topHostData).second.hp.machineName;
  312. item.item.cchTextMax= (*topHostData).second.hp.machineName.length() + 1;
  313. item.item.iImage = 2;
  314. item.item.iSelectedImage = 2;
  315. item.item.lParam = (LPARAM ) new _bstr_t((*topHostData).second.hp.machineName );
  316. item.item.cChildren = 0;
  317. GetTreeCtrl().InsertItem( &item );
  318. }
  319. GetTreeCtrl().Expand( clusterParent, TVE_EXPAND );
  320. }
  321. LRESULT result;
  322. OnSelchanged( NULL, &result );
  323. }
  324. void
  325. LeftView::OnWorldConnect()
  326. {
  327. ClusterData* p_clusterData = new ClusterData;
  328. ClusterConnectPage clusterConnect( p_clusterData, this );
  329. _bstr_t tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_CONNECT_CLUSTER_CAPTION );
  330. CPropertySheet tabbedDlg( tabbedDlgCaption );
  331. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  332. tabbedDlg.AddPage( &clusterConnect );
  333. int rc = tabbedDlg.DoModal();
  334. if( rc != IDOK )
  335. {
  336. delete p_clusterData;
  337. return;
  338. }
  339. else
  340. {
  341. // we have connected directly.
  342. p_clusterData->connectedDirect = true;
  343. // form the tree
  344. //
  345. TVINSERTSTRUCT item;
  346. item.hParent = GetTreeCtrl().GetRootItem();
  347. item.hInsertAfter = TVI_LAST;
  348. item.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  349. item.item.pszText = p_clusterData->cp.cIP;
  350. item.item.cchTextMax= p_clusterData->cp.cIP.length() + 1;
  351. item.item.iImage = 1;
  352. item.item.iSelectedImage = 1;
  353. item.item.lParam = (LPARAM ) p_clusterData;
  354. item.item.cChildren = 1;
  355. HTREEITEM clusterParent = GetTreeCtrl().InsertItem( &item );
  356. GetTreeCtrl().Expand( GetTreeCtrl().GetRootItem(), TVE_EXPAND );
  357. map<_bstr_t, HostData>::iterator topHostData;
  358. for( topHostData = p_clusterData->hosts.begin(); topHostData != p_clusterData->hosts.end(); ++topHostData )
  359. {
  360. item.hParent = clusterParent;
  361. item.hInsertAfter = TVI_LAST;
  362. item.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  363. item.item.pszText = (*topHostData).second.hp.machineName;
  364. item.item.cchTextMax= (*topHostData).second.hp.machineName.length() + 1;
  365. item.item.iImage = 2;
  366. item.item.iSelectedImage = 2;
  367. item.item.lParam = (LPARAM ) new _bstr_t((*topHostData).second.hp.machineName );
  368. item.item.cChildren = 0;
  369. GetTreeCtrl().InsertItem( &item );
  370. }
  371. GetTreeCtrl().Expand( clusterParent, TVE_EXPAND );
  372. }
  373. LRESULT result;
  374. OnSelchanged( NULL, &result );
  375. }
  376. void
  377. LeftView::OnWorldConnectIndirect()
  378. {
  379. ClusterData* p_clusterData = new ClusterData;
  380. ClusterConnectIndirectPage clusterConnect( p_clusterData, this );
  381. _bstr_t tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_CONNECT_CLUSTER_CAPTION );
  382. CPropertySheet tabbedDlg( tabbedDlgCaption );
  383. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  384. tabbedDlg.AddPage( &clusterConnect );
  385. int rc = tabbedDlg.DoModal();
  386. if( rc != IDOK )
  387. {
  388. delete p_clusterData;
  389. return;
  390. }
  391. else
  392. {
  393. // form the tree
  394. //
  395. // we have connected indirectly.
  396. p_clusterData->connectedDirect = false;
  397. TVINSERTSTRUCT item;
  398. item.hParent = GetTreeCtrl().GetRootItem();
  399. item.hInsertAfter = TVI_LAST;
  400. item.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  401. item.item.pszText = p_clusterData->cp.cIP;
  402. item.item.cchTextMax= p_clusterData->cp.cIP.length() + 1;
  403. item.item.iImage = 1;
  404. item.item.iSelectedImage = 1;
  405. item.item.lParam = (LPARAM ) p_clusterData;
  406. item.item.cChildren = 1;
  407. HTREEITEM clusterParent = GetTreeCtrl().InsertItem( &item );
  408. GetTreeCtrl().Expand( GetTreeCtrl().GetRootItem(), TVE_EXPAND );
  409. map<_bstr_t, HostData>::iterator topHostData;
  410. for( topHostData = p_clusterData->hosts.begin(); topHostData != p_clusterData->hosts.end(); ++topHostData )
  411. {
  412. item.hParent = clusterParent;
  413. item.hInsertAfter = TVI_LAST;
  414. item.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  415. item.item.pszText = (*topHostData).second.hp.machineName;
  416. item.item.cchTextMax= (*topHostData).second.hp.machineName.length() + 1;
  417. item.item.iImage = 2;
  418. item.item.iSelectedImage = 2;
  419. item.item.lParam = (LPARAM ) new _bstr_t((*topHostData).second.hp.machineName );
  420. item.item.cChildren = 0;
  421. GetTreeCtrl().InsertItem( &item );
  422. }
  423. GetTreeCtrl().Expand( clusterParent, TVE_EXPAND );
  424. }
  425. LRESULT result;
  426. OnSelchanged( NULL, &result );
  427. }
  428. void
  429. LeftView::OnWorldNewCluster()
  430. {
  431. ClusterData* p_clusterData = new ClusterData;
  432. // set up default values.
  433. // defaults for cluster.
  434. p_clusterData->cp.cIP = L"0.0.0.0";
  435. p_clusterData->cp.cSubnetMask = L"0.0.0.0";
  436. p_clusterData->cp.cFullInternetName = L"www.cluster.com";
  437. p_clusterData->cp.cNetworkAddress = L"00-00-00-00-00-00";
  438. // defaults for port rules.
  439. PortDataELB portRule;
  440. portRule._startPort = 0;
  441. portRule._key = portRule._startPort;
  442. portRule._endPort = 65535;
  443. portRule._trafficToHandle = MNLBPortRule::Protocol::both;
  444. portRule._isEqualLoadBalanced = true;
  445. p_clusterData->portELB[0] = portRule;
  446. //
  447. // fDisablePage = false
  448. //
  449. ClusterPage clusterPage( &p_clusterData->cp, false );
  450. PortsPage portsPage( p_clusterData );
  451. CPropertySheet tabbedDlg( GETRESOURCEIDSTRING( IDS_PROPERTIES_CAPTION ) );
  452. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  453. tabbedDlg.AddPage( &clusterPage );
  454. tabbedDlg.AddPage( &portsPage );
  455. int rc = tabbedDlg.DoModal();
  456. if( rc != IDOK )
  457. {
  458. delete p_clusterData;
  459. return;
  460. }
  461. else
  462. {
  463. // when creating assume indirect.
  464. //
  465. p_clusterData->connectedDirect = false;
  466. // check if this cluster already exists in nlbmgr view.
  467. //
  468. bool isClusterDuplicate = doesClusterExistInView( p_clusterData->cp.cIP );
  469. if( isClusterDuplicate == true )
  470. {
  471. MessageBox( p_clusterData->cp.cIP + L":" + GETRESOURCEIDSTRING (IDS_CLUSTER_ALREADY ),
  472. GETRESOURCEIDSTRING (IDR_MAINFRAME ),
  473. MB_ICONEXCLAMATION );
  474. delete p_clusterData;
  475. return;
  476. }
  477. // form the tree
  478. //
  479. TVINSERTSTRUCT item;
  480. item.hParent = GetTreeCtrl().GetRootItem();
  481. item.hInsertAfter = TVI_LAST;
  482. item.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  483. item.item.pszText = p_clusterData->cp.cIP;
  484. item.item.cchTextMax= p_clusterData->cp.cIP.length() + 1;
  485. item.item.iImage = 1;
  486. item.item.iSelectedImage = 1;
  487. item.item.lParam = (LPARAM ) p_clusterData;
  488. item.item.cChildren = 1;
  489. HTREEITEM clusterParent = GetTreeCtrl().InsertItem( &item );
  490. GetTreeCtrl().Expand( GetTreeCtrl().GetRootItem(), TVE_EXPAND );
  491. }
  492. LRESULT result;
  493. OnSelchanged( NULL, &result );
  494. }
  495. void
  496. LeftView::OnClusterProperties()
  497. {
  498. // find tree view cluster member which has been selected.
  499. //
  500. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  501. TVITEM selectedItem;
  502. selectedItem.hItem = hdlSelectedItem;
  503. selectedItem.mask = TVIF_PARAM;
  504. GetTreeCtrl().GetItem( &selectedItem );
  505. ClusterData* p_oldSettings = (ClusterData *) selectedItem.lParam;
  506. ClusterData newSettings = *( (ClusterData *) selectedItem.lParam );
  507. ClusterData* p_clusterData = (ClusterData *) selectedItem.lParam;
  508. ClusterPage clusterPage( &newSettings.cp, false );
  509. PortsPage portsPage( &newSettings );
  510. _bstr_t tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_PROPERTIES_CAPTION );
  511. CPropertySheet tabbedDlg( tabbedDlgCaption );
  512. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  513. tabbedDlg.AddPage( &clusterPage );
  514. tabbedDlg.AddPage( &portsPage );
  515. int rc = tabbedDlg.DoModal();
  516. if( rc != IDOK )
  517. {
  518. return;
  519. }
  520. else
  521. {
  522. // clear the old status if any.
  523. dataSink( GETRESOURCEIDSTRING( IDS_INFO_LINE_SEPARATOR ) );
  524. dumpClusterData( &newSettings );
  525. try
  526. {
  527. bool bClusterIpChanged;
  528. CommonNLB::changeNLBClusterAndPortSettings( p_oldSettings,
  529. &newSettings,
  530. this,
  531. &bClusterIpChanged);
  532. *p_clusterData = newSettings;
  533. if (bClusterIpChanged)
  534. {
  535. GetTreeCtrl().SetItemText(hdlSelectedItem, newSettings.cp.cIP);
  536. }
  537. }
  538. catch( _com_error e )
  539. {
  540. _bstr_t errText;
  541. GetErrorCodeText( e.Error(), errText );
  542. dataSink( errText );
  543. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  544. }
  545. }
  546. LRESULT result;
  547. OnSelchanged( NULL, &result );
  548. }
  549. void
  550. LeftView::OnClusterManageVIPS()
  551. {
  552. return;
  553. // find tree view cluster member which has been selected.
  554. //
  555. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  556. TVITEM selectedItem;
  557. selectedItem.hItem = hdlSelectedItem;
  558. selectedItem.mask = TVIF_PARAM;
  559. GetTreeCtrl().GetItem( &selectedItem );
  560. ClusterData* p_clusterSettings = (ClusterData *) selectedItem.lParam;
  561. ClusterData newSettings = *( (ClusterData *) selectedItem.lParam );
  562. ManageVirtualIPSPage manageVirtualIPSPage( &newSettings );
  563. _bstr_t tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_VIRTUAL_IPS_CAPTION );
  564. CPropertySheet tabbedDlg( tabbedDlgCaption );
  565. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  566. tabbedDlg.AddPage( &manageVirtualIPSPage );
  567. int rc = tabbedDlg.DoModal();
  568. if( rc != IDOK )
  569. {
  570. return;
  571. }
  572. LRESULT result;
  573. OnSelchanged( NULL, &result );
  574. }
  575. void
  576. LeftView::OnHostProperties()
  577. {
  578. // find tree view host member which has been selected.
  579. //
  580. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  581. TVITEM selectedItem;
  582. selectedItem.hItem = hdlSelectedItem;
  583. selectedItem.mask = TVIF_PARAM;
  584. GetTreeCtrl().GetItem( &selectedItem );
  585. // get parent cluster of the selected host member.
  586. HTREEITEM hdlParentItem;
  587. hdlParentItem = GetTreeCtrl().GetParentItem( hdlSelectedItem );
  588. TVITEM parentItem;
  589. parentItem.hItem = hdlParentItem;
  590. parentItem.mask = TVIF_PARAM;
  591. GetTreeCtrl().GetItem( &parentItem );
  592. ClusterData* p_oldSettings = (ClusterData *) parentItem.lParam;
  593. ClusterData newSettings = *( (ClusterData *) parentItem.lParam );
  594. _bstr_t machine = *( (_bstr_t *) (selectedItem.lParam));
  595. ClusterData* p_clusterData = (ClusterData *) parentItem.lParam;
  596. vector<CommonNLB::NicNLBBound> listOfNics;
  597. CommonNLB::NicNLBBound nicInfo;
  598. nicInfo.fullNicName = p_clusterData->hosts[machine].hp.nicInfo.fullNicName;
  599. nicInfo.adapterGuid = p_clusterData->hosts[machine].hp.nicInfo.adapterGuid;
  600. nicInfo.friendlyName = p_clusterData->hosts[machine].hp.nicInfo.friendlyName;
  601. nicInfo.ipsOnNic = p_clusterData->hosts[machine].hp.nicInfo.ipsOnNic;
  602. nicInfo.subnetMasks = p_clusterData->hosts[machine].hp.nicInfo.subnetMasks;
  603. nicInfo.isBoundToNLB = true;
  604. listOfNics.push_back( nicInfo );
  605. HostPage hostPage( machine,
  606. &newSettings,
  607. listOfNics,
  608. false
  609. );
  610. PortsPage portsPage( machine,
  611. &newSettings );
  612. //
  613. // fDisablePage = true
  614. //
  615. ClusterPage clusterPage( &newSettings.cp, true );
  616. _bstr_t tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_PROPERTIES_CAPTION );
  617. CPropertySheet tabbedDlg( tabbedDlgCaption );
  618. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  619. //
  620. // Display the host page first
  621. //
  622. tabbedDlg.m_psh.nStartPage = 1;
  623. tabbedDlg.AddPage( &clusterPage );
  624. tabbedDlg.AddPage( &hostPage );
  625. tabbedDlg.AddPage( &portsPage );
  626. int rc = tabbedDlg.DoModal();
  627. if( rc != IDOK )
  628. {
  629. return;
  630. }
  631. else
  632. {
  633. // clear the old status if any.
  634. dataSink( GETRESOURCEIDSTRING( IDS_INFO_LINE_SEPARATOR ) );
  635. try
  636. {
  637. CommonNLB::changeNLBHostSettings( p_oldSettings,
  638. &newSettings,
  639. machine,
  640. this );
  641. CommonNLB::changeNLBHostPortSettings( p_oldSettings,
  642. &newSettings,
  643. machine,
  644. this );
  645. *p_clusterData = newSettings;
  646. }
  647. catch( _com_error e )
  648. {
  649. _bstr_t errText;
  650. GetErrorCodeText( e.Error(), errText );
  651. dataSink( errText );
  652. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  653. }
  654. }
  655. LRESULT result;
  656. OnSelchanged( NULL, &result );
  657. }
  658. void
  659. LeftView::OnClusterRemove()
  660. {
  661. // verify once again that user really wants to remove.
  662. int userSelection = MessageBox( GETRESOURCEIDSTRING (IDS_WARNING_CLUSTER_REMOVE ),
  663. GETRESOURCEIDSTRING (IDR_MAINFRAME ),
  664. MB_YESNO | MB_ICONEXCLAMATION );
  665. if( userSelection == IDNO )
  666. {
  667. return;
  668. }
  669. // find tree view cluster member which has been selected.
  670. //
  671. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  672. TVITEM selectedItem;
  673. selectedItem.hItem = hdlSelectedItem;
  674. selectedItem.mask = TVIF_PARAM;
  675. GetTreeCtrl().GetItem( &selectedItem );
  676. ClusterData* p_clusterSettings = (ClusterData *) selectedItem.lParam;
  677. // remove cluster
  678. try
  679. {
  680. // clear the old status if any.
  681. dataSink( GETRESOURCEIDSTRING( IDS_INFO_LINE_SEPARATOR ) );
  682. CommonNLB::removeCluster( p_clusterSettings,
  683. this );
  684. // need to remove it from our view too.
  685. // and free allocated memory.
  686. GetTreeCtrl().DeleteItem( hdlSelectedItem );
  687. // deleting memory of host needs to be done.
  688. // TODO
  689. delete p_clusterSettings;
  690. // free up the memory for the all the hosts
  691. // TODO
  692. }
  693. catch( _com_error e )
  694. {
  695. _bstr_t errText;
  696. GetErrorCodeText( e.Error(), errText );
  697. dataSink( errText );
  698. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  699. }
  700. LRESULT result;
  701. OnSelchanged( NULL, &result );
  702. }
  703. void
  704. LeftView::OnClusterUnmanage()
  705. {
  706. // find tree view cluster member which has been selected.
  707. //
  708. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  709. TVITEM selectedItem;
  710. selectedItem.hItem = hdlSelectedItem;
  711. selectedItem.mask = TVIF_PARAM;
  712. GetTreeCtrl().GetItem( &selectedItem );
  713. ClusterData* p_clusterSettings = (ClusterData *) selectedItem.lParam;
  714. // need to remove it from our view
  715. // and free allocated memory.
  716. GetTreeCtrl().DeleteItem( hdlSelectedItem );
  717. // deleting memory of host needs to be done.
  718. // TODO
  719. delete p_clusterSettings;
  720. LRESULT result;
  721. OnSelchanged( NULL, &result );
  722. }
  723. void
  724. LeftView::OnClusterAddHost()
  725. {
  726. // find tree view cluster member which has been selected.
  727. //
  728. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  729. TVITEM selectedItem;
  730. selectedItem.hItem = hdlSelectedItem;
  731. selectedItem.mask = TVIF_PARAM;
  732. GetTreeCtrl().GetItem( &selectedItem );
  733. ClusterData* p_clusterSettings = (ClusterData *) selectedItem.lParam;
  734. ClusterData newSettings = *( (ClusterData *) selectedItem.lParam );
  735. // get machine which needs to be added.
  736. //
  737. _bstr_t machineToConnect;
  738. MachineConnectPage machineConnectPage( &machineToConnect );
  739. _bstr_t tabbedDlgCaptionConnect = GETRESOURCEIDSTRING( IDS_CONNECT_CAPTION );
  740. CPropertySheet tabbedDlgConnect( tabbedDlgCaptionConnect );
  741. tabbedDlgConnect.m_psh.dwFlags = tabbedDlgConnect.m_psh.dwFlags | PSH_NOAPPLYNOW;
  742. tabbedDlgConnect.AddPage( &machineConnectPage );
  743. int rc = tabbedDlgConnect.DoModal();
  744. if( rc != IDOK )
  745. {
  746. return;
  747. }
  748. // connect to machine, and find nics which are there on
  749. // this machine and which have nlb bound. Also find
  750. // server name of this machine.
  751. //
  752. dataSink( GETRESOURCEIDSTRING( IDS_INFO_LINE_SEPARATOR ) );
  753. // check if ip provided to connect is valid.
  754. bool isIPValid = MIPAddress::checkIfValid( machineToConnect );
  755. if( isIPValid == false )
  756. {
  757. // invalid ip.
  758. dataSink( GETRESOURCEIDSTRING( IDS_WARNING_IP_INVALID ) + machineToConnect );
  759. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  760. return;
  761. }
  762. // the machine ip should not be the cluster ip.
  763. if( machineToConnect == p_clusterSettings->cp.cIP )
  764. {
  765. // cluster ip and member are same.
  766. // This is not allowed.
  767. // invalid ip.
  768. dataSink( GETRESOURCEIDSTRING( IDS_WARNING_CL_CONN_SAME ) );
  769. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  770. return;
  771. }
  772. vector<CommonNLB::NicNLBBound> listOfNics;
  773. _bstr_t machineServerName;
  774. try
  775. {
  776. dataSink(
  777. GETRESOURCEIDSTRING( IDS_INFO_CONNECTING ) + machineToConnect );
  778. CommonNLB::connectToMachine(
  779. machineToConnect,
  780. machineServerName,
  781. listOfNics,
  782. this );
  783. dataSink(
  784. GETRESOURCEIDSTRING( IDS_INFO_DONE ) );
  785. }
  786. catch( _com_error e )
  787. {
  788. _bstr_t errText;
  789. GetErrorCodeText( e.Error(), errText );
  790. dataSink( errText );
  791. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  792. return;
  793. }
  794. // check if machine has any nics
  795. if( listOfNics.size() == 0 )
  796. {
  797. // no nics on this machine, then how the hell did we connect?
  798. dataSink( GETRESOURCEIDSTRING( IDS_WLBS_UNKNOWN ) );
  799. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  800. return;
  801. }
  802. // check if machine already is part of cluster.
  803. // if so we cannot add.
  804. if ( newSettings.hosts.find( machineServerName )
  805. !=
  806. newSettings.hosts.end() )
  807. {
  808. // this host is already part of the cluster
  809. // we cannot readd.
  810. dataSink( GETRESOURCEIDSTRING( IDS_HOST_ALREADY ) );
  811. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  812. return;
  813. }
  814. set<int> availHostIDS = newSettings.getAvailableHostIDS();
  815. if( availHostIDS.size() == 0 )
  816. {
  817. // no more available host ids.
  818. // max cluster size limit reached.
  819. dataSink( GETRESOURCEIDSTRING( IDS_CLUSTER_MAX ) );
  820. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  821. return;
  822. }
  823. // this machine is new
  824. // set up all defaults.
  825. //
  826. newSettings.hosts[ machineServerName ].connectionIP
  827. =
  828. machineToConnect;
  829. // need to fill in host ip and subnet.
  830. newSettings.hosts[ machineServerName ].hp.hID =
  831. *(availHostIDS.begin() );
  832. newSettings.hosts[ machineServerName ].hp.initialClusterStateActive =
  833. true;
  834. newSettings.hosts[ machineServerName ].hp.machineName =
  835. machineServerName;
  836. newSettings.hosts[ machineServerName ].hp.hIP =
  837. machineToConnect;
  838. // find subnet corresponding to machineToConnect.
  839. //
  840. _bstr_t machineToConnectSubnet;
  841. MIPAddress::getDefaultSubnetMask( machineToConnect,
  842. machineToConnectSubnet );
  843. newSettings.hosts[ machineServerName ].hp.hSubnetMask =
  844. machineToConnectSubnet;
  845. // make the nic selection to be the connection nic.
  846. //
  847. int i;
  848. for( i = 0; i < listOfNics.size(); ++i )
  849. {
  850. if( find( listOfNics[i].ipsOnNic.begin(),
  851. listOfNics[i].ipsOnNic.end(),
  852. machineToConnect )
  853. !=
  854. listOfNics[i].ipsOnNic.end() )
  855. {
  856. // connection nic found.
  857. break;
  858. }
  859. }
  860. newSettings.hosts[ machineServerName ].hp.nicInfo.fullNicName =
  861. listOfNics[i].fullNicName;
  862. newSettings.hosts[ machineServerName ].hp.nicInfo.adapterGuid =
  863. listOfNics[i].adapterGuid;
  864. newSettings.hosts[ machineServerName ].hp.nicInfo.friendlyName =
  865. listOfNics[i].friendlyName;
  866. newSettings.hosts[ machineServerName ].hp.nicInfo.ipsOnNic =
  867. listOfNics[i].ipsOnNic;
  868. newSettings.hosts[ machineServerName ].hp.nicInfo.subnetMasks =
  869. listOfNics[i].subnetMasks;
  870. // set up all port rule defaults.
  871. map<long, PortDataULB>::iterator topULB;
  872. for( topULB = newSettings.portULB.begin();
  873. topULB != newSettings.portULB.end();
  874. ++topULB )
  875. {
  876. (*topULB).second.machineMapToLoadWeight[ machineServerName ] = 50;
  877. }
  878. map<long, PortDataF>::iterator topF;
  879. for( topF = newSettings.portF.begin();
  880. topF != newSettings.portF.end();
  881. ++topF )
  882. {
  883. set<long> availPriorities = (*topF).second.getAvailablePriorities();
  884. (*topF).second.machineMapToPriority[ machineServerName ] =
  885. *(availPriorities.begin());
  886. }
  887. HostPage hostPage( machineServerName,
  888. &newSettings,
  889. listOfNics,
  890. true
  891. );
  892. PortsPage portsPage( machineServerName,
  893. &newSettings );
  894. //
  895. // fDisablePage = true
  896. //
  897. ClusterPage clusterPage( &newSettings.cp, true);
  898. _bstr_t tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_PROPERTIES_CAPTION );
  899. CPropertySheet tabbedDlg( tabbedDlgCaption );
  900. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  901. //
  902. // Display the host page first
  903. //
  904. tabbedDlg.m_psh.nStartPage = 1;
  905. tabbedDlg.AddPage( &clusterPage );
  906. tabbedDlg.AddPage( &hostPage );
  907. tabbedDlg.AddPage( &portsPage );
  908. rc = tabbedDlg.DoModal();
  909. if( rc != IDOK )
  910. {
  911. return;
  912. }
  913. try
  914. {
  915. // check if host to add has nlb bound on nic
  916. // specified.
  917. MNLBNetCfg nlbNetCfg(
  918. newSettings.hosts[machineServerName].connectionIP,
  919. newSettings.hosts[machineServerName].hp.nicInfo.fullNicName
  920. );
  921. if( nlbNetCfg.isBound() == MNLBNetCfg::BOUND )
  922. {
  923. // nlb is already bound on this machine.
  924. // ask user if he wants to really proceed.
  925. // TODO
  926. // if yes need to remove old cluster ip from
  927. // machine.
  928. _bstr_t clusterIP = Common::mapNicToClusterIP( newSettings.hosts[machineServerName].connectionIP,
  929. newSettings.hosts[machineServerName].hp.nicInfo.fullNicName );
  930. // ask user if he wants to continue.
  931. wchar_t buffer[Common::BUF_SIZE];
  932. swprintf( buffer,
  933. GETRESOURCEIDSTRING( IDS_NLB_ALREADY ),
  934. (wchar_t * ) newSettings.hosts[machineServerName].hp.nicInfo.friendlyName,
  935. (wchar_t * ) clusterIP
  936. );
  937. int ignoreWarning = MessageBox( buffer,
  938. GETRESOURCEIDSTRING( IDS_PARM_WARN ),
  939. MB_ICONEXCLAMATION | MB_YESNO );
  940. if( ignoreWarning == IDNO )
  941. {
  942. return;
  943. }
  944. dataSink(
  945. GETRESOURCEIDSTRING( IDS_NIC_BOUND ) );
  946. dataSink(
  947. GETRESOURCEIDSTRING( IDS_INFO_REMOVING_CL_IP ) );
  948. MIPAddressAdmin ipAdmin( newSettings.hosts[machineServerName].connectionIP,
  949. newSettings.hosts[machineServerName].hp.nicInfo.fullNicName );
  950. ipAdmin.deleteIPAddress( clusterIP );
  951. dataSink(
  952. GETRESOURCEIDSTRING( IDS_INFO_DONE ) );
  953. }
  954. dataSink(
  955. GETRESOURCEIDSTRING( IDS_HOST_ADDING ) );
  956. CommonNLB::addHostToCluster( &newSettings,
  957. machineServerName,
  958. this );
  959. dataSink(
  960. GETRESOURCEIDSTRING( IDS_INFO_REQUEST ) );
  961. }
  962. catch( _com_error e )
  963. {
  964. _bstr_t errText;
  965. GetErrorCodeText( e.Error(), errText );
  966. dataSink( errText );
  967. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  968. return;
  969. }
  970. // host has been added successfully, add it to nlbmanager
  971. // view.
  972. *p_clusterSettings = newSettings;
  973. TVINSERTSTRUCT item;
  974. item.hParent = hdlSelectedItem;
  975. item.hInsertAfter = TVI_LAST;
  976. item.item.mask = TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN;
  977. item.item.pszText = machineServerName;
  978. item.item.cchTextMax= machineServerName.length() + 1;
  979. item.item.iImage = 2;
  980. item.item.iSelectedImage = 2;
  981. item.item.lParam = (LPARAM ) new _bstr_t ( machineServerName );
  982. item.item.cChildren = 0;
  983. GetTreeCtrl().InsertItem( &item );
  984. GetTreeCtrl().Expand( hdlSelectedItem, TVE_EXPAND );
  985. LRESULT result;
  986. OnSelchanged( NULL, &result );
  987. }
  988. void
  989. LeftView::OnHostRemove()
  990. {
  991. // verify once again that user really wants to remove.
  992. int userSelection = MessageBox( GETRESOURCEIDSTRING (IDS_WARNING_HOST_REMOVE ),
  993. GETRESOURCEIDSTRING (IDR_MAINFRAME ),
  994. MB_YESNO | MB_ICONEXCLAMATION );
  995. if( userSelection == IDNO )
  996. {
  997. return;
  998. }
  999. // find tree view host member which has been selected.
  1000. //
  1001. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  1002. TVITEM selectedItem;
  1003. selectedItem.hItem = hdlSelectedItem;
  1004. selectedItem.mask = TVIF_PARAM;
  1005. GetTreeCtrl().GetItem( &selectedItem );
  1006. // get parent cluster of the selected host member.
  1007. HTREEITEM hdlParentItem;
  1008. hdlParentItem = GetTreeCtrl().GetParentItem( hdlSelectedItem );
  1009. TVITEM parentItem;
  1010. parentItem.hItem = hdlParentItem;
  1011. parentItem.mask = TVIF_PARAM;
  1012. GetTreeCtrl().GetItem( &parentItem );
  1013. ClusterData* p_clusterSettings = (ClusterData *) parentItem.lParam;
  1014. _bstr_t machine = *( (_bstr_t *) (selectedItem.lParam));
  1015. try
  1016. {
  1017. // clear the old status if any.
  1018. dataSink( GETRESOURCEIDSTRING( IDS_INFO_LINE_SEPARATOR ) );
  1019. CommonNLB::removeHost( p_clusterSettings,
  1020. machine,
  1021. this );
  1022. // delete this host from host list.
  1023. p_clusterSettings->hosts.erase( machine );
  1024. // delete this host from ULB and F port rules
  1025. map<long, PortDataULB>::iterator topULB;
  1026. for( topULB = p_clusterSettings->portULB.begin();
  1027. topULB != p_clusterSettings->portULB.end();
  1028. ++topULB )
  1029. {
  1030. (*topULB).second.machineMapToLoadWeight.erase( machine );
  1031. }
  1032. map<long, PortDataF>::iterator topF;
  1033. for( topF = p_clusterSettings->portF.begin();
  1034. topF != p_clusterSettings->portF.end();
  1035. ++topF )
  1036. {
  1037. (*topF).second.machineMapToPriority.erase( machine );
  1038. }
  1039. // need to remove it from our view too.
  1040. // and modify p_clusterSettings to reflect this host
  1041. // no longer present
  1042. GetTreeCtrl().DeleteItem( hdlSelectedItem );
  1043. // free up the memory for the display
  1044. delete ( (_bstr_t *) (selectedItem.lParam));
  1045. }
  1046. catch( _com_error e )
  1047. {
  1048. _bstr_t errText;
  1049. GetErrorCodeText( e.Error(), errText );
  1050. dataSink( errText );
  1051. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  1052. }
  1053. LRESULT result;
  1054. OnSelchanged( NULL, &result );
  1055. }
  1056. void
  1057. LeftView::OnClusterControl( UINT nID )
  1058. {
  1059. // find tree view cluster member which has been selected.
  1060. //
  1061. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  1062. TVITEM selectedItem;
  1063. selectedItem.hItem = hdlSelectedItem;
  1064. selectedItem.mask = TVIF_PARAM;
  1065. GetTreeCtrl().GetItem( &selectedItem );
  1066. ClusterData* p_oldSettings = (ClusterData *) selectedItem.lParam;
  1067. ClusterData newSettings = *( (ClusterData *) selectedItem.lParam );
  1068. // clear the old status if any.
  1069. dataSink( GETRESOURCEIDSTRING( IDS_INFO_LINE_SEPARATOR ) );
  1070. dataSink( L"cluster control");
  1071. try
  1072. {
  1073. switch( nID )
  1074. {
  1075. case ID_CLUSTER_EXE_QUERY :
  1076. CommonNLB::runControlMethodOnCluster( &newSettings,
  1077. this,
  1078. L"query",
  1079. 0 );
  1080. break;
  1081. case ID_CLUSTER_EXE_START :
  1082. CommonNLB::runControlMethodOnCluster( &newSettings,
  1083. this,
  1084. L"start",
  1085. 0 );
  1086. break;
  1087. case ID_CLUSTER_EXE_STOP :
  1088. CommonNLB::runControlMethodOnCluster( &newSettings,
  1089. this,
  1090. L"stop",
  1091. 0 );
  1092. break;
  1093. case ID_CLUSTER_EXE_DRAINSTOP :
  1094. CommonNLB::runControlMethodOnCluster( &newSettings,
  1095. this,
  1096. L"drainstop",
  1097. 0 );
  1098. break;
  1099. case ID_CLUSTER_EXE_RESUME :
  1100. CommonNLB::runControlMethodOnCluster( &newSettings,
  1101. this,
  1102. L"resume",
  1103. 0 );
  1104. break;
  1105. case ID_CLUSTER_EXE_SUSPEND :
  1106. CommonNLB::runControlMethodOnCluster( &newSettings,
  1107. this,
  1108. L"suspend",
  1109. 0 );
  1110. break;
  1111. default:
  1112. break;
  1113. }
  1114. dataSink(
  1115. GETRESOURCEIDSTRING( IDS_INFO_DONE ) );
  1116. }
  1117. catch( _com_error e )
  1118. {
  1119. _bstr_t errText;
  1120. GetErrorCodeText( e.Error(), errText );
  1121. dataSink( errText );
  1122. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  1123. }
  1124. LRESULT result;
  1125. OnSelchanged( NULL, &result );
  1126. }
  1127. void
  1128. LeftView::OnClusterPortControl( UINT nID )
  1129. {
  1130. // clear the old status if any.
  1131. dataSink( GETRESOURCEIDSTRING( IDS_INFO_LINE_SEPARATOR ) );
  1132. // find tree view cluster member which has been selected.
  1133. //
  1134. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  1135. TVITEM selectedItem;
  1136. selectedItem.hItem = hdlSelectedItem;
  1137. selectedItem.mask = TVIF_PARAM;
  1138. GetTreeCtrl().GetItem( &selectedItem );
  1139. ClusterData* p_clusterSettings = (ClusterData *) selectedItem.lParam;
  1140. // check if there are any ports on which
  1141. // control methods can be run.
  1142. if( ( p_clusterSettings->portELB.size() == 0 )
  1143. &&
  1144. ( p_clusterSettings->portULB.size() == 0 )
  1145. &&
  1146. ( p_clusterSettings->portD.size() == 0 )
  1147. &&
  1148. ( p_clusterSettings->portF.size() == 0 )
  1149. )
  1150. {
  1151. // there are no ports to run control method on.
  1152. dataSink(
  1153. GETRESOURCEIDSTRING( IDS_PORTS_CONTROL_NONE ) );
  1154. return;
  1155. }
  1156. unsigned long portAffected;
  1157. PortsControlPage portsControlPage( p_clusterSettings,
  1158. &portAffected );
  1159. _bstr_t tabbedDlgCaption;
  1160. switch( nID )
  1161. {
  1162. case ID_CLUSTER_EXE_ENABLE :
  1163. tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_COMMAND_ENABLE );
  1164. break;
  1165. case ID_CLUSTER_EXE_DISABLE :
  1166. tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_COMMAND_DISABLE );
  1167. break;
  1168. case ID_CLUSTER_EXE_DRAIN :
  1169. tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_COMMAND_DRAIN );
  1170. break;
  1171. default:
  1172. break;
  1173. }
  1174. CPropertySheet tabbedDlg( tabbedDlgCaption );
  1175. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  1176. tabbedDlg.AddPage( &portsControlPage );
  1177. int rc = tabbedDlg.DoModal();
  1178. if( rc != IDOK )
  1179. {
  1180. return;
  1181. }
  1182. try
  1183. {
  1184. switch( nID )
  1185. {
  1186. case ID_CLUSTER_EXE_ENABLE :
  1187. CommonNLB::runControlMethodOnCluster( p_clusterSettings,
  1188. this,
  1189. L"enable",
  1190. portAffected );
  1191. break;
  1192. case ID_CLUSTER_EXE_DISABLE :
  1193. CommonNLB::runControlMethodOnCluster( p_clusterSettings,
  1194. this,
  1195. L"disable",
  1196. portAffected );
  1197. break;
  1198. case ID_CLUSTER_EXE_DRAIN :
  1199. CommonNLB::runControlMethodOnCluster( p_clusterSettings,
  1200. this,
  1201. L"drain",
  1202. portAffected );
  1203. break;
  1204. default:
  1205. break;
  1206. }
  1207. dataSink(
  1208. GETRESOURCEIDSTRING( IDS_INFO_DONE ) );
  1209. }
  1210. catch( _com_error e )
  1211. {
  1212. _bstr_t errText;
  1213. GetErrorCodeText( e.Error(), errText );
  1214. dataSink( errText );
  1215. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  1216. }
  1217. LRESULT result;
  1218. OnSelchanged( NULL, &result );
  1219. }
  1220. void
  1221. LeftView::OnHostControl( UINT nID )
  1222. {
  1223. // find tree view host member which has been selected.
  1224. //
  1225. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  1226. TVITEM selectedItem;
  1227. selectedItem.hItem = hdlSelectedItem;
  1228. selectedItem.mask = TVIF_PARAM;
  1229. GetTreeCtrl().GetItem( &selectedItem );
  1230. // get parent cluster of the selected host member.
  1231. HTREEITEM hdlParentItem;
  1232. hdlParentItem = GetTreeCtrl().GetParentItem( hdlSelectedItem );
  1233. TVITEM parentItem;
  1234. parentItem.hItem = hdlParentItem;
  1235. parentItem.mask = TVIF_PARAM;
  1236. GetTreeCtrl().GetItem( &parentItem );
  1237. ClusterData* p_oldSettings = (ClusterData *) parentItem.lParam;
  1238. ClusterData newSettings = *( (ClusterData *) parentItem.lParam );
  1239. _bstr_t machine = *( (_bstr_t *) (selectedItem.lParam));
  1240. ClusterData* p_clusterData = (ClusterData *) parentItem.lParam;
  1241. // clear the old status if any.
  1242. dataSink( GETRESOURCEIDSTRING( IDS_INFO_LINE_SEPARATOR ) );
  1243. dataSink( L"host control");
  1244. try
  1245. {
  1246. switch( nID )
  1247. {
  1248. case ID_HOST_EXE_QUERY :
  1249. CommonNLB::runControlMethodOnHost( &newSettings,
  1250. machine,
  1251. this,
  1252. L"query",
  1253. 0 );
  1254. break;
  1255. case ID_HOST_EXE_START :
  1256. CommonNLB::runControlMethodOnHost( &newSettings,
  1257. machine,
  1258. this,
  1259. L"start",
  1260. 0 );
  1261. break;
  1262. case ID_HOST_EXE_STOP :
  1263. CommonNLB::runControlMethodOnHost( &newSettings,
  1264. machine,
  1265. this,
  1266. L"stop",
  1267. 0 );
  1268. break;
  1269. case ID_HOST_EXE_DRAINSTOP :
  1270. CommonNLB::runControlMethodOnHost( &newSettings,
  1271. machine,
  1272. this,
  1273. L"drainstop",
  1274. 0 );
  1275. break;
  1276. case ID_HOST_EXE_RESUME :
  1277. CommonNLB::runControlMethodOnHost( &newSettings,
  1278. machine,
  1279. this,
  1280. L"resume",
  1281. 0 );
  1282. break;
  1283. case ID_HOST_EXE_SUSPEND :
  1284. CommonNLB::runControlMethodOnHost( &newSettings,
  1285. machine,
  1286. this,
  1287. L"suspend",
  1288. 0 );
  1289. break;
  1290. default:
  1291. break;
  1292. }
  1293. dataSink(
  1294. GETRESOURCEIDSTRING( IDS_INFO_DONE ) );
  1295. }
  1296. catch( _com_error e )
  1297. {
  1298. _bstr_t errText;
  1299. GetErrorCodeText( e.Error(), errText );
  1300. dataSink( errText );
  1301. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  1302. }
  1303. LRESULT result;
  1304. OnSelchanged( NULL, &result );
  1305. }
  1306. void
  1307. LeftView::OnHostPortControl( UINT nID )
  1308. {
  1309. // clear the old status if any.
  1310. dataSink( GETRESOURCEIDSTRING( IDS_INFO_LINE_SEPARATOR ) );
  1311. //
  1312. HTREEITEM hdlSelectedItem = GetTreeCtrl().GetSelectedItem();
  1313. TVITEM selectedItem;
  1314. selectedItem.hItem = hdlSelectedItem;
  1315. selectedItem.mask = TVIF_PARAM;
  1316. GetTreeCtrl().GetItem( &selectedItem );
  1317. // get parent cluster of the selected host member.
  1318. HTREEITEM hdlParentItem;
  1319. hdlParentItem = GetTreeCtrl().GetParentItem( hdlSelectedItem );
  1320. TVITEM parentItem;
  1321. parentItem.hItem = hdlParentItem;
  1322. parentItem.mask = TVIF_PARAM;
  1323. GetTreeCtrl().GetItem( &parentItem );
  1324. ClusterData* p_clusterSettings = (ClusterData *) parentItem.lParam;
  1325. // check if there are any ports on which
  1326. // control methods can be run.
  1327. if( ( p_clusterSettings->portELB.size() == 0 )
  1328. &&
  1329. ( p_clusterSettings->portULB.size() == 0 )
  1330. &&
  1331. ( p_clusterSettings->portD.size() == 0 )
  1332. &&
  1333. ( p_clusterSettings->portF.size() == 0 )
  1334. )
  1335. {
  1336. // there are no ports to run control method on.
  1337. dataSink(
  1338. GETRESOURCEIDSTRING( IDS_PORTS_CONTROL_NONE ) );
  1339. return;
  1340. }
  1341. _bstr_t machine = *( (_bstr_t *) (selectedItem.lParam));
  1342. unsigned long portAffected;
  1343. PortsControlPage portsControlPage( p_clusterSettings,
  1344. &portAffected );
  1345. _bstr_t tabbedDlgCaption;
  1346. switch( nID )
  1347. {
  1348. case ID_HOST_EXE_ENABLE :
  1349. tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_COMMAND_ENABLE );
  1350. break;
  1351. case ID_HOST_EXE_DISABLE :
  1352. tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_COMMAND_DISABLE );
  1353. break;
  1354. case ID_HOST_EXE_DRAIN :
  1355. tabbedDlgCaption = GETRESOURCEIDSTRING( IDS_COMMAND_DRAIN );
  1356. break;
  1357. default:
  1358. break;
  1359. }
  1360. CPropertySheet tabbedDlg( tabbedDlgCaption );
  1361. tabbedDlg.m_psh.dwFlags = tabbedDlg.m_psh.dwFlags | PSH_NOAPPLYNOW;
  1362. tabbedDlg.AddPage( &portsControlPage );
  1363. int rc = tabbedDlg.DoModal();
  1364. if( rc != IDOK )
  1365. {
  1366. return;
  1367. }
  1368. try
  1369. {
  1370. switch( nID )
  1371. {
  1372. case ID_HOST_EXE_ENABLE :
  1373. CommonNLB::runControlMethodOnHost( p_clusterSettings,
  1374. machine,
  1375. this,
  1376. L"enable",
  1377. portAffected );
  1378. break;
  1379. case ID_HOST_EXE_DISABLE :
  1380. CommonNLB::runControlMethodOnHost( p_clusterSettings,
  1381. machine,
  1382. this,
  1383. L"disable",
  1384. portAffected );
  1385. break;
  1386. case ID_HOST_EXE_DRAIN :
  1387. CommonNLB::runControlMethodOnHost( p_clusterSettings,
  1388. machine,
  1389. this,
  1390. L"drain",
  1391. portAffected );
  1392. break;
  1393. default:
  1394. break;
  1395. }
  1396. dataSink(
  1397. GETRESOURCEIDSTRING( IDS_INFO_DONE ) );
  1398. }
  1399. catch( _com_error e )
  1400. {
  1401. _bstr_t errText;
  1402. GetErrorCodeText( e.Error(), errText );
  1403. dataSink( errText );
  1404. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  1405. }
  1406. LRESULT result;
  1407. OnSelchanged( NULL, &result );
  1408. }
  1409. void
  1410. LeftView::dataSink( _bstr_t data )
  1411. {
  1412. dataStore += data;
  1413. dataStore += GETRESOURCEIDSTRING( IDS_INFO_NEWLINE );
  1414. GetDocument()->getStatusPane().SetWindowText( title +
  1415. dataStore );
  1416. // scroll
  1417. int numLines = GetDocument()->getStatusPane().GetLineCount();
  1418. GetDocument()->getStatusPane().LineScroll( numLines - 1);
  1419. UpdateWindow();
  1420. }
  1421. void
  1422. LeftView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
  1423. {
  1424. BOOL rcBOOL;
  1425. // get selected item.
  1426. //
  1427. HTREEITEM hdlSelItem;
  1428. hdlSelItem = GetTreeCtrl().GetSelectedItem();
  1429. TVITEM selItem;
  1430. selItem.hItem = hdlSelItem;
  1431. selItem.mask = TVIF_PARAM | TVIF_IMAGE;
  1432. GetTreeCtrl().GetItem( &selItem );
  1433. // delete all previous items.
  1434. //
  1435. GetDocument()->getListPane().DeleteAllItems();
  1436. // Delete all of the previous columns.
  1437. int nColumnCount =
  1438. GetDocument()->getListPane().GetHeaderCtrl()->GetItemCount();
  1439. for (int i = 0; i < nColumnCount; i++)
  1440. {
  1441. GetDocument()->getListPane().DeleteColumn(0);
  1442. }
  1443. int index = 0;
  1444. map<bstr_t, HostData>::iterator top;
  1445. ClusterData* p_clusterData;
  1446. CWnd* pMain = AfxGetMainWnd();
  1447. CMenu* pMenu = pMain->GetMenu();
  1448. CMenu* subMenu;
  1449. UINT retValue;
  1450. BOOL retBool;
  1451. switch( selItem.iImage )
  1452. {
  1453. case 0:
  1454. // this is root icon.
  1455. // disable all commands at cluster and host level.
  1456. // cluster menu
  1457. subMenu = pMenu->GetSubMenu( 1 );
  1458. retValue = subMenu->EnableMenuItem( ID_CLUSTER_ADD_HOST,
  1459. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1460. retValue = subMenu->EnableMenuItem( ID_CLUSTER_REMOVE,
  1461. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1462. retValue = subMenu->EnableMenuItem( ID_CLUSTER_PROPERTIES,
  1463. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1464. retValue = subMenu->EnableMenuItem( ID_REFRESH,
  1465. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1466. retValue = subMenu->EnableMenuItem( ID_CLUSTER_UNMANAGE,
  1467. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1468. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_QUERY,
  1469. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1470. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_START,
  1471. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1472. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_STOP,
  1473. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1474. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_DRAINSTOP,
  1475. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1476. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_RESUME,
  1477. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1478. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_SUSPEND,
  1479. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1480. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_SUSPEND,
  1481. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1482. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_ENABLE,
  1483. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1484. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_DISABLE,
  1485. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1486. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_DRAIN,
  1487. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1488. // host menu
  1489. subMenu = pMenu->GetSubMenu( 2 );
  1490. retValue = subMenu->EnableMenuItem( ID_HOST_REMOVE,
  1491. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1492. retValue = subMenu->EnableMenuItem( ID_HOST_PROPERTIES,
  1493. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1494. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_QUERY,
  1495. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1496. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_START,
  1497. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1498. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_STOP,
  1499. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1500. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_DRAINSTOP,
  1501. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1502. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_RESUME,
  1503. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1504. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_SUSPEND,
  1505. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1506. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_SUSPEND,
  1507. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1508. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_ENABLE,
  1509. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1510. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_DISABLE,
  1511. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1512. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_DRAIN,
  1513. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1514. pMain->DrawMenuBar();
  1515. GetDocument()->getListPane().InsertColumn( 0,
  1516. GETRESOURCEIDSTRING( IDS_HEADER_C_IP ) ,
  1517. LVCFMT_LEFT,
  1518. Document::LV_COLUMN_LARGE );
  1519. GetDocument()->getListPane().InsertColumn( 1,
  1520. GETRESOURCEIDSTRING( IDS_HEADER_C_SUBNET ),
  1521. LVCFMT_LEFT,
  1522. Document::LV_COLUMN_LARGE );
  1523. GetDocument()->getListPane().InsertColumn( 2,
  1524. GETRESOURCEIDSTRING( IDS_HEADER_INTERNET_NAME ),
  1525. LVCFMT_LEFT,
  1526. Document::LV_COLUMN_LARGE );
  1527. GetDocument()->getListPane().InsertColumn( 3,
  1528. GETRESOURCEIDSTRING( IDS_HEADER_MAC_ADDRESS ),
  1529. LVCFMT_LEFT,
  1530. Document::LV_COLUMN_LARGE );
  1531. GetDocument()->getListPane().InsertColumn( 4,
  1532. GETRESOURCEIDSTRING( IDS_HEADER_C_MODE ),
  1533. LVCFMT_LEFT,
  1534. Document::LV_COLUMN_LARGE );
  1535. GetDocument()->getListPane().InsertColumn( 5,
  1536. GETRESOURCEIDSTRING( IDS_HEADER_REMOTE_CTRL ),
  1537. LVCFMT_LEFT,
  1538. Document::LV_COLUMN_SMALL );
  1539. // get children of the selected item.
  1540. if( GetTreeCtrl().ItemHasChildren( hdlSelItem ) )
  1541. {
  1542. HTREEITEM hNextItem;
  1543. HTREEITEM hChildItem = GetTreeCtrl().GetChildItem( hdlSelItem );
  1544. index = 0;
  1545. while( hChildItem != NULL )
  1546. {
  1547. hNextItem = GetTreeCtrl().GetNextItem( hChildItem, TVGN_NEXT );
  1548. selItem.hItem = hChildItem;
  1549. selItem.mask = TVIF_PARAM;
  1550. GetTreeCtrl().GetItem( &selItem );
  1551. p_clusterData = (ClusterData *) selItem.lParam;
  1552. LVITEM item;
  1553. item.mask = LVIF_TEXT | LVIF_IMAGE;
  1554. item.iItem = index;
  1555. item.iSubItem = 0;
  1556. item.iImage = 1;
  1557. item.pszText = p_clusterData->cp.cIP;
  1558. item.cchTextMax = p_clusterData->cp.cIP.length() + 1;
  1559. GetDocument()->getListPane().InsertItem( &item );
  1560. item.mask = LVIF_TEXT;
  1561. item.iItem = index;
  1562. item.iSubItem = 1;
  1563. item.pszText = p_clusterData->cp.cSubnetMask;
  1564. item.cchTextMax = p_clusterData->cp.cSubnetMask.length() + 1;
  1565. GetDocument()->getListPane().SetItem( &item );
  1566. item.mask = LVIF_TEXT;
  1567. item.iItem = index;
  1568. item.iSubItem = 2;
  1569. item.pszText = p_clusterData->cp.cFullInternetName;
  1570. item.cchTextMax = p_clusterData->cp.cFullInternetName.length() + 1;
  1571. GetDocument()->getListPane().SetItem( &item );
  1572. item.mask = LVIF_TEXT;
  1573. item.iItem = index;
  1574. item.iSubItem = 3;
  1575. item.pszText = p_clusterData->cp.cNetworkAddress;
  1576. item.cchTextMax = p_clusterData->cp.cNetworkAddress.length() + 1;
  1577. GetDocument()->getListPane().SetItem( &item );
  1578. item.mask = LVIF_TEXT;
  1579. item.iItem = index;
  1580. item.iSubItem = 4;
  1581. if( p_clusterData->cp.multicastSupportEnabled
  1582. &&
  1583. p_clusterData->cp.igmpSupportEnabled )
  1584. {
  1585. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_IGMP );
  1586. }
  1587. else if( p_clusterData->cp.multicastSupportEnabled )
  1588. {
  1589. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_MULTICAST );
  1590. }
  1591. else
  1592. {
  1593. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_UNICAST );
  1594. }
  1595. item.cchTextMax = 100;
  1596. GetDocument()->getListPane().SetItem( &item );
  1597. item.mask = LVIF_TEXT;
  1598. item.iItem = index;
  1599. item.iSubItem = 5;
  1600. if( p_clusterData->cp.remoteControlEnabled )
  1601. {
  1602. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_ON );
  1603. }
  1604. else
  1605. {
  1606. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_OFF );
  1607. }
  1608. item.cchTextMax = 100;
  1609. GetDocument()->getListPane().SetItem( &item );
  1610. hChildItem = hNextItem;
  1611. ++index;
  1612. }
  1613. }
  1614. break;
  1615. case 1:
  1616. // this is some cluster
  1617. // enable all commands at cluster level menu.
  1618. // disable all commands at host level.
  1619. // cluster menu
  1620. subMenu = pMenu->GetSubMenu( 1 );
  1621. retValue = subMenu->EnableMenuItem( ID_CLUSTER_ADD_HOST,
  1622. MF_BYCOMMAND | MF_ENABLED );
  1623. retValue = subMenu->EnableMenuItem( ID_CLUSTER_REMOVE,
  1624. MF_BYCOMMAND | MF_ENABLED );
  1625. retValue = subMenu->EnableMenuItem( ID_CLUSTER_PROPERTIES,
  1626. MF_BYCOMMAND | MF_ENABLED );
  1627. retValue = subMenu->EnableMenuItem( ID_REFRESH,
  1628. MF_BYCOMMAND | MF_ENABLED );
  1629. retValue = subMenu->EnableMenuItem( ID_CLUSTER_UNMANAGE,
  1630. MF_BYCOMMAND | MF_ENABLED );
  1631. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_QUERY,
  1632. MF_BYCOMMAND | MF_ENABLED);
  1633. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_START,
  1634. MF_BYCOMMAND | MF_ENABLED);
  1635. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_STOP,
  1636. MF_BYCOMMAND | MF_ENABLED);
  1637. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_DRAINSTOP,
  1638. MF_BYCOMMAND | MF_ENABLED);
  1639. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_RESUME,
  1640. MF_BYCOMMAND | MF_ENABLED);
  1641. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_SUSPEND,
  1642. MF_BYCOMMAND | MF_ENABLED);
  1643. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_SUSPEND,
  1644. MF_BYCOMMAND | MF_ENABLED);
  1645. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_ENABLE,
  1646. MF_BYCOMMAND | MF_ENABLED);
  1647. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_DISABLE,
  1648. MF_BYCOMMAND | MF_ENABLED);
  1649. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_DRAIN,
  1650. MF_BYCOMMAND | MF_ENABLED);
  1651. // host menu
  1652. subMenu = pMenu->GetSubMenu( 2 );
  1653. retValue = subMenu->EnableMenuItem( ID_HOST_REMOVE,
  1654. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1655. retValue = subMenu->EnableMenuItem( ID_HOST_PROPERTIES,
  1656. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1657. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_QUERY,
  1658. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1659. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_START,
  1660. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1661. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_STOP,
  1662. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1663. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_DRAINSTOP,
  1664. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1665. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_RESUME,
  1666. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1667. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_SUSPEND,
  1668. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1669. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_SUSPEND,
  1670. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1671. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_ENABLE,
  1672. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1673. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_DISABLE,
  1674. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1675. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_DRAIN,
  1676. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1677. pMain->DrawMenuBar();
  1678. GetDocument()->getListPane().InsertColumn( 0,
  1679. GETRESOURCEIDSTRING( IDS_HEADER_MACHINE ) ,
  1680. LVCFMT_LEFT,
  1681. Document::LV_COLUMN_LARGE );
  1682. GetDocument()->getListPane().InsertColumn( 1,
  1683. GETRESOURCEIDSTRING( IDS_HEADER_D_IP ) ,
  1684. LVCFMT_LEFT,
  1685. Document::LV_COLUMN_LARGE );
  1686. GetDocument()->getListPane().InsertColumn( 2,
  1687. GETRESOURCEIDSTRING( IDS_HEADER_D_SUBNET ),
  1688. LVCFMT_LEFT,
  1689. Document::LV_COLUMN_LARGE );
  1690. GetDocument()->getListPane().InsertColumn( 3,
  1691. GETRESOURCEIDSTRING( IDS_HEADER_PRIORITY ),
  1692. LVCFMT_LEFT,
  1693. Document::LV_COLUMN_SMALL );
  1694. GetDocument()->getListPane().InsertColumn( 4,
  1695. GETRESOURCEIDSTRING( IDS_HEADER_INITIAL_STATE ),
  1696. LVCFMT_LEFT,
  1697. Document::LV_COLUMN_SMALL );
  1698. GetDocument()->getListPane().InsertColumn( 5,
  1699. GETRESOURCEIDSTRING( IDS_HEADER_NIC ),
  1700. LVCFMT_LEFT,
  1701. Document::LV_COLUMN_LARGE );
  1702. p_clusterData =
  1703. (ClusterData *) selItem.lParam;
  1704. index = 0;
  1705. for( top = p_clusterData->hosts.begin();
  1706. top != p_clusterData->hosts.end();
  1707. ++top )
  1708. {
  1709. LVITEM item;
  1710. item.mask = LVIF_TEXT | LVIF_IMAGE;
  1711. item.iItem = index;
  1712. item.iSubItem = 0;
  1713. item.iImage = 2;
  1714. item.pszText = (*top).second.hp.machineName;
  1715. item.cchTextMax = (*top).second.hp.machineName.length() + 1;
  1716. GetDocument()->getListPane().InsertItem( &item );
  1717. item.mask = LVIF_TEXT;
  1718. item.iItem = index;
  1719. item.iSubItem = 1;
  1720. item.pszText = (*top).second.hp.hIP;
  1721. item.cchTextMax = (*top).second.hp.hIP.length() + 1;
  1722. GetDocument()->getListPane().SetItem( &item );
  1723. item.mask = LVIF_TEXT;
  1724. item.iItem = index;
  1725. item.iSubItem = 2;
  1726. item.pszText = (*top).second.hp.hSubnetMask;
  1727. item.cchTextMax = (*top).second.hp.hSubnetMask.length() + 1;
  1728. GetDocument()->getListPane().SetItem( &item );
  1729. item.mask = LVIF_TEXT;
  1730. item.iItem = index;
  1731. item.iSubItem = 3;
  1732. wchar_t buf[Common::BUF_SIZE];
  1733. swprintf( buf, L"%d", (*top).second.hp.hID );
  1734. item.pszText = buf;
  1735. item.cchTextMax = 100;
  1736. GetDocument()->getListPane().SetItem( &item );
  1737. item.mask = LVIF_TEXT;
  1738. item.iItem = index;
  1739. item.iSubItem = 4;
  1740. if( (*top).second.hp.initialClusterStateActive )
  1741. {
  1742. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_ON );
  1743. }
  1744. else
  1745. {
  1746. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_OFF );
  1747. }
  1748. item.cchTextMax = 100;
  1749. GetDocument()->getListPane().SetItem( &item );
  1750. item.mask = LVIF_TEXT;
  1751. item.iItem = index;
  1752. item.iSubItem = 5;
  1753. item.pszText = (*top).second.hp.nicInfo.friendlyName;
  1754. item.cchTextMax = (*top).second.hp.nicInfo.fullNicName.length() + 1;
  1755. GetDocument()->getListPane().SetItem( &item );
  1756. ++index;
  1757. }
  1758. break;
  1759. case 2:
  1760. // this is some node.
  1761. // disable all commands at cluster level.
  1762. // enable all commands at host level.
  1763. // cluster menu
  1764. subMenu = pMenu->GetSubMenu( 1 );
  1765. retValue = subMenu->EnableMenuItem( ID_CLUSTER_ADD_HOST,
  1766. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1767. retValue = subMenu->EnableMenuItem( ID_CLUSTER_REMOVE,
  1768. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1769. retValue = subMenu->EnableMenuItem( ID_CLUSTER_PROPERTIES,
  1770. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1771. retValue = subMenu->EnableMenuItem( ID_REFRESH,
  1772. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1773. retValue = subMenu->EnableMenuItem( ID_CLUSTER_UNMANAGE,
  1774. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1775. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_QUERY,
  1776. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1777. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_START,
  1778. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1779. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_STOP,
  1780. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1781. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_DRAINSTOP,
  1782. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1783. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_RESUME,
  1784. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1785. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_SUSPEND,
  1786. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1787. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_SUSPEND,
  1788. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1789. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_ENABLE,
  1790. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1791. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_DISABLE,
  1792. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1793. retValue = subMenu->EnableMenuItem( ID_CLUSTER_EXE_DRAIN,
  1794. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  1795. // host menu
  1796. subMenu = pMenu->GetSubMenu( 2 );
  1797. retValue = subMenu->EnableMenuItem( ID_HOST_REMOVE,
  1798. MF_BYCOMMAND | MF_ENABLED );
  1799. retValue = subMenu->EnableMenuItem( ID_HOST_PROPERTIES,
  1800. MF_BYCOMMAND | MF_ENABLED );
  1801. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_QUERY,
  1802. MF_BYCOMMAND | MF_ENABLED);
  1803. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_START,
  1804. MF_BYCOMMAND | MF_ENABLED);
  1805. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_STOP,
  1806. MF_BYCOMMAND | MF_ENABLED);
  1807. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_DRAINSTOP,
  1808. MF_BYCOMMAND | MF_ENABLED);
  1809. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_RESUME,
  1810. MF_BYCOMMAND | MF_ENABLED);
  1811. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_SUSPEND,
  1812. MF_BYCOMMAND | MF_ENABLED);
  1813. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_SUSPEND,
  1814. MF_BYCOMMAND | MF_ENABLED);
  1815. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_ENABLE,
  1816. MF_BYCOMMAND | MF_ENABLED);
  1817. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_DISABLE,
  1818. MF_BYCOMMAND | MF_ENABLED);
  1819. retValue = subMenu->EnableMenuItem( ID_HOST_EXE_DRAIN,
  1820. MF_BYCOMMAND | MF_ENABLED);
  1821. pMain->DrawMenuBar();
  1822. GetDocument()->getListPane().InsertColumn( 0,
  1823. GETRESOURCEIDSTRING( IDS_HEADER_P_START ) ,
  1824. LVCFMT_LEFT,
  1825. Document::LV_COLUMN_SMALL );
  1826. GetDocument()->getListPane().InsertColumn( 1,
  1827. GETRESOURCEIDSTRING( IDS_HEADER_P_END ),
  1828. LVCFMT_LEFT,
  1829. Document::LV_COLUMN_SMALL );
  1830. GetDocument()->getListPane().InsertColumn( 2,
  1831. GETRESOURCEIDSTRING( IDS_HEADER_P_PROTOCOL ),
  1832. LVCFMT_LEFT,
  1833. Document::LV_COLUMN_SMALL );
  1834. GetDocument()->getListPane().InsertColumn( 3,
  1835. GETRESOURCEIDSTRING( IDS_HEADER_P_MODE ),
  1836. LVCFMT_LEFT,
  1837. Document::LV_COLUMN_SMALL );
  1838. GetDocument()->getListPane().InsertColumn( 4,
  1839. GETRESOURCEIDSTRING( IDS_HEADER_P_PRIORITY ),
  1840. LVCFMT_LEFT,
  1841. Document::LV_COLUMN_SMALL );
  1842. GetDocument()->getListPane().InsertColumn( 5,
  1843. GETRESOURCEIDSTRING( IDS_HEADER_P_LOAD ),
  1844. LVCFMT_LEFT,
  1845. Document::LV_COLUMN_SMALL );
  1846. GetDocument()->getListPane().InsertColumn( 6,
  1847. GETRESOURCEIDSTRING( IDS_HEADER_P_AFFINITY ),
  1848. LVCFMT_LEFT,
  1849. Document::LV_COLUMN_SMALL );
  1850. // get parent cluster of the selected host member.
  1851. HTREEITEM hdlParentItem;
  1852. hdlParentItem = GetTreeCtrl().GetParentItem( hdlSelItem );
  1853. TVITEM parentItem;
  1854. parentItem.hItem = hdlParentItem;
  1855. parentItem.mask = TVIF_PARAM;
  1856. GetTreeCtrl().GetItem( &parentItem );
  1857. ClusterData* p_clusterSettings = const_cast<ClusterData *> ( (ClusterData *) parentItem.lParam );
  1858. _bstr_t machine = *( (_bstr_t *) (selItem.lParam));
  1859. wchar_t buf[Common::BUF_SIZE];
  1860. index = 0;
  1861. map< long, PortDataELB>::iterator topELB;
  1862. for( topELB = p_clusterSettings->portELB.begin();
  1863. topELB != p_clusterSettings->portELB.end();
  1864. ++topELB )
  1865. {
  1866. // start port
  1867. swprintf( buf, L"%d", (*topELB).second._startPort );
  1868. LVITEM item;
  1869. item.mask = LVIF_TEXT | LVIF_IMAGE;;
  1870. item.iItem = index;
  1871. item.iSubItem = 0;
  1872. item.iImage = 4;
  1873. item.pszText = buf;
  1874. item.cchTextMax = 100;
  1875. GetDocument()->getListPane().InsertItem( &item );
  1876. // end port
  1877. swprintf( buf, L"%d", (*topELB).second._endPort );
  1878. item.mask = LVIF_TEXT;
  1879. item.iItem = index;
  1880. item.iSubItem = 1;
  1881. item.pszText = buf;
  1882. item.cchTextMax = 100;
  1883. GetDocument()->getListPane().SetItem( &item );
  1884. // protocol
  1885. item.mask = LVIF_TEXT;
  1886. item.iItem = index;
  1887. item.iSubItem = 2;
  1888. switch( (*topELB).second._trafficToHandle )
  1889. {
  1890. case MNLBPortRule::both :
  1891. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_BOTH );
  1892. break;
  1893. case MNLBPortRule::tcp :
  1894. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_TCP );
  1895. break;
  1896. case MNLBPortRule::udp :
  1897. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_UDP );
  1898. break;
  1899. }
  1900. item.cchTextMax = 100;
  1901. GetDocument()->getListPane().SetItem( &item );
  1902. // mode
  1903. item.mask = LVIF_TEXT;
  1904. item.iItem = index;
  1905. item.iSubItem = 3;
  1906. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE );
  1907. item.cchTextMax = 100;
  1908. GetDocument()->getListPane().SetItem( &item );
  1909. // priority
  1910. item.mask = LVIF_TEXT;
  1911. item.iItem = index;
  1912. item.iSubItem = 4;
  1913. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY );
  1914. item.cchTextMax = 100;
  1915. GetDocument()->getListPane().SetItem( &item );
  1916. // load
  1917. item.mask = LVIF_TEXT;
  1918. item.iItem = index;
  1919. item.iSubItem = 5;
  1920. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_LOAD_EQUAL );
  1921. item.cchTextMax = 100;
  1922. GetDocument()->getListPane().SetItem( &item );
  1923. // affinity
  1924. item.mask = LVIF_TEXT;
  1925. item.iItem = index;
  1926. item.iSubItem = 6;
  1927. switch( (*topELB).second._affinity )
  1928. {
  1929. case MNLBPortRule::none :
  1930. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_NONE );
  1931. break;
  1932. case MNLBPortRule::single :
  1933. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_SINGLE );
  1934. break;
  1935. case MNLBPortRule::classC :
  1936. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_CLASSC );
  1937. break;
  1938. }
  1939. item.cchTextMax = 100;
  1940. GetDocument()->getListPane().SetItem( &item );
  1941. ++index;
  1942. }
  1943. index = 0;
  1944. map< long, PortDataULB>::iterator topULB;
  1945. for( topULB = p_clusterSettings->portULB.begin();
  1946. topULB != p_clusterSettings->portULB.end();
  1947. ++topULB )
  1948. {
  1949. // start port
  1950. swprintf( buf, L"%d", (*topULB).second._startPort );
  1951. LVITEM item;
  1952. item.mask = LVIF_TEXT | LVIF_IMAGE;
  1953. item.iItem = index;
  1954. item.iSubItem = 0;
  1955. item.iImage = 4;
  1956. item.pszText = buf;
  1957. item.cchTextMax = 100;
  1958. GetDocument()->getListPane().InsertItem( &item );
  1959. // end port
  1960. swprintf( buf, L"%d", (*topULB).second._endPort );
  1961. item.mask = LVIF_TEXT;
  1962. item.iItem = index;
  1963. item.iSubItem = 1;
  1964. item.pszText = buf;
  1965. item.cchTextMax = 100;
  1966. GetDocument()->getListPane().SetItem( &item );
  1967. // protocol
  1968. item.mask = LVIF_TEXT;
  1969. item.iItem = index;
  1970. item.iSubItem = 2;
  1971. switch( (*topULB).second._trafficToHandle )
  1972. {
  1973. case MNLBPortRule::both :
  1974. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_BOTH );
  1975. break;
  1976. case MNLBPortRule::tcp :
  1977. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_TCP );
  1978. break;
  1979. case MNLBPortRule::udp :
  1980. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_UDP );
  1981. break;
  1982. }
  1983. item.cchTextMax = 100;
  1984. GetDocument()->getListPane().SetItem( &item );
  1985. // mode
  1986. item.mask = LVIF_TEXT;
  1987. item.iItem = index;
  1988. item.iSubItem = 3;
  1989. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_MODE_MULTIPLE );
  1990. item.cchTextMax = 100;
  1991. GetDocument()->getListPane().SetItem( &item );
  1992. // priority
  1993. item.mask = LVIF_TEXT;
  1994. item.iItem = index;
  1995. item.iSubItem = 4;
  1996. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY );
  1997. item.cchTextMax = 100;
  1998. GetDocument()->getListPane().SetItem( &item );
  1999. // load
  2000. item.mask = LVIF_TEXT;
  2001. item.iItem = index;
  2002. item.iSubItem = 5;
  2003. swprintf( buf, L"%d", (*topULB).second.machineMapToLoadWeight[machine] );
  2004. item.pszText = buf;
  2005. item.cchTextMax = 100;
  2006. GetDocument()->getListPane().SetItem( &item );
  2007. // affinity
  2008. item.mask = LVIF_TEXT;
  2009. item.iItem = index;
  2010. item.iSubItem = 6;
  2011. switch( (*topULB).second._affinity )
  2012. {
  2013. case MNLBPortRule::none :
  2014. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_NONE );
  2015. break;
  2016. case MNLBPortRule::single :
  2017. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_SINGLE );
  2018. break;
  2019. case MNLBPortRule::classC :
  2020. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_AFFINITY_CLASSC );
  2021. break;
  2022. }
  2023. item.cchTextMax = 100;
  2024. GetDocument()->getListPane().SetItem( &item );
  2025. ++index;
  2026. }
  2027. index = 0;
  2028. map< long, PortDataF>::iterator topF;
  2029. for( topF = p_clusterSettings->portF.begin();
  2030. topF != p_clusterSettings->portF.end();
  2031. ++topF )
  2032. {
  2033. // start port
  2034. swprintf( buf, L"%d", (*topF).second._startPort );
  2035. LVITEM item;
  2036. item.mask = LVIF_TEXT | LVIF_IMAGE;
  2037. item.iItem = index;
  2038. item.iSubItem = 0;
  2039. item.iImage = 4;
  2040. item.pszText = buf;
  2041. item.cchTextMax = 100;
  2042. GetDocument()->getListPane().InsertItem( &item );
  2043. // end port
  2044. swprintf( buf, L"%d", (*topF).second._endPort );
  2045. item.mask = LVIF_TEXT;
  2046. item.iItem = index;
  2047. item.iSubItem = 1;
  2048. item.pszText = buf;
  2049. item.cchTextMax = 100;
  2050. GetDocument()->getListPane().SetItem( &item );
  2051. // protocol
  2052. item.mask = LVIF_TEXT;
  2053. item.iItem = index;
  2054. item.iSubItem = 2;
  2055. switch( (*topF).second._trafficToHandle )
  2056. {
  2057. case MNLBPortRule::both :
  2058. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_BOTH );
  2059. break;
  2060. case MNLBPortRule::tcp :
  2061. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_TCP );
  2062. break;
  2063. case MNLBPortRule::udp :
  2064. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_UDP );
  2065. break;
  2066. }
  2067. item.cchTextMax = 100;
  2068. GetDocument()->getListPane().SetItem( &item );
  2069. // mode
  2070. item.mask = LVIF_TEXT;
  2071. item.iItem = index;
  2072. item.iSubItem = 3;
  2073. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_MODE_SINGLE );
  2074. item.cchTextMax = 100;
  2075. GetDocument()->getListPane().SetItem( &item );
  2076. // priority
  2077. item.mask = LVIF_TEXT;
  2078. item.iItem = index;
  2079. item.iSubItem = 4;
  2080. swprintf( buf, L"%d", (*topF).second.machineMapToPriority[machine] );
  2081. item.pszText = buf;
  2082. item.cchTextMax = 100;
  2083. GetDocument()->getListPane().SetItem( &item );
  2084. // load
  2085. item.mask = LVIF_TEXT;
  2086. item.iItem = index;
  2087. item.iSubItem = 5;
  2088. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY );
  2089. item.cchTextMax = 100;
  2090. GetDocument()->getListPane().SetItem( &item );
  2091. // affinity
  2092. item.mask = LVIF_TEXT;
  2093. item.iItem = index;
  2094. item.iSubItem = 6;
  2095. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY );
  2096. item.cchTextMax = 100;
  2097. GetDocument()->getListPane().SetItem( &item );
  2098. ++index;
  2099. }
  2100. index = 0;
  2101. map< long, PortDataD>::iterator topD;
  2102. for( topD = p_clusterSettings->portD.begin();
  2103. topD != p_clusterSettings->portD.end();
  2104. ++topD )
  2105. {
  2106. // start port
  2107. swprintf( buf, L"%d", (*topD).second._startPort );
  2108. LVITEM item;
  2109. item.mask = LVIF_TEXT | LVIF_IMAGE;
  2110. item.iItem = index;
  2111. item.iSubItem = 0;
  2112. item.iImage = 4;
  2113. item.pszText = buf;
  2114. item.cchTextMax = 100;
  2115. GetDocument()->getListPane().InsertItem( &item );
  2116. // end port
  2117. swprintf( buf, L"%d", (*topD).second._endPort );
  2118. item.mask = LVIF_TEXT;
  2119. item.iItem = index;
  2120. item.iSubItem = 1;
  2121. item.pszText = buf;
  2122. item.cchTextMax = 100;
  2123. GetDocument()->getListPane().SetItem( &item );
  2124. // protocol
  2125. item.mask = LVIF_TEXT;
  2126. item.iItem = index;
  2127. item.iSubItem = 2;
  2128. switch( (*topD).second._trafficToHandle )
  2129. {
  2130. case MNLBPortRule::both :
  2131. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_BOTH );
  2132. break;
  2133. case MNLBPortRule::tcp :
  2134. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_TCP );
  2135. break;
  2136. case MNLBPortRule::udp :
  2137. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_PROTOCOL_UDP );
  2138. break;
  2139. }
  2140. item.cchTextMax = 100;
  2141. GetDocument()->getListPane().SetItem( &item );
  2142. // mode
  2143. item.mask = LVIF_TEXT;
  2144. item.iItem = index;
  2145. item.iSubItem = 3;
  2146. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_MODE_DISABLED );
  2147. item.cchTextMax = 100;
  2148. GetDocument()->getListPane().SetItem( &item );
  2149. // priority
  2150. item.mask = LVIF_TEXT;
  2151. item.iItem = index;
  2152. item.iSubItem = 4;
  2153. item.pszText = GETRESOURCEIDSTRING(IDS_REPORT_EMPTY );
  2154. item.cchTextMax = 100;
  2155. GetDocument()->getListPane().SetItem( &item );
  2156. // load
  2157. item.mask = LVIF_TEXT;
  2158. item.iItem = index;
  2159. item.iSubItem = 5;
  2160. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_EMPTY );
  2161. item.cchTextMax = 100;
  2162. GetDocument()->getListPane().SetItem( &item );
  2163. // affinity
  2164. item.mask = LVIF_TEXT;
  2165. item.iItem = index;
  2166. item.iSubItem = 6;
  2167. item.pszText = GETRESOURCEIDSTRING( IDS_REPORT_EMPTY );
  2168. item.cchTextMax = 100;
  2169. GetDocument()->getListPane().SetItem( &item );
  2170. ++index;
  2171. }
  2172. // sort it based on start port
  2173. vector<PortsPage::PortData> ports;
  2174. int index;
  2175. // get all the port rules presently in the list.
  2176. for( index = 0; index < GetDocument()->getListPane().GetItemCount(); ++index )
  2177. {
  2178. PortsPage::PortData portData;
  2179. GetDocument()->getListPane().GetItemText( index, 0, buf, Common::BUF_SIZE );
  2180. portData.start_port = buf;
  2181. GetDocument()->getListPane().GetItemText( index, 1, buf, Common::BUF_SIZE );
  2182. portData.end_port = buf;
  2183. GetDocument()->getListPane().GetItemText( index, 2, buf, Common::BUF_SIZE );
  2184. portData.protocol = buf;
  2185. GetDocument()->getListPane().GetItemText( index, 3, buf, Common::BUF_SIZE );
  2186. portData.mode = buf;
  2187. GetDocument()->getListPane().GetItemText( index, 4, buf, Common::BUF_SIZE );
  2188. portData.priority = buf;
  2189. GetDocument()->getListPane().GetItemText( index, 5, buf, Common::BUF_SIZE );
  2190. portData.load = buf;
  2191. GetDocument()->getListPane().GetItemText( index, 6, buf, Common::BUF_SIZE );
  2192. portData.affinity = buf;
  2193. ports.push_back( portData );
  2194. }
  2195. sort( ports.begin(), ports.end(), comp_start_port() );
  2196. int portIndex;
  2197. int itemCount = GetDocument()->getListPane().GetItemCount();
  2198. for( index = 0; index < itemCount; ++index )
  2199. {
  2200. portIndex = index;
  2201. GetDocument()->getListPane().SetItemText( index, 0, ports[portIndex].start_port );
  2202. GetDocument()->getListPane().SetItemText( index, 1, ports[portIndex].end_port );
  2203. GetDocument()->getListPane().SetItemText( index, 2, ports[portIndex].protocol );
  2204. GetDocument()->getListPane().SetItemText( index, 3, ports[portIndex].mode );
  2205. GetDocument()->getListPane().SetItemText( index, 4, ports[portIndex].priority );
  2206. GetDocument()->getListPane().SetItemText( index, 5, ports[portIndex].load );
  2207. GetDocument()->getListPane().SetItemText( index, 6, ports[portIndex].affinity );
  2208. }
  2209. break;
  2210. }
  2211. *pResult = 0;
  2212. }
  2213. bool
  2214. LeftView::doesClusterExistInView( const _bstr_t& clusterToCheck )
  2215. {
  2216. HTREEITEM rootItem = GetTreeCtrl().GetRootItem();
  2217. ClusterData* p_clusterDataItem;
  2218. if( GetTreeCtrl().ItemHasChildren( rootItem ) )
  2219. {
  2220. HTREEITEM hNextItem;
  2221. HTREEITEM hChildItem = GetTreeCtrl().GetChildItem(rootItem);
  2222. while (hChildItem != NULL)
  2223. {
  2224. hNextItem = GetTreeCtrl().GetNextItem(hChildItem, TVGN_NEXT);
  2225. p_clusterDataItem = ( ClusterData * ) GetTreeCtrl().GetItemData( hChildItem );
  2226. if( p_clusterDataItem->cp.cIP == clusterToCheck )
  2227. {
  2228. // this cluster already exists.
  2229. return true;
  2230. }
  2231. hChildItem = hNextItem;
  2232. }
  2233. }
  2234. return false;
  2235. }
  2236. void
  2237. LeftView::OnTest()
  2238. {
  2239. MIPAddressAdmin ipAdmin( L"Intel 8255x-based PCI Ethernet Adapter (10/100)" );
  2240. for( int i = 0; i < 100; ++i )
  2241. {
  2242. dataSink( GETRESOURCEIDSTRING( IDS_INFO_LINE_SEPARATOR ) );
  2243. if ( ipAdmin.addIPAddress( L"1.1.1.121",
  2244. L"255.0.0.0" ) !=
  2245. MIPAddressAdmin::MIPAddressAdmin_SUCCESS )
  2246. {
  2247. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  2248. }
  2249. else
  2250. {
  2251. dataSink( GETRESOURCEIDSTRING( IDS_INFO_DONE ) );
  2252. }
  2253. if ( ipAdmin.deleteIPAddress( L"1.1.1.121" )
  2254. !=
  2255. MIPAddressAdmin::MIPAddressAdmin_SUCCESS )
  2256. {
  2257. dataSink( GETRESOURCEIDSTRING( IDS_INFO_FAILED ) );
  2258. }
  2259. else
  2260. {
  2261. dataSink( GETRESOURCEIDSTRING( IDS_INFO_DONE ) );
  2262. }
  2263. }
  2264. }
  2265. void
  2266. LeftView::dumpClusterData( const ClusterData* clusterData )
  2267. {
  2268. map< long, PortDataELB>::iterator topELB;
  2269. PortDataELB portELB;
  2270. for( topELB = clusterData->portELB.begin();
  2271. topELB != clusterData->portELB.end();
  2272. ++topELB )
  2273. {
  2274. portELB = (*topELB).second;
  2275. }
  2276. map< long, PortDataULB>::iterator topULB;
  2277. PortDataULB portULB;
  2278. int loadWeight;
  2279. for( topULB = clusterData->portULB.begin();
  2280. topULB != clusterData->portULB.end();
  2281. ++topULB )
  2282. {
  2283. portULB = (*topULB).second;
  2284. map< _bstr_t, HostData>::iterator topHosts;
  2285. for( topHosts = clusterData->hosts.begin();
  2286. topHosts != clusterData->hosts.end();
  2287. ++topHosts )
  2288. {
  2289. loadWeight = portULB.machineMapToLoadWeight[ (*topHosts).first ];
  2290. }
  2291. }
  2292. map< long, PortDataF>::iterator topF;
  2293. PortDataF portF;
  2294. int priority;
  2295. for( topF = clusterData->portF.begin();
  2296. topF != clusterData->portF.end();
  2297. ++topF )
  2298. {
  2299. portF = (*topF).second;
  2300. map< _bstr_t, HostData>::iterator topHosts;
  2301. for( topHosts = clusterData->hosts.begin();
  2302. topHosts != clusterData->hosts.end();
  2303. ++topHosts )
  2304. {
  2305. loadWeight = portF.machineMapToPriority[ (*topHosts).first ];
  2306. }
  2307. }
  2308. map< long, PortDataD>::iterator topD;
  2309. PortDataD portD;
  2310. for( topD = clusterData->portD.begin();
  2311. topD != clusterData->portD.end();
  2312. ++topD )
  2313. {
  2314. portD = (*topD).second;
  2315. }
  2316. }