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.

200 lines
5.7 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ClusterGroupNode.cpp
  7. //
  8. // Description:
  9. // Implementation of CClusterGroupNode class
  10. //
  11. // Author:
  12. // Ozan Ozhan (ozano) 02-JUN-2001
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "Pch.h"
  16. #include "ClusterGroupNode.h"
  17. //****************************************************************************
  18. //
  19. // CClusterGroupNode
  20. //
  21. //****************************************************************************
  22. //////////////////////////////////////////////////////////////////////////////
  23. //++
  24. //
  25. // CClusterGroupNode::CClusterGroupNode(
  26. //
  27. // Description:
  28. // Constructor for 'cluster Group to 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. CClusterGroupNode::CClusterGroupNode(
  41. LPCWSTR pwszNameIn,
  42. CWbemServices * pNamespaceIn,
  43. DWORD dwEnumTypeIn
  44. )
  45. : CClusterObjAssoc( pwszNameIn, pNamespaceIn, dwEnumTypeIn )
  46. {
  47. } //*** CClusterGroupNode::CClusterGroupNode()
  48. //////////////////////////////////////////////////////////////////////////////
  49. //++
  50. //
  51. // static
  52. // CProvBase *
  53. // CClusterGroupNode::S_CreateThis(
  54. //
  55. // Description:
  56. // Create a 'cluster Group to 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. CClusterGroupNode::S_CreateThis(
  70. LPCWSTR pwszNameIn,
  71. CWbemServices * pNamespaceIn,
  72. DWORD dwEnumTypeIn
  73. )
  74. {
  75. return new CClusterGroupNode(
  76. pwszNameIn,
  77. pNamespaceIn,
  78. dwEnumTypeIn
  79. );
  80. } //*** CClusterGroupNode::S_CreateThis()
  81. //////////////////////////////////////////////////////////////////////////////
  82. //++
  83. //
  84. // SCODE
  85. // CClusterGroupNode::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. CClusterGroupNode::EnumInstance(
  106. long lFlagsIn,
  107. IWbemContext * pCtxIn,
  108. IWbemObjectSink * pHandlerIn
  109. )
  110. {
  111. SAFECLUSTER shCluster;
  112. SAFEGROUP shGroup;
  113. SAFEGROUPENUM shGroupEnum;
  114. LPCWSTR pwszGroupName = NULL;
  115. DWORD cchNodeName = MAX_PATH;
  116. CWstrBuf wsbNodeName;
  117. DWORD cch;
  118. DWORD dwError;
  119. DWORD dwIndex;
  120. DWORD dwType;
  121. CWbemClassObject wco;
  122. CWbemClassObject wcoGroup;
  123. CWbemClassObject wcoPart;
  124. _bstr_t bstrGroup;
  125. _bstr_t bstrPart;
  126. shCluster = OpenCluster( NULL );
  127. CClusterEnum clusEnum( shCluster, m_dwEnumType );
  128. while ( ( pwszGroupName = clusEnum.GetNext() ) != NULL )
  129. {
  130. shGroup = OpenClusterGroup( shCluster, pwszGroupName );
  131. shGroupEnum = ClusterGroupOpenEnum(
  132. shGroup,
  133. CLUSTER_GROUP_ENUM_NODES
  134. );
  135. dwIndex = 0;
  136. for( ; ; )
  137. {
  138. wsbNodeName.SetSize( cchNodeName );
  139. dwError = ClusterGroupEnum(
  140. shGroupEnum,
  141. dwIndex,
  142. &dwType,
  143. wsbNodeName,
  144. &cch
  145. );
  146. if ( dwError == ERROR_MORE_DATA )
  147. {
  148. cchNodeName = ++cch;
  149. wsbNodeName.SetSize( cch );
  150. dwError = ClusterGroupEnum(
  151. shGroupEnum,
  152. dwIndex,
  153. &dwType,
  154. wsbNodeName,
  155. &cch
  156. );
  157. } // if: more data
  158. if ( dwError == ERROR_SUCCESS )
  159. {
  160. m_wcoGroup.SpawnInstance( 0, & wcoGroup );
  161. m_wcoPart.SpawnInstance( 0, & wcoPart );
  162. wcoGroup.SetProperty( pwszGroupName, PVD_PROP_GROUP_NAME );
  163. wcoGroup.GetProperty( bstrGroup, PVD_WBEM_RELPATH );
  164. wcoPart.SetProperty( wsbNodeName, CLUSREG_NAME_GRP_NAME );
  165. wcoPart.GetProperty( bstrPart, PVD_WBEM_RELPATH );
  166. m_pClass->SpawnInstance( 0, & wco );
  167. wco.SetProperty( (LPWSTR) bstrGroup, PVD_PROP_GROUPCOMPONENT );
  168. wco.SetProperty( (LPWSTR ) bstrPart, PVD_PROP_PARTCOMPONENT );
  169. pHandlerIn->Indicate( 1, & wco );
  170. } // if: success
  171. else
  172. {
  173. break;
  174. } // else
  175. dwIndex++;
  176. } // for: Preferred Node List
  177. } // while: more items to enumerate
  178. return WBEM_S_NO_ERROR;
  179. } //*** CClusterGroupNode::EnumInstance(()