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.

5669 lines
166 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // TaskAnalyzeCluster.cpp
  7. //
  8. // Description:
  9. // CTaskAnalyzeCluster implementation.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 02-FEB-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "pch.h"
  16. #include "TaskAnalyzeCluster.h"
  17. #include "ManagedDevice.h"
  18. #include <nameutil.h>
  19. // For CsRpcGetJoinVersionData() and constants like JoinVersion_v2_0_c_ifspec
  20. #include <ClusRPC.h>
  21. #include <ClusVerp.h>
  22. DEFINE_THISCLASS( "CTaskAnalyzeCluster" )
  23. //
  24. // Failure code.
  25. //
  26. #define SSR_ANALYSIS_FAILED( _major, _minor, _hr ) \
  27. { \
  28. HRESULT hrTemp; \
  29. BSTR bstrNotification = NULL; \
  30. THR( HrLoadStringIntoBSTR( g_hInstance, IDS_ERR_ANALYSIS_FAILED_TRY_TO_REANALYZE, &bstrNotification ) ); \
  31. hrTemp = THR( SendStatusReport( NULL, _major, _minor, 0, 1, 1, _hr, bstrNotification, NULL, NULL ) ); \
  32. TraceSysFreeString( bstrNotification ); \
  33. if ( FAILED( hrTemp ) ) \
  34. { \
  35. _hr = hrTemp; \
  36. } \
  37. }
  38. //****************************************************************************
  39. //
  40. // Constants
  41. //
  42. //****************************************************************************
  43. #define CHECKING_TIMEOUT 90 // seconds
  44. // ************************************************************************
  45. //
  46. // Constructor / Destructor
  47. //
  48. // ************************************************************************
  49. //////////////////////////////////////////////////////////////////////////////
  50. //
  51. // HRESULT
  52. // CTaskAnalyzeCluster::S_HrCreateInstance(
  53. // IUnknown ** ppunkOut
  54. // )
  55. //
  56. //////////////////////////////////////////////////////////////////////////////
  57. HRESULT
  58. CTaskAnalyzeCluster::S_HrCreateInstance(
  59. IUnknown ** ppunkOut
  60. )
  61. {
  62. TraceFunc( "" );
  63. Assert( ppunkOut != NULL );
  64. HRESULT hr;
  65. CTaskAnalyzeCluster * ptac = new CTaskAnalyzeCluster;
  66. if ( ptac != NULL )
  67. {
  68. hr = THR( ptac->Init() );
  69. if ( SUCCEEDED( hr ) )
  70. {
  71. hr = THR( ptac->TypeSafeQI( IUnknown, ppunkOut ) );
  72. }
  73. ptac->Release();
  74. }
  75. else
  76. {
  77. hr = E_OUTOFMEMORY;
  78. }
  79. HRETURN( hr );
  80. } //*** CTaskAnalyzeCluster::S_HrCreateInstance()
  81. //////////////////////////////////////////////////////////////////////////////
  82. //
  83. // CTaskAnalyzeCluster::CTaskAnalyzeCluster( void )
  84. //
  85. //////////////////////////////////////////////////////////////////////////////
  86. CTaskAnalyzeCluster::CTaskAnalyzeCluster( void )
  87. {
  88. TraceFunc( "" );
  89. InterlockedIncrement( &g_cObjects );
  90. TraceFuncExit();
  91. } //*** CTaskAnalyzeCluster::CTaskAnalyzeCluster()
  92. //////////////////////////////////////////////////////////////////////////////
  93. //
  94. // STDMETHODIMP
  95. // CTaskAnalyzeCluster::Init( void )
  96. //
  97. //////////////////////////////////////////////////////////////////////////////
  98. STDMETHODIMP
  99. CTaskAnalyzeCluster::Init( void )
  100. {
  101. TraceFunc( "" );
  102. HRESULT hr = S_OK;
  103. // IUnknown stuff
  104. Assert( m_cRef == 0 );
  105. AddRef(); // Add one count
  106. // IDoTask / ITaskAnalyzeCluster
  107. Assert( m_cookieCompletion == 0 );
  108. Assert( m_pcccb == NULL );
  109. Assert( m_pcookies == NULL );
  110. Assert( m_cNodes == 0 );
  111. Assert( m_event == NULL );
  112. Assert( m_cookieCluster == NULL );
  113. Assert( m_fJoiningMode == FALSE );
  114. Assert( m_cUserNodes == 0 );
  115. Assert( m_pcookiesUser == NULL );
  116. Assert( m_pnui == NULL );
  117. Assert( m_pom == NULL );
  118. Assert( m_ptm == NULL );
  119. Assert( m_pcm == NULL );
  120. Assert( m_fStop == false );
  121. // INotifyUI
  122. Assert( m_cSubTasksDone == 0 );
  123. Assert( m_hrStatus == 0 );
  124. hr = HrGetComputerName( ComputerNameNetBIOS, &m_bstrNodeName );
  125. HRETURN( hr );
  126. } // Init()
  127. //////////////////////////////////////////////////////////////////////////////
  128. //
  129. // CTaskAnalyzeCluster::~CTaskAnalyzeCluster( void )
  130. //
  131. //////////////////////////////////////////////////////////////////////////////
  132. CTaskAnalyzeCluster::~CTaskAnalyzeCluster( void )
  133. {
  134. TraceFunc( "" );
  135. // m_cRef
  136. // m_cookieCompletion
  137. if ( m_pcccb != NULL )
  138. {
  139. m_pcccb->Release();
  140. }
  141. if ( m_pcookies != NULL )
  142. {
  143. THR( HrFreeCookies() );
  144. }
  145. // m_cCookies
  146. // m_cNodes
  147. if ( m_event != NULL )
  148. {
  149. CloseHandle( m_event );
  150. }
  151. // m_cookieCluster
  152. TraceMoveFromMemoryList( m_bstrClusterName, g_GlobalMemoryList );
  153. TraceSysFreeString( m_bstrClusterName );
  154. TraceSysFreeString( m_bstrNodeName );
  155. // m_fJoiningMode
  156. // m_cUserNodes
  157. if ( m_pcookiesUser != NULL )
  158. {
  159. TraceFree( m_pcookiesUser );
  160. }
  161. if ( m_pnui != NULL )
  162. {
  163. m_pnui->Release();
  164. }
  165. if ( m_pom != NULL )
  166. {
  167. m_pom->Release();
  168. }
  169. if ( m_ptm != NULL )
  170. {
  171. m_ptm->Release();
  172. }
  173. if ( m_pcm != NULL )
  174. {
  175. m_pcm->Release();
  176. } // if:
  177. TraceSysFreeString( m_bstrQuorumUID );
  178. // m_cSubTasksDone
  179. // m_hrStatus
  180. InterlockedDecrement( &g_cObjects );
  181. TraceFuncExit();
  182. } //*** CTaskAnalyzeCluster::~CTaskAnalyzeCluster()
  183. // ************************************************************************
  184. //
  185. // IUnknown
  186. //
  187. // ************************************************************************
  188. //////////////////////////////////////////////////////////////////////////////
  189. //
  190. // STDMETHODIMP
  191. // CTaskAnalyzeCluster::QueryInterface(
  192. // REFIID riidIn,
  193. // LPVOID * ppvOut
  194. // )
  195. //
  196. //////////////////////////////////////////////////////////////////////////////
  197. STDMETHODIMP
  198. CTaskAnalyzeCluster::QueryInterface(
  199. REFIID riidIn,
  200. LPVOID * ppvOut
  201. )
  202. {
  203. TraceQIFunc( riidIn, ppvOut );
  204. HRESULT hr = E_NOINTERFACE;
  205. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  206. {
  207. *ppvOut = static_cast< ITaskAnalyzeCluster * >( this );
  208. hr = S_OK;
  209. } // if: IUnknown
  210. else if ( IsEqualIID( riidIn, IID_ITaskAnalyzeCluster ) )
  211. {
  212. *ppvOut = TraceInterface( __THISCLASS__, ITaskAnalyzeCluster, this, 0 );
  213. hr = S_OK;
  214. } // else if: ITaskAnalyzeCluster
  215. else if ( IsEqualIID( riidIn, IID_IDoTask ) )
  216. {
  217. *ppvOut = TraceInterface( __THISCLASS__, IDoTask, this, 0 );
  218. hr = S_OK;
  219. } // else if: IDoTask
  220. else if ( IsEqualIID( riidIn, IID_IClusCfgCallback ) )
  221. {
  222. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgCallback, this, 0 );
  223. hr = S_OK;
  224. } // else if: IClusCfgCallback
  225. else if ( IsEqualIID( riidIn, IID_INotifyUI ) )
  226. {
  227. *ppvOut = TraceInterface( __THISCLASS__, INotifyUI, this, 0 );
  228. hr = S_OK;
  229. } // else if: INotifyUI
  230. if ( SUCCEEDED( hr ) )
  231. {
  232. ((IUnknown*) *ppvOut)->AddRef();
  233. } // if: success
  234. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  235. } //*** CTaskAnalyzeCluster::QueryInterface()
  236. //////////////////////////////////////////////////////////////////////////////
  237. //
  238. // STDMETHODIMP_( ULONG )
  239. // CTaskAnalyzeCluster::AddRef( void )
  240. //
  241. //////////////////////////////////////////////////////////////////////////////
  242. STDMETHODIMP_( ULONG )
  243. CTaskAnalyzeCluster::AddRef( void )
  244. {
  245. TraceFunc( "[IUnknown]" );
  246. InterlockedIncrement( &m_cRef );
  247. RETURN( m_cRef );
  248. } //*** CTaskAnalyzeCluster::AddRef()
  249. //////////////////////////////////////////////////////////////////////////////
  250. //
  251. // STDMETHODIMP_( ULONG )
  252. // CTaskAnalyzeCluster::Release( void )
  253. //
  254. //////////////////////////////////////////////////////////////////////////////
  255. STDMETHODIMP_( ULONG )
  256. CTaskAnalyzeCluster::Release( void )
  257. {
  258. TraceFunc( "[IUnknown]" );
  259. LONG cRef;
  260. InterlockedDecrement( &m_cRef );
  261. cRef = m_cRef;
  262. if ( cRef == 0 )
  263. {
  264. TraceDo( delete this );
  265. }
  266. RETURN( cRef );
  267. } //*** CTaskAnalyzeCluster::Release()
  268. // ************************************************************************
  269. //
  270. // IDoTask / ITaskAnalyzeCluster
  271. //
  272. // ************************************************************************
  273. //////////////////////////////////////////////////////////////////////////////
  274. //
  275. // STDMETHODIMP
  276. // CTaskAnalyzeCluster::BeginTask( void );
  277. //
  278. //////////////////////////////////////////////////////////////////////////////
  279. STDMETHODIMP
  280. CTaskAnalyzeCluster::BeginTask( void )
  281. {
  282. TraceFunc( "[IDoTask]" );
  283. HRESULT hr;
  284. DWORD dwCookie = 0;
  285. IServiceProvider * psp = NULL;
  286. IConnectionPointContainer * pcpc = NULL;
  287. IConnectionPoint * pcp = NULL;
  288. TraceInitializeThread( L"TaskAnalyzeCluster" );
  289. //
  290. // Gather the managers we need to complete the task.
  291. //
  292. hr = THR( CoCreateInstance( CLSID_ServiceManager, NULL, CLSCTX_INPROC_SERVER, TypeSafeParams( IServiceProvider, &psp ) ) );
  293. if ( FAILED( hr ) )
  294. {
  295. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_BeginTask_CoCreate_Service_Manager, hr );
  296. goto Cleanup;
  297. }
  298. Assert( m_pnui == NULL );
  299. Assert( m_ptm == NULL );
  300. Assert( m_pom == NULL );
  301. hr = THR( psp->TypeSafeQS( CLSID_NotificationManager, IConnectionPointContainer, &pcpc ) );
  302. if ( FAILED( hr ) )
  303. {
  304. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_BeginTask_QueryService_Notification_Manager, hr );
  305. goto Cleanup;
  306. }
  307. hr = THR( pcpc->FindConnectionPoint( IID_INotifyUI, &pcp ) );
  308. if ( FAILED( hr ) )
  309. {
  310. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_BeginTask_NotificationMan_FindConnectionPoint, hr );
  311. goto Cleanup;
  312. }
  313. pcp = TraceInterface( L"CTaskAnalyzeCluster!IConnectionPoint", IConnectionPoint, pcp, 1 );
  314. hr = THR( pcp->TypeSafeQI( INotifyUI, &m_pnui ) );
  315. if ( FAILED( hr ) )
  316. {
  317. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_BeginTask_NotificationMan_FindConnectionPoint_QI_INotifyUI, hr );
  318. goto Cleanup;
  319. }
  320. hr = THR( psp->TypeSafeQS( CLSID_TaskManager, ITaskManager, &m_ptm ) );
  321. if ( FAILED( hr ) )
  322. {
  323. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_BeginTask_QueryService_TaskManager, hr );
  324. goto Cleanup;
  325. }
  326. hr = THR( psp->TypeSafeQS( CLSID_ObjectManager, IObjectManager, &m_pom ) );
  327. if ( FAILED( hr ) )
  328. {
  329. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_BeginTask_QueryService_ObjectManager, hr );
  330. goto Cleanup;
  331. }
  332. hr = THR( psp->TypeSafeQS( CLSID_ClusterConnectionManager, IConnectionManager, &m_pcm ) );
  333. if ( FAILED( hr ) )
  334. {
  335. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_BeginTask_QueryService_ConnectionManager, hr );
  336. goto Cleanup;
  337. } // if:
  338. //
  339. // Release the Service Manager.
  340. //
  341. psp->Release();
  342. psp = NULL;
  343. //
  344. // Create an event to wait upon.
  345. //
  346. m_event = CreateEvent( NULL, TRUE, FALSE, NULL );
  347. if ( m_event == NULL )
  348. goto Win32Error;
  349. //
  350. // Register with the Notification Manager to get notified.
  351. //
  352. Assert( m_cCookies == 0 && m_pcookies == NULL && m_cSubTasksDone == 0 );
  353. hr = THR( pcp->Advise( static_cast< INotifyUI * >( this ), &dwCookie ) );
  354. if ( FAILED( hr ) )
  355. {
  356. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_BeginTask_Advise, hr );
  357. goto Cleanup;
  358. }
  359. //
  360. // Wait for the cluster connection to stablize.
  361. //
  362. hr = STHR( HrWaitForClusterConnection() );
  363. if ( FAILED( hr ) )
  364. goto Cleanup;
  365. if ( FAILED( m_hrStatus ) )
  366. {
  367. hr = THR( m_hrStatus );
  368. goto Cleanup;
  369. }
  370. Assert( m_bstrClusterName != NULL );
  371. //
  372. // Tell the UI layer we are starting this task.
  373. //
  374. hr = THR( SendStatusReport( NULL,
  375. TASKID_Major_Establish_Connection,
  376. TASKID_Minor_Update_Progress,
  377. 0,
  378. CHECKING_TIMEOUT,
  379. 0,
  380. S_OK,
  381. NULL,
  382. NULL,
  383. NULL
  384. ) );
  385. if ( FAILED( hr ) )
  386. {
  387. goto Cleanup;
  388. } // if:
  389. //
  390. // Count the number of nodes to be analyzed.
  391. //
  392. hr = STHR( HrCountNumberOfNodes() );
  393. if ( FAILED( hr ) )
  394. goto Cleanup;
  395. if ( FAILED( m_hrStatus ) )
  396. {
  397. hr = THR( m_hrStatus );
  398. goto Cleanup;
  399. }
  400. //
  401. // Create separate tasks to gather node information.
  402. //
  403. hr = STHR( HrCreateSubTasksToGatherNodeInfo() );
  404. if ( FAILED( hr ) )
  405. goto Cleanup;
  406. if ( FAILED( m_hrStatus ) )
  407. {
  408. hr = THR( m_hrStatus );
  409. goto Cleanup;
  410. }
  411. //
  412. // Tell the UI layer we have completed this task.
  413. //
  414. hr = THR( SendStatusReport( NULL,
  415. TASKID_Major_Establish_Connection,
  416. TASKID_Minor_Update_Progress,
  417. 0,
  418. CHECKING_TIMEOUT,
  419. CHECKING_TIMEOUT,
  420. S_OK,
  421. NULL,
  422. NULL,
  423. NULL
  424. ) );
  425. if ( FAILED( hr ) )
  426. {
  427. goto Cleanup;
  428. } // if:
  429. //
  430. // Create separate tasks to gather node resources and networks.
  431. //
  432. hr = STHR( HrCreateSubTasksToGatherNodeResourcesAndNetworks() );
  433. if ( FAILED( hr ) )
  434. goto Cleanup;
  435. if ( FAILED( m_hrStatus ) )
  436. {
  437. hr = THR( m_hrStatus );
  438. goto Cleanup;
  439. }
  440. //
  441. // Count the number of nodes to be analyzed again. TaskGatherInformation
  442. // will delete the cookies of unresponsive nodes.
  443. //
  444. hr = STHR( HrCountNumberOfNodes() );
  445. if ( FAILED( hr ) )
  446. goto Cleanup;
  447. if ( FAILED( m_hrStatus ) )
  448. {
  449. hr = THR( m_hrStatus );
  450. goto Cleanup;
  451. }
  452. //
  453. // Create the feasibility task.
  454. //
  455. hr = STHR( HrCheckClusterFeasibility() );
  456. if ( FAILED( hr ) )
  457. goto Cleanup;
  458. if ( FAILED( m_hrStatus ) )
  459. {
  460. hr = THR( m_hrStatus );
  461. goto Cleanup;
  462. }
  463. Cleanup:
  464. if ( psp != NULL )
  465. {
  466. psp->Release();
  467. }
  468. if ( pcpc != NULL )
  469. {
  470. pcpc->Release();
  471. }
  472. if ( pcp != NULL )
  473. {
  474. HRESULT hr2;
  475. hr2 = THR( pcp->Unadvise( dwCookie ) );
  476. if ( FAILED( hr2 ) )
  477. {
  478. SSR_ANALYSIS_FAILED( TASKID_Major_Client_And_Server_Log, TASKID_Minor_BeginTask_Unadvise, hr2 );
  479. }
  480. pcp->Release();
  481. }
  482. if ( m_cookieCompletion != 0 )
  483. {
  484. if ( m_pom != NULL )
  485. {
  486. HRESULT hr2;
  487. IUnknown * punk;
  488. hr2 = THR( m_pom->GetObject( DFGUID_StandardInfo, m_cookieCompletion, &punk ) );
  489. if ( SUCCEEDED( hr2 ) )
  490. {
  491. IStandardInfo * psi;
  492. hr2 = THR( punk->TypeSafeQI( IStandardInfo, &psi ) );
  493. punk->Release();
  494. if ( SUCCEEDED( hr2 ) )
  495. {
  496. hr2 = THR( psi->SetStatus( hr ) );
  497. psi->Release();
  498. }
  499. else
  500. {
  501. SSR_ANALYSIS_FAILED( TASKID_Major_Client_And_Server_Log, TASKID_Minor_BeginTask_SetStatus, hr2 );
  502. }
  503. }
  504. else
  505. {
  506. SSR_ANALYSIS_FAILED( TASKID_Major_Client_And_Server_Log, TASKID_Minor_BeginTask_GetObject, hr2 );
  507. }
  508. }
  509. if ( m_pnui != NULL )
  510. {
  511. //
  512. // Have the notification manager signal the completion cookie.
  513. //
  514. HRESULT hr2 = THR( m_pnui->ObjectChanged( m_cookieCompletion ) );
  515. if ( FAILED( hr2 ) )
  516. {
  517. SSR_ANALYSIS_FAILED( TASKID_Major_Client_And_Server_Log, TASKID_Minor_BeginTask_ObjectChanged, hr2 );
  518. }
  519. }
  520. m_cookieCompletion = 0;
  521. }
  522. HRETURN( hr );
  523. Win32Error:
  524. hr = THR( HRESULT_FROM_WIN32( GetLastError() ) );
  525. SSR_ANALYSIS_FAILED( TASKID_Major_Client_And_Server_Log, TASKID_Minor_BeginTask_Win32Error, hr );
  526. goto Cleanup;
  527. } //*** CTaskAnalyzeCluster::BeginTask()
  528. //////////////////////////////////////////////////////////////////////////////
  529. //
  530. // STDMETHODIMP
  531. // CTaskAnalyzeCluster::StopTask( void )
  532. //
  533. //////////////////////////////////////////////////////////////////////////////
  534. STDMETHODIMP
  535. CTaskAnalyzeCluster::StopTask( void )
  536. {
  537. TraceFunc( "[IDoTask]" );
  538. HRESULT hr = S_OK;
  539. LogMsg( L"[MT] The client has requested that this task, TaskAnalyzeCluster, be canceled" );
  540. m_fStop = true;
  541. HRETURN( hr );
  542. } //*** CTaskAnalyzeCluster::StopTask()
  543. //////////////////////////////////////////////////////////////////////////////
  544. //
  545. // STDMETHODIMP
  546. // CTaskAnalyzeCluster::SetJoiningMode( void )
  547. //
  548. //////////////////////////////////////////////////////////////////////////////
  549. STDMETHODIMP
  550. CTaskAnalyzeCluster::SetJoiningMode( void )
  551. {
  552. TraceFunc( "[ITaskAnalyzeCluster]" );
  553. HRESULT hr = S_OK;
  554. m_fJoiningMode = TRUE;
  555. HRETURN( hr );
  556. } //*** CTaskAnalyzeCluster::SetJoiningMode()
  557. //////////////////////////////////////////////////////////////////////////////
  558. //
  559. // STDMETHODIMP
  560. // CTaskAnalyzeCluster::SetCookie(
  561. // OBJECTCOOKIE cookieIn
  562. // )
  563. //
  564. //////////////////////////////////////////////////////////////////////////////
  565. STDMETHODIMP
  566. CTaskAnalyzeCluster::SetCookie(
  567. OBJECTCOOKIE cookieIn
  568. )
  569. {
  570. TraceFunc( "[ITaskAnalyzeCluster]" );
  571. HRESULT hr = S_OK;
  572. m_cookieCompletion = cookieIn;
  573. HRETURN( hr );
  574. } //*** CTaskAnalyzeCluster::SetCookie()
  575. //////////////////////////////////////////////////////////////////////////////
  576. //
  577. // STDMETHODIMP
  578. // CTaskAnalyzeCluster::SetClusterCookie(
  579. // OBJECTCOOKIE cookieClusterIn
  580. // )
  581. //
  582. //////////////////////////////////////////////////////////////////////////////
  583. STDMETHODIMP
  584. CTaskAnalyzeCluster::SetClusterCookie(
  585. OBJECTCOOKIE cookieClusterIn
  586. )
  587. {
  588. TraceFunc( "[ITaskAnalyzeCluster]" );
  589. HRESULT hr = S_OK;
  590. m_cookieCluster = cookieClusterIn;
  591. HRETURN( hr );
  592. } //*** CTaskAnalyzeCluster::SetClusterCookie()
  593. //****************************************************************************
  594. //
  595. // IClusCfgCallback
  596. //
  597. //****************************************************************************
  598. //////////////////////////////////////////////////////////////////////////////
  599. //
  600. // STDMETHODIMP
  601. // CTaskAnalyzeCluster::SendStatusReport(
  602. // LPCWSTR pcszNodeNameIn
  603. // , CLSID clsidTaskMajorIn
  604. // , CLSID clsidTaskMinorIn
  605. // , ULONG ulMinIn
  606. // , ULONG ulMaxIn
  607. // , ULONG ulCurrentIn
  608. // , HRESULT hrStatusIn
  609. // , LPCWSTR pcszDescriptionIn
  610. // , FILETIME * pftTimeIn
  611. // , LPCWSTR pcszReferenceIn
  612. // )
  613. //
  614. //////////////////////////////////////////////////////////////////////////////
  615. STDMETHODIMP
  616. CTaskAnalyzeCluster::SendStatusReport(
  617. LPCWSTR pcszNodeNameIn
  618. , CLSID clsidTaskMajorIn
  619. , CLSID clsidTaskMinorIn
  620. , ULONG ulMinIn
  621. , ULONG ulMaxIn
  622. , ULONG ulCurrentIn
  623. , HRESULT hrStatusIn
  624. , LPCWSTR pcszDescriptionIn
  625. , FILETIME * pftTimeIn
  626. , LPCWSTR pcszReferenceIn
  627. )
  628. {
  629. TraceFunc( "[IClusCfgCallback]" );
  630. HRESULT hr = S_OK;
  631. IServiceProvider * psp = NULL;
  632. IConnectionPointContainer * pcpc = NULL;
  633. IConnectionPoint * pcp = NULL;
  634. FILETIME ft;
  635. if ( m_pcccb == NULL )
  636. {
  637. //
  638. // Collect the manager we need to complete this task.
  639. //
  640. hr = THR( CoCreateInstance( CLSID_ServiceManager,
  641. NULL,
  642. CLSCTX_INPROC_SERVER,
  643. TypeSafeParams( IServiceProvider, &psp )
  644. ) );
  645. if ( FAILED( hr ) )
  646. goto Cleanup;
  647. hr = THR( psp->TypeSafeQS( CLSID_NotificationManager,
  648. IConnectionPointContainer,
  649. &pcpc
  650. ) );
  651. if ( FAILED( hr ) )
  652. goto Cleanup;
  653. hr = THR( pcpc->FindConnectionPoint( IID_IClusCfgCallback, &pcp ) );
  654. if ( FAILED( hr ) )
  655. goto Cleanup;
  656. pcp = TraceInterface( L"CConfigurationConnection!IConnectionPoint", IConnectionPoint, pcp, 1 );
  657. hr = THR( pcp->TypeSafeQI( IClusCfgCallback, &m_pcccb ) );
  658. if ( FAILED( hr ) )
  659. goto Cleanup;
  660. m_pcccb = TraceInterface( L"CConfigurationConnection!IClusCfgCallback", IClusCfgCallback, m_pcccb, 1 );
  661. psp->Release();
  662. psp = NULL;
  663. }
  664. if ( pftTimeIn == NULL )
  665. {
  666. GetSystemTimeAsFileTime( &ft );
  667. pftTimeIn = &ft;
  668. } // if:
  669. //
  670. // Send the message!
  671. //
  672. hr = THR( m_pcccb->SendStatusReport(
  673. pcszNodeNameIn != NULL ? pcszNodeNameIn : m_bstrNodeName
  674. , clsidTaskMajorIn
  675. , clsidTaskMinorIn
  676. , ulMinIn
  677. , ulMaxIn
  678. , ulCurrentIn
  679. , hrStatusIn
  680. , pcszDescriptionIn
  681. , pftTimeIn
  682. , pcszReferenceIn
  683. ) );
  684. if ( m_fStop )
  685. {
  686. hr = E_ABORT;
  687. } // if:
  688. Cleanup:
  689. if ( psp != NULL )
  690. {
  691. psp->Release();
  692. }
  693. if ( pcpc != NULL )
  694. {
  695. pcpc->Release();
  696. }
  697. if ( pcp != NULL )
  698. {
  699. pcp->Release();
  700. }
  701. HRETURN( hr );
  702. } //*** CTaskAnalyzeCluster::SendStatusReport()
  703. //****************************************************************************
  704. //
  705. // INotifyUI
  706. //
  707. //****************************************************************************
  708. //////////////////////////////////////////////////////////////////////////////
  709. //
  710. // STDMETHODIMP
  711. // CTaskAnalyzeCluster::ObjectChanged(
  712. // OBJECTCOOKIE cookieIn
  713. // )
  714. //
  715. //////////////////////////////////////////////////////////////////////////////
  716. STDMETHODIMP
  717. CTaskAnalyzeCluster::ObjectChanged(
  718. OBJECTCOOKIE cookieIn
  719. )
  720. {
  721. TraceFunc( "[INotifyUI]" );
  722. BOOL b;
  723. ULONG cCookies;
  724. HRESULT hr = S_OK;
  725. Assert( cookieIn != 0 );
  726. for ( cCookies = 0; cCookies < m_cCookies; cCookies ++ )
  727. {
  728. Assert( m_pcookies != NULL );
  729. if ( cookieIn == m_pcookies[ cCookies ] )
  730. {
  731. //
  732. // Make sure it won't be signalled twice.
  733. //
  734. OBJECTCOOKIE cookie = m_pcookies[ cCookies ];
  735. m_pcookies[ cCookies ] = NULL;
  736. // don't care if this fails, but it really shouldn't
  737. THR( m_pom->RemoveObject( cookie ) );
  738. InterlockedIncrement( reinterpret_cast< long * >( &m_cSubTasksDone ) );
  739. if ( m_cSubTasksDone == m_cCookies )
  740. {
  741. //
  742. // Signal the event if all the nodes are done.
  743. //
  744. b = SetEvent( m_event );
  745. if ( !b )
  746. goto Win32Error;
  747. } // if: all done
  748. } // if: matched cookie
  749. } // for: cCookies
  750. Cleanup:
  751. HRETURN( hr );
  752. Win32Error:
  753. hr = THR( HRESULT_FROM_WIN32( GetLastError() ) );
  754. SSR_ANALYSIS_FAILED( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ObjectChanged_Win32Error, hr );
  755. goto Cleanup;
  756. } //*** CTaskAnalyzeCluster::ObjectChanged()
  757. //****************************************************************************
  758. //
  759. // Private
  760. //
  761. //****************************************************************************
  762. //////////////////////////////////////////////////////////////////////////////
  763. //
  764. // HRESULT
  765. // CTaskAnalyzeCluster::HrWaitForClusterConnection( void )
  766. //
  767. //////////////////////////////////////////////////////////////////////////////
  768. HRESULT
  769. CTaskAnalyzeCluster::HrWaitForClusterConnection( void )
  770. {
  771. TraceFunc( "" );
  772. HRESULT hrStatus;
  773. ULONG ulCurrent;
  774. DWORD sc;
  775. OBJECTCOOKIE * pcookies;
  776. HRESULT hr = S_OK;
  777. BSTR bstrDescription = NULL;
  778. IUnknown * punk = NULL;
  779. ITaskGatherClusterInfo * ptgci = NULL;
  780. IStandardInfo * psi = NULL;
  781. //
  782. // Tell the UI layer that we are starting to search for an existing cluster.
  783. //
  784. THR( HrLoadStringIntoBSTR( g_hInstance, IDS_TASKID_MAJOR_CHECKING_FOR_EXISTING_CLUSTER, &bstrDescription ) );
  785. hr = THR( SendStatusReport( NULL,
  786. TASKID_Major_Checking_For_Existing_Cluster,
  787. TASKID_Minor_Update_Progress,
  788. 0,
  789. CHECKING_TIMEOUT,
  790. 0,
  791. S_OK,
  792. bstrDescription,
  793. NULL,
  794. NULL
  795. ) );
  796. if ( FAILED( hr ) )
  797. goto Cleanup;
  798. //
  799. // Get the cluster name
  800. //
  801. hr = THR( m_pom->GetObject( DFGUID_StandardInfo, m_cookieCluster, &punk ) );
  802. if ( FAILED( hr ) )
  803. {
  804. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_GetObject, hr );
  805. goto Cleanup;
  806. }
  807. hr = THR( punk->TypeSafeQI( IStandardInfo, &psi ) );
  808. if ( FAILED( hr ) )
  809. {
  810. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_GetObject_QI, hr );
  811. goto Cleanup;
  812. }
  813. psi = TraceInterface( L"TaskAnalyzeCluster!IStandardInfo", IStandardInfo, psi, 1 );
  814. punk->Release();
  815. punk = NULL;
  816. //
  817. // Retrieve the cluster's name.
  818. //
  819. hr = THR( psi->GetName( &m_bstrClusterName ) );
  820. if ( FAILED( hr ) )
  821. {
  822. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_GetName, hr );
  823. goto Cleanup;
  824. }
  825. TraceMemoryAddBSTR( m_bstrClusterName );
  826. TraceMoveToMemoryList( m_bstrClusterName, g_GlobalMemoryList );
  827. //
  828. // Create a completion cookie list.
  829. //
  830. Assert( m_cCookies == 0 );
  831. Assert( m_pcookies == NULL );
  832. Assert( m_cSubTasksDone == 0 );
  833. m_pcookies = reinterpret_cast< OBJECTCOOKIE * >( TraceAlloc( 0, sizeof( OBJECTCOOKIE ) ) );
  834. if ( m_pcookies == NULL )
  835. goto OutOfMemory;
  836. hr = THR( m_pom->FindObject( CLSID_ClusterCompletionCookie, m_cookieCluster, m_bstrClusterName, IID_NULL, &m_pcookies[ 0 ], &punk ) );
  837. Assert( punk == NULL );
  838. if ( FAILED( hr ) )
  839. {
  840. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_CreateCompletionCookie, hr );
  841. goto Cleanup;
  842. }
  843. m_cCookies = 1;
  844. //
  845. // Create the task object.
  846. //
  847. hr = THR( m_ptm->CreateTask( TASK_GatherClusterInfo,
  848. &punk
  849. ) );
  850. if ( FAILED( hr ) )
  851. {
  852. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_CreateTask, hr );
  853. goto Cleanup;
  854. }
  855. Assert( punk != NULL );
  856. hr = THR( punk->TypeSafeQI( ITaskGatherClusterInfo, &ptgci ) );
  857. if ( FAILED( hr ) )
  858. {
  859. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_CreateTask_QI, hr );
  860. goto Cleanup;
  861. }
  862. punk->Release();
  863. punk = NULL;
  864. //
  865. // Set the object cookie in the task.
  866. //
  867. hr = THR( ptgci->SetCookie( m_cookieCluster ) );
  868. if ( FAILED( hr ) )
  869. {
  870. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_SetCookie, hr );
  871. goto Cleanup;
  872. }
  873. hr = THR( ptgci->SetCompletionCookie( m_pcookies[ 0 ] ) );
  874. if ( FAILED( hr ) )
  875. {
  876. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_SetCompletionCookie, hr );
  877. goto Cleanup;
  878. }
  879. //
  880. // Submit the task.
  881. //
  882. hr = THR( m_ptm->SubmitTask( ptgci ) );
  883. if ( FAILED( hr ) )
  884. {
  885. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_SubmitTask, hr );
  886. goto Cleanup;
  887. }
  888. //
  889. // Now wait for the work to be done.
  890. //
  891. for ( ulCurrent = 0, sc = WAIT_OBJECT_0 + 1
  892. ; sc != WAIT_OBJECT_0
  893. ;
  894. )
  895. {
  896. MSG msg;
  897. while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
  898. {
  899. TranslateMessage( &msg );
  900. DispatchMessage( &msg );
  901. }
  902. sc = MsgWaitForMultipleObjectsEx( 1,
  903. &m_event,
  904. 1000, // 1 second
  905. QS_ALLEVENTS | QS_ALLINPUT | QS_ALLPOSTMESSAGE,
  906. 0
  907. );
  908. //
  909. // Tell the UI layer that we are still searching for the cluster. BUT
  910. // don't let the progress reach 100% if it is taking longer than
  911. // CHECKING_TIMEOUT seconds.
  912. //
  913. if ( ulCurrent != CHECKING_TIMEOUT )
  914. {
  915. ulCurrent ++;
  916. Assert( ulCurrent != CHECKING_TIMEOUT );
  917. hr = THR( SendStatusReport( NULL,
  918. TASKID_Major_Checking_For_Existing_Cluster,
  919. TASKID_Minor_Update_Progress,
  920. 0,
  921. CHECKING_TIMEOUT,
  922. ulCurrent,
  923. S_OK,
  924. NULL,
  925. NULL,
  926. NULL
  927. ) );
  928. if ( FAILED( hr ) )
  929. goto Cleanup;
  930. }
  931. } // for: sc != WAIT_OBJECT_0
  932. //
  933. // Cleanup the completion cookies
  934. //
  935. THR( HrFreeCookies() );
  936. //
  937. // Check out the status of the cluster.
  938. //
  939. hr = THR( psi->GetStatus( &hrStatus ) );
  940. if ( FAILED( hr ) )
  941. {
  942. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_GetStatus, hr );
  943. goto Cleanup;
  944. }
  945. //
  946. // If we are in joining mode and can't connect to the cluster, this
  947. // should be deemed a bad thing!
  948. //
  949. if ( m_fJoiningMode )
  950. {
  951. //
  952. // JOINING
  953. //
  954. switch ( hrStatus )
  955. {
  956. case S_OK:
  957. //
  958. // This is what we are expecting.
  959. //
  960. break;
  961. case HR_S_RPC_S_SERVER_UNAVAILABLE:
  962. {
  963. //
  964. // If we failed to connect to the server....
  965. //
  966. THR( HrLoadStringIntoBSTR( g_hInstance, IDS_TASKID_MINOR_CLUSTER_NOT_FOUND, &bstrDescription ) );
  967. hr = THR( SendStatusReport( m_bstrClusterName,
  968. TASKID_Major_Checking_For_Existing_Cluster,
  969. TASKID_Minor_Cluster_Not_Found,
  970. 0,
  971. CHECKING_TIMEOUT,
  972. CHECKING_TIMEOUT,
  973. HRESULT_FROM_WIN32( RPC_S_SERVER_UNAVAILABLE ),
  974. bstrDescription,
  975. NULL,
  976. NULL
  977. ) );
  978. hr = THR( HRESULT_FROM_WIN32( RPC_S_SERVER_UNAVAILABLE ) );
  979. }
  980. goto Cleanup;
  981. default:
  982. {
  983. //
  984. // If something else goes wrong, stop.
  985. //
  986. hr = THR( HrLoadStringIntoBSTR( g_hInstance,
  987. IDS_TASKID_MINOR_ERROR_CONTACTING_CLUSTER,
  988. &bstrDescription
  989. ) );
  990. hr = THR( SendStatusReport( m_bstrClusterName,
  991. TASKID_Major_Checking_For_Existing_Cluster,
  992. TASKID_Minor_Error_Contacting_Cluster,
  993. 0,
  994. CHECKING_TIMEOUT,
  995. CHECKING_TIMEOUT,
  996. hrStatus,
  997. bstrDescription,
  998. NULL,
  999. NULL
  1000. ) );
  1001. hr = THR( hrStatus );
  1002. }
  1003. goto Cleanup;
  1004. } // switch: hrStatus
  1005. } // if: joining
  1006. else
  1007. {
  1008. //
  1009. // FORMING
  1010. //
  1011. switch ( hrStatus )
  1012. {
  1013. case HR_S_RPC_S_SERVER_UNAVAILABLE:
  1014. //
  1015. // This is what we are expecting.
  1016. //
  1017. break;
  1018. case HRESULT_FROM_WIN32( ERROR_CONNECTION_REFUSED ):
  1019. case REGDB_E_CLASSNOTREG:
  1020. case E_ACCESSDENIED:
  1021. case S_OK:
  1022. {
  1023. //
  1024. // If we are forming and we find an existing cluster with the same name
  1025. // that we trying to form, we shouldn't let the user continue.
  1026. //
  1027. // NOTE that some error conditions indicate that "something" is hosting
  1028. // the cluster name.
  1029. //
  1030. hr = THR( HrFormatStringIntoBSTR(
  1031. g_hInstance
  1032. , IDS_TASKID_MINOR_EXISTING_CLUSTER_FOUND
  1033. , &bstrDescription
  1034. , m_bstrClusterName
  1035. ) );
  1036. hr = THR( SendStatusReport( m_bstrClusterName,
  1037. TASKID_Major_Checking_For_Existing_Cluster,
  1038. TASKID_Minor_Existing_Cluster_Found,
  1039. 0,
  1040. CHECKING_TIMEOUT,
  1041. CHECKING_TIMEOUT,
  1042. HRESULT_FROM_WIN32( ERROR_DUP_NAME ),
  1043. bstrDescription,
  1044. NULL,
  1045. NULL
  1046. ) );
  1047. hr = THR( HRESULT_FROM_WIN32( ERROR_DUP_NAME ) );
  1048. }
  1049. goto Cleanup;
  1050. default:
  1051. {
  1052. //
  1053. // If something else goes wrong, stop.
  1054. //
  1055. hr = THR( HrLoadStringIntoBSTR( g_hInstance,
  1056. IDS_TASKID_MINOR_ERROR_CONTACTING_CLUSTER,
  1057. &bstrDescription
  1058. ) );
  1059. hr = THR( SendStatusReport( m_bstrClusterName,
  1060. TASKID_Major_Checking_For_Existing_Cluster,
  1061. TASKID_Minor_Error_Contacting_Cluster,
  1062. 0,
  1063. CHECKING_TIMEOUT,
  1064. CHECKING_TIMEOUT,
  1065. hrStatus,
  1066. bstrDescription,
  1067. NULL,
  1068. NULL
  1069. ) );
  1070. hr = THR( hrStatus );
  1071. }
  1072. goto Cleanup;
  1073. } // switch: hrStatus
  1074. } // else: forming
  1075. if ( m_fJoiningMode )
  1076. {
  1077. //
  1078. // Memorize the cookies of the objects that the user entered.
  1079. //
  1080. hr = THR( HrGetUsersNodesCookies() );
  1081. if ( FAILED( hr ) )
  1082. goto Cleanup;
  1083. //
  1084. // Create cookies for the existing nodes.
  1085. //
  1086. hr = THR( HrAddJoinedNodes() );
  1087. if ( FAILED( hr ) )
  1088. goto Cleanup;
  1089. }
  1090. //
  1091. // Tell the UI layer that we are done searching for the cluster.
  1092. //
  1093. hr = THR( SendStatusReport( NULL,
  1094. TASKID_Major_Checking_For_Existing_Cluster,
  1095. TASKID_Minor_Update_Progress,
  1096. 0,
  1097. CHECKING_TIMEOUT,
  1098. CHECKING_TIMEOUT,
  1099. S_OK,
  1100. NULL,
  1101. NULL,
  1102. NULL
  1103. ) );
  1104. if ( FAILED( hr ) )
  1105. goto Cleanup;
  1106. Cleanup:
  1107. if ( punk != NULL )
  1108. {
  1109. punk->Release();
  1110. }
  1111. if ( psi != NULL )
  1112. {
  1113. psi->Release();
  1114. }
  1115. TraceSysFreeString( bstrDescription );
  1116. if ( ptgci != NULL )
  1117. {
  1118. ptgci->Release();
  1119. }
  1120. HRETURN( hr );
  1121. OutOfMemory:
  1122. hr = E_OUTOFMEMORY;
  1123. SSR_ANALYSIS_FAILED( TASKID_Major_Checking_For_Existing_Cluster, TASKID_Minor_WaitForCluster_OutOfMemory, hr );
  1124. goto Cleanup;
  1125. } //*** CTaskAnalyzeCluster::HrWaitForClusterConnection()
  1126. //////////////////////////////////////////////////////////////////////////////
  1127. //
  1128. // HRESULT
  1129. // CTaskAnalyzeCluster::HrCountNumberOfNodes( void )
  1130. //
  1131. //////////////////////////////////////////////////////////////////////////////
  1132. HRESULT
  1133. CTaskAnalyzeCluster::HrCountNumberOfNodes()
  1134. {
  1135. TraceFunc( "" );
  1136. HRESULT hr;
  1137. OBJECTCOOKIE cookie;
  1138. OBJECTCOOKIE cookieDummy;
  1139. IUnknown * punk = NULL;
  1140. IEnumCookies * pec = NULL;
  1141. //
  1142. // Make sure all the node object that (will) make up the cluster
  1143. // are in a stable state.
  1144. //
  1145. hr = THR( m_pom->FindObject( CLSID_NodeType, m_cookieCluster, NULL, DFGUID_EnumCookies, &cookieDummy, &punk ) );
  1146. if ( FAILED( hr ) )
  1147. {
  1148. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CountNodes_FindObject, hr );
  1149. goto Cleanup;
  1150. }
  1151. hr = THR( punk->TypeSafeQI( IEnumCookies, &pec ) );
  1152. if ( FAILED( hr ) )
  1153. {
  1154. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CountNodes_FindObject_QI, hr );
  1155. goto Cleanup;
  1156. }
  1157. pec = TraceInterface( L"CTaskAnalyzeCluster!IEnumCookies", IEnumCookies, pec, 1 );
  1158. punk->Release();
  1159. punk = NULL;
  1160. // While we're checking the node's statuses, we'll also count how
  1161. // many nodes there are.
  1162. m_cNodes = 0;
  1163. Assert( hr == S_OK );
  1164. while ( hr == S_OK )
  1165. {
  1166. HRESULT hrStatus;
  1167. ULONG celtDummy;
  1168. hr = STHR( pec->Next( 1, &cookie, &celtDummy ) );
  1169. if ( FAILED( hr ) )
  1170. {
  1171. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CountNodes_EnumNodes_Next, hr );
  1172. goto Cleanup;
  1173. }
  1174. if ( hr == S_FALSE )
  1175. break; // exit condition
  1176. m_cNodes ++;
  1177. } // while: hr == S_OK
  1178. if ( hr == S_FALSE)
  1179. {
  1180. hr = S_OK;
  1181. }
  1182. Cleanup:
  1183. if ( punk != NULL )
  1184. {
  1185. punk->Release();
  1186. }
  1187. if ( pec != NULL )
  1188. {
  1189. pec->Release();
  1190. }
  1191. HRETURN( hr );
  1192. } //*** CTaskAnalyzeCluster::HrCountNumberOfNodes()
  1193. //////////////////////////////////////////////////////////////////////////////
  1194. //
  1195. // HRESULT
  1196. // HrCreateSubTasksToGatherNodeInfo( void )
  1197. //
  1198. //////////////////////////////////////////////////////////////////////////////
  1199. HRESULT
  1200. CTaskAnalyzeCluster::HrCreateSubTasksToGatherNodeInfo( void )
  1201. {
  1202. TraceFunc( "" );
  1203. HRESULT hr;
  1204. ULONG cNode;
  1205. ULONG cNodesToProcess;
  1206. ULONG ulCurrent;
  1207. DWORD sc;
  1208. OBJECTCOOKIE cookie;
  1209. OBJECTCOOKIE cookieDummy;
  1210. OBJECTCOOKIE cookieNode;
  1211. BSTR bstrName = NULL;
  1212. BSTR bstrNotification = NULL;
  1213. IUnknown * punk = NULL;
  1214. IConnectionPoint * pcp = NULL;
  1215. IClusCfgNodeInfo * pccni = NULL;
  1216. IEnumCookies * pec = NULL;
  1217. ITaskGatherNodeInfo * ptgni = NULL;
  1218. IStandardInfo * psi = NULL;
  1219. IStandardInfo ** psiCompletion = NULL;
  1220. Assert( m_hrStatus == S_OK );
  1221. //
  1222. // Get the enum of the nodes.
  1223. //
  1224. hr = THR( m_pom->FindObject( CLSID_NodeType, m_cookieCluster, NULL, DFGUID_EnumCookies, &cookieDummy, &punk ) );
  1225. if ( FAILED( hr ) )
  1226. {
  1227. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_FindObject, hr );
  1228. goto Cleanup;
  1229. }
  1230. hr = THR( punk->TypeSafeQI( IEnumCookies, &pec ) );
  1231. if ( FAILED( hr ) )
  1232. {
  1233. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_FindObject_QI, hr );
  1234. goto Cleanup;
  1235. }
  1236. pec = TraceInterface( L"CTaskAnalyzeCluster!IEnumCookies", IEnumCookies, pec, 1 );
  1237. punk->Release();
  1238. punk = NULL;
  1239. //
  1240. // Allocate a buffer to collect cookies
  1241. //
  1242. Assert( m_cCookies == 0 );
  1243. Assert( m_pcookies == NULL );
  1244. Assert( m_cSubTasksDone == 0 );
  1245. m_pcookies = reinterpret_cast< OBJECTCOOKIE * >( TraceAlloc( 0, m_cNodes * sizeof( OBJECTCOOKIE ) ) );
  1246. if ( m_pcookies == NULL )
  1247. goto OutOfMemory;
  1248. //
  1249. // KB: gpease 29-NOV-2000
  1250. // Create a list of "interesting" completion cookie StandardInfo-s. If any of the
  1251. // statuses return from this list are FAILED, then abort the analysis.
  1252. //
  1253. psiCompletion = reinterpret_cast< IStandardInfo ** >( TraceAlloc( HEAP_ZERO_MEMORY, m_cNodes * sizeof( IStandardInfo * ) ) );
  1254. if ( psiCompletion == NULL )
  1255. goto OutOfMemory;
  1256. //
  1257. // Loop thru the nodes, creating cookies and allocating a gather task for
  1258. // that node.
  1259. //
  1260. for ( cNode = 0; cNode < m_cNodes; cNode ++ )
  1261. {
  1262. LPWSTR psz;
  1263. ULONG celtDummy;
  1264. ULONG idx;
  1265. BOOL fFound;
  1266. //
  1267. // Grab the next node.
  1268. //
  1269. hr = STHR( pec->Next( 1, &cookieNode, &celtDummy ) );
  1270. if ( hr == S_FALSE )
  1271. break; // exit condition
  1272. if ( FAILED( hr ) )
  1273. {
  1274. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_Next, hr );
  1275. goto Cleanup;
  1276. }
  1277. //
  1278. // Get the nodes name. We are using this to distinguish one nodes
  1279. // completion cookie from another. It might also make debugging
  1280. // easier (??).
  1281. //
  1282. hr = THR( m_pom->GetObject( DFGUID_NodeInformation, cookieNode, &punk ) );
  1283. if ( FAILED( hr ) )
  1284. {
  1285. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_GetObject, hr );
  1286. goto Cleanup;
  1287. }
  1288. hr = THR( punk->TypeSafeQI( IClusCfgNodeInfo, &pccni ) );
  1289. if ( FAILED( hr ) )
  1290. {
  1291. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_GetObject_QI, hr );
  1292. goto Cleanup;
  1293. }
  1294. punk->Release();
  1295. punk = NULL;
  1296. hr = THR( pccni->GetName( &bstrName ) );
  1297. if ( FAILED( hr ) )
  1298. {
  1299. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_GetName, hr );
  1300. goto Cleanup;
  1301. }
  1302. TraceMemoryAddBSTR( bstrName );
  1303. //
  1304. // Create a completion cookie.
  1305. //
  1306. hr = THR( m_pom->FindObject( IID_NULL, m_cookieCluster, bstrName, DFGUID_StandardInfo, &m_pcookies[ cNode ], &punk ) );
  1307. if ( FAILED( hr ) )
  1308. {
  1309. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_CompletionCookie_FindObject, hr );
  1310. goto Cleanup;
  1311. }
  1312. //
  1313. // Increment the cookie counter.
  1314. //
  1315. m_cCookies ++;
  1316. //
  1317. // See if this node is one of the user entered nodes.
  1318. //
  1319. if ( !m_fJoiningMode )
  1320. {
  1321. //
  1322. // All nodes are "interesting" during a form operation.
  1323. //
  1324. Assert( m_cUserNodes == 0 );
  1325. Assert( m_pcookiesUser == NULL );
  1326. fFound = TRUE;
  1327. }
  1328. else
  1329. {
  1330. //
  1331. // Only the nodes the user entered are interesting during a join operation.
  1332. //
  1333. for ( fFound = FALSE, idx = 0; idx < m_cUserNodes; idx ++ )
  1334. {
  1335. if ( m_pcookiesUser[ idx ] == cookieNode )
  1336. {
  1337. fFound = TRUE;
  1338. break;
  1339. }
  1340. }
  1341. }
  1342. if ( fFound )
  1343. {
  1344. hr = THR( punk->TypeSafeQI( IStandardInfo, &psiCompletion[ cNode ] ) );
  1345. if ( FAILED( hr ) )
  1346. {
  1347. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_CompletionCookie_FindObject_QI, hr );
  1348. goto Cleanup;
  1349. }
  1350. }
  1351. else
  1352. {
  1353. Assert( psiCompletion[ cNode ] == NULL );
  1354. }
  1355. punk->Release();
  1356. punk = NULL;
  1357. //
  1358. // Create a task to gather this nodes information.
  1359. //
  1360. hr = THR( m_ptm->CreateTask( TASK_GatherNodeInfo,
  1361. &punk
  1362. ) );
  1363. if ( FAILED( hr ) )
  1364. {
  1365. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_CreateTask, hr );
  1366. goto Cleanup;
  1367. }
  1368. hr = THR( punk->TypeSafeQI( ITaskGatherNodeInfo, &ptgni ) );
  1369. if ( FAILED( hr ) )
  1370. {
  1371. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_QI_GatherNodeInfo, hr );
  1372. goto Cleanup;
  1373. }
  1374. punk->Release();
  1375. punk = NULL;
  1376. //
  1377. // Set the tasks completion cookie.
  1378. //
  1379. hr = THR( ptgni->SetCompletionCookie( m_pcookies[ cNode ] ) );
  1380. if ( FAILED( hr ) )
  1381. {
  1382. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_SetCompletionCookie, hr );
  1383. goto Cleanup;
  1384. }
  1385. //
  1386. // Tell it what node it is suppose to gather information from.
  1387. //
  1388. hr = THR( ptgni->SetCookie( cookieNode ) );
  1389. if ( FAILED( hr ) )
  1390. {
  1391. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_SetCookie, hr );
  1392. goto Cleanup;
  1393. }
  1394. //
  1395. // Submit the task.
  1396. //
  1397. hr = THR( m_ptm->SubmitTask( ptgni ) );
  1398. if ( FAILED( hr ) )
  1399. {
  1400. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_EnumNodes_SubmitTask, hr );
  1401. goto Cleanup;
  1402. }
  1403. //
  1404. // Cleanup for the next node.
  1405. //
  1406. pccni->Release();
  1407. pccni = NULL;
  1408. TraceSysFreeString( bstrName );
  1409. bstrName = NULL;
  1410. ptgni->Release();
  1411. ptgni = NULL;
  1412. } // while: looping thru nodes
  1413. Assert( m_cCookies == m_cNodes );
  1414. //
  1415. // Reset the signal event.
  1416. //
  1417. {
  1418. BOOL bRet = ResetEvent( m_event );
  1419. Assert( bRet );
  1420. }
  1421. //
  1422. // Now wait for the work to be done.
  1423. //
  1424. for ( ulCurrent = 0, sc = WAIT_OBJECT_0 + 1
  1425. ; sc != WAIT_OBJECT_0
  1426. ;
  1427. )
  1428. {
  1429. MSG msg;
  1430. while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
  1431. {
  1432. TranslateMessage( &msg );
  1433. DispatchMessage( &msg );
  1434. }
  1435. sc = MsgWaitForMultipleObjectsEx( 1,
  1436. &m_event,
  1437. INFINITE,
  1438. QS_ALLEVENTS | QS_ALLINPUT | QS_ALLPOSTMESSAGE,
  1439. 0
  1440. );
  1441. if ( ulCurrent != CHECKING_TIMEOUT )
  1442. {
  1443. ulCurrent ++;
  1444. Assert( ulCurrent != CHECKING_TIMEOUT );
  1445. hr = THR( SendStatusReport( NULL,
  1446. TASKID_Major_Establish_Connection,
  1447. TASKID_Minor_Update_Progress,
  1448. 0,
  1449. CHECKING_TIMEOUT,
  1450. ulCurrent,
  1451. S_OK,
  1452. NULL,
  1453. NULL,
  1454. NULL
  1455. ) );
  1456. if ( FAILED( hr ) )
  1457. goto Cleanup;
  1458. }
  1459. } // while: sc == WAIT_OBJECT_0
  1460. //
  1461. // Now check the results using the list of completion cookie StandardInfo-s
  1462. // built earlier of interesting objects. If any of these "interesting" cookies
  1463. // return a FAILED status, then abort the analysis.
  1464. //
  1465. for ( cNode = 0, cNodesToProcess = 0; cNode < m_cNodes; cNode++ )
  1466. {
  1467. HRESULT hrStatus;
  1468. if ( psiCompletion[ cNode ] == NULL )
  1469. continue;
  1470. hr = THR( psiCompletion[ cNode ]->GetStatus( &hrStatus ) );
  1471. if ( FAILED( hrStatus ) )
  1472. {
  1473. hr = THR( hrStatus );
  1474. goto Cleanup;
  1475. }
  1476. if ( hrStatus == S_OK )
  1477. {
  1478. cNodesToProcess++;
  1479. } // if:
  1480. } // for: cNode
  1481. if ( cNodesToProcess == 0 )
  1482. {
  1483. BSTR bstr = NULL;
  1484. hr = HRESULT_FROM_WIN32( TW32( ERROR_NODE_NOT_AVAILABLE ) );
  1485. THR( HrLoadStringIntoBSTR( g_hInstance, IDS_TASKID_MINOR_NO_NODES_TO_PROCESS, &bstr ) );
  1486. THR( SendStatusReport(
  1487. bstrName
  1488. , TASKID_Major_Establish_Connection
  1489. , TASKID_Minor_No_Nodes_To_Process
  1490. , 0
  1491. , 1
  1492. , 1
  1493. , hr
  1494. , bstr
  1495. , NULL
  1496. , NULL
  1497. ) );
  1498. TraceSysFreeString( bstr );
  1499. goto Cleanup;
  1500. } // if:
  1501. hr = S_OK;
  1502. Cleanup:
  1503. THR( HrFreeCookies() );
  1504. TraceSysFreeString( bstrName );
  1505. TraceSysFreeString( bstrNotification );
  1506. if ( punk != NULL )
  1507. {
  1508. punk->Release();
  1509. }
  1510. if ( pccni != NULL )
  1511. {
  1512. pccni->Release();
  1513. }
  1514. if ( pec != NULL )
  1515. {
  1516. pec->Release();
  1517. }
  1518. if ( ptgni != NULL )
  1519. {
  1520. ptgni->Release();
  1521. }
  1522. if ( psi != NULL )
  1523. {
  1524. psi->Release();
  1525. }
  1526. if ( psiCompletion != NULL )
  1527. {
  1528. for ( cNode = 0; cNode < m_cNodes; cNode++ )
  1529. {
  1530. if ( psiCompletion[ cNode ] != NULL )
  1531. {
  1532. psiCompletion[ cNode ]->Release();
  1533. }
  1534. }
  1535. TraceFree( psiCompletion );
  1536. }
  1537. HRETURN( hr );
  1538. //Win32Error:
  1539. hr = HRESULT_FROM_WIN32( TW32( GetLastError() ) );
  1540. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_Win32Error, hr );
  1541. goto Cleanup;
  1542. OutOfMemory:
  1543. hr = E_OUTOFMEMORY;
  1544. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_CreateNodeTasks_OutOfMemory, hr );
  1545. goto Cleanup;
  1546. } //*** CTaskAnalyzeCluster::HrCreateSubTasksToGatherNodeInfo()
  1547. //////////////////////////////////////////////////////////////////////////////
  1548. //
  1549. // HRESULT
  1550. // HrCreateSubTasksToGatherNodeResourcesAndNetworks( void )
  1551. //
  1552. //////////////////////////////////////////////////////////////////////////////
  1553. HRESULT
  1554. CTaskAnalyzeCluster::HrCreateSubTasksToGatherNodeResourcesAndNetworks( void )
  1555. {
  1556. TraceFunc( "" );
  1557. HRESULT hr;
  1558. ULONG idxNode;
  1559. ULONG ulCurrent;
  1560. DWORD sc;
  1561. OBJECTCOOKIE cookie;
  1562. OBJECTCOOKIE cookieDummy;
  1563. OBJECTCOOKIE cookieNode;
  1564. OBJECTCOOKIE * pcookies;
  1565. BSTR bstrName = NULL;
  1566. BSTR bstrNotification = NULL;
  1567. IUnknown * punk = NULL;
  1568. IConnectionPoint * pcp = NULL;
  1569. IClusCfgNodeInfo * pccni = NULL;
  1570. IEnumCookies * pec = NULL;
  1571. ITaskGatherInformation * ptgi = NULL;
  1572. IStandardInfo * psi = NULL;
  1573. IStandardInfo ** ppsiStatuses = NULL;
  1574. Assert( m_hrStatus == S_OK );
  1575. //
  1576. // Tell the UI layer we are starting to retrieve the resources/networks.
  1577. //
  1578. hr = THR( SendStatusReport( NULL,
  1579. TASKID_Major_Find_Devices,
  1580. TASKID_Minor_Update_Progress,
  1581. 0,
  1582. CHECKING_TIMEOUT,
  1583. 0,
  1584. S_OK,
  1585. NULL,
  1586. NULL,
  1587. NULL
  1588. ) );
  1589. if ( FAILED( hr ) )
  1590. goto Cleanup;
  1591. //
  1592. // Get the enum of the nodes.
  1593. //
  1594. hr = THR( m_pom->FindObject( CLSID_NodeType, m_cookieCluster, NULL, DFGUID_EnumCookies, &cookieDummy, &punk ) );
  1595. if ( FAILED( hr ) )
  1596. {
  1597. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_FindObject, hr );
  1598. goto Cleanup;
  1599. }
  1600. hr = THR( punk->TypeSafeQI( IEnumCookies, &pec ) );
  1601. if ( FAILED( hr ) )
  1602. {
  1603. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_FindObject_QI, hr );
  1604. goto Cleanup;
  1605. }
  1606. pec = TraceInterface( L"CTaskAnalyzeCluster!IEnumCookies", IEnumCookies, pec, 1 );
  1607. punk->Release();
  1608. punk = NULL;
  1609. //
  1610. // Allocate a buffer to collect cookies
  1611. //
  1612. Assert( m_cCookies == 0 );
  1613. Assert( m_pcookies == NULL );
  1614. Assert( m_cSubTasksDone == 0 );
  1615. m_pcookies = reinterpret_cast< OBJECTCOOKIE * >( TraceAlloc( 0, m_cNodes * sizeof( OBJECTCOOKIE ) ) );
  1616. if ( m_pcookies == NULL )
  1617. goto OutOfMemory;
  1618. ppsiStatuses = reinterpret_cast< IStandardInfo ** >( TraceAlloc( 0, m_cNodes * sizeof( IStandardInfo * ) ) );
  1619. if ( ppsiStatuses == NULL )
  1620. goto OutOfMemory;
  1621. //
  1622. // Loop thru the nodes, creating cookies and allocating a gather task for
  1623. // that node.
  1624. //
  1625. for ( idxNode = 0 ; idxNode < m_cNodes ; idxNode++ )
  1626. {
  1627. LPWSTR psz;
  1628. ULONG celtDummy;
  1629. //
  1630. // Grab the next node.
  1631. //
  1632. hr = STHR( pec->Next( 1, &cookieNode, &celtDummy ) );
  1633. if ( hr == S_FALSE )
  1634. break; // exit condition
  1635. if ( FAILED( hr ) )
  1636. {
  1637. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_Next, hr );
  1638. goto Cleanup;
  1639. }
  1640. //
  1641. // Get the node's name. We are using this to distinguish one node's
  1642. // completion cookie from another. It might also make debugging
  1643. // easier (??).
  1644. //
  1645. hr = THR( m_pom->GetObject( DFGUID_NodeInformation, cookieNode, &punk ) );
  1646. if ( FAILED( hr ) )
  1647. {
  1648. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_GetObject, hr );
  1649. goto Cleanup;
  1650. }
  1651. hr = THR( punk->TypeSafeQI( IClusCfgNodeInfo, &pccni ) );
  1652. if ( FAILED( hr ) )
  1653. {
  1654. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_GetObject_QI, hr );
  1655. goto Cleanup;
  1656. }
  1657. punk->Release();
  1658. punk = NULL;
  1659. hr = THR( pccni->GetName( &bstrName ) );
  1660. if ( FAILED( hr ) )
  1661. {
  1662. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_GetName, hr );
  1663. goto Cleanup;
  1664. }
  1665. TraceMemoryAddBSTR( bstrName );
  1666. //
  1667. // Create a completion cookie.
  1668. //
  1669. hr = THR( m_pom->FindObject( IID_NULL, m_cookieCluster, bstrName, DFGUID_StandardInfo, &m_pcookies[ idxNode ], &punk ) );
  1670. if ( FAILED( hr ) )
  1671. {
  1672. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_CompletionCookie_FindObject, hr );
  1673. goto Cleanup;
  1674. }
  1675. hr = THR( punk->TypeSafeQI( IStandardInfo, &ppsiStatuses[ idxNode ] ) );
  1676. if ( FAILED( hr ) )
  1677. {
  1678. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_CompletionCookie_FindObject_QI, hr );
  1679. goto Cleanup;
  1680. }
  1681. punk->Release();
  1682. punk = NULL;
  1683. //
  1684. // Increment the cookie counter.
  1685. //
  1686. m_cCookies ++;
  1687. //
  1688. // Create a task to gather this node's information.
  1689. //
  1690. hr = THR( m_ptm->CreateTask( TASK_GatherInformation, &punk ) );
  1691. if ( FAILED( hr ) )
  1692. {
  1693. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_CreateTask, hr );
  1694. goto Cleanup;
  1695. }
  1696. TraceMoveFromMemoryList( punk, g_GlobalMemoryList );
  1697. hr = THR( punk->TypeSafeQI( ITaskGatherInformation, &ptgi ) );
  1698. if ( FAILED( hr ) )
  1699. {
  1700. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_QI_GatherNodeInfo, hr );
  1701. goto Cleanup;
  1702. }
  1703. punk->Release();
  1704. punk = NULL;
  1705. //
  1706. // Set the tasks completion cookie.
  1707. //
  1708. hr = THR( ptgi->SetCompletionCookie( m_pcookies[ idxNode ] ) );
  1709. if ( FAILED( hr ) )
  1710. {
  1711. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_SetCompletionCookie, hr );
  1712. goto Cleanup;
  1713. }
  1714. //
  1715. // Tell it what node it is suppose to gather information from.
  1716. //
  1717. hr = THR( ptgi->SetNodeCookie( cookieNode ) );
  1718. if ( FAILED( hr ) )
  1719. {
  1720. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_SetCookie, hr );
  1721. goto Cleanup;
  1722. }
  1723. //
  1724. // Tell it if we are joining or not.
  1725. //
  1726. if ( m_fJoiningMode )
  1727. {
  1728. hr = THR( ptgi->SetJoining() );
  1729. if ( FAILED( hr ) )
  1730. {
  1731. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_SetJoining, hr );
  1732. goto Cleanup;
  1733. }
  1734. }
  1735. //
  1736. // Submit the task.
  1737. //
  1738. hr = THR( m_ptm->SubmitTask( ptgi ) );
  1739. if ( FAILED( hr ) )
  1740. {
  1741. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_EnumNodes_SubmitTask, hr );
  1742. goto Cleanup;
  1743. }
  1744. //
  1745. // Cleanup for the next node.
  1746. //
  1747. pccni->Release();
  1748. pccni = NULL;
  1749. TraceSysFreeString( bstrName );
  1750. bstrName = NULL;
  1751. ptgi->Release();
  1752. ptgi = NULL;
  1753. } // while: looping thru nodes
  1754. Assert( m_cCookies == m_cNodes );
  1755. //
  1756. // Reset the signal event.
  1757. //
  1758. {
  1759. BOOL bRet = ResetEvent( m_event );
  1760. Assert( bRet );
  1761. }
  1762. //
  1763. // Now wait for the work to be done.
  1764. //
  1765. for ( ulCurrent = 0, sc = WAIT_OBJECT_0 + 1
  1766. ; sc != WAIT_OBJECT_0
  1767. ;
  1768. )
  1769. {
  1770. MSG msg;
  1771. while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
  1772. {
  1773. TranslateMessage( &msg );
  1774. DispatchMessage( &msg );
  1775. }
  1776. sc = MsgWaitForMultipleObjectsEx( 1,
  1777. &m_event,
  1778. INFINITE,
  1779. QS_ALLEVENTS | QS_ALLINPUT | QS_ALLPOSTMESSAGE,
  1780. 0
  1781. );
  1782. if ( ulCurrent != CHECKING_TIMEOUT )
  1783. {
  1784. ulCurrent ++;
  1785. Assert( ulCurrent != CHECKING_TIMEOUT );
  1786. hr = THR( SendStatusReport( NULL,
  1787. TASKID_Major_Find_Devices,
  1788. TASKID_Minor_Update_Progress,
  1789. 0,
  1790. CHECKING_TIMEOUT,
  1791. ulCurrent,
  1792. S_OK,
  1793. NULL,
  1794. NULL,
  1795. NULL
  1796. ) );
  1797. if ( FAILED( hr ) )
  1798. goto Cleanup;
  1799. }
  1800. } // while: sc == WAIT_OBJECT_0
  1801. //
  1802. // See if anything went wrong.
  1803. //
  1804. for ( idxNode = 0 ; idxNode < m_cNodes ; idxNode++ )
  1805. {
  1806. HRESULT hrStatus;
  1807. if ( ppsiStatuses[ idxNode ] == NULL )
  1808. continue;
  1809. hr = THR( ppsiStatuses[ idxNode ]->GetStatus( &hrStatus ) );
  1810. if ( FAILED( hr ) )
  1811. {
  1812. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_GetStatus, hr );
  1813. goto Cleanup;
  1814. }
  1815. if ( FAILED( hrStatus ) )
  1816. {
  1817. hr = THR( hrStatus );
  1818. goto Cleanup;
  1819. }
  1820. }
  1821. //
  1822. // Tell the UI we are done.
  1823. //
  1824. hr = THR( SendStatusReport(
  1825. NULL
  1826. , TASKID_Major_Find_Devices
  1827. , TASKID_Minor_Update_Progress
  1828. , 0
  1829. , CHECKING_TIMEOUT
  1830. , CHECKING_TIMEOUT
  1831. , S_OK
  1832. , NULL
  1833. , NULL
  1834. , NULL
  1835. ) );
  1836. Cleanup:
  1837. THR( HrFreeCookies() );
  1838. TraceSysFreeString( bstrName );
  1839. TraceSysFreeString( bstrNotification );
  1840. if ( punk != NULL )
  1841. {
  1842. punk->Release();
  1843. }
  1844. if ( pccni != NULL )
  1845. {
  1846. pccni->Release();
  1847. }
  1848. if ( pec != NULL )
  1849. {
  1850. pec->Release();
  1851. }
  1852. if ( ptgi != NULL )
  1853. {
  1854. ptgi->Release();
  1855. }
  1856. if ( psi != NULL )
  1857. {
  1858. psi->Release();
  1859. }
  1860. if ( ppsiStatuses != NULL )
  1861. {
  1862. for ( idxNode = 0 ; idxNode < m_cNodes ; idxNode++ )
  1863. {
  1864. if ( ppsiStatuses[ idxNode ] != NULL )
  1865. {
  1866. ppsiStatuses[ idxNode ]->Release();
  1867. }
  1868. }
  1869. TraceFree( ppsiStatuses );
  1870. }
  1871. HRETURN( hr );
  1872. //Win32Error:
  1873. hr = HRESULT_FROM_WIN32( TW32( GetLastError() ) );
  1874. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_Win32Error, hr );
  1875. goto Cleanup;
  1876. OutOfMemory:
  1877. hr = E_OUTOFMEMORY;
  1878. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_GatherInformation_OutOfMemory, hr );
  1879. goto Cleanup;
  1880. } //*** CTaskAnalyzeCluster::HrCreateSubTasksToGatherNodeResourcesAndNetworks()
  1881. //////////////////////////////////////////////////////////////////////////////
  1882. //
  1883. // HRESULT
  1884. // CTaskAnalyzeCluster::HrCheckClusterFeasibility( void )
  1885. //
  1886. //////////////////////////////////////////////////////////////////////////////
  1887. HRESULT
  1888. CTaskAnalyzeCluster::HrCheckClusterFeasibility( void )
  1889. {
  1890. TraceFunc( "" );
  1891. HRESULT hr;
  1892. BOOL fNeedToCheckMembership = FALSE;
  1893. IEnumNodes * pen = NULL;
  1894. IClusCfgNodeInfo * pccni = NULL;
  1895. //
  1896. // Notify the UI layer that we have started.
  1897. //
  1898. hr = THR( SendStatusReport( NULL,
  1899. TASKID_Major_Check_Cluster_Feasibility,
  1900. TASKID_Minor_Update_Progress,
  1901. 0,
  1902. 5,
  1903. 0,
  1904. S_OK,
  1905. NULL,
  1906. NULL,
  1907. NULL
  1908. ) );
  1909. if ( FAILED( hr ) )
  1910. goto Cleanup;
  1911. //
  1912. // Check membership.
  1913. //
  1914. hr = THR( HrCheckClusterMembership() );
  1915. if ( FAILED( hr ) )
  1916. goto Cleanup;
  1917. hr = THR( SendStatusReport( NULL,
  1918. TASKID_Major_Check_Cluster_Feasibility,
  1919. TASKID_Minor_Update_Progress,
  1920. 0,
  1921. 5,
  1922. 1,
  1923. S_OK,
  1924. NULL,
  1925. NULL,
  1926. NULL
  1927. ) );
  1928. if ( FAILED( hr ) )
  1929. goto Cleanup;
  1930. //
  1931. // Check version interoperability.
  1932. //
  1933. hr = STHR( HrCheckInteroperability() );
  1934. if ( FAILED( hr ) )
  1935. goto Cleanup;
  1936. hr = THR( SendStatusReport( NULL,
  1937. TASKID_Major_Check_Cluster_Feasibility,
  1938. TASKID_Minor_Update_Progress,
  1939. 0,
  1940. 5,
  1941. 2,
  1942. S_OK,
  1943. NULL,
  1944. NULL,
  1945. NULL
  1946. ) );
  1947. if ( FAILED( hr ) )
  1948. goto Cleanup;
  1949. //
  1950. // Compare the devices.
  1951. //
  1952. hr = THR( HrCompareResources() );
  1953. if ( FAILED( hr ) )
  1954. goto Cleanup;
  1955. hr = THR( SendStatusReport( NULL,
  1956. TASKID_Major_Check_Cluster_Feasibility,
  1957. TASKID_Minor_Update_Progress,
  1958. 0,
  1959. 5,
  1960. 3,
  1961. S_OK,
  1962. NULL,
  1963. NULL,
  1964. NULL
  1965. ) );
  1966. if ( FAILED( hr ) )
  1967. goto Cleanup;
  1968. //
  1969. // Compare the networks.
  1970. //
  1971. hr = THR( HrCompareNetworks() );
  1972. if ( FAILED( hr ) )
  1973. goto Cleanup;
  1974. hr = THR( SendStatusReport( NULL,
  1975. TASKID_Major_Check_Cluster_Feasibility,
  1976. TASKID_Minor_Update_Progress,
  1977. 0,
  1978. 5,
  1979. 4,
  1980. S_OK,
  1981. NULL,
  1982. NULL,
  1983. NULL
  1984. ) );
  1985. if ( FAILED( hr ) )
  1986. goto Cleanup;
  1987. //
  1988. // Now check to see if the nodes can all see the selected quorum resource.
  1989. //
  1990. hr = THR( HrCheckForCommonQuorumResource() );
  1991. if ( FAILED( hr ) )
  1992. goto Cleanup;
  1993. //
  1994. // Notify the UI layer that we are done.
  1995. //
  1996. hr = THR( SendStatusReport( NULL,
  1997. TASKID_Major_Check_Cluster_Feasibility,
  1998. TASKID_Minor_Update_Progress,
  1999. 0,
  2000. 5,
  2001. 5,
  2002. S_OK,
  2003. NULL,
  2004. NULL,
  2005. NULL
  2006. ) );
  2007. Cleanup:
  2008. if ( pen != NULL )
  2009. {
  2010. pen->Release();
  2011. }
  2012. if ( pccni != NULL )
  2013. {
  2014. pccni->Release();
  2015. }
  2016. HRETURN( hr );
  2017. } //*** CTaskAnalyzeCluster::HrCheckClusterFeasibility()
  2018. //////////////////////////////////////////////////////////////////////////////
  2019. //
  2020. // HRESULT
  2021. // CTaskAnalyzeCluster::HrAddJoinedNodes( void )
  2022. //
  2023. //////////////////////////////////////////////////////////////////////////////
  2024. HRESULT
  2025. CTaskAnalyzeCluster::HrAddJoinedNodes( void )
  2026. {
  2027. TraceFunc( "" );
  2028. HRESULT hr;
  2029. ULONG idx;
  2030. DWORD dw;
  2031. DWORD dwType;
  2032. DWORD cchName;
  2033. WCHAR szName[ DNS_MAX_NAME_BUFFER_LENGTH ];
  2034. OBJECTCOOKIE cookieDummy;
  2035. LPWSTR pszDomain;
  2036. BSTR bstrFQDNName = NULL;
  2037. BSTR bstrBindingString = NULL;
  2038. HCLUSTER hCluster = NULL;
  2039. HCLUSENUM hClusEnum = NULL;
  2040. IUnknown * punkDummy = NULL;
  2041. IUnknown * punk = NULL;
  2042. IClusCfgServer * piccs = NULL;
  2043. // CLSID clsidLog;
  2044. // CopyMemory( &clsidLog, &TASKID_Major_Establish_Connection, sizeof( clsidLog ) );
  2045. hr = THR( m_pcm->GetConnectionToObject( m_cookieCluster, &punk ) );
  2046. if ( FAILED( hr ) )
  2047. {
  2048. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrAddJoinedNodes_GetConnectionObject, hr );
  2049. goto Cleanup;
  2050. } // if:
  2051. hr = THR( punk->TypeSafeQI( IClusCfgServer, &piccs ) );
  2052. if ( FAILED( hr ) )
  2053. {
  2054. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrAddJoinedNodes_ConfigConnection_QI, hr );
  2055. goto Cleanup;
  2056. } // if:
  2057. hr = THR( piccs->GetBindingString( &bstrBindingString ) );
  2058. if ( FAILED( hr ) )
  2059. {
  2060. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrAddJoinedNodes_GetBindingString, hr );
  2061. goto Cleanup;
  2062. } // if:
  2063. TraceMemoryAddBSTR( bstrBindingString );
  2064. pszDomain = wcschr( m_bstrClusterName, L'.' ); // we don't need to move past the dot.
  2065. hCluster = OpenCluster( bstrBindingString );
  2066. if ( hCluster == NULL )
  2067. {
  2068. hr = HRESULT_FROM_WIN32( TW32( GetLastError() ) );
  2069. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_AddJoinedNodes_OpenCluster, hr );
  2070. goto Cleanup;
  2071. }
  2072. hClusEnum = ClusterOpenEnum( hCluster, CLUSTER_ENUM_NODE );
  2073. if ( hClusEnum == NULL )
  2074. {
  2075. hr = HRESULT_FROM_WIN32( TW32( GetLastError() ) );
  2076. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_AddJoinedNodes_ClusterOpenEnum, hr );
  2077. goto Cleanup;
  2078. }
  2079. for ( idx = 0; ; idx ++ )
  2080. {
  2081. //
  2082. // Cleanup
  2083. //
  2084. TraceSysFreeString( bstrFQDNName );
  2085. bstrFQDNName = NULL;
  2086. // TraceSysFreeString( bstrBindingString );
  2087. // bstrBindingString = NULL;
  2088. //
  2089. // Get the next node name from the cluster.
  2090. //
  2091. cchName = ARRAYSIZE( szName );
  2092. // can't wrap can return ERROR_NO_MORE_ITEMS.
  2093. dw = ClusterEnum( hClusEnum, idx, &dwType, szName, &cchName );
  2094. if ( dw == ERROR_NO_MORE_ITEMS )
  2095. break; // exit condition
  2096. if ( dw != ERROR_SUCCESS )
  2097. {
  2098. hr = HRESULT_FROM_WIN32( TW32( dw ) );
  2099. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_AddJoinedNodes_ClusterEnum, hr );
  2100. goto Cleanup;
  2101. }
  2102. //
  2103. // Build the FQDN name of the node.
  2104. //
  2105. cchName += wcslen( pszDomain ) + 1 /* NULL */;
  2106. bstrFQDNName = TraceSysAllocStringLen( NULL, cchName );
  2107. if ( bstrFQDNName == NULL )
  2108. goto OutOfMemory;
  2109. wcscpy( bstrFQDNName, szName );
  2110. wcscat( bstrFQDNName, pszDomain );
  2111. // hr = THR( HrCreateBinding( this, &clsidLog, bstrFQDNName, &bstrBindingString ) );
  2112. // if ( FAILED( hr ) )
  2113. // {
  2114. // hr = HR_S_RPC_S_SERVER_UNAVAILABLE;
  2115. // goto Cleanup;
  2116. // }
  2117. //
  2118. // Prime the object manager to retrieve the node information.
  2119. //
  2120. // can't wrap - should return E_PENDING
  2121. hr = m_pom->FindObject( CLSID_NodeType, m_cookieCluster, bstrFQDNName, DFGUID_NodeInformation, &cookieDummy, &punkDummy );
  2122. if ( FAILED( hr ) )
  2123. {
  2124. Assert( punkDummy == NULL );
  2125. if ( hr == E_PENDING )
  2126. {
  2127. continue; // expected error
  2128. }
  2129. THR( hr );
  2130. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_AddJoinedNodes_FindObject, hr );
  2131. goto Cleanup;
  2132. }
  2133. punkDummy->Release();
  2134. punkDummy = NULL;
  2135. } // for: idx
  2136. hr = S_OK;
  2137. Cleanup:
  2138. Assert( punkDummy == NULL );
  2139. TraceSysFreeString( bstrFQDNName );
  2140. TraceSysFreeString( bstrBindingString );
  2141. if ( punk != NULL )
  2142. {
  2143. punk->Release();
  2144. } // if:
  2145. if ( piccs != NULL )
  2146. {
  2147. piccs->Release();
  2148. }
  2149. if ( hClusEnum != NULL )
  2150. {
  2151. ClusterCloseEnum( hClusEnum );
  2152. }
  2153. if ( hCluster != NULL )
  2154. {
  2155. CloseCluster( hCluster );
  2156. }
  2157. HRETURN( hr );
  2158. OutOfMemory:
  2159. hr = E_OUTOFMEMORY;
  2160. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_AddJoinedNodes_OutOfMemory, hr );
  2161. goto Cleanup;
  2162. } //*** CTaskAnalyzeCluster::HrAddJoinedNodes()
  2163. //////////////////////////////////////////////////////////////////////////////
  2164. //
  2165. // HRESULT
  2166. // CTaskAnalyzeCluster::HrCheckClusterMembership( void )
  2167. //
  2168. // ERROR_CLUSTER_NODE_EXISTS
  2169. // ERROR_CLUSTER_NODE_ALREADY_MEMBER
  2170. //
  2171. //////////////////////////////////////////////////////////////////////////////
  2172. HRESULT
  2173. CTaskAnalyzeCluster::HrCheckClusterMembership( void )
  2174. {
  2175. TraceFunc( "" );
  2176. HRESULT hr;
  2177. OBJECTCOOKIE cookieDummy;
  2178. IClusCfgClusterInfo * pccci;
  2179. BSTR bstrNodeName = NULL;
  2180. BSTR bstrClusterName = NULL;
  2181. BSTR bstrNotification = NULL;
  2182. IUnknown * punk = NULL;
  2183. IEnumNodes * pen = NULL;
  2184. IClusCfgNodeInfo * pccni = NULL;
  2185. //
  2186. // Ask the object manager for the node enumerator.
  2187. //
  2188. hr = THR( m_pom->FindObject( CLSID_NodeType, m_cookieCluster, NULL, DFGUID_EnumNodes,&cookieDummy, &punk ) );
  2189. if ( FAILED( hr ) )
  2190. {
  2191. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_FindObject, hr );
  2192. goto Cleanup;
  2193. }
  2194. hr = THR( punk->TypeSafeQI( IEnumNodes, &pen ) );
  2195. if ( FAILED( hr ) )
  2196. {
  2197. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_FindObject_QI, hr );
  2198. goto Cleanup;
  2199. }
  2200. //
  2201. // If we are joining an existing cluster, make sure that all the other
  2202. // nodes are members of the same cluster.
  2203. //
  2204. Assert( SUCCEEDED( hr ) );
  2205. while ( SUCCEEDED( hr ) )
  2206. {
  2207. ULONG celtDummy;
  2208. //
  2209. // Cleanup
  2210. //
  2211. if ( pccni != NULL )
  2212. {
  2213. pccni->Release();
  2214. pccni = NULL;
  2215. }
  2216. TraceSysFreeString( bstrClusterName );
  2217. bstrClusterName = NULL;
  2218. //
  2219. // Get the next node.
  2220. //
  2221. hr = STHR( pen->Next( 1, &pccni, &celtDummy ) );
  2222. if ( hr == S_FALSE )
  2223. break; // exit condition
  2224. if ( FAILED( hr ) )
  2225. {
  2226. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_EnumNode_Next, hr );
  2227. goto Cleanup;
  2228. }
  2229. //
  2230. // Check to see if we need to "form a cluster" by seeing if any
  2231. // of the nodes are already clustered.
  2232. //
  2233. hr = STHR( pccni->IsMemberOfCluster() );
  2234. if ( FAILED( hr ) )
  2235. {
  2236. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_EnumNode_IsMemberOfCluster, hr );
  2237. goto Cleanup;
  2238. }
  2239. if ( hr == S_OK )
  2240. {
  2241. //
  2242. // Retrieve the name and make sure they match.
  2243. //
  2244. hr = THR( pccni->GetClusterConfigInfo( &pccci ) );
  2245. if ( FAILED( hr ) )
  2246. {
  2247. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_EnumNode_GetClusterConfigInfo, hr );
  2248. goto Cleanup;
  2249. }
  2250. hr = THR( pccci->GetName( &bstrClusterName ) );
  2251. pccci->Release(); // release promptly
  2252. if ( FAILED( hr ) )
  2253. {
  2254. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_EnumNode_GetName, hr );
  2255. goto Cleanup;
  2256. }
  2257. TraceMemoryAddBSTR( bstrClusterName );
  2258. hr = THR( pccni->GetName( &bstrNodeName ) );
  2259. if ( FAILED( hr ) )
  2260. {
  2261. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_EnumNode_GetNodeName, hr );
  2262. goto Cleanup;
  2263. }
  2264. TraceMemoryAddBSTR( bstrNodeName );
  2265. if ( StrCmpI( m_bstrClusterName, bstrClusterName ) != 0 )
  2266. {
  2267. //
  2268. // They don't match! Tell the UI layer!
  2269. //
  2270. hr = THR( pccni->GetName( &bstrNodeName ) );
  2271. if ( FAILED( hr ) )
  2272. {
  2273. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_EnumNode_GetNodeName, hr );
  2274. goto Cleanup;
  2275. }
  2276. TraceMemoryAddBSTR( bstrNodeName );
  2277. hr = THR( HrFormatMessageIntoBSTR( g_hInstance, IDS_TASKID_MINOR_CLUSTER_NAME_MISMATCH, &bstrNotification, bstrClusterName ) );
  2278. if ( FAILED( hr ) )
  2279. {
  2280. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_EnumNode_FormatMessage, hr );
  2281. goto Cleanup;
  2282. }
  2283. hr = HRESULT_FROM_WIN32( TW32( ERROR_INVALID_DATA ) );
  2284. THR( SendStatusReport( bstrNodeName,
  2285. TASKID_Major_Check_Cluster_Feasibility,
  2286. TASKID_Minor_Cluster_Name_Mismatch,
  2287. 0,
  2288. 1,
  2289. 1,
  2290. hr,
  2291. bstrNotification,
  2292. NULL,
  2293. NULL
  2294. ) );
  2295. //
  2296. // We don't care what the return value is since we are bailing the analysis.
  2297. //
  2298. goto Cleanup;
  2299. } // if: cluster names don't match
  2300. else
  2301. {
  2302. hr = STHR( HrIsUserAddedNode( bstrNodeName ) );
  2303. if ( FAILED( hr ) )
  2304. {
  2305. goto Cleanup;
  2306. } // if:
  2307. if ( hr == S_OK )
  2308. {
  2309. hr = THR( HrFormatMessageIntoBSTR( g_hInstance, IDS_TASKID_MINOR_NODE_ALREADY_IS_MEMBER, &bstrNotification, bstrNodeName, bstrClusterName ) );
  2310. if ( FAILED( hr ) )
  2311. {
  2312. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_EnumNode_FormatMessage1, hr );
  2313. goto Cleanup;
  2314. }
  2315. //
  2316. // Make this a success code because we don't want to abort. We simply want to tell the user...
  2317. //
  2318. hr = MAKE_HRESULT( SEVERITY_SUCCESS, FACILITY_WIN32, ERROR_CLUSTER_NODE_ALREADY_MEMBER );
  2319. THR( SendStatusReport( bstrNodeName,
  2320. TASKID_Major_Check_Cluster_Feasibility,
  2321. TASKID_Minor_Cluster_Name_Match,
  2322. 0,
  2323. 1,
  2324. 1,
  2325. hr,
  2326. bstrNotification,
  2327. NULL,
  2328. NULL
  2329. ) );
  2330. } // if:
  2331. } // else: cluster names do match then this node is already a member of this cluster
  2332. TraceSysFreeString( bstrNodeName );
  2333. bstrNodeName = NULL;
  2334. } // if: cluster member
  2335. } // while: hr
  2336. hr = THR( HrFormatMessageIntoBSTR( g_hInstance, IDS_TASKID_MINOR_CLUSTER_MEMBERSHIP_VERIFIED, &bstrNotification ) );
  2337. if ( FAILED( hr ) )
  2338. {
  2339. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_CheckMembership_FormatMessage, hr );
  2340. goto Cleanup;
  2341. }
  2342. hr = THR( SendStatusReport( NULL,
  2343. TASKID_Major_Check_Cluster_Feasibility,
  2344. TASKID_Minor_Cluster_Membership_Verified,
  2345. 0,
  2346. 1,
  2347. 1,
  2348. hr,
  2349. NULL,
  2350. NULL,
  2351. NULL
  2352. ) );
  2353. Cleanup:
  2354. if ( punk != NULL )
  2355. {
  2356. punk->Release();
  2357. }
  2358. TraceSysFreeString( bstrNodeName );
  2359. TraceSysFreeString( bstrClusterName );
  2360. TraceSysFreeString( bstrNotification );
  2361. HRETURN( hr );
  2362. } //*** CTaskAnalyzeCluster::HrCheckClusterMembership()
  2363. //////////////////////////////////////////////////////////////////////////////
  2364. //
  2365. // HRESULT
  2366. // CTaskAnalyzeCluster::HrCompareResources( void )
  2367. //
  2368. //////////////////////////////////////////////////////////////////////////////
  2369. HRESULT
  2370. CTaskAnalyzeCluster::HrCompareResources( void )
  2371. {
  2372. TraceFunc( "" );
  2373. OBJECTCOOKIE cookie;
  2374. OBJECTCOOKIE cookieNode;
  2375. OBJECTCOOKIE cookieDummy;
  2376. OBJECTCOOKIE cookieFirst;
  2377. BSTR bstrUIDExisting;
  2378. ULONG celtDummy;
  2379. IClusCfgManagedResourceInfo * pccmriNew = NULL;
  2380. HRESULT hr = S_OK;
  2381. BSTR bstrName = NULL;
  2382. BSTR bstrUID = NULL;
  2383. BSTR bstrNotification = NULL;
  2384. BSTR bstrResName = NULL;
  2385. IUnknown * punk = NULL;
  2386. IEnumCookies * pecNodes = NULL;
  2387. IEnumClusCfgManagedResources * peccmr = NULL;
  2388. IEnumClusCfgManagedResources * peccmrCluster = NULL;
  2389. IClusCfgManagedResourceInfo * pccmri = NULL;
  2390. IClusCfgManagedResourceInfo * pccmriCluster = NULL;
  2391. IClusCfgNodeInfo * pccni = NULL;
  2392. //
  2393. // Get the node cookie enumerator.
  2394. //
  2395. hr = THR( m_pom->FindObject( CLSID_NodeType, m_cookieCluster, NULL, DFGUID_EnumCookies, &cookieDummy, &punk ) );
  2396. if ( FAILED( hr ) )
  2397. {
  2398. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Enum_Nodes_Find_Object, hr );
  2399. goto Cleanup;
  2400. }
  2401. hr = THR( punk->TypeSafeQI( IEnumCookies, &pecNodes ) );
  2402. if ( FAILED( hr ) )
  2403. {
  2404. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Enum_Nodes_Find_Object_QI, hr );
  2405. goto Cleanup;
  2406. }
  2407. pecNodes = TraceInterface( L"CTaskAnalyzeCluster!IEnumCookies", IEnumCookies, pecNodes, 1 );
  2408. punk->Release();
  2409. punk = NULL;
  2410. //
  2411. // If forming, it doesn't matter who we pick to prime the cluster configuration
  2412. //
  2413. if ( !m_fJoiningMode )
  2414. {
  2415. //
  2416. // The first guy thru, we just copy his resources under the cluster
  2417. // configuration.
  2418. //
  2419. hr = THR( pecNodes->Next( 1, &cookieFirst, &celtDummy ) );
  2420. if ( FAILED( hr ) )
  2421. {
  2422. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Enum_Nodes_Next, hr );
  2423. goto Cleanup;
  2424. }
  2425. } // if: not joining
  2426. else
  2427. {
  2428. //
  2429. // We are joining nodes to the cluster. Find a node that has current
  2430. // configuration and use it to prime the new configuration.
  2431. //
  2432. for ( ;; )
  2433. {
  2434. //
  2435. // Cleanup
  2436. //
  2437. if ( pccni != NULL )
  2438. {
  2439. pccni->Release();
  2440. pccni = NULL;
  2441. }
  2442. hr = STHR( pecNodes->Next( 1, &cookieFirst, &celtDummy ) );
  2443. if ( hr == S_FALSE )
  2444. {
  2445. //
  2446. // We shouldn't make it here. There should be at least one node
  2447. // in the cluster that we are joining.
  2448. //
  2449. hr = THR( HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) );
  2450. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Find_Formed_Node_Next, hr );
  2451. goto Cleanup;
  2452. }
  2453. if ( FAILED( hr ) )
  2454. {
  2455. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Find_Formed_Node_Next, hr );
  2456. goto Cleanup;
  2457. }
  2458. //
  2459. // Retrieve the node information.
  2460. //
  2461. hr = THR( m_pom->GetObject( DFGUID_NodeInformation, cookieFirst, &punk ) );
  2462. if ( FAILED( hr ) )
  2463. {
  2464. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareResources_NodeInfo_FindObject, hr );
  2465. goto Cleanup;
  2466. }
  2467. hr = THR( punk->TypeSafeQI( IClusCfgNodeInfo, &pccni ) );
  2468. if ( FAILED( hr ) )
  2469. {
  2470. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareResources_NodeInfo_FindObject_QI, hr );
  2471. goto Cleanup;
  2472. }
  2473. pccni = TraceInterface( L"CTaskAnalyzeCluster!IClusCfgNodeInfo", IClusCfgNodeInfo, pccni, 1 );
  2474. punk->Release();
  2475. punk = NULL;
  2476. hr = STHR( pccni->IsMemberOfCluster() );
  2477. if ( hr == S_OK )
  2478. break; // exit condition
  2479. } // for: ever
  2480. } // else: joining
  2481. //
  2482. // Retrieve the node's name for error messages.
  2483. //
  2484. hr = THR( HrRetrieveCookiesName( TASKID_Major_Find_Devices, cookieFirst, &bstrName ) );
  2485. if ( FAILED( hr ) )
  2486. goto Cleanup;
  2487. //
  2488. // Retrieve the managed resources enumer.
  2489. //
  2490. hr = THR( m_pom->FindObject( CLSID_ManagedResourceType, cookieFirst, NULL, DFGUID_EnumManageableResources, &cookieDummy, &punk ) );
  2491. if ( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) )
  2492. {
  2493. hr = THR( HrLoadStringIntoBSTR( g_hInstance, IDS_TASKID_MINOR_NO_MANAGED_RESOURCES_FOUND, &bstrNotification ) );
  2494. if ( FAILED( hr ) )
  2495. goto Cleanup;
  2496. hr = THR( SendStatusReport( bstrName,
  2497. TASKID_Major_Find_Devices,
  2498. TASKID_Minor_No_Managed_Resources_Found,
  2499. 0,
  2500. 1,
  2501. 1,
  2502. MAKE_HRESULT( 0, FACILITY_WIN32, ERROR_NOT_FOUND ),
  2503. bstrNotification,
  2504. NULL,
  2505. NULL
  2506. ) );
  2507. if ( FAILED( hr ) )
  2508. goto Cleanup;
  2509. hr = HRESULT_FROM_WIN32( ERROR_NOT_FOUND );
  2510. // fall thru - the while ( hr == S_OK ) will be false and keep going
  2511. }
  2512. else if ( FAILED( hr ) )
  2513. {
  2514. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_First_Node_Find_Object, hr );
  2515. goto Cleanup;
  2516. }
  2517. else
  2518. {
  2519. hr = THR( punk->TypeSafeQI( IEnumClusCfgManagedResources, &peccmr ) );
  2520. if ( FAILED( hr ) )
  2521. {
  2522. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_First_Node_Find_Object_QI, hr );
  2523. goto Cleanup;
  2524. }
  2525. peccmr = TraceInterface( L"CTaskAnalyzeCluster!IEnumClusCfgManagedResources", IEnumClusCfgManagedResources, peccmr, 1 );
  2526. punk->Release();
  2527. punk = NULL;
  2528. }
  2529. //
  2530. // Loop thru the first nodes resources create an equalivant resource
  2531. // under the cluster configuration object/cookie.
  2532. //
  2533. while ( hr == S_OK )
  2534. {
  2535. // Cleanup
  2536. if ( pccmri != NULL )
  2537. {
  2538. pccmri->Release();
  2539. pccmri = NULL;
  2540. }
  2541. // Get next resource
  2542. hr = STHR( peccmr->Next( 1, &pccmri, &celtDummy ) );
  2543. if ( FAILED( hr ) )
  2544. {
  2545. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_First_Node_Next, hr );
  2546. goto Cleanup;
  2547. }
  2548. if ( hr == S_FALSE )
  2549. break; // exit condition
  2550. // create a new object
  2551. hr = THR( HrCreateNewManagedResourceInClusterConfiguration( pccmri, &pccmriNew ) );
  2552. if ( FAILED( hr ) )
  2553. goto Cleanup;
  2554. hr = STHR( pccmriNew->IsQuorumDevice() );
  2555. if ( hr == S_OK )
  2556. {
  2557. Assert( m_bstrQuorumUID == NULL );
  2558. hr = THR( pccmriNew->GetUID( &m_bstrQuorumUID ) );
  2559. TraceMemoryAddBSTR( m_bstrQuorumUID );
  2560. if ( FAILED( hr ) )
  2561. {
  2562. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_First_Node_Get_Quorum_UID, hr );
  2563. goto Cleanup;
  2564. }
  2565. // Checking that the quorum is joinable if we are in join mode.
  2566. if ( ( hr == S_OK ) && m_fJoiningMode )
  2567. {
  2568. hr = THR( pccmriNew->IsDeviceJoinable() );
  2569. if ( FAILED( hr ) )
  2570. {
  2571. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_First_Node_Is_Device_Joinable, hr );
  2572. goto Cleanup;
  2573. }
  2574. else if ( hr == S_FALSE )
  2575. {
  2576. // Souldn't allow this to proceed, no joinable quorum in join mode.
  2577. hr = THR( HrLoadStringIntoBSTR( g_hInstance,
  2578. IDS_TASKID_MINOR_MISSING_JOINABLE_QUORUM_RESOURCE,
  2579. &bstrNotification
  2580. ) );
  2581. hr = THR( SendStatusReport( NULL,
  2582. TASKID_Major_Find_Devices,
  2583. TASKID_Minor_Compare_Resources_Enum_First_Node_Is_Device_Joinable,
  2584. 0,
  2585. 1,
  2586. 1,
  2587. HRESULT_FROM_WIN32( TW32( ERROR_QUORUM_DISK_NOT_FOUND ) ),
  2588. bstrNotification,
  2589. NULL,
  2590. NULL
  2591. ) );
  2592. hr = HRESULT_FROM_WIN32( TW32( ERROR_QUORUM_DISK_NOT_FOUND ) );
  2593. goto Cleanup;
  2594. }
  2595. } // if:
  2596. pccmriNew->Release();
  2597. pccmriNew = NULL;
  2598. }
  2599. else
  2600. {
  2601. pccmriNew->Release();
  2602. pccmriNew = NULL;
  2603. hr = S_OK;
  2604. }
  2605. } // while: S_OK
  2606. hr = THR( pecNodes->Reset() );
  2607. if ( FAILED( hr ) )
  2608. {
  2609. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Reset, hr );
  2610. goto Cleanup;
  2611. }
  2612. //
  2613. // Loop thru the rest of the nodes comparing the resources.
  2614. //
  2615. for ( ; ; )
  2616. {
  2617. //
  2618. // Cleanup
  2619. //
  2620. if ( peccmr != NULL )
  2621. {
  2622. peccmr->Release();
  2623. peccmr = NULL;
  2624. }
  2625. TraceSysFreeString( bstrName );
  2626. bstrName = NULL;
  2627. //
  2628. // Get the next node.
  2629. //
  2630. hr = STHR( pecNodes->Next( 1, &cookieNode, &celtDummy ) );
  2631. if ( FAILED( hr ) )
  2632. {
  2633. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Next, hr );
  2634. goto Cleanup;
  2635. }
  2636. if ( hr == S_FALSE )
  2637. break; // exit condition
  2638. //
  2639. // Skip the "first" node since we already have its configuration.
  2640. //
  2641. if ( cookieFirst == cookieNode )
  2642. continue;
  2643. //
  2644. // Retrieve the node's name for error messages.
  2645. //
  2646. hr = THR( HrRetrieveCookiesName( TASKID_Major_Find_Devices, cookieNode, &bstrName ) );
  2647. if ( FAILED( hr ) )
  2648. goto Cleanup;
  2649. //
  2650. // Retrieve the managed resources enumer.
  2651. //
  2652. hr = THR( m_pom->FindObject( CLSID_ManagedResourceType, cookieNode, NULL, DFGUID_EnumManageableResources, &cookieDummy, &punk ) );
  2653. if ( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) )
  2654. {
  2655. hr = THR( HrLoadStringIntoBSTR( g_hInstance, IDS_TASKID_MINOR_NO_MANAGED_RESOURCES_FOUND, &bstrNotification ) );
  2656. if ( FAILED( hr ) )
  2657. goto Cleanup;
  2658. hr = THR( SendStatusReport( bstrName,
  2659. TASKID_Major_Find_Devices,
  2660. TASKID_Minor_No_Managed_Resources_Found,
  2661. 0,
  2662. 1,
  2663. 1,
  2664. MAKE_HRESULT( 0, FACILITY_WIN32, ERROR_NOT_FOUND ),
  2665. bstrNotification,
  2666. NULL,
  2667. NULL
  2668. ) );
  2669. if ( FAILED( hr ) )
  2670. goto Cleanup;
  2671. continue; // skip this node
  2672. }
  2673. else if ( FAILED( hr ) )
  2674. {
  2675. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Find_Object, hr );
  2676. goto Cleanup;
  2677. }
  2678. hr = THR( punk->TypeSafeQI( IEnumClusCfgManagedResources, &peccmr ) );
  2679. if ( FAILED( hr ) )
  2680. {
  2681. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Find_Object_QI, hr );
  2682. goto Cleanup;
  2683. }
  2684. peccmr = TraceInterface( L"CTaskAnalyzeCluster!IEnumClusCfgManagedResources", IEnumClusCfgManagedResources, peccmr, 1 );
  2685. punk->Release();
  2686. punk = NULL;
  2687. //
  2688. // Loop thru the managed resources already that the node has.
  2689. //
  2690. for ( ; ; )
  2691. {
  2692. //
  2693. // Cleanup
  2694. //
  2695. if ( pccmri != NULL )
  2696. {
  2697. pccmri->Release();
  2698. pccmri = NULL;
  2699. }
  2700. TraceSysFreeString( bstrUID );
  2701. bstrUID = NULL;
  2702. if ( peccmrCluster != NULL )
  2703. {
  2704. peccmrCluster->Release();
  2705. peccmrCluster = NULL;
  2706. }
  2707. //
  2708. // Get next resource
  2709. //
  2710. hr = STHR( peccmr->Next( 1, &pccmri, &celtDummy ) );
  2711. if ( FAILED( hr ) )
  2712. {
  2713. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Next, hr );
  2714. goto Cleanup;
  2715. }
  2716. if ( hr == S_FALSE )
  2717. break; // exit condition
  2718. pccmri = TraceInterface( L"CTaskAnalyzeCluster!IClusCfgManagedResourceInfo", IClusCfgManagedResourceInfo, pccmri, 1 );
  2719. //
  2720. // Grab the resource's UUID.
  2721. //
  2722. hr = THR( pccmri->GetUID( &bstrUID ) );
  2723. if ( FAILED( hr ) )
  2724. {
  2725. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_GetUID, hr );
  2726. goto Cleanup;
  2727. }
  2728. TraceMemoryAddBSTR( bstrUID );
  2729. //
  2730. // See if it matches a resource already in the cluster configuration.
  2731. //
  2732. hr = THR( m_pom->FindObject( CLSID_ManagedResourceType, m_cookieCluster, NULL, DFGUID_EnumManageableResources, &cookieDummy, &punk ) );
  2733. if ( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) )
  2734. {
  2735. hr = S_FALSE; // create a new object.
  2736. // fall thru
  2737. }
  2738. else if ( FAILED( hr ) )
  2739. {
  2740. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_Find_Object, hr );
  2741. goto Cleanup;
  2742. }
  2743. hr = THR( punk->TypeSafeQI( IEnumClusCfgManagedResources, &peccmrCluster ) );
  2744. if ( FAILED( hr ) )
  2745. {
  2746. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_Find_Object_QI, hr );
  2747. goto Cleanup;
  2748. }
  2749. punk->Release();
  2750. punk = NULL;
  2751. //
  2752. // Loop thru the configured cluster resources to see what matches.
  2753. //
  2754. while( hr == S_OK )
  2755. {
  2756. HRESULT hrCluster;
  2757. BOOL fMatch;
  2758. //
  2759. // Cleanup
  2760. //
  2761. if ( pccmriCluster != NULL )
  2762. {
  2763. pccmriCluster->Release();
  2764. pccmriCluster = NULL;
  2765. }
  2766. hr = STHR( peccmrCluster->Next( 1, &pccmriCluster, &celtDummy ) );
  2767. if ( FAILED( hr ) )
  2768. {
  2769. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_Next, hr );
  2770. goto Cleanup;
  2771. }
  2772. if ( hr == S_FALSE )
  2773. break; // exit condition
  2774. hr = THR( pccmriCluster->GetUID( &bstrUIDExisting ) );
  2775. if ( FAILED( hr ) )
  2776. {
  2777. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_GetUID, hr );
  2778. goto Cleanup;
  2779. }
  2780. TraceMemoryAddBSTR( bstrUIDExisting );
  2781. fMatch = ( wcscmp( bstrUID, bstrUIDExisting ) == 0 );
  2782. TraceSysFreeString( bstrUIDExisting );
  2783. if ( !fMatch )
  2784. continue; // keep looping
  2785. //
  2786. // A resource is already in the database. See if it is the same from
  2787. // the POV of management.
  2788. //
  2789. //
  2790. // Check the quorum capabilities.
  2791. //
  2792. hrCluster = STHR( pccmriCluster->IsQuorumCapable() );
  2793. if ( FAILED( hrCluster ) )
  2794. {
  2795. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_IsQuorumCapable_Cluster, hr );
  2796. goto Cleanup;
  2797. }
  2798. hr = STHR( pccmri->IsQuorumCapable() );
  2799. if ( FAILED( hr ) )
  2800. {
  2801. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_IsQuorumCapable_Node, hr );
  2802. goto Cleanup;
  2803. }
  2804. if ( hr != hrCluster )
  2805. {
  2806. //
  2807. // The quorum capabilities don't match. Tell the user.
  2808. //
  2809. BSTR bstrResource;
  2810. hr = THR( pccmriCluster->GetName( &bstrResource ) );
  2811. if ( FAILED( hr ) )
  2812. {
  2813. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_GetName, hr );
  2814. goto Cleanup;
  2815. }
  2816. hr = THR( HrFormatMessageIntoBSTR( g_hInstance,
  2817. IDS_TASKID_MINOR_RESOURCE_CAPABILITIES_DONT_MATCH,
  2818. &bstrNotification,
  2819. bstrResource
  2820. ) );
  2821. TraceSysFreeString( bstrResource );
  2822. hr = THR( SendStatusReport( bstrName,
  2823. TASKID_Major_Check_Cluster_Feasibility,
  2824. TASKID_Minor_Resource_Capabilities_Dont_Match,
  2825. 0,
  2826. 1,
  2827. 1,
  2828. E_FAIL,
  2829. bstrNotification,
  2830. NULL,
  2831. NULL
  2832. ) );
  2833. hr = THR( E_FAIL );
  2834. goto Cleanup; // bail!
  2835. }
  2836. //
  2837. //
  2838. // If we made it here then we think it truely is the same resource. The
  2839. // rest is stuff we need to fixup during the commit phase.
  2840. //
  2841. //
  2842. //
  2843. // Is this node wants its resources managed, mark it as being managed in the cluster
  2844. // configuration as well.
  2845. //
  2846. hr = STHR( pccmri->IsManaged() );
  2847. if ( FAILED( hr ) )
  2848. {
  2849. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_IsManaged, hr );
  2850. goto Cleanup;
  2851. }
  2852. if ( hr == S_OK )
  2853. {
  2854. hr = THR( pccmriCluster->SetManaged( TRUE ) );
  2855. if ( FAILED( hr ) )
  2856. {
  2857. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_SetManaged, hr );
  2858. goto Cleanup;
  2859. }
  2860. //
  2861. // Since this node manages this resource, it should be able to provide us with a name.
  2862. // We will use this name to overwrite whatever we currently have, except for the quorum
  2863. // resource, which already has the correct name.
  2864. //
  2865. hr = STHR( pccmri->IsQuorumDevice() );
  2866. if ( hr == S_FALSE )
  2867. {
  2868. hr = THR( pccmri->GetName( &bstrResName ) );
  2869. if ( FAILED( hr ) )
  2870. {
  2871. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_GetResName, hr );
  2872. goto Cleanup;
  2873. }
  2874. TraceMemoryAddBSTR( bstrResName );
  2875. hr = THR( pccmriCluster->SetName( bstrResName ) );
  2876. if ( FAILED( hr ) )
  2877. {
  2878. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_SetResName, hr );
  2879. goto Cleanup;
  2880. }
  2881. TraceSysFreeString( bstrResName );
  2882. bstrResName = NULL;
  2883. }
  2884. }
  2885. //
  2886. // Check to see if the resource is the quorum resource. If so, mark that
  2887. // we found a common quorum resource.
  2888. //
  2889. if ( m_bstrQuorumUID == NULL )
  2890. {
  2891. //
  2892. // No previous quorum has been set. See if this is the quorum resource.
  2893. //
  2894. hr = STHR( pccmri->IsQuorumDevice() );
  2895. if ( hr == S_OK )
  2896. {
  2897. //
  2898. // Yes it is. The mark it in the configuration as such.
  2899. //
  2900. hr = THR( pccmriCluster->SetQuorumedDevice( TRUE ) );
  2901. if ( FAILED( hr ) )
  2902. {
  2903. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_SetQuorumDevice_Cluster, hr );
  2904. goto Cleanup;
  2905. }
  2906. //
  2907. // Remember that this resource is the quorum.
  2908. //
  2909. hr = THR( pccmriCluster->GetUID( &m_bstrQuorumUID ) );
  2910. if ( FAILED( hr ) )
  2911. {
  2912. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_SetQuorumDevice_GetUID, hr );
  2913. goto Cleanup;
  2914. }
  2915. TraceMemoryAddBSTR( m_bstrQuorumUID );
  2916. }
  2917. }
  2918. else if ( wcscmp( m_bstrQuorumUID, bstrUID ) == 0 )
  2919. {
  2920. //
  2921. // This is the same quorum. Mark the Node's configuration.
  2922. //
  2923. hr = THR( pccmri->SetQuorumedDevice( TRUE ) );
  2924. if ( FAILED( hr ) )
  2925. {
  2926. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_SetQuorumDevice_Node_True, hr );
  2927. goto Cleanup;
  2928. }
  2929. }
  2930. else
  2931. {
  2932. //
  2933. // Otherwize, make sure that the device isn't marked as quorum. (paranoid)
  2934. //
  2935. hr = THR( pccmri->SetQuorumedDevice( FALSE ) );
  2936. if ( FAILED( hr ) )
  2937. {
  2938. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Enum_Nodes_Enum_Resources_Enum_Cluster_SetQuorumDevice_Node_False, hr );
  2939. goto Cleanup;
  2940. }
  2941. }
  2942. //
  2943. // Exit the loop with S_OK so we don't create a new resource.
  2944. //
  2945. hr = S_OK;
  2946. break; // exit loop
  2947. } // while: S_OK
  2948. if ( hr == S_FALSE )
  2949. {
  2950. //
  2951. // Need to create a new object.
  2952. //
  2953. Assert( pccmri != NULL );
  2954. hr = THR( HrCreateNewManagedResourceInClusterConfiguration( pccmri, &pccmriNew ) );
  2955. if ( FAILED( hr ) )
  2956. goto Cleanup;
  2957. Assert( hr == S_OK );
  2958. hr = STHR( pccmriNew->IsQuorumDevice() );
  2959. if ( hr == S_OK )
  2960. {
  2961. //
  2962. // Remember the quorum device's UID.
  2963. //
  2964. Assert( m_bstrQuorumUID == NULL );
  2965. m_bstrQuorumUID = bstrUID;
  2966. bstrUID = NULL;
  2967. }
  2968. else
  2969. {
  2970. pccmriNew->Release();
  2971. pccmriNew = NULL;
  2972. hr = S_OK;
  2973. }
  2974. } // if: object not found
  2975. } // for: resources
  2976. } // for: nodes
  2977. hr = S_OK;
  2978. Cleanup:
  2979. if ( pccmriNew != NULL )
  2980. {
  2981. pccmriNew->Release();
  2982. } // if:
  2983. TraceSysFreeString( bstrNotification );
  2984. TraceSysFreeString( bstrName );
  2985. TraceSysFreeString( bstrUID );
  2986. TraceSysFreeString( bstrNotification );
  2987. TraceSysFreeString( bstrResName );
  2988. if ( punk != NULL )
  2989. {
  2990. punk->Release();
  2991. }
  2992. if ( pecNodes != NULL )
  2993. {
  2994. pecNodes->Release();
  2995. }
  2996. if ( peccmr != NULL )
  2997. {
  2998. peccmr->Release();
  2999. }
  3000. if ( peccmrCluster != NULL )
  3001. {
  3002. peccmrCluster->Release();
  3003. }
  3004. if ( pccmri != NULL )
  3005. {
  3006. pccmri->Release();
  3007. }
  3008. if ( pccmriCluster != NULL )
  3009. {
  3010. pccmriCluster->Release();
  3011. }
  3012. if ( pccni != NULL )
  3013. {
  3014. pccni->Release();
  3015. }
  3016. HRETURN( hr );
  3017. } //*** CTaskAnalyzeCluster::HrCompareResources()
  3018. //////////////////////////////////////////////////////////////////////////////
  3019. //
  3020. // HRESULT
  3021. // CTaskAnalyzeCluster::HrCreateNewManagedResourceInClusterConfiguration(
  3022. // IClusCfgManagedResourceInfo * pccmriIn,
  3023. // IClusCfgManagedResourceInfo ** ppccmriNewOut
  3024. // )
  3025. //
  3026. //////////////////////////////////////////////////////////////////////////////
  3027. HRESULT
  3028. CTaskAnalyzeCluster::HrCreateNewManagedResourceInClusterConfiguration(
  3029. IClusCfgManagedResourceInfo * pccmriIn,
  3030. IClusCfgManagedResourceInfo ** ppccmriNewOut
  3031. )
  3032. {
  3033. TraceFunc( "" );
  3034. HRESULT hr;
  3035. OBJECTCOOKIE cookieDummy;
  3036. BSTR bstrUID = NULL;
  3037. IUnknown * punk = NULL;
  3038. IGatherData * pgd = NULL;
  3039. IClusCfgManagedResourceInfo * pccmri = NULL;
  3040. //
  3041. // TODO: gpease 28-JUN-2000
  3042. // Make this dynamic - for now we'll just create a "managed device."
  3043. //
  3044. // grab the name
  3045. hr = THR( pccmriIn->GetUID( &bstrUID ) );
  3046. if ( FAILED( hr ) )
  3047. {
  3048. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Create_Resource_GetUID, hr );
  3049. goto Cleanup;
  3050. }
  3051. TraceMemoryAddBSTR( bstrUID );
  3052. // create an object in the object manager.
  3053. hr = THR( m_pom->FindObject( CLSID_ManagedResourceType,
  3054. m_cookieCluster,
  3055. bstrUID,
  3056. DFGUID_ManagedResource,
  3057. &cookieDummy,
  3058. &punk
  3059. ) );
  3060. if ( FAILED( hr ) )
  3061. {
  3062. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Create_Resource_FindObject, hr );
  3063. goto Cleanup;
  3064. }
  3065. // find the IGatherData interface
  3066. hr = THR( punk->TypeSafeQI( IGatherData, &pgd ) );
  3067. if ( FAILED( hr ) )
  3068. {
  3069. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Create_Resource_FindObject_QI, hr );
  3070. goto Cleanup;
  3071. }
  3072. // have the new object gather all information it needs
  3073. hr = THR( pgd->Gather( m_cookieCluster, pccmriIn ) );
  3074. if ( FAILED( hr ) )
  3075. {
  3076. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Create_Resource_Gather, hr );
  3077. goto Cleanup;
  3078. }
  3079. // hand the object out if requested
  3080. if ( ppccmriNewOut != NULL )
  3081. {
  3082. // find the IClusCfgManagedResourceInfo
  3083. hr = THR( punk->TypeSafeQI( IClusCfgManagedResourceInfo, &pccmri ) );
  3084. if ( FAILED( hr ) )
  3085. {
  3086. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Create_Resource_QI, hr );
  3087. goto Cleanup;
  3088. }
  3089. *ppccmriNewOut = TraceInterface( L"ManagedDevice!ICCMRI", IClusCfgManagedResourceInfo, pccmri, 0 );
  3090. (*ppccmriNewOut)->AddRef();
  3091. }
  3092. Cleanup:
  3093. TraceSysFreeString( bstrUID );
  3094. if ( pccmri != NULL )
  3095. {
  3096. pccmri->Release();
  3097. }
  3098. if ( pgd != NULL )
  3099. {
  3100. pgd->Release();
  3101. }
  3102. if ( punk != NULL )
  3103. {
  3104. punk->Release();
  3105. }
  3106. HRETURN( hr );
  3107. } //*** CTaskAnalyzeCluster::HrCreateNewManagedResourceInClusterConfiguration()
  3108. //////////////////////////////////////////////////////////////////////////////
  3109. //
  3110. // HRESULT
  3111. // CTaskAnalyzeCluster::HrCheckForCommonQuorumResource( void )
  3112. //
  3113. //////////////////////////////////////////////////////////////////////////////
  3114. HRESULT
  3115. CTaskAnalyzeCluster::HrCheckForCommonQuorumResource( void )
  3116. {
  3117. TraceFunc( "" );
  3118. HRESULT hr;
  3119. OBJECTCOOKIE cookie;
  3120. OBJECTCOOKIE cookieDummy;
  3121. ULONG cMatchedNodes = 0;
  3122. ULONG cAnalyzedNodes = 0;
  3123. BOOL fNodeCanAccess = FALSE;
  3124. BSTR bstrUID = NULL;
  3125. BSTR bstrNotification = NULL;
  3126. BSTR bstrNodeName = NULL;
  3127. IUnknown * punk = NULL;
  3128. IEnumCookies * pecNodes = NULL;
  3129. IEnumClusCfgManagedResources * peccmr = NULL;
  3130. IClusCfgManagedResourceInfo * pccmri = NULL;
  3131. IClusCfgNodeInfo * piccni = NULL;
  3132. //
  3133. // BUGBUG: 08-MAY-2001 GalenB
  3134. //
  3135. // There is no status or progress for this feasibility step. It simply "hangs" until it succeeds or fails.
  3136. //
  3137. /*
  3138. THR( HrLoadStringIntoBSTR( g_hInstance, IDS_TASKID_MINOR_FOUND_COMMON_QUORUM_RESOURCE, &bstrNotification ) );
  3139. hr = THR( SendStatusReport( NULL,
  3140. TASKID_Major_Check_Cluster_Feasibility,
  3141. TASKID_Minor_Finding_Common_Quorum_Device,
  3142. 0,
  3143. 0,
  3144. 1,
  3145. S_OK,
  3146. bstrNotification,
  3147. NULL,
  3148. NULL
  3149. ) );
  3150. */
  3151. if ( m_bstrQuorumUID != NULL )
  3152. {
  3153. //
  3154. // Grab the cookie enumer for nodes in our cluster configuration.
  3155. //
  3156. hr = THR( m_pom->FindObject( CLSID_NodeType, m_cookieCluster, NULL, DFGUID_EnumCookies, &cookieDummy, &punk ) );
  3157. if ( FAILED( hr ) )
  3158. {
  3159. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_Check_Common_FindObject, hr );
  3160. goto Cleanup;
  3161. }
  3162. hr = THR( punk->TypeSafeQI( IEnumCookies, &pecNodes ) );
  3163. if ( FAILED( hr ) )
  3164. {
  3165. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_Check_Common_FindObject_QI, hr );
  3166. goto Cleanup;
  3167. }
  3168. pecNodes = TraceInterface( L"CTaskAnalyzeCluster!IEnumCookies", IEnumCookies, pecNodes, 1 );
  3169. punk->Release();
  3170. punk = NULL;
  3171. //
  3172. // Scan the cluster configurations looking for the quorum resource.
  3173. //
  3174. for ( ;; )
  3175. {
  3176. ULONG celtDummy;
  3177. if ( peccmr != NULL )
  3178. {
  3179. peccmr->Release();
  3180. peccmr = NULL;
  3181. } // if:
  3182. hr = STHR( pecNodes->Next( 1, &cookie, &celtDummy ) );
  3183. if ( FAILED( hr ) )
  3184. {
  3185. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_Check_Common_Enum_Nodes_Next, hr );
  3186. goto Cleanup;
  3187. } // if:
  3188. if ( hr == S_FALSE )
  3189. break; // exit condition
  3190. hr = THR( m_pom->GetObject( DFGUID_NodeInformation, cookie, &punk ) );
  3191. if ( FAILED( hr ) )
  3192. goto Cleanup;
  3193. hr = THR( punk->TypeSafeQI( IClusCfgNodeInfo, &piccni ) );
  3194. if ( FAILED( hr ) )
  3195. goto Cleanup;
  3196. punk->Release();
  3197. punk = NULL;
  3198. TraceSysFreeString( bstrNodeName );
  3199. bstrNodeName = NULL;
  3200. hr = THR( piccni->GetName( &bstrNodeName ) );
  3201. if ( FAILED( hr ) )
  3202. goto Cleanup;
  3203. TraceMemoryAddBSTR( bstrNodeName );
  3204. //
  3205. // increment counter for a "nice" progress bar
  3206. //
  3207. cAnalyzedNodes ++;
  3208. THR( HrFormatStringIntoBSTR( g_hInstance,
  3209. IDS_TASKID_MINOR_FINDING_COMMON_QUORUM_DEVICE,
  3210. &bstrNotification,
  3211. bstrNodeName ) );
  3212. hr = THR( SendStatusReport( NULL,
  3213. TASKID_Major_Check_Cluster_Feasibility,
  3214. TASKID_Minor_Finding_Common_Quorum_Device,
  3215. 0,
  3216. m_cNodes + 1,
  3217. cAnalyzedNodes,
  3218. S_OK,
  3219. bstrNotification,
  3220. NULL,
  3221. NULL
  3222. ) );
  3223. //
  3224. // Grab the managed resource enumer for resources that our node has.
  3225. //
  3226. hr = THR( m_pom->FindObject( CLSID_ManagedResourceType, cookie, NULL, DFGUID_EnumManageableResources, &cookieDummy, &punk ) );
  3227. if ( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) )
  3228. {
  3229. continue; // ignore and continue
  3230. }
  3231. else if ( FAILED( hr ) )
  3232. {
  3233. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_Check_Common_Enum_Nodes_FindObject, hr );
  3234. goto Cleanup;
  3235. }
  3236. hr = THR( punk->TypeSafeQI( IEnumClusCfgManagedResources, &peccmr ) );
  3237. if ( FAILED( hr ) )
  3238. {
  3239. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_Check_Common_Enum_Nodes_FindObject_QI, hr );
  3240. goto Cleanup;
  3241. }
  3242. peccmr = TraceInterface( L"CTaskAnalyzeCluster!IEnumClusCfgManagedResources", IEnumClusCfgManagedResources, peccmr, 1 );
  3243. punk->Release();
  3244. punk = NULL;
  3245. fNodeCanAccess = FALSE;
  3246. //
  3247. // Loop thru the resources trying to match the UID of the quorum resource.
  3248. //
  3249. for ( ;; )
  3250. {
  3251. ULONG celtDummy;
  3252. TraceSysFreeString( bstrUID );
  3253. bstrUID = NULL;
  3254. if ( pccmri != NULL )
  3255. {
  3256. pccmri->Release();
  3257. pccmri = NULL;
  3258. }
  3259. hr = STHR( peccmr->Next( 1, &pccmri, &celtDummy ) );
  3260. if ( FAILED( hr ) )
  3261. {
  3262. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_Check_Common_Enum_Nodes_Enum_Resources_Next, hr );
  3263. goto Cleanup;
  3264. }
  3265. if ( hr == S_FALSE )
  3266. break; // exit condition
  3267. pccmri = TraceInterface( L"CTaskAnalyzeCluster!IClusCfgManagedResourceInfo", IClusCfgManagedResourceInfo, pccmri, 1 );
  3268. hr = THR( pccmri->GetUID( &bstrUID ) );
  3269. if ( FAILED( hr ) )
  3270. {
  3271. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_Check_Common_Enum_Nodes_Enum_Resources_GetUID, hr );
  3272. goto Cleanup;
  3273. }
  3274. TraceMemoryAddBSTR( bstrUID );
  3275. if ( wcscmp( bstrUID, m_bstrQuorumUID ) != 0 )
  3276. continue; // doesn't match - keep going
  3277. cMatchedNodes ++;
  3278. fNodeCanAccess = TRUE;
  3279. break; // exit condition
  3280. } // while: S_OK
  3281. //
  3282. // Give the UI feedback if this node has no access to the quorum
  3283. //
  3284. if ( !fNodeCanAccess )
  3285. {
  3286. THR( HrLoadStringIntoBSTR( g_hInstance,
  3287. IDS_TASKID_MINOR_NODE_CANNOT_ACCESS_QUORUM,
  3288. &bstrNotification ) );
  3289. hr = THR( SendStatusReport( bstrNodeName,
  3290. TASKID_Major_Check_Cluster_Feasibility,
  3291. TASKID_Minor_Node_Cannot_Access_Quorum,
  3292. 0,
  3293. 1,
  3294. 1,
  3295. HRESULT_FROM_WIN32( TW32( ERROR_QUORUM_DISK_NOT_FOUND ) ),
  3296. bstrNotification,
  3297. NULL,
  3298. NULL
  3299. ) );
  3300. } // if ( !fNodeCanAccess )
  3301. } // while: S_OK
  3302. } // if: m_bstrQuorumUID != NULL
  3303. //
  3304. // Figure out if we ended up with a common quorum device.
  3305. //
  3306. if ( cMatchedNodes == m_cNodes )
  3307. {
  3308. //
  3309. // We found a device that can be used as a common quorum device.
  3310. //
  3311. THR( HrLoadStringIntoBSTR( g_hInstance, IDS_TASKID_MINOR_FOUND_COMMON_QUORUM_RESOURCE, &bstrNotification ) );
  3312. hr = THR( SendStatusReport( NULL,
  3313. TASKID_Major_Check_Cluster_Feasibility,
  3314. TASKID_Minor_Finding_Common_Quorum_Device,
  3315. 0,
  3316. m_cNodes + 1,
  3317. m_cNodes + 1,
  3318. S_OK,
  3319. bstrNotification,
  3320. NULL,
  3321. NULL
  3322. ) );
  3323. // error checked outside if/else statement
  3324. }
  3325. else
  3326. {
  3327. if ( ( m_cNodes == 1 ) && ( !m_fJoiningMode ) )
  3328. {
  3329. //
  3330. // We didn't find a common quorum device, but we're only forming. We can
  3331. // create the cluster with a local quorum. Just put up a warning.
  3332. //
  3333. THR( HrLoadStringIntoBSTR( g_hInstance, IDS_TASKID_MINOR_FORCED_LOCAL_QUORUM, &bstrNotification ) );
  3334. hr = THR( SendStatusReport( NULL,
  3335. TASKID_Major_Check_Cluster_Feasibility,
  3336. TASKID_Minor_Finding_Common_Quorum_Device,
  3337. 0,
  3338. m_cNodes + 1,
  3339. m_cNodes + 1,
  3340. MAKE_HRESULT( SEVERITY_SUCCESS, FACILITY_WIN32, ERROR_QUORUM_DISK_NOT_FOUND ),
  3341. bstrNotification,
  3342. NULL,
  3343. NULL
  3344. ) );
  3345. // error checked outside if/else statement
  3346. }
  3347. else
  3348. {
  3349. //
  3350. // We didn't find a common quorum device.
  3351. //
  3352. THR( HrLoadStringIntoBSTR( g_hInstance, IDS_TASKID_MINOR_MISSING_COMMON_QUORUM_RESOURCE, &bstrNotification ) );
  3353. hr = THR( SendStatusReport( NULL,
  3354. TASKID_Major_Check_Cluster_Feasibility,
  3355. TASKID_Minor_Finding_Common_Quorum_Device,
  3356. 0,
  3357. m_cNodes + 1,
  3358. m_cNodes + 1,
  3359. HRESULT_FROM_WIN32( TW32( ERROR_QUORUM_DISK_NOT_FOUND ) ),
  3360. bstrNotification,
  3361. NULL,
  3362. NULL
  3363. ) );
  3364. // we always bail.
  3365. hr = HRESULT_FROM_WIN32( TW32( ERROR_QUORUM_DISK_NOT_FOUND ) );
  3366. goto Cleanup;
  3367. }
  3368. }
  3369. //
  3370. // Check to see if any of the SendStatusReports() returned anything
  3371. // of interest.
  3372. //
  3373. if ( FAILED( hr ) )
  3374. goto Cleanup;
  3375. hr = S_OK;
  3376. Cleanup:
  3377. if ( punk != NULL )
  3378. {
  3379. punk->Release();
  3380. } // if:
  3381. if ( piccni != NULL )
  3382. {
  3383. piccni->Release();
  3384. } // if:
  3385. TraceSysFreeString( bstrNotification );
  3386. TraceSysFreeString( bstrUID );
  3387. if ( pccmri != NULL )
  3388. {
  3389. pccmri->Release();
  3390. } // if:
  3391. if ( peccmr != NULL )
  3392. {
  3393. peccmr->Release();
  3394. } // if:
  3395. if ( pecNodes != NULL )
  3396. {
  3397. pecNodes->Release();
  3398. } // if:
  3399. HRETURN( hr );
  3400. } //*** CTaskAnalyzeCluster::HrCheckForCommonQuorumResource()
  3401. //////////////////////////////////////////////////////////////////////////////
  3402. //
  3403. // HRESULT
  3404. // CTaskAnalyzeCluster::HrCompareNetworks( void )
  3405. //
  3406. //////////////////////////////////////////////////////////////////////////////
  3407. HRESULT
  3408. CTaskAnalyzeCluster::HrCompareNetworks( void )
  3409. {
  3410. TraceFunc( "" );
  3411. OBJECTCOOKIE cookie;
  3412. OBJECTCOOKIE cookieNode;
  3413. OBJECTCOOKIE cookieDummy;
  3414. OBJECTCOOKIE cookieFirst;
  3415. BSTR bstrUIDExisting;
  3416. ULONG celtDummy;
  3417. IClusCfgNetworkInfo * pccmriNew;
  3418. HRESULT hr = S_OK;
  3419. BSTR bstrUID = NULL;
  3420. BSTR bstrName = NULL;
  3421. BSTR bstrNotification = NULL;
  3422. IUnknown * punk = NULL;
  3423. IEnumCookies * pecNodes = NULL;
  3424. IEnumClusCfgNetworks * peccn = NULL;
  3425. IEnumClusCfgNetworks * peccnCluster = NULL;
  3426. IClusCfgNetworkInfo * pccni = NULL;
  3427. IClusCfgNetworkInfo * pccniCluster = NULL;
  3428. IClusCfgNodeInfo * pccNode = NULL;
  3429. hr = THR( m_pom->FindObject( CLSID_NodeType,
  3430. m_cookieCluster,
  3431. NULL,
  3432. DFGUID_EnumCookies,
  3433. &cookieDummy,
  3434. &punk
  3435. ) );
  3436. if ( FAILED( hr ) )
  3437. {
  3438. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_FindObject, hr );
  3439. goto Cleanup;
  3440. }
  3441. hr = THR( punk->TypeSafeQI( IEnumCookies, &pecNodes ) );
  3442. if ( FAILED( hr ) )
  3443. {
  3444. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_FindObject_QI, hr );
  3445. goto Cleanup;
  3446. }
  3447. pecNodes = TraceInterface( L"CTaskAnalyzeCluster!IEnumCookies", IEnumCookies, pecNodes, 1 );
  3448. punk->Release();
  3449. punk = NULL;
  3450. if ( !m_fJoiningMode )
  3451. {
  3452. //
  3453. // The first guy thru, we just copy his networks under the cluster
  3454. // configuration.
  3455. //
  3456. hr = THR( pecNodes->Next( 1, &cookieFirst, &celtDummy ) );
  3457. if ( FAILED( hr ) )
  3458. {
  3459. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_Next, hr );
  3460. goto Cleanup;
  3461. }
  3462. }
  3463. else
  3464. {
  3465. //
  3466. // We are joining nodes to the cluster. Find a node that has current
  3467. // configuration and use it to prime the new configuration.
  3468. //
  3469. for ( ;; )
  3470. {
  3471. //
  3472. // Cleanup
  3473. //
  3474. if ( pccNode != NULL )
  3475. {
  3476. pccNode->Release();
  3477. pccNode = NULL;
  3478. }
  3479. hr = STHR( pecNodes->Next( 1, &cookieFirst, &celtDummy ) );
  3480. if ( hr == S_FALSE )
  3481. {
  3482. //
  3483. // We shouldn't make it here. There should be at least one node
  3484. // in the cluster that we are joining.
  3485. //
  3486. hr = THR( HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) );
  3487. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Find_Formed_Node_Next, hr );
  3488. goto Cleanup;
  3489. }
  3490. if ( FAILED( hr ) )
  3491. {
  3492. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_Compare_Resources_Find_Formed_Node_Next, hr );
  3493. goto Cleanup;
  3494. }
  3495. //
  3496. // Retrieve the node information.
  3497. //
  3498. hr = THR( m_pom->GetObject( DFGUID_NodeInformation,
  3499. cookieFirst,
  3500. &punk
  3501. ) );
  3502. if ( FAILED( hr ) )
  3503. {
  3504. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareResources_NodeInfo_FindObject, hr );
  3505. goto Cleanup;
  3506. }
  3507. hr = THR( punk->TypeSafeQI( IClusCfgNodeInfo, &pccNode ) );
  3508. if ( FAILED( hr ) )
  3509. {
  3510. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareResources_NodeInfo_FindObject_QI, hr );
  3511. goto Cleanup;
  3512. }
  3513. pccNode = TraceInterface( L"CTaskAnalyzeCluster!IClusCfgNodeInfo", IClusCfgNodeInfo, pccNode, 1 );
  3514. punk->Release();
  3515. punk = NULL;
  3516. hr = STHR( pccNode->IsMemberOfCluster() );
  3517. if ( hr == S_OK )
  3518. break; // exit condition
  3519. } // for: ever
  3520. } // else: joining
  3521. //
  3522. // Retrieve the node name in case of errors.
  3523. //
  3524. hr = THR( HrRetrieveCookiesName( TASKID_Major_Find_Devices,
  3525. cookieFirst,
  3526. &bstrName
  3527. ) );
  3528. if ( FAILED( hr ) )
  3529. goto Cleanup;
  3530. //
  3531. // Retrieve the networks enumer.
  3532. //
  3533. hr = THR( m_pom->FindObject( CLSID_NetworkType,
  3534. cookieFirst,
  3535. NULL,
  3536. DFGUID_EnumManageableNetworks,
  3537. &cookieDummy,
  3538. &punk
  3539. ) );
  3540. if ( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) )
  3541. {
  3542. hr = THR( HrLoadStringIntoBSTR( g_hInstance,
  3543. IDS_TASKID_MINOR_NO_MANAGED_NETWORKS_FOUND,
  3544. &bstrNotification
  3545. ) );
  3546. hr = THR( SendStatusReport( bstrName,
  3547. TASKID_Major_Find_Devices,
  3548. TASKID_Minor_No_Managed_Networks_Found,
  3549. 0,
  3550. 1,
  3551. 1,
  3552. MAKE_HRESULT( 0, FACILITY_WIN32, ERROR_NOT_FOUND ),
  3553. bstrNotification,
  3554. NULL,
  3555. NULL
  3556. ) );
  3557. if ( FAILED( hr ) )
  3558. goto Cleanup;
  3559. hr = HRESULT_FROM_WIN32( ERROR_NOT_FOUND );
  3560. // fall thru - the while ( hr == S_OK ) will be false and keep going
  3561. }
  3562. else if ( FAILED( hr ) )
  3563. {
  3564. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumResources_FindObject, hr );
  3565. goto Cleanup;
  3566. }
  3567. else
  3568. {
  3569. hr = THR( punk->TypeSafeQI( IEnumClusCfgNetworks, &peccn ) );
  3570. if ( FAILED( hr ) )
  3571. {
  3572. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumResources_FindObject_QI, hr );
  3573. goto Cleanup;
  3574. }
  3575. peccn = TraceInterface( L"CTaskAnalyzeCluster!IEnumClusCfgNetworks", IEnumClusCfgNetworks, peccn, 1 );
  3576. punk->Release();
  3577. punk = NULL;
  3578. }
  3579. //
  3580. // Loop thru the first nodes networks create an equalivant network
  3581. // under the cluster configuration object/cookie.
  3582. //
  3583. while ( hr == S_OK )
  3584. {
  3585. // Cleanup
  3586. if ( pccni != NULL )
  3587. {
  3588. pccni->Release();
  3589. pccni = NULL;
  3590. }
  3591. // Get next network
  3592. hr = STHR( peccn->Next( 1, &pccni, &celtDummy ) );
  3593. if ( FAILED( hr ) )
  3594. {
  3595. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_EnumNetwork_Next, hr );
  3596. goto Cleanup;
  3597. }
  3598. if ( hr == S_FALSE )
  3599. break; // exit condition
  3600. pccni = TraceInterface( L"CTaskAnalyzeCluster!IClusCfgNetworkInfo", IClusCfgNetworkInfo, pccni, 1 );
  3601. // create a new object
  3602. hr = THR( HrCreateNewNetworkInClusterConfiguration( pccni, NULL ) );
  3603. if ( FAILED( hr ) )
  3604. goto Cleanup;
  3605. } // while: S_OK
  3606. //
  3607. // Reset the enumeration.
  3608. //
  3609. hr = THR( pecNodes->Reset() );
  3610. if ( FAILED( hr ) )
  3611. {
  3612. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_Reset, hr );
  3613. goto Cleanup;
  3614. }
  3615. //
  3616. // Loop thru the rest of the nodes comparing the networks.
  3617. //
  3618. do
  3619. {
  3620. //
  3621. // Cleanup
  3622. //
  3623. if ( peccn != NULL )
  3624. {
  3625. peccn->Release();
  3626. peccn = NULL;
  3627. }
  3628. TraceSysFreeString( bstrName );
  3629. bstrName = NULL;
  3630. //
  3631. // Get the next node.
  3632. //
  3633. hr = STHR( pecNodes->Next( 1, &cookieNode, &celtDummy ) );
  3634. if ( FAILED( hr ) )
  3635. {
  3636. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_NextNode, hr );
  3637. goto Cleanup;
  3638. }
  3639. if ( hr == S_FALSE )
  3640. break; // exit condition
  3641. if ( cookieNode == cookieFirst )
  3642. continue; // skip it
  3643. //
  3644. // Retrieve the node's name
  3645. //
  3646. hr = THR( HrRetrieveCookiesName( TASKID_Major_Find_Devices,
  3647. cookieNode,
  3648. &bstrName
  3649. ) );
  3650. if ( FAILED( hr ) )
  3651. goto Cleanup;
  3652. //
  3653. // Retrieve the networks enumer.
  3654. //
  3655. hr = THR( m_pom->FindObject( CLSID_NetworkType,
  3656. cookieNode,
  3657. NULL,
  3658. DFGUID_EnumManageableNetworks,
  3659. &cookieDummy,
  3660. &punk
  3661. ) );
  3662. if ( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) )
  3663. {
  3664. hr = THR( HrLoadStringIntoBSTR( g_hInstance,
  3665. IDS_TASKID_MINOR_NO_MANAGED_NETWORKS_FOUND,
  3666. &bstrNotification
  3667. ) );
  3668. if ( FAILED( hr ) )
  3669. {
  3670. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_Next_LoadString, hr );
  3671. goto Cleanup;
  3672. }
  3673. hr = THR( SendStatusReport( bstrName,
  3674. TASKID_Major_Find_Devices,
  3675. TASKID_Minor_No_Managed_Networks_Found,
  3676. 0,
  3677. 1,
  3678. 1,
  3679. MAKE_HRESULT( 0, FACILITY_WIN32, ERROR_NOT_FOUND ),
  3680. bstrNotification,
  3681. NULL,
  3682. NULL
  3683. ) );
  3684. if ( FAILED( hr ) )
  3685. goto Cleanup;
  3686. continue; // skip this node
  3687. }
  3688. else if ( FAILED( hr ) )
  3689. {
  3690. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_Next_FindObject, hr );
  3691. goto Cleanup;
  3692. }
  3693. hr = THR( punk->TypeSafeQI( IEnumClusCfgNetworks, &peccn ) );
  3694. if ( FAILED( hr ) )
  3695. goto Cleanup;
  3696. peccn = TraceInterface( L"CTaskAnalyzeCluster!IEnumClusCfgNetworks", IEnumClusCfgNetworks, peccn, 1 );
  3697. punk->Release();
  3698. punk = NULL;
  3699. //
  3700. // Loop thru the networks already that the node has.
  3701. //
  3702. do
  3703. {
  3704. //
  3705. // Cleanup
  3706. //
  3707. if ( pccni != NULL )
  3708. {
  3709. pccni->Release();
  3710. pccni = NULL;
  3711. }
  3712. TraceSysFreeString( bstrUID );
  3713. bstrUID = NULL;
  3714. if ( peccnCluster != NULL )
  3715. {
  3716. peccnCluster->Release();
  3717. peccnCluster = NULL;
  3718. }
  3719. //
  3720. // Get next network
  3721. //
  3722. hr = STHR( peccn->Next( 1, &pccni, &celtDummy ) );
  3723. if ( FAILED( hr ) )
  3724. {
  3725. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_EnumNetworks_Next, hr );
  3726. goto Cleanup;
  3727. }
  3728. if ( hr == S_FALSE )
  3729. break; // exit condition
  3730. pccni = TraceInterface( L"CTaskAnalyzeCluster!IClusCfgNetworkInfo", IClusCfgNetworkInfo, pccni, 1 );
  3731. //
  3732. // Grab the network's UUID.
  3733. //
  3734. hr = THR( pccni->GetUID( &bstrUID ) );
  3735. if ( FAILED( hr ) )
  3736. {
  3737. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_EnumNetworks_GetUID, hr );
  3738. goto Cleanup;
  3739. }
  3740. TraceMemoryAddBSTR( bstrUID );
  3741. //
  3742. // See if it matches a network already in the cluster configuration.
  3743. //
  3744. hr = THR( m_pom->FindObject( CLSID_NetworkType,
  3745. m_cookieCluster,
  3746. NULL,
  3747. DFGUID_EnumManageableNetworks,
  3748. &cookieDummy,
  3749. &punk
  3750. ) );
  3751. if ( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) )
  3752. {
  3753. hr = S_FALSE; // create a new object.
  3754. // fall thru
  3755. }
  3756. else if ( FAILED( hr ) )
  3757. {
  3758. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_EnumNetworks_FindObject, hr );
  3759. goto Cleanup;
  3760. }
  3761. hr = THR( punk->TypeSafeQI( IEnumClusCfgNetworks, &peccnCluster ) );
  3762. if ( FAILED( hr ) )
  3763. {
  3764. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_EnumNetworks_FindObject_QI, hr );
  3765. goto Cleanup;
  3766. }
  3767. peccnCluster = TraceInterface( L"CTaskAnalyzeCluster!IEnumClusCfgNetworks", IEnumClusCfgNetworks, peccnCluster, 1 );
  3768. punk->Release();
  3769. punk = NULL;
  3770. //
  3771. // Loop thru the configured cluster network to see what matches.
  3772. //
  3773. while( hr == S_OK )
  3774. {
  3775. HRESULT hrCluster;
  3776. BOOL fMatch;
  3777. //
  3778. // Cleanup
  3779. //
  3780. if ( pccniCluster != NULL )
  3781. {
  3782. pccniCluster->Release();
  3783. pccniCluster = NULL;
  3784. }
  3785. hr = STHR( peccnCluster->Next( 1, &pccniCluster, &celtDummy ) );
  3786. if ( FAILED( hr ) )
  3787. {
  3788. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_EnumNetworks_Cluster_Next, hr );
  3789. goto Cleanup;
  3790. }
  3791. if ( hr == S_FALSE )
  3792. break; // exit condition
  3793. pccniCluster = TraceInterface( L"CTaskAnalyzeCluster!IClusCfgNetworkInfo", IClusCfgNetworkInfo, pccniCluster, 1 );
  3794. hr = THR( pccniCluster->GetUID( &bstrUIDExisting ) );
  3795. if ( FAILED( hr ) )
  3796. {
  3797. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CompareNetworks_EnumNodes_EnumNetworks_Cluster_GetUID, hr );
  3798. goto Cleanup;
  3799. }
  3800. TraceMemoryAddBSTR( bstrUIDExisting );
  3801. fMatch = ( wcscmp( bstrUID, bstrUIDExisting ) == 0 );
  3802. TraceSysFreeString( bstrUIDExisting );
  3803. if ( !fMatch )
  3804. continue; // keep looping
  3805. //
  3806. //
  3807. // If we made it here then we think it truely is the same network. The
  3808. // rest is stuff we need to fixup during the commit phase.
  3809. //
  3810. //
  3811. //
  3812. // Exit the loop with S_OK so we don't create a new network.
  3813. //
  3814. hr = S_OK;
  3815. break; // exit loop
  3816. } // while: S_OK
  3817. if ( hr == S_FALSE )
  3818. {
  3819. //
  3820. // Need to create a new object.
  3821. //
  3822. Assert( pccni != NULL );
  3823. hr = THR( HrCreateNewNetworkInClusterConfiguration( pccni, NULL ) );
  3824. if ( FAILED( hr ) )
  3825. goto Cleanup;
  3826. } // if: object not found
  3827. } while ( hr == S_OK ); // networks
  3828. } while ( hr == S_OK ); // nodes
  3829. hr = S_OK;
  3830. Cleanup:
  3831. TraceSysFreeString( bstrUID );
  3832. TraceSysFreeString( bstrName );
  3833. TraceSysFreeString( bstrNotification );
  3834. if ( punk != NULL )
  3835. {
  3836. punk->Release();
  3837. }
  3838. if ( pecNodes != NULL )
  3839. {
  3840. pecNodes->Release();
  3841. }
  3842. if ( peccn != NULL )
  3843. {
  3844. peccn->Release();
  3845. }
  3846. if ( peccnCluster != NULL )
  3847. {
  3848. peccnCluster->Release();
  3849. }
  3850. if ( pccni != NULL )
  3851. {
  3852. pccni->Release();
  3853. }
  3854. if ( pccniCluster != NULL )
  3855. {
  3856. pccniCluster->Release();
  3857. }
  3858. if ( pccNode != NULL )
  3859. {
  3860. pccNode->Release();
  3861. }
  3862. HRETURN( hr );
  3863. } //*** CTaskAnalyzeCluster::HrCompareNetworks()
  3864. //////////////////////////////////////////////////////////////////////////////
  3865. //
  3866. // HRESULT
  3867. // CTaskAnalyzeCluster::HrCreateNewNetworkInClusterConfiguration(
  3868. // IClusCfgNetworkInfo * pccniIn,
  3869. // IClusCfgNetworkInfo ** pccniNewOut
  3870. // )
  3871. //
  3872. //////////////////////////////////////////////////////////////////////////////
  3873. HRESULT
  3874. CTaskAnalyzeCluster::HrCreateNewNetworkInClusterConfiguration(
  3875. IClusCfgNetworkInfo * pccniIn,
  3876. IClusCfgNetworkInfo ** ppccniNewOut
  3877. )
  3878. {
  3879. TraceFunc( "" );
  3880. HRESULT hr;
  3881. OBJECTCOOKIE cookieDummy;
  3882. BSTR bstrUID = NULL;
  3883. IUnknown * punk = NULL;
  3884. IGatherData * pgd = NULL;
  3885. IClusCfgNetworkInfo * pccni = NULL;
  3886. // grab the name
  3887. hr = THR( pccniIn->GetUID( &bstrUID ) );
  3888. if ( FAILED( hr ) )
  3889. {
  3890. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CreateNetwork_GetUID, hr );
  3891. goto Cleanup;
  3892. }
  3893. TraceMemoryAddBSTR( bstrUID );
  3894. // create an object in the object manager.
  3895. hr = THR( m_pom->FindObject( CLSID_NetworkType,
  3896. m_cookieCluster,
  3897. bstrUID,
  3898. DFGUID_NetworkResource,
  3899. &cookieDummy,
  3900. &punk
  3901. ) );
  3902. if ( FAILED( hr ) )
  3903. {
  3904. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CreateNetwork_FindObject, hr );
  3905. goto Cleanup;
  3906. }
  3907. // find the IGatherData interface
  3908. hr = THR( punk->TypeSafeQI( IGatherData, &pgd ) );
  3909. if ( FAILED( hr ) )
  3910. {
  3911. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CreateNetwork_FindObject_QI, hr );
  3912. goto Cleanup;
  3913. }
  3914. // have the new object gather all information it needs
  3915. hr = THR( pgd->Gather( m_cookieCluster, pccniIn ) );
  3916. if ( FAILED( hr ) )
  3917. {
  3918. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CreateNetwork_Gather, hr );
  3919. goto Cleanup;
  3920. }
  3921. // hand the object out if requested
  3922. if ( ppccniNewOut != NULL )
  3923. {
  3924. // find the IClusCfgManagedResourceInfo
  3925. hr = THR( punk->TypeSafeQI( IClusCfgNetworkInfo, &pccni ) );
  3926. if ( FAILED( hr ) )
  3927. {
  3928. SSR_ANALYSIS_FAILED( TASKID_Major_Find_Devices, TASKID_Minor_CreateNetwork_QI, hr );
  3929. goto Cleanup;
  3930. }
  3931. *ppccniNewOut = TraceInterface( L"ManagedDevice!ICCNI", IClusCfgNetworkInfo, pccni, 0 );
  3932. (*ppccniNewOut)->AddRef();
  3933. }
  3934. Cleanup:
  3935. TraceSysFreeString( bstrUID );
  3936. if ( pccni != NULL )
  3937. {
  3938. pccni->Release();
  3939. }
  3940. if ( pgd != NULL )
  3941. {
  3942. pgd->Release();
  3943. }
  3944. if ( punk != NULL )
  3945. {
  3946. punk->Release();
  3947. }
  3948. HRETURN( hr );
  3949. } //*** CTaskAnalyzeCluster::HrCreateNewNetworkInClusterConfiguration()
  3950. //////////////////////////////////////////////////////////////////////////////
  3951. //
  3952. //
  3953. // HRESULT
  3954. // CTaskAnalyzeCluster::HrFreeCookies( void )
  3955. //
  3956. //////////////////////////////////////////////////////////////////////////////
  3957. HRESULT
  3958. CTaskAnalyzeCluster::HrFreeCookies( void )
  3959. {
  3960. TraceFunc( "" );
  3961. HRESULT hr;
  3962. HRESULT hrReturn = S_OK;
  3963. Assert( m_pom != NULL );
  3964. while( m_cCookies != 0 )
  3965. {
  3966. m_cCookies --;
  3967. if ( m_pcookies[ m_cCookies ] != NULL )
  3968. {
  3969. hr = THR( m_pom->RemoveObject( m_pcookies[ m_cCookies ] ) );
  3970. if ( FAILED( hr ) )
  3971. {
  3972. hrReturn = hr;
  3973. }
  3974. }
  3975. }
  3976. Assert( m_cCookies == 0 );
  3977. m_cSubTasksDone = 0;
  3978. TraceFree( m_pcookies );
  3979. m_pcookies = NULL;
  3980. HRETURN( hrReturn );
  3981. } //*** CTaskAnalyzeCluster::HrFreeCookies()
  3982. //////////////////////////////////////////////////////////////////////////////
  3983. //
  3984. //
  3985. // HRESULT
  3986. // CTaskAnalyzeCluster::HrRetrieveCookiesName(
  3987. // CLSID clsidMajorIn,
  3988. // OBJECTCOOKIE cookieIn,
  3989. // BSTR * pbstrNameOut
  3990. // )
  3991. //
  3992. //////////////////////////////////////////////////////////////////////////////
  3993. HRESULT
  3994. CTaskAnalyzeCluster::HrRetrieveCookiesName(
  3995. CLSID clsidMajorIn,
  3996. OBJECTCOOKIE cookieIn,
  3997. BSTR * pbstrNameOut
  3998. )
  3999. {
  4000. TraceFunc( "" );
  4001. HRESULT hr;
  4002. IUnknown * punk = NULL;
  4003. IStandardInfo * psi = NULL;
  4004. Assert( cookieIn != NULL );
  4005. Assert( pbstrNameOut != NULL );
  4006. //
  4007. // Retrieve the node name in case of errors.
  4008. //
  4009. hr = THR( m_pom->GetObject( DFGUID_StandardInfo,
  4010. cookieIn,
  4011. &punk
  4012. ) );
  4013. if ( FAILED( hr ) )
  4014. {
  4015. SSR_ANALYSIS_FAILED( clsidMajorIn, TASKID_Minor_HrRetrieveCookiesName_FindObject_StandardInfo, hr );
  4016. goto Cleanup;
  4017. }
  4018. hr = THR( punk->TypeSafeQI( IStandardInfo, &psi ) );
  4019. if ( FAILED( hr ) )
  4020. {
  4021. SSR_ANALYSIS_FAILED( clsidMajorIn, TASKID_Minor_HrRetrieveCookiesName_FindObject_StandardInfo_QI_psi, hr );
  4022. goto Cleanup;
  4023. }
  4024. hr = THR( psi->GetName( pbstrNameOut ) );
  4025. if ( FAILED( hr ) )
  4026. {
  4027. SSR_ANALYSIS_FAILED( clsidMajorIn, TASKID_Minor_HrRetrieveCookiesName_GetName, hr );
  4028. goto Cleanup;
  4029. }
  4030. TraceMemoryAddBSTR( *pbstrNameOut );
  4031. Cleanup:
  4032. if ( punk != NULL )
  4033. {
  4034. punk->Release();
  4035. }
  4036. if ( psi != NULL )
  4037. {
  4038. psi->Release();
  4039. }
  4040. HRETURN( hr );
  4041. } //*** CTaskAnalyzeCluster::HrRetrieveCookiesName
  4042. //////////////////////////////////////////////////////////////////////////////
  4043. //
  4044. // HRESULT
  4045. // CTaskAnalyzeCluster::HrCheckInteroperability( void )
  4046. //
  4047. //////////////////////////////////////////////////////////////////////////////
  4048. HRESULT
  4049. CTaskAnalyzeCluster::HrCheckInteroperability( void )
  4050. {
  4051. TraceFunc( "" );
  4052. Assert( m_pcm != NULL );
  4053. HRESULT hr = S_OK;
  4054. RPC_STATUS rpcs = RPC_S_OK;
  4055. RPC_BINDING_HANDLE rbhBindingHandle = NULL;
  4056. LPWSTR pszBindingString = NULL;
  4057. BSTR bstrNodeName = NULL;
  4058. BSTR bstrNotification = NULL;
  4059. BSTR bstrBindingString = NULL;
  4060. DWORD sc;
  4061. IUnknown * punk = NULL;
  4062. bool fAllNodesMatch;
  4063. DWORD dwSponsorNodeId;
  4064. DWORD dwClusterHighestVersion;
  4065. DWORD dwClusterLowestVersion;
  4066. DWORD dwJoinStatus;
  4067. DWORD dwNodeHighestVersion;
  4068. DWORD dwNodeLowestVersion;
  4069. bool fVersionMismatch = false;
  4070. IClusCfgServer * piccs = NULL;
  4071. //
  4072. // If were are forming there is no need to do this check.
  4073. //
  4074. if ( !m_fJoiningMode )
  4075. {
  4076. goto Cleanup;
  4077. } // if:
  4078. //
  4079. // Tell the UI were are starting this.
  4080. //
  4081. hr = THR( HrLoadStringIntoBSTR( g_hInstance, IDS_TASKID_MINOR_CHECKINTEROPERABILITY, &bstrNotification ) );
  4082. if ( FAILED( hr ) )
  4083. {
  4084. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrCheckInteroperability_LoadString_Checking, hr );
  4085. goto Cleanup;
  4086. }
  4087. hr = THR( SendStatusReport( NULL,
  4088. TASKID_Major_Check_Cluster_Feasibility,
  4089. TASKID_Minor_CheckInteroperability,
  4090. 0,
  4091. 0,
  4092. 1,
  4093. S_OK,
  4094. bstrNotification,
  4095. NULL,
  4096. NULL
  4097. ) );
  4098. if ( FAILED( hr ) )
  4099. goto Cleanup;
  4100. //
  4101. // All nodes must be at the same level diring a bulk add.
  4102. //
  4103. hr = STHR( HrEnsureAllJoiningNodesSameVersion( &dwNodeHighestVersion, &dwNodeLowestVersion, &fAllNodesMatch ) );
  4104. if ( FAILED( hr ) )
  4105. {
  4106. goto Error;
  4107. } // if:
  4108. //
  4109. // Just bail if no nodes found that are joining, then there isn't a need to
  4110. // do this check.
  4111. //
  4112. if ( hr == S_FALSE )
  4113. goto Cleanup;
  4114. if ( !fAllNodesMatch )
  4115. {
  4116. hr = THR( HRESULT_FROM_WIN32( ERROR_CLUSTER_INCOMPATIBLE_VERSIONS ) );
  4117. goto Cleanup;
  4118. } // if:
  4119. hr = THR( m_pcm->GetConnectionToObject( m_cookieCluster, &punk ) );
  4120. if ( FAILED( hr ) )
  4121. {
  4122. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrCheckInteroperability_GetConnectionObject, hr );
  4123. goto Cleanup;
  4124. } // if:
  4125. hr = THR( punk->TypeSafeQI( IClusCfgServer, &piccs ) );
  4126. if ( FAILED( hr ) )
  4127. {
  4128. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrCheckInteroperability_ConfigConnection_QI, hr );
  4129. goto Error;
  4130. } // if:
  4131. hr = THR( piccs->GetBindingString( &bstrBindingString ) );
  4132. if ( FAILED( hr ) )
  4133. {
  4134. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrCheckInteroperability_GetBindingString, hr );
  4135. goto Error;
  4136. } // if:
  4137. TraceMemoryAddBSTR( bstrBindingString );
  4138. // Create a string binding handle.
  4139. rpcs = TW32( RpcStringBindingComposeW(
  4140. L"6e17aaa0-1a47-11d1-98bd-0000f875292e"
  4141. , L"ncadg_ip_udp"
  4142. , bstrBindingString
  4143. , NULL
  4144. , NULL
  4145. , &pszBindingString
  4146. ) );
  4147. if ( rpcs != RPC_S_OK )
  4148. {
  4149. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrCheckInteroperability_RpcStringBindingComposeW, hr );
  4150. goto RpcError;
  4151. } // if: RpcStringBindingComposeW() failed
  4152. // Get the actual binding handle
  4153. rpcs = TW32( RpcBindingFromStringBindingW( pszBindingString, &rbhBindingHandle ) );
  4154. if ( rpcs != RPC_S_OK )
  4155. {
  4156. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrCheckInteroperability_RpcBindingFromStringBindingW, hr );
  4157. goto RpcError;
  4158. } // if: RpcBindingFromStringBindingW() failed
  4159. // Resolve the binding handle
  4160. rpcs = TW32( RpcEpResolveBinding( rbhBindingHandle, JoinVersion_v2_0_c_ifspec ) );
  4161. if ( rpcs != RPC_S_OK )
  4162. {
  4163. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrCheckInteroperability_RpcEpResolveBinding, hr );
  4164. goto RpcError;
  4165. } // if: RpcEpResolveBinding() failed
  4166. // Set RPC security
  4167. rpcs = TW32( RpcBindingSetAuthInfoW(
  4168. rbhBindingHandle
  4169. , NULL
  4170. , RPC_C_AUTHN_LEVEL_CONNECT
  4171. , RPC_C_AUTHN_WINNT
  4172. , NULL
  4173. , RPC_C_AUTHZ_NAME
  4174. ) );
  4175. if ( rpcs != RPC_S_OK )
  4176. {
  4177. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrCheckInteroperability_RpcBindingSetAuthInfoW, hr );
  4178. goto RpcError;
  4179. } // if: RpcBindingSetAuthInfoW() failed
  4180. //
  4181. // Get and verify the sponsor version
  4182. //
  4183. //
  4184. // From Whistler onwards, CsRpcGetJoinVersionData() will return a failure code in its last parameter
  4185. // if the version of this node is not compatible with the sponsor version. Prior to this, the last
  4186. // parameter always contained a success value and the cluster versions had to be compared subsequent to this
  4187. // call. This will, however, still have to be done as long as interoperability with Win2K
  4188. // is a requirement, since Win2K sponsors do not return an error in the last parameter.
  4189. //
  4190. sc = TW32( CsRpcGetJoinVersionData(
  4191. rbhBindingHandle
  4192. , 0
  4193. , dwNodeHighestVersion
  4194. , dwNodeLowestVersion
  4195. , &dwSponsorNodeId
  4196. , &dwClusterHighestVersion
  4197. , &dwClusterLowestVersion
  4198. , &dwJoinStatus
  4199. ) );
  4200. if ( sc != ERROR_SUCCESS )
  4201. {
  4202. hr = HRESULT_FROM_WIN32( sc );
  4203. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrCheckInteroperability_CsRpcGetJoinVersionData, hr );
  4204. goto Cleanup;
  4205. } // if: CsRpcGetJoinVersionData() failed
  4206. LogMsg(
  4207. "[MT] ( Node Highest, Node Lowest ) = ( %#08x, %#08x ), ( Cluster Highest, Cluster Lowest ) = ( %#08x, %#08x )."
  4208. , dwNodeHighestVersion
  4209. , dwNodeLowestVersion
  4210. , dwClusterHighestVersion
  4211. , dwClusterLowestVersion
  4212. );
  4213. if ( dwJoinStatus == ERROR_SUCCESS )
  4214. {
  4215. DWORD dwClusterMajorVersion = CLUSTER_GET_MAJOR_VERSION( dwClusterHighestVersion );
  4216. Assert( dwClusterMajorVersion >= ( CLUSTER_INTERNAL_CURRENT_MAJOR_VERSION - 1 ) );
  4217. //
  4218. // Only want to join clusters that are no more than one version back.
  4219. //
  4220. if ( dwClusterMajorVersion < ( CLUSTER_INTERNAL_CURRENT_MAJOR_VERSION - 1 ) )
  4221. {
  4222. fVersionMismatch = true;
  4223. } // if:
  4224. } // if: the join status was ok
  4225. else
  4226. {
  4227. fVersionMismatch = true;
  4228. } // else: join is not possible
  4229. if ( fVersionMismatch )
  4230. {
  4231. hr = THR( HRESULT_FROM_WIN32( ERROR_CLUSTER_INCOMPATIBLE_VERSIONS ) );
  4232. } // if: there was a version mismatch
  4233. else
  4234. {
  4235. Assert( hr == S_OK );
  4236. }
  4237. goto UpdateStatus;
  4238. RpcError:
  4239. hr = HRESULT_FROM_WIN32( rpcs );
  4240. Error:
  4241. UpdateStatus:
  4242. {
  4243. HRESULT hr2;
  4244. hr2 = THR( SendStatusReport( NULL,
  4245. TASKID_Major_Check_Cluster_Feasibility,
  4246. TASKID_Minor_CheckInteroperability,
  4247. 0,
  4248. 1,
  4249. 1,
  4250. hr,
  4251. NULL,
  4252. NULL,
  4253. NULL
  4254. ) );
  4255. if ( FAILED( hr2 ) )
  4256. {
  4257. hr = hr2;
  4258. }
  4259. }
  4260. Cleanup:
  4261. if ( punk != NULL )
  4262. {
  4263. punk->Release();
  4264. } // if:
  4265. if ( rbhBindingHandle != NULL )
  4266. {
  4267. RpcBindingFree( &rbhBindingHandle );
  4268. } // if:
  4269. if ( pszBindingString != NULL )
  4270. {
  4271. RpcStringFree( &pszBindingString );
  4272. } // if:
  4273. if ( piccs != NULL )
  4274. {
  4275. piccs->Release();
  4276. } // if:
  4277. TraceSysFreeString( bstrNotification );
  4278. TraceSysFreeString( bstrNodeName );
  4279. TraceSysFreeString( bstrBindingString );
  4280. HRETURN( hr );
  4281. } //*** CTaskAnalyzeCluster::HrCheckInteroperability()
  4282. //////////////////////////////////////////////////////////////////////////////
  4283. //
  4284. // HRESULT
  4285. // CTaskAnalyzeCluster::HrEnsureAllJoiningNodesSameVersion(
  4286. // DWORD * pdwNodeHighestVersionOut,
  4287. // DWORD * pdwNodeLowestVersionOut,
  4288. // bool * pfAllNodesMatchOut
  4289. // )
  4290. //
  4291. //////////////////////////////////////////////////////////////////////////////
  4292. HRESULT
  4293. CTaskAnalyzeCluster::HrEnsureAllJoiningNodesSameVersion(
  4294. DWORD * pdwNodeHighestVersionOut,
  4295. DWORD * pdwNodeLowestVersionOut,
  4296. bool * pfAllNodesMatchOut
  4297. )
  4298. {
  4299. TraceFunc( "" );
  4300. Assert( m_fJoiningMode );
  4301. Assert( pdwNodeHighestVersionOut != NULL );
  4302. Assert( pdwNodeLowestVersionOut != NULL );
  4303. Assert( pfAllNodesMatchOut != NULL );
  4304. HRESULT hr = S_OK;
  4305. OBJECTCOOKIE cookieDummy;
  4306. IUnknown * punk = NULL;
  4307. IEnumNodes * pen = NULL;
  4308. IClusCfgNodeInfo * pccni = NULL;
  4309. DWORD rgdwNodeHighestVersion[ 2 ];
  4310. DWORD rgdwNodeLowestVersion[ 2 ];
  4311. int idx = 0;
  4312. BSTR bstrDescription = NULL;
  4313. BSTR bstrNodeName = NULL;
  4314. BSTR bstrFirstNodeName = NULL;
  4315. BOOL fFoundAtLeastOneJoiningNode = FALSE;
  4316. *pfAllNodesMatchOut = true;
  4317. ZeroMemory( rgdwNodeHighestVersion, sizeof( rgdwNodeHighestVersion ) );
  4318. ZeroMemory( rgdwNodeLowestVersion, sizeof( rgdwNodeLowestVersion ) );
  4319. //
  4320. // Ask the object manager for the node enumerator.
  4321. //
  4322. hr = THR( m_pom->FindObject( CLSID_NodeType,
  4323. m_cookieCluster,
  4324. NULL,
  4325. DFGUID_EnumNodes,
  4326. &cookieDummy,
  4327. &punk
  4328. ) );
  4329. if ( FAILED( hr ) )
  4330. {
  4331. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrEnsureAllJoiningNodesSameVersion_FindObject, hr );
  4332. goto Cleanup;
  4333. }
  4334. hr = THR( punk->TypeSafeQI( IEnumNodes, &pen ) );
  4335. if ( FAILED( hr ) )
  4336. {
  4337. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrEnsureAllJoiningNodesSameVersion_FindObject_QI, hr );
  4338. goto Cleanup;
  4339. }
  4340. //
  4341. // Look at each node and ensure that they all have the same version.
  4342. //
  4343. Assert( SUCCEEDED( hr ) );
  4344. while ( SUCCEEDED( hr ) )
  4345. {
  4346. ULONG celtDummy;
  4347. //
  4348. // Cleanup
  4349. //
  4350. if ( pccni != NULL )
  4351. {
  4352. pccni->Release();
  4353. pccni = NULL;
  4354. } // if:
  4355. //
  4356. // Get the next node.
  4357. //
  4358. hr = STHR( pen->Next( 1, &pccni, &celtDummy ) );
  4359. if ( hr == S_FALSE )
  4360. {
  4361. break; // exit condition
  4362. } // if:
  4363. if ( FAILED( hr ) )
  4364. {
  4365. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrEnsureAllJoiningNodesSameVersion_EnumNode_Next, hr );
  4366. goto Cleanup;
  4367. } // if:
  4368. hr = STHR( pccni->IsMemberOfCluster() );
  4369. if ( FAILED( hr ) )
  4370. {
  4371. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrEnsureAllJoiningNodesSameVersion_Node_IsMemberOfCluster, hr );
  4372. goto Cleanup;
  4373. } // if:
  4374. //
  4375. // Only want to check those nodes that are not already members of a cluster. The nodes being added.
  4376. //
  4377. if ( hr == S_FALSE )
  4378. {
  4379. fFoundAtLeastOneJoiningNode = TRUE;
  4380. hr = THR( pccni->GetClusterVersion( &rgdwNodeHighestVersion[ idx ], &rgdwNodeLowestVersion[ idx ] ) );
  4381. if ( FAILED( hr ) )
  4382. {
  4383. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrEnsureAllJoiningNodesSameVersion_Node_GetClusterVersion, hr );
  4384. goto Cleanup;
  4385. } // if:
  4386. idx++;
  4387. //
  4388. // Need to get the another node's version.
  4389. //
  4390. if ( idx == 1 )
  4391. {
  4392. WCHAR * psz = NULL;
  4393. hr = THR( pccni->GetName( &bstrFirstNodeName ) );
  4394. if ( FAILED( hr ) )
  4395. {
  4396. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrEnsureAllJoiningNodesSameVersion_GetName, hr );
  4397. goto Cleanup;
  4398. } // if:
  4399. psz = wcschr( bstrFirstNodeName, L'.' );
  4400. if ( psz != NULL )
  4401. {
  4402. *psz = L'\0'; // change from an FQDN to a simple node name.
  4403. } // if:
  4404. continue;
  4405. } // if:
  4406. //
  4407. // Let's compare two nodes at a time...
  4408. //
  4409. if ( idx == 2 )
  4410. {
  4411. if ( ( rgdwNodeHighestVersion[ 0 ] == rgdwNodeHighestVersion[ 1 ] )
  4412. && ( rgdwNodeLowestVersion[ 1 ] == rgdwNodeLowestVersion[ 1 ] ) )
  4413. {
  4414. idx = 1; // reset to put the next node's version values at the second position...
  4415. continue;
  4416. } // if:
  4417. else
  4418. {
  4419. *pfAllNodesMatchOut = false;
  4420. hr = THR( pccni->GetName( &bstrNodeName ) );
  4421. if ( FAILED( hr ) )
  4422. {
  4423. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrEnsureAllJoiningNodesSameVersion_GetName, hr );
  4424. goto Cleanup;
  4425. } // if:
  4426. hr = THR( HrFormatStringIntoBSTR( g_hInstance, IDS_TASKID_MINOR_NODES_VERSION_MISMATCH, &bstrDescription, bstrFirstNodeName ) );
  4427. if ( FAILED( hr ) )
  4428. {
  4429. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrEnsureAllJoiningNodesSameVersion_FormatString, hr );
  4430. goto Cleanup;
  4431. } // if:
  4432. hr = THR( SendStatusReport( bstrNodeName,
  4433. TASKID_Major_Check_Cluster_Feasibility,
  4434. TASKID_Minor_CheckInteroperability,
  4435. 0,
  4436. 0,
  4437. 1,
  4438. HRESULT_FROM_WIN32( ERROR_CLUSTER_INCOMPATIBLE_VERSIONS ),
  4439. bstrDescription,
  4440. NULL,
  4441. NULL
  4442. ) );
  4443. goto Cleanup;
  4444. } // else:
  4445. } // if:
  4446. } // if:
  4447. } // while: hr
  4448. if ( !fFoundAtLeastOneJoiningNode )
  4449. {
  4450. THR( HrLoadStringIntoBSTR( g_hInstance,
  4451. IDS_TASKID_MINOR_NO_JOINING_NODES_FOUND_FOR_VERSION_CHECK,
  4452. &bstrDescription
  4453. ) );
  4454. hr = THR( SendStatusReport( NULL,
  4455. TASKID_Major_Check_Cluster_Feasibility,
  4456. TASKID_Minor_CheckInteroperability,
  4457. 0,
  4458. 1,
  4459. 1,
  4460. S_FALSE,
  4461. bstrDescription,
  4462. NULL,
  4463. NULL
  4464. ) );
  4465. hr = S_FALSE;
  4466. goto Cleanup;
  4467. }
  4468. //
  4469. // Fill in the out args...
  4470. //
  4471. *pdwNodeHighestVersionOut = rgdwNodeHighestVersion[ 0 ];
  4472. *pdwNodeLowestVersionOut = rgdwNodeLowestVersion[ 0 ];
  4473. hr = S_OK;
  4474. Cleanup:
  4475. if ( pccni != NULL )
  4476. {
  4477. pccni->Release();
  4478. } // if:
  4479. if ( pen != NULL )
  4480. {
  4481. pen->Release();
  4482. } // if:
  4483. if ( punk != NULL )
  4484. {
  4485. punk->Release();
  4486. } // if:
  4487. TraceSysFreeString( bstrNodeName );
  4488. TraceSysFreeString( bstrFirstNodeName );
  4489. TraceSysFreeString( bstrDescription );
  4490. HRETURN( hr );
  4491. } //*** CTaskAnalyzeCluster::HrEnsureAllJoiningNodesSameVersion()
  4492. //////////////////////////////////////////////////////////////////////////////
  4493. //
  4494. // HRESULT
  4495. // CTaskAnalyzeCluster::HrGetUsersNodesCookies( void )
  4496. //
  4497. //////////////////////////////////////////////////////////////////////////////
  4498. HRESULT
  4499. CTaskAnalyzeCluster::HrGetUsersNodesCookies( void )
  4500. {
  4501. TraceFunc( "" );
  4502. HRESULT hr;
  4503. ULONG ulDummy;
  4504. OBJECTCOOKIE cookie;
  4505. OBJECTCOOKIE cookieDummy;
  4506. ULONG cNode;
  4507. IUnknown * punk = NULL;
  4508. IEnumCookies * pec = NULL;
  4509. //
  4510. // Get the cookie enumerator.
  4511. //
  4512. hr = THR( m_pom->FindObject( CLSID_NodeType, m_cookieCluster, NULL, DFGUID_EnumCookies, &cookieDummy, &punk ) );
  4513. if ( FAILED( hr ) )
  4514. {
  4515. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_GetUsersNodesCookies_FindObject, hr );
  4516. goto Cleanup;
  4517. }
  4518. hr = THR( punk->TypeSafeQI( IEnumCookies, &pec ) );
  4519. if ( FAILED( hr ) )
  4520. {
  4521. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_GetUsersNodesCookies_FindObject_QI, hr );
  4522. goto Cleanup;
  4523. }
  4524. pec = TraceInterface( L"CTaskAnalyzeCluster!IEnumCookies", IEnumCookies, pec, 1 );
  4525. punk->Release();
  4526. punk = NULL;
  4527. //
  4528. // Enumerate the cookies to figure out how big a buffer to allocate.
  4529. //
  4530. for ( m_cUserNodes = 0; ; )
  4531. {
  4532. hr = STHR( pec->Next( 1, &cookie, &ulDummy ) );
  4533. if ( hr == S_FALSE )
  4534. break; // exit condition
  4535. if ( FAILED( hr ) )
  4536. {
  4537. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_GetUsersNodesCookies_EnumCookies_Next, hr );
  4538. goto Cleanup;
  4539. }
  4540. m_cUserNodes ++;
  4541. } // for: ever
  4542. //
  4543. // Allocate a buffer for the cookies.
  4544. //
  4545. m_pcookiesUser = (OBJECTCOOKIE *) TraceAlloc( 0, sizeof( OBJECTCOOKIE ) * m_cUserNodes );
  4546. if ( m_pcookiesUser == NULL )
  4547. goto OutOfMemory;
  4548. //
  4549. // Reset the enumerator.
  4550. //
  4551. hr = THR( pec->Reset() );
  4552. if ( FAILED( hr ) )
  4553. {
  4554. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_GetUsersNodesCookies_EnumCookies_Reset, hr );
  4555. goto Cleanup;
  4556. }
  4557. //
  4558. // Enumerate them again this time putting the cookies into the buffer.
  4559. //
  4560. for ( cNode = 0; cNode < m_cUserNodes; cNode ++ )
  4561. {
  4562. hr = THR( pec->Next( 1, &m_pcookiesUser[ cNode ], &ulDummy ) );
  4563. AssertMsg( hr != S_FALSE, "We should never hit this because the count of nodes should change!" );
  4564. if ( hr != S_OK )
  4565. {
  4566. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_GetUsersNodesCookies_EnumCookies_Next2, hr );
  4567. goto Cleanup;
  4568. }
  4569. } // for:
  4570. Assert( cNode == m_cUserNodes );
  4571. #ifdef DEBUG
  4572. hr = STHR( pec->Next( 1, &cookie, &ulDummy ) );
  4573. Assert( hr == S_FALSE );
  4574. #endif
  4575. hr = S_OK;
  4576. Cleanup:
  4577. if ( punk != NULL )
  4578. {
  4579. punk->Release();
  4580. }
  4581. if ( pec != NULL )
  4582. {
  4583. pec->Release();
  4584. }
  4585. HRETURN( hr );
  4586. OutOfMemory:
  4587. hr = E_OUTOFMEMORY;
  4588. SSR_ANALYSIS_FAILED( TASKID_Major_Establish_Connection, TASKID_Minor_GetUsersNodesCookies_OutOfMemory, hr );
  4589. goto Cleanup;
  4590. } //*** CTaskAnalyzeCluster::HrGetUsersNodesCookies()
  4591. //////////////////////////////////////////////////////////////////////////////
  4592. //
  4593. // HRESULT
  4594. // CTaskAnalyzeCluster::HrIsUserAddedNode( BSTR bstrNodeNameIn )
  4595. //
  4596. //////////////////////////////////////////////////////////////////////////////
  4597. HRESULT
  4598. CTaskAnalyzeCluster::HrIsUserAddedNode( BSTR bstrNodeNameIn )
  4599. {
  4600. TraceFunc( "HrGetUsersNodesCookies( ... )\n" );
  4601. HRESULT hr;
  4602. ULONG cNode;
  4603. IUnknown * punk = NULL;
  4604. IClusCfgNodeInfo * pccni = NULL;
  4605. BSTR bstrNodeName = NULL;
  4606. for ( cNode = 0; cNode < m_cUserNodes; cNode ++ )
  4607. {
  4608. hr = THR( m_pom->GetObject( DFGUID_NodeInformation, m_pcookiesUser[ cNode ], &punk ) );
  4609. if ( FAILED( hr ) )
  4610. {
  4611. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrIsUserAddedNode_GetObject, hr );
  4612. goto Cleanup;
  4613. } // if:
  4614. hr = THR( punk->TypeSafeQI( IClusCfgNodeInfo, &pccni ) );
  4615. if ( FAILED( hr ) )
  4616. {
  4617. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrIsUserAddedNode_GetObject_QI, hr );
  4618. goto Cleanup;
  4619. }
  4620. punk->Release();
  4621. punk = NULL;
  4622. hr = THR( pccni->GetName( &bstrNodeName ) );
  4623. if ( FAILED( hr ) )
  4624. {
  4625. SSR_ANALYSIS_FAILED( TASKID_Major_Check_Cluster_Feasibility, TASKID_Minor_HrIsUserAddedNode_GetName, hr );
  4626. goto Cleanup;
  4627. }
  4628. TraceMemoryAddBSTR( bstrNodeName );
  4629. pccni->Release();
  4630. pccni = NULL;
  4631. if ( wcscmp( bstrNodeNameIn, bstrNodeName ) == 0 )
  4632. {
  4633. hr = S_OK;
  4634. break;
  4635. } // if:
  4636. TraceSysFreeString( bstrNodeName );
  4637. bstrNodeName = NULL;
  4638. hr = S_FALSE;
  4639. } // for:
  4640. Cleanup:
  4641. if ( pccni != NULL )
  4642. {
  4643. pccni->Release();
  4644. } // if:
  4645. if ( punk != NULL )
  4646. {
  4647. punk->Release();
  4648. } // if:
  4649. TraceSysFreeString( bstrNodeName );
  4650. HRETURN( hr );
  4651. } //*** CTaskAnalyzeCluster::HrIsUserAddedNode()