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.

1195 lines
27 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CClusCfgNodeInfo.cpp
  7. //
  8. // Description:
  9. // This file contains the definition of the CClusCfgNodeInfo
  10. // class.
  11. //
  12. // The class CClusCfgNodeInfo is the representation of a
  13. // computer that can be a cluster node. It implements the
  14. // IClusCfgNodeInfo interface.
  15. //
  16. // Documentation:
  17. //
  18. // Header File:
  19. // CClusCfgNodeInfo.h
  20. //
  21. // Maintained By:
  22. // Galen Barbee (GalenB) 21-FEB-2000
  23. //
  24. //////////////////////////////////////////////////////////////////////////////
  25. //////////////////////////////////////////////////////////////////////////////
  26. // Include Files
  27. //////////////////////////////////////////////////////////////////////////////
  28. #include "pch.h"
  29. #include "CClusCfgNodeInfo.h"
  30. #include "CClusCfgClusterInfo.h"
  31. #include <ClusApi.h>
  32. #include <ClusVerp.h>
  33. //////////////////////////////////////////////////////////////////////////////
  34. // Constant Definitions
  35. //////////////////////////////////////////////////////////////////////////////
  36. DEFINE_THISCLASS( "CClusCfgNodeInfo" );
  37. //*************************************************************************//
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CClusCfgNodeInfo class
  40. /////////////////////////////////////////////////////////////////////////////
  41. //////////////////////////////////////////////////////////////////////////////
  42. //++
  43. //
  44. // CClusCfgNodeInfo::S_HrCreateInstance()
  45. //
  46. // Description:
  47. // Create a CClusCfgNodeInfo instance.
  48. //
  49. // Arguments:
  50. // None.
  51. //
  52. // Return Values:
  53. // Pointer to CClusCfgNodeInfo instance.
  54. //
  55. //--
  56. //////////////////////////////////////////////////////////////////////////////
  57. HRESULT
  58. CClusCfgNodeInfo::S_HrCreateInstance( IUnknown ** ppunkOut )
  59. {
  60. TraceFunc( "" );
  61. HRESULT hr;
  62. CClusCfgNodeInfo * lpccs = NULL;
  63. if ( ppunkOut == NULL )
  64. {
  65. hr = THR( E_POINTER );
  66. goto Cleanup;
  67. } // if:
  68. lpccs = new CClusCfgNodeInfo();
  69. if ( lpccs == NULL )
  70. {
  71. hr = THR( E_OUTOFMEMORY );
  72. goto Cleanup;
  73. } // if: error allocating object
  74. hr = THR( lpccs->HrInit() );
  75. if ( FAILED( hr ) )
  76. {
  77. goto Cleanup;
  78. } // if: HrInit() failed
  79. hr = THR( lpccs->TypeSafeQI( IUnknown, ppunkOut ) );
  80. Cleanup:
  81. if ( FAILED( hr ) )
  82. {
  83. LogMsg( L"[SRV] CClusCfgNodeInfo::S_HrCreateInstance() failed. (hr = %#08x)", hr );
  84. } // if:
  85. if ( lpccs != NULL )
  86. {
  87. lpccs->Release();
  88. } // if:
  89. HRETURN( hr );
  90. } //*** CClusCfgNodeInfo::S_HrCreateInstance()
  91. //////////////////////////////////////////////////////////////////////////////
  92. //++
  93. //
  94. // CClusCfgNodeInfo::CClusCfgNodeInfo()
  95. //
  96. // Description:
  97. // Constructor of the CClusCfgNodeInfo class. This initializes
  98. // the m_cRef variable to 1 instead of 0 to account of possible
  99. // QueryInterface failure in DllGetClassObject.
  100. //
  101. // Arguments:
  102. // None.
  103. //
  104. // Return Value:
  105. // None.
  106. //
  107. // Remarks:
  108. // None.
  109. //
  110. //--
  111. //////////////////////////////////////////////////////////////////////////////
  112. CClusCfgNodeInfo::CClusCfgNodeInfo( void )
  113. : m_cRef( 1 )
  114. , m_lcid( LOCALE_NEUTRAL )
  115. , m_fIsClusterNode( false )
  116. {
  117. TraceFunc( "" );
  118. // Increment the count of components in memory so the DLL hosting this
  119. // object cannot be unloaded.
  120. InterlockedIncrement( &g_cObjects );
  121. Assert( m_bstrFullDnsName == NULL );
  122. Assert( m_picccCallback == NULL );
  123. Assert( m_pIWbemServices == NULL );
  124. Assert( m_punkClusterInfo == NULL );
  125. TraceFuncExit();
  126. } //*** CClusCfgNodeInfo::CClusCfgNodeInfo
  127. //////////////////////////////////////////////////////////////////////////////
  128. //++
  129. //
  130. // CClusCfgNodeInfo::~CClusCfgNodeInfo()
  131. //
  132. // Description:
  133. // Desstructor of the CClusCfgNodeInfo class.
  134. //
  135. // Arguments:
  136. // None.
  137. //
  138. // Return Value:
  139. // None.
  140. //
  141. // Remarks:
  142. // None.
  143. //
  144. //--
  145. //////////////////////////////////////////////////////////////////////////////
  146. CClusCfgNodeInfo::~CClusCfgNodeInfo( void )
  147. {
  148. TraceFunc( "" );
  149. TraceSysFreeString( m_bstrFullDnsName );
  150. if ( m_pIWbemServices != NULL )
  151. {
  152. m_pIWbemServices->Release();
  153. } // if:
  154. if ( m_picccCallback != NULL )
  155. {
  156. m_picccCallback->Release();
  157. } // if:
  158. if ( m_punkClusterInfo != NULL )
  159. {
  160. m_punkClusterInfo->Release();
  161. } // if:
  162. // There's going to be one less component in memory. Decrement component count.
  163. InterlockedDecrement( &g_cObjects );
  164. TraceFuncExit();
  165. } //*** CClusCfgNodeInfo::~CClusCfgNodeInfo
  166. //*************************************************************************//
  167. /////////////////////////////////////////////////////////////////////////////
  168. // CClusCfgNodeInfo -- IUknkown interface.
  169. /////////////////////////////////////////////////////////////////////////////
  170. //////////////////////////////////////////////////////////////////////////////
  171. //++
  172. //
  173. // STDMETHODIMP_( ULONG )
  174. // CClusCfgNodeInfo:: [IUNKNOWN] AddRef()
  175. //
  176. // Description:
  177. // Increment the reference count of this object by one.
  178. //
  179. // Arguments:
  180. // None.
  181. //
  182. // Return Value:
  183. // The new reference count.
  184. //
  185. // Remarks:
  186. // None.
  187. //
  188. //--
  189. //////////////////////////////////////////////////////////////////////////////
  190. STDMETHODIMP_( ULONG )
  191. CClusCfgNodeInfo::AddRef( void )
  192. {
  193. TraceFunc( "[IUnknown]" );
  194. InterlockedIncrement( & m_cRef );
  195. RETURN( m_cRef );
  196. } //*** CClusCfgNodeInfo::AddRef()
  197. //////////////////////////////////////////////////////////////////////////////
  198. //++
  199. //
  200. // STDMETHODIMP_( ULONG )
  201. // CClusCfgNodeInfo:: [IUNKNOWN] Release()
  202. //
  203. // Description:
  204. // Decrement the reference count of this object by one.
  205. //
  206. // Arguments:
  207. // None.
  208. //
  209. // Return Value:
  210. // The new reference count.
  211. //
  212. // Remarks:
  213. // None.
  214. //
  215. //--
  216. //////////////////////////////////////////////////////////////////////////////
  217. STDMETHODIMP_( ULONG )
  218. CClusCfgNodeInfo::Release( void )
  219. {
  220. TraceFunc( "[IUnknown]" );
  221. LONG cRef;
  222. cRef = InterlockedDecrement( &m_cRef );
  223. if ( cRef == 0 )
  224. {
  225. TraceDo( delete this );
  226. } // if: reference count equal to zero
  227. RETURN( cRef );
  228. } //*** CClusCfgNodeInfo::Release()
  229. //////////////////////////////////////////////////////////////////////////////
  230. //++
  231. //
  232. // CClusCfgNodeInfo:: [INKNOWN] QueryInterface()
  233. //
  234. // Description:
  235. // Query this object for the passed in interface.
  236. //
  237. // Arguments:
  238. // IN REFIID riid,
  239. // Id of interface requested.
  240. //
  241. // OUT void ** ppv
  242. // Pointer to the requested interface.
  243. //
  244. // Return Value:
  245. // S_OK
  246. // If the interface is available on this object.
  247. //
  248. // E_NOINTERFACE
  249. // If the interface is not available.
  250. //
  251. // Remarks:
  252. // None.
  253. //
  254. //--
  255. //////////////////////////////////////////////////////////////////////////////
  256. STDMETHODIMP
  257. CClusCfgNodeInfo::QueryInterface( REFIID riid, void ** ppv )
  258. {
  259. TraceQIFunc( riid, ppv );
  260. HRESULT hr = E_NOINTERFACE;
  261. if ( IsEqualIID( riid, IID_IUnknown ) )
  262. {
  263. *ppv = static_cast< IClusCfgNodeInfo * >( this );
  264. hr = S_OK;
  265. } // if: IUnknown
  266. else if ( IsEqualIID( riid, IID_IClusCfgNodeInfo ) )
  267. {
  268. *ppv = TraceInterface( __THISCLASS__, IClusCfgNodeInfo, this, 0 );
  269. hr = S_OK;
  270. } // else if:
  271. else if ( IsEqualIID( riid, IID_IClusCfgWbemServices ) )
  272. {
  273. *ppv = TraceInterface( __THISCLASS__, IClusCfgWbemServices, this, 0 );
  274. hr = S_OK;
  275. } // else if:
  276. else if ( IsEqualIID( riid, IID_IClusCfgInitialize ) )
  277. {
  278. *ppv = TraceInterface( __THISCLASS__, IClusCfgInitialize, this, 0 );
  279. hr = S_OK;
  280. } // else if:
  281. if ( SUCCEEDED( hr ) )
  282. {
  283. ((IUnknown *) *ppv)->AddRef( );
  284. } // if: success
  285. QIRETURN_IGNORESTDMARSHALLING( hr, riid );
  286. } //*** CClusCfgNodeInfo::QueryInterface()
  287. //*************************************************************************//
  288. /////////////////////////////////////////////////////////////////////////////
  289. // CClusCfgNodeInfo -- IClusCfgWbemServices
  290. // interface.
  291. /////////////////////////////////////////////////////////////////////////////
  292. //////////////////////////////////////////////////////////////////////////////
  293. //++
  294. //
  295. // CClusCfgNodeInfo::SetWbemServices()
  296. //
  297. // Description:
  298. // Set the WBEM services provider.
  299. //
  300. // Arguments:
  301. // IN IWbemServices pIWbemServicesIn
  302. //
  303. // Return Value:
  304. // S_OK
  305. // Success
  306. //
  307. // E_POINTER
  308. // The pIWbemServicesIn param is NULL.
  309. //
  310. // Remarks:
  311. // None.
  312. //
  313. //--
  314. //////////////////////////////////////////////////////////////////////////////
  315. STDMETHODIMP
  316. CClusCfgNodeInfo::SetWbemServices( IWbemServices * pIWbemServicesIn )
  317. {
  318. TraceFunc( "[IClusCfgWbemServices]" );
  319. HRESULT hr = S_OK;
  320. if ( pIWbemServicesIn == NULL )
  321. {
  322. hr = THR( E_POINTER );
  323. STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_SetWbemServices_Node, IDS_ERROR_NULL_POINTER, hr );
  324. goto Cleanup;
  325. } // if:
  326. m_pIWbemServices = pIWbemServicesIn;
  327. m_pIWbemServices->AddRef();
  328. Cleanup:
  329. HRETURN( hr );
  330. } //*** CClusCfgNodeInfo::SetWbemServices()
  331. //*************************************************************************//
  332. /////////////////////////////////////////////////////////////////////////////
  333. // CClusCfgNodeInfo -- IClusCfgInitialize interface.
  334. /////////////////////////////////////////////////////////////////////////////
  335. //////////////////////////////////////////////////////////////////////////////
  336. //++
  337. //
  338. // CClusCfgNodeInfo::Initialize()
  339. //
  340. // Description:
  341. // Initialize this component.
  342. //
  343. // Arguments:
  344. // IN IUknown * punkCallbackIn
  345. //
  346. // IN LCID lcidIn
  347. //
  348. // Return Value:
  349. // S_OK
  350. // Success
  351. //
  352. // Remarks:
  353. // None.
  354. //
  355. //--
  356. //////////////////////////////////////////////////////////////////////////////
  357. STDMETHODIMP
  358. CClusCfgNodeInfo::Initialize(
  359. IUnknown * punkCallbackIn,
  360. LCID lcidIn
  361. )
  362. {
  363. TraceFunc( "[IClusCfgInitialize]" );
  364. Assert( m_picccCallback == NULL );
  365. HRESULT hr = S_OK;
  366. m_lcid = lcidIn;
  367. if ( punkCallbackIn == NULL )
  368. {
  369. hr = THR( E_POINTER );
  370. goto Cleanup;
  371. } // if:
  372. hr = THR( punkCallbackIn->TypeSafeQI( IClusCfgCallback, &m_picccCallback ) );
  373. Cleanup:
  374. HRETURN( hr );
  375. } //*** CClusCfgNodeInfo::Initialize()
  376. //*************************************************************************//
  377. /////////////////////////////////////////////////////////////////////////////
  378. // CClusCfgNodeInfo -- IClusCfgNodeInfo interface.
  379. /////////////////////////////////////////////////////////////////////////////
  380. //////////////////////////////////////////////////////////////////////////////
  381. //++
  382. //
  383. // CClusCfgNodeInfo::GetName()
  384. //
  385. // Description:
  386. // Return the name of this computer.
  387. //
  388. // Arguments:
  389. //
  390. // Return Value:
  391. //
  392. // Remarks:
  393. // None.
  394. //
  395. //--
  396. //////////////////////////////////////////////////////////////////////////////
  397. STDMETHODIMP
  398. CClusCfgNodeInfo::GetName( BSTR * pbstrNameOut )
  399. {
  400. TraceFunc( "[IClusCfgNodeInfo]" );
  401. HRESULT hr = S_OK;
  402. if ( pbstrNameOut == NULL )
  403. {
  404. hr = THR( E_POINTER );
  405. STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_NodeInfo_GetName_Pointer, IDS_ERROR_NULL_POINTER, hr );
  406. goto Cleanup;
  407. } // if:
  408. *pbstrNameOut = SysAllocString( m_bstrFullDnsName );
  409. if ( *pbstrNameOut == NULL )
  410. {
  411. hr = THR( E_OUTOFMEMORY );
  412. STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_GetName_Memory, IDS_ERROR_OUTOFMEMORY, hr );
  413. } // if:
  414. Cleanup:
  415. HRETURN( hr );
  416. } //*** CClusCfgNodeInfo::GetName()
  417. //////////////////////////////////////////////////////////////////////////////
  418. //++
  419. //
  420. // CClusCfgNodeInfo::SetName()
  421. //
  422. // Description:
  423. // Change the name of this computer.
  424. //
  425. // Arguments:
  426. // IN LPCWSTR pcszNameIn
  427. // The new name for this computer.
  428. // Return Value:
  429. // S_OK
  430. // Success
  431. //
  432. // Remarks:
  433. // None.
  434. //
  435. //--
  436. //////////////////////////////////////////////////////////////////////////////
  437. STDMETHODIMP
  438. CClusCfgNodeInfo::SetName( LPCWSTR pcszNameIn )
  439. {
  440. TraceFunc1( "[IClusCfgNodeInfo] pcszNameIn = '%ls'", pcszNameIn == NULL ? L"<null>" : pcszNameIn );
  441. HRESULT hr = THR( E_NOTIMPL );
  442. HRETURN( hr );
  443. } //*** CClusCfgNodeInfo::SetName()
  444. //////////////////////////////////////////////////////////////////////////////
  445. //++
  446. //
  447. // CClusCfgNodeInfo::IsMemberOfCluster()
  448. //
  449. // Description:
  450. // Is this computer a member of a cluster?
  451. //
  452. // Arguments:
  453. // None.
  454. //
  455. // Return Value:
  456. // S_OK
  457. // This node is a member of a cluster.
  458. //
  459. // S_FALSE
  460. // This node is not member of a cluster.
  461. //
  462. // Other Win32 errors as HRESULT if GetNodeClusterState() fails.
  463. //
  464. // Remarks:
  465. // None.
  466. //
  467. //--
  468. //////////////////////////////////////////////////////////////////////////////
  469. STDMETHODIMP
  470. CClusCfgNodeInfo::IsMemberOfCluster( void )
  471. {
  472. TraceFunc( "[IClusCfgNodeInfo]" );
  473. HRESULT hr = S_FALSE; // default to not a cluster node.
  474. if ( m_fIsClusterNode )
  475. {
  476. hr = S_OK;
  477. } // if:
  478. HRETURN( hr );
  479. } //*** CClusCfgNodeInfo::IsMemberOfCluster()
  480. //////////////////////////////////////////////////////////////////////////////
  481. //++
  482. //
  483. // CClusCfgNodeInfo::GetClusterConfigInfo()
  484. //
  485. // Description:
  486. // Return the configuration information about the cluster that this
  487. // conputer belongs to.
  488. //
  489. // Arguments:
  490. // OUT IClusCfgClusterInfo ** ppClusCfgClusterInfoOut
  491. // Catches the CClusterConfigurationInfo object.
  492. //
  493. // Return Value:
  494. // S_OK
  495. // Success
  496. //
  497. // E_POINTER
  498. // The out param was NULL.
  499. //
  500. // E_OUTOFMEMORY
  501. // The CClusCfgNodeInfo object could not be allocated.
  502. //
  503. // Remarks:
  504. // None.
  505. //
  506. //--
  507. //////////////////////////////////////////////////////////////////////////////
  508. STDMETHODIMP
  509. CClusCfgNodeInfo::GetClusterConfigInfo(
  510. IClusCfgClusterInfo ** ppClusCfgClusterInfoOut
  511. )
  512. {
  513. TraceFunc( "[IClusCfgNodeInfo]" );
  514. HRESULT hr = S_OK;
  515. HRESULT hrInit = S_OK;
  516. IClusCfgSetClusterNodeInfo * pccsgni = NULL;
  517. if ( ppClusCfgClusterInfoOut == NULL )
  518. {
  519. hr = THR( E_POINTER );
  520. STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_GetClusterConfigInfo, IDS_ERROR_NULL_POINTER, hr );
  521. goto Cleanup;
  522. } // if:
  523. if ( m_punkClusterInfo != NULL )
  524. {
  525. hr = S_OK;
  526. LogMsg( L"[SRV] CClusCfgNodeInfo::GetClusterConfigInfo() skipped object creation." );
  527. goto SkipCreate;
  528. } // if:
  529. hr = THR( CClusCfgClusterInfo::S_HrCreateInstance( &m_punkClusterInfo ) );
  530. if ( FAILED( hr ) )
  531. {
  532. goto Cleanup;
  533. } // if:
  534. m_punkClusterInfo = TraceInterface( L"CClusCfgClusterInfo", IUnknown, m_punkClusterInfo, 1 );
  535. //
  536. // KB: 01-JUN-200 GalenB
  537. //
  538. // This must be done before the CClusCfgClusterInfo class is initialized.
  539. //
  540. hr = THR( m_punkClusterInfo->TypeSafeQI( IClusCfgSetClusterNodeInfo, &pccsgni ) );
  541. if ( FAILED( hr ) )
  542. {
  543. goto Cleanup;
  544. } // if:
  545. hr = THR( pccsgni->SetClusterNodeInfo( this ) );
  546. if ( FAILED( hr ) )
  547. {
  548. goto Cleanup;
  549. } // if:
  550. //
  551. // KB: 01-JUN-200 GalenB
  552. //
  553. // This must be done after SetClusterNodeInfo() is called, but before Initialize.
  554. //
  555. hr = THR( HrSetWbemServices( m_punkClusterInfo, m_pIWbemServices ) );
  556. if ( FAILED( hr ) )
  557. {
  558. LogMsg( L"[SRV] Could not set the WBEM services on a CClusCfgClusterInfo object. (hr = %#08x)", hr );
  559. goto Cleanup;
  560. } // if:
  561. //
  562. // KB: 01-JUN-200 GalenB
  563. //
  564. // This must be done after SetClusterNodeInfo() and HrSetWbemServices are called.
  565. //
  566. hrInit = STHR( HrSetInitialize( m_punkClusterInfo, m_picccCallback, m_lcid ) );
  567. hr = hrInit; // need hrInit later...
  568. if ( FAILED( hr ) )
  569. {
  570. LogMsg( L"[SRV] Could not initialize CClusCfgClusterInfo object. (hr = %#08x)", hr );
  571. goto Cleanup;
  572. } // if:
  573. SkipCreate:
  574. if ( SUCCEEDED( hr ) )
  575. {
  576. Assert( m_punkClusterInfo != NULL );
  577. hr = THR( m_punkClusterInfo->TypeSafeQI( IClusCfgClusterInfo, ppClusCfgClusterInfoOut ) );
  578. } // if:
  579. Cleanup:
  580. //
  581. // If hrInit is not S_OK then it is most likely HR_S_RPC_S_CLUSTER_NODE_DOWN which
  582. // needs to get passed up... Everything else must have succeeded an hr must be
  583. // S_OK too.
  584. //
  585. if ( ( hr == S_OK ) && ( hrInit != S_OK ) )
  586. {
  587. hr = hrInit;
  588. } // if:
  589. LOG_STATUS_REPORT1( TASKID_Minor_Server_GetClusterInfo, L"GetClusterConfigInfo() completed.", hr );
  590. if ( pccsgni != NULL )
  591. {
  592. pccsgni->Release();
  593. } // if:
  594. HRETURN( hr );
  595. } //*** CClusCfgNodeInfo::GetClusterConfigInfo()
  596. //////////////////////////////////////////////////////////////////////////////
  597. //++
  598. //
  599. // CClusCfgNodeInfo::GetOSVersion()
  600. //
  601. // Description:
  602. // What is the OS version on this computer?
  603. //
  604. // Arguments:
  605. // None.
  606. //
  607. // Return Value:
  608. //
  609. // Remarks:
  610. //
  611. //--
  612. //////////////////////////////////////////////////////////////////////////////
  613. STDMETHODIMP
  614. CClusCfgNodeInfo::GetOSVersion(
  615. DWORD * pdwMajorVersionOut,
  616. DWORD * pdwMinorVersionOut,
  617. WORD * pwSuiteMaskOut,
  618. BYTE * pbProductTypeOut,
  619. BSTR * pbstrCSDVersionOut
  620. )
  621. {
  622. TraceFunc( "[IClusCfgNodeInfo]" );
  623. OSVERSIONINFOEX osv;
  624. HRESULT hr = S_OK;
  625. osv.dwOSVersionInfoSize = sizeof( osv );
  626. if ( !GetVersionEx( (OSVERSIONINFO *) &osv ) )
  627. {
  628. DWORD sc;
  629. sc = TW32( GetLastError() );
  630. hr = HRESULT_FROM_WIN32( sc );
  631. goto Cleanup;
  632. } // if: GetVersionEx() failed
  633. if ( pdwMajorVersionOut != NULL )
  634. {
  635. *pdwMajorVersionOut = osv.dwMajorVersion;
  636. } // if:
  637. if ( pdwMinorVersionOut != NULL )
  638. {
  639. *pdwMinorVersionOut = osv.dwMinorVersion;
  640. } // if:
  641. if ( pwSuiteMaskOut != NULL )
  642. {
  643. *pwSuiteMaskOut = osv.wSuiteMask;
  644. } // if:
  645. if ( pbProductTypeOut != NULL )
  646. {
  647. *pbProductTypeOut = osv.wProductType;
  648. } // if:
  649. if ( pbstrCSDVersionOut != NULL )
  650. {
  651. *pbstrCSDVersionOut = SysAllocString( osv.szCSDVersion );
  652. if ( *pbstrCSDVersionOut == NULL )
  653. {
  654. hr = THR( E_OUTOFMEMORY );
  655. STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_GetOSVersion, IDS_ERROR_OUTOFMEMORY, hr );
  656. goto Cleanup;
  657. } // if:
  658. } // if:
  659. Cleanup:
  660. HRETURN( hr );
  661. } //*** CClusCfgNodeInfo::GetOSVersion()
  662. //////////////////////////////////////////////////////////////////////////////
  663. //++
  664. //
  665. // CClusCfgNodeInfo::GetClusterVersion()
  666. //
  667. // Description:
  668. // Return the cluster version information for the cluster this
  669. // computer belongs to.
  670. //
  671. // Arguments:
  672. //
  673. // Return Value:
  674. //
  675. // Remarks:
  676. // None.
  677. //
  678. //--
  679. //////////////////////////////////////////////////////////////////////////////
  680. STDMETHODIMP
  681. CClusCfgNodeInfo::GetClusterVersion(
  682. DWORD * pdwNodeHighestVersion,
  683. DWORD * pdwNodeLowestVersion
  684. )
  685. {
  686. TraceFunc( "[IClusCfgNodeInfo]" );
  687. HRESULT hr = S_OK;
  688. if ( ( pdwNodeHighestVersion == NULL ) || ( pdwNodeLowestVersion == NULL ) )
  689. {
  690. goto BadParams;
  691. } // if:
  692. *pdwNodeHighestVersion = CLUSTER_MAKE_VERSION( CLUSTER_INTERNAL_CURRENT_MAJOR_VERSION, VER_PRODUCTBUILD );
  693. *pdwNodeLowestVersion = CLUSTER_INTERNAL_PREVIOUS_HIGHEST_VERSION;
  694. goto Cleanup;
  695. BadParams:
  696. hr = THR( E_POINTER );
  697. STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_GetClusterVersion, IDS_ERROR_NULL_POINTER, hr );
  698. Cleanup:
  699. HRETURN( hr );
  700. } //*** CClusCfgNodeInfo::GetClusterVersion()
  701. //////////////////////////////////////////////////////////////////////////////
  702. //++
  703. //
  704. // CClusCfgNodeInfo::GetDriveLetterMappings()
  705. //
  706. // Description:
  707. //
  708. // Arguments:
  709. // None.
  710. //
  711. // Return Value:
  712. //
  713. // Remarks:
  714. //
  715. //--
  716. //////////////////////////////////////////////////////////////////////////////
  717. STDMETHODIMP
  718. CClusCfgNodeInfo::GetDriveLetterMappings(
  719. SDriveLetterMapping * pdlmDriveLetterUsageOut
  720. )
  721. {
  722. TraceFunc( "[IClusCfgNodeInfo]" );
  723. HRESULT hr = S_FALSE;
  724. DWORD sc;
  725. DWORD cchDrives = ( 4 * 26 ) + 1; // "C:\<null>" times 26 drive letters
  726. WCHAR * pszDrives = NULL;
  727. pszDrives = new WCHAR[ cchDrives ];
  728. if ( pszDrives == NULL )
  729. {
  730. goto OutOfMemory;
  731. } // if:
  732. sc = GetLogicalDriveStrings( cchDrives, pszDrives );
  733. if ( sc == 0 )
  734. {
  735. sc = TW32( GetLastError() );
  736. hr = HRESULT_FROM_WIN32( sc );
  737. goto Cleanup;
  738. } // if:
  739. if ( sc > cchDrives )
  740. {
  741. delete [] pszDrives;
  742. pszDrives = NULL;
  743. cchDrives = sc + 1;
  744. pszDrives = new WCHAR[ cchDrives ];
  745. if ( pszDrives == NULL )
  746. {
  747. goto OutOfMemory;
  748. } // if:
  749. sc = GetLogicalDriveStrings( cchDrives, pszDrives );
  750. if ( sc == 0 )
  751. {
  752. sc = TW32( GetLastError() );
  753. hr = HRESULT_FROM_WIN32( sc );
  754. goto Cleanup;
  755. } // if:
  756. } // if:
  757. hr = THR( HrComputeDriveLetterUsageEnums( pszDrives, pdlmDriveLetterUsageOut ) );
  758. if ( FAILED( hr ) )
  759. {
  760. goto Cleanup;
  761. } // if:
  762. hr = THR( HrComputeSystemDriveLetterUsage( pdlmDriveLetterUsageOut ) );
  763. if ( FAILED( hr ) )
  764. {
  765. goto Cleanup;
  766. } // if:
  767. hr = THR( HrSetPageFileEnumIndex( pdlmDriveLetterUsageOut ) );
  768. goto Cleanup;
  769. OutOfMemory:
  770. hr = THR( E_OUTOFMEMORY );
  771. STATUS_REPORT( TASKID_Major_Find_Devices, TASKID_Minor_GetDriveLetterMappings_Node, IDS_ERROR_OUTOFMEMORY, hr );
  772. Cleanup:
  773. delete [] pszDrives;
  774. HRETURN( hr );
  775. } //*** CClusCfgNodeInfo::GetDriveLetterMappings()
  776. //*************************************************************************//
  777. /////////////////////////////////////////////////////////////////////////////
  778. // CClusCfgNodeInfo -- Private Methods.
  779. /////////////////////////////////////////////////////////////////////////////
  780. //////////////////////////////////////////////////////////////////////////////
  781. //++
  782. //
  783. // CClusCfgNodeInfo::HrInit()
  784. //
  785. // Description:
  786. // Initialize this component.
  787. //
  788. // Arguments:
  789. //
  790. //
  791. // Return Value:
  792. //
  793. //
  794. // Remarks:
  795. // None.
  796. //
  797. //--
  798. //////////////////////////////////////////////////////////////////////////////
  799. HRESULT
  800. CClusCfgNodeInfo::HrInit( void )
  801. {
  802. TraceFunc( "" );
  803. HRESULT hr = S_OK;
  804. DWORD sc;
  805. DWORD dwClusterState;
  806. hr = THR( HrGetComputerName( ComputerNameDnsFullyQualified, &m_bstrFullDnsName ) );
  807. if ( FAILED( hr ) )
  808. {
  809. goto Cleanup;
  810. } // if:
  811. sc = TW32( GetNodeClusterState( NULL, &dwClusterState ) );
  812. if ( sc != ERROR_SUCCESS )
  813. {
  814. hr = HRESULT_FROM_WIN32( sc );
  815. goto Cleanup;
  816. } // if : GetClusterState() failed
  817. //
  818. // If the current cluster node state is running or not running then this node is part of a cluster.
  819. //
  820. m_fIsClusterNode = ( dwClusterState == ClusterStateNotRunning ) || ( dwClusterState == ClusterStateRunning );
  821. Cleanup:
  822. HRETURN( hr );
  823. } //*** CClusCfgNodeInfo::HrInit()
  824. //////////////////////////////////////////////////////////////////////////////
  825. //++
  826. //
  827. // CClusCfgNodeInfo::HrComputeDriveLetterUsageEnums()
  828. //
  829. // Description:
  830. // Fill the array with the enums that represent the drive letter usage.
  831. //
  832. // Arguments:
  833. //
  834. //
  835. // Return Value:
  836. //
  837. //
  838. // Remarks:
  839. // None.
  840. //
  841. //--
  842. //////////////////////////////////////////////////////////////////////////////
  843. HRESULT
  844. CClusCfgNodeInfo::HrComputeDriveLetterUsageEnums(
  845. WCHAR * pszDrivesIn,
  846. SDriveLetterMapping * pdlmDriveLetterUsageOut
  847. )
  848. {
  849. TraceFunc( "" );
  850. Assert( pszDrivesIn != NULL );
  851. Assert( pdlmDriveLetterUsageOut != NULL );
  852. HRESULT hr = S_OK;
  853. WCHAR * pszDrive = pszDrivesIn;
  854. UINT uiType;
  855. int idx;
  856. while ( *pszDrive != NULL )
  857. {
  858. uiType = GetDriveType( pszDrive );
  859. CharUpper( pszDrive );
  860. idx = pszDrive[ 0 ] - 'A';
  861. pdlmDriveLetterUsageOut->dluDrives[ idx ] = (EDriveLetterUsage) uiType;
  862. pszDrive += 4;
  863. } // while:
  864. HRETURN( hr );
  865. } //*** CClusCfgNodeInfo::HrComputeDriveLetterUsageEnums()
  866. //////////////////////////////////////////////////////////////////////////////
  867. //++
  868. //
  869. // CClusCfgNodeInfo::HrComputeSystemDriveLetterUsage()
  870. //
  871. // Description:
  872. // Fill the array with the enums that represent the drive letter usage.
  873. //
  874. // Arguments:
  875. //
  876. //
  877. // Return Value:
  878. //
  879. //
  880. // Remarks:
  881. // None.
  882. //
  883. //--
  884. //////////////////////////////////////////////////////////////////////////////
  885. HRESULT
  886. CClusCfgNodeInfo::HrComputeSystemDriveLetterUsage(
  887. SDriveLetterMapping * pdlmDriveLetterUsageOut
  888. )
  889. {
  890. TraceFunc( "" );
  891. Assert( pdlmDriveLetterUsageOut != NULL );
  892. HRESULT hr = S_OK;
  893. BSTR bstrBootLogicalDisk = NULL;
  894. BSTR bstrSystemDevice = NULL;
  895. BSTR bstrSystemLogicalDisk = NULL;
  896. int idx;
  897. // hr = THR( HrLoadOperatingSystemInfo( m_picccCallback, m_pIWbemServices, &bstrBootDevice, &bstrSystemDevice ) );
  898. // if ( FAILED( hr ) )
  899. // {
  900. // goto Cleanup;
  901. // } // if:
  902. hr = THR( HrGetSystemDevice( &bstrSystemDevice ) );
  903. if ( FAILED( hr ) )
  904. {
  905. goto Cleanup;
  906. } // if:
  907. hr = HrConvertDeviceVolumeToLogicalDisk( bstrSystemDevice, &bstrSystemLogicalDisk );
  908. if ( HRESULT_CODE( hr ) == ERROR_INVALID_FUNCTION )
  909. {
  910. //
  911. // system volume is an EFI volume on IA64 and won't have a logical disk anyway...
  912. //
  913. hr = S_OK;
  914. } // if:
  915. else if ( hr == S_OK )
  916. {
  917. idx = bstrSystemLogicalDisk[ 0 ] - 'A';
  918. pdlmDriveLetterUsageOut->dluDrives[ idx ] = dluSYSTEM;
  919. } // else if:
  920. if ( FAILED( hr ) )
  921. {
  922. THR( hr );
  923. goto Cleanup;
  924. } // if:
  925. hr = THR( HrGetBootLogicalDisk( &bstrBootLogicalDisk ) );
  926. if ( FAILED( hr ) )
  927. {
  928. goto Cleanup;
  929. } // if:
  930. idx = bstrBootLogicalDisk[ 0 ] - 'A';
  931. pdlmDriveLetterUsageOut->dluDrives[ idx ] = dluSYSTEM;
  932. Cleanup:
  933. TraceSysFreeString( bstrBootLogicalDisk );
  934. TraceSysFreeString( bstrSystemDevice );
  935. TraceSysFreeString( bstrSystemLogicalDisk );
  936. HRETURN( hr );
  937. } //*** CClusCfgNodeInfo::HrComputeSystemDriveLetterUsage()
  938. /////////////////////////////////////////////////////////////////////////////
  939. //++
  940. //
  941. // CClusCfgNodeInfo::HrSetPageFileEnumIndex()
  942. //
  943. // Description:
  944. // Mark the drives that have paging files on them.
  945. //
  946. // Arguments:
  947. //
  948. //
  949. // Return Value:
  950. // S_OK
  951. // Success.
  952. //
  953. // Remarks:
  954. // None.
  955. //
  956. //--
  957. //////////////////////////////////////////////////////////////////////////////
  958. HRESULT
  959. CClusCfgNodeInfo::HrSetPageFileEnumIndex(
  960. SDriveLetterMapping * pdlmDriveLetterUsageOut
  961. )
  962. {
  963. TraceFunc( "" );
  964. HRESULT hr = S_OK;
  965. WCHAR szLogicalDisks[ 26 ];
  966. int cLogicalDisks = 0;
  967. int idx;
  968. int idxDrive;
  969. hr = THR( HrGetPageFileLogicalDisks( m_picccCallback, m_pIWbemServices, szLogicalDisks, &cLogicalDisks ) );
  970. if ( FAILED( hr ) )
  971. {
  972. goto Cleanup;
  973. } // if:
  974. for ( idx = 0; idx < cLogicalDisks; idx++ )
  975. {
  976. idxDrive = szLogicalDisks[ idx ] - L'A';
  977. pdlmDriveLetterUsageOut->dluDrives[ idxDrive ] = dluSYSTEM;
  978. } // for:
  979. Cleanup:
  980. HRETURN( hr );
  981. } //*** CClusCfgNodeInfo::HrSetPageFileEnumIndex()