Leaked source code of windows server 2003
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.

175 lines
4.9 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ClusterNodeGroup.cpp
  7. //
  8. // Description:
  9. // Implementation of CClusterNodeGroup class
  10. //
  11. // Author:
  12. // Henry Wang (HenryWa) 24-AUG-1999
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "Pch.h"
  16. #include "ClusterNodeGroup.h"
  17. //****************************************************************************
  18. //
  19. // CClusterNodeGroup
  20. //
  21. //****************************************************************************
  22. //////////////////////////////////////////////////////////////////////////////
  23. //++
  24. //
  25. // CClusterNodeGroup::CClusterNodeGroup(
  26. //
  27. // Description:
  28. // Create a cluster node object.
  29. //
  30. // Arguments:
  31. // pwszNameIn -- Class name
  32. // pNamespaceIn -- Namespace
  33. // dwEnumTypeIn -- Type id
  34. //
  35. // Return Values:
  36. // pointer to the CProvBase
  37. //
  38. //--
  39. //////////////////////////////////////////////////////////////////////////////
  40. CClusterNodeGroup::CClusterNodeGroup(
  41. LPCWSTR pwszNameIn,
  42. CWbemServices * pNamespaceIn,
  43. DWORD dwEnumTypeIn
  44. )
  45. : CClusterObjAssoc( pwszNameIn, pNamespaceIn, dwEnumTypeIn )
  46. {
  47. } //*** CClusterNodeGroup::CClusterNodeGroup()
  48. //////////////////////////////////////////////////////////////////////////////
  49. //++
  50. //
  51. // static
  52. // CProvBase *
  53. // CClusterNodeGroup::S_CreateThis(
  54. //
  55. // Description:
  56. // Create a cluster node object.
  57. //
  58. // Arguments:
  59. // pwszNameIn -- Class name
  60. // pNamespaceIn -- Namespace
  61. // dwEnumTypeIn -- Type id
  62. //
  63. // Return Values:
  64. // pointer to the CProvBase
  65. //
  66. //--
  67. //////////////////////////////////////////////////////////////////////////////
  68. CProvBase *
  69. CClusterNodeGroup::S_CreateThis(
  70. const WCHAR * pwszNameIn,
  71. CWbemServices * pNamespaceIn,
  72. DWORD dwEnumTypeIn
  73. )
  74. {
  75. return new CClusterNodeGroup(
  76. pwszNameIn,
  77. pNamespaceIn,
  78. dwEnumTypeIn
  79. );
  80. } //*** CClusterNodeGroup::S_CreateThis()
  81. //////////////////////////////////////////////////////////////////////////////
  82. //++
  83. //
  84. // SCODE
  85. // CClusterNodeGroup::EnumInstance(
  86. // long lFlagsIn,
  87. // IWbemContext * pCtxIn,
  88. // IWbemObjectSink * pHandlerIn
  89. // )
  90. //
  91. // Description:
  92. // Enumerate instances
  93. //
  94. // Arguments:
  95. // lFlagsIn --
  96. // pCtxIn --
  97. // pHandlerIn --
  98. //
  99. // Return Values:
  100. // SCODE
  101. //
  102. //--
  103. //////////////////////////////////////////////////////////////////////////////
  104. SCODE
  105. CClusterNodeGroup::EnumInstance(
  106. long lFlagsIn,
  107. IWbemContext * pCtxIn,
  108. IWbemObjectSink * pHandlerIn
  109. )
  110. {
  111. SAFECLUSTER shCluster;
  112. SAFEGROUP shGroup;
  113. LPCWSTR pwszName = NULL;
  114. DWORD cchNodeName = MAX_PATH;
  115. CWstrBuf wsbNodeName;
  116. DWORD cch;
  117. CError er;
  118. DWORD dwError;
  119. CWbemClassObject wco;
  120. CWbemClassObject wcoGroup;
  121. CWbemClassObject wcoPart;
  122. _bstr_t bstrGroup;
  123. _bstr_t bstrPart;
  124. shCluster = OpenCluster( NULL );
  125. CClusterEnum clusEnum( shCluster, m_dwEnumType );
  126. m_wcoGroup.SpawnInstance( 0, & wcoGroup );
  127. m_wcoPart.SpawnInstance( 0, & wcoPart );
  128. wsbNodeName.SetSize( cchNodeName );
  129. while ( ( pwszName = clusEnum.GetNext() ) != NULL )
  130. {
  131. DWORD dwState;
  132. cch = cchNodeName;
  133. wcoPart.SetProperty( pwszName, PVD_PROP_GROUP_NAME );
  134. wcoPart.GetProperty( bstrPart, PVD_WBEM_RELPATH );
  135. shGroup = OpenClusterGroup( shCluster, pwszName );
  136. dwState = GetClusterGroupState( shGroup, wsbNodeName, & cch );
  137. if ( dwState == ClusterGroupStateUnknown )
  138. {
  139. dwError = GetLastError();
  140. if ( dwError == ERROR_MORE_DATA )
  141. {
  142. cchNodeName = ++ cch;
  143. wsbNodeName.SetSize( cch );
  144. GetClusterGroupState( shGroup, wsbNodeName, & cch );
  145. } // if: more data
  146. else
  147. {
  148. er = dwError;
  149. } // else
  150. } // if: StateUnknown
  151. wcoGroup.SetProperty( wsbNodeName, CLUSREG_NAME_GRP_NAME );
  152. wcoGroup.GetProperty( bstrGroup, PVD_WBEM_RELPATH );
  153. m_pClass->SpawnInstance( 0, & wco );
  154. wco.SetProperty( (LPWSTR) bstrGroup, PVD_PROP_GROUPCOMPONENT );
  155. wco.SetProperty( (LPWSTR ) bstrPart, PVD_PROP_PARTCOMPONENT );
  156. pHandlerIn->Indicate( 1, & wco );
  157. } // while: more items to enumerate
  158. return WBEM_S_NO_ERROR;
  159. } //*** CClusterNodeGroup::EnumInstance(()