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.6 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ClusterResNode.cpp
  7. //
  8. // Description:
  9. // Implementation of CClusterResNode class
  10. //
  11. // Author:
  12. // Ozan Ozhan (ozano) 01-JUN-2001
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "Pch.h"
  16. #include "ClusterResNode.h"
  17. //****************************************************************************
  18. //
  19. // CClusterResNode
  20. //
  21. //****************************************************************************
  22. //////////////////////////////////////////////////////////////////////////////
  23. //++
  24. //
  25. // CClusterResNode::CClusterResNode(
  26. //
  27. // Description:
  28. // Constructor for 'cluster resource 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. CClusterResNode::CClusterResNode(
  41. LPCWSTR pwszNameIn,
  42. CWbemServices * pNamespaceIn,
  43. DWORD dwEnumTypeIn
  44. )
  45. : CClusterObjAssoc( pwszNameIn, pNamespaceIn, dwEnumTypeIn )
  46. {
  47. } //*** CClusterResNode::CClusterResNode()
  48. //////////////////////////////////////////////////////////////////////////////
  49. //++
  50. //
  51. // static
  52. // CProvBase *
  53. // CClusterResNode::S_CreateThis(
  54. //
  55. // Description:
  56. // Create a 'cluster resource 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. CClusterResNode::S_CreateThis(
  70. LPCWSTR pwszNameIn,
  71. CWbemServices * pNamespaceIn,
  72. DWORD dwEnumTypeIn
  73. )
  74. {
  75. return new CClusterResNode(
  76. pwszNameIn,
  77. pNamespaceIn,
  78. dwEnumTypeIn
  79. );
  80. } //*** CClusterResNode::S_CreateThis()
  81. //////////////////////////////////////////////////////////////////////////////
  82. //++
  83. //
  84. // SCODE
  85. // CClusterResNode::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. CClusterResNode::EnumInstance(
  106. long lFlagsIn,
  107. IWbemContext * pCtxIn,
  108. IWbemObjectSink * pHandlerIn
  109. )
  110. {
  111. SAFECLUSTER shCluster;
  112. SAFERESOURCE shResource;
  113. SAFERESENUM shResEnum;
  114. LPCWSTR pwszResName = 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 ( ( pwszResName = clusEnum.GetNext() ) != NULL )
  129. {
  130. shResource = OpenClusterResource( shCluster, pwszResName );
  131. shResEnum = ClusterResourceOpenEnum(
  132. shResource,
  133. CLUSTER_RESOURCE_ENUM_NODES
  134. );
  135. dwIndex = 0;
  136. for( ; ; )
  137. {
  138. wsbNodeName.SetSize( cchNodeName );
  139. dwError = ClusterResourceEnum(
  140. shResEnum,
  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 = ClusterResourceEnum(
  151. shResEnum,
  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( pwszResName, PVD_PROP_RES_NAME );
  163. wcoGroup.GetProperty( bstrGroup, PVD_WBEM_RELPATH );
  164. wcoPart.SetProperty( wsbNodeName, CLUSREG_NAME_RES_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: Possible Owners
  177. } // while: more items to enumerate
  178. return WBEM_S_NO_ERROR;
  179. } //*** CClusterResNode::EnumInstance(()