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.

234 lines
5.8 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CClusSvcCreate.cpp
  7. //
  8. // Description:
  9. // Contains the definition of the CClusSvcCreate class.
  10. //
  11. // Maintained By:
  12. // David Potter (DavidP) 14-JUN-2001
  13. // Vij Vasu (Vvasu) 08-MAR-2000
  14. //
  15. //////////////////////////////////////////////////////////////////////////////
  16. //////////////////////////////////////////////////////////////////////////////
  17. // Include Files
  18. //////////////////////////////////////////////////////////////////////////////
  19. // The precompiled header.
  20. #include "Pch.h"
  21. // The header for this file
  22. #include "CClusSvcCreate.h"
  23. // For the CBaseClusterAddNode class.
  24. #include "CBaseClusterAddNode.h"
  25. //////////////////////////////////////////////////////////////////////////////
  26. //++
  27. //
  28. // CClusSvcCreate::CClusSvcCreate
  29. //
  30. // Description:
  31. // Constructor of the CClusSvcCreate class
  32. //
  33. // Arguments:
  34. // pbcanParentActionIn
  35. // Pointer to the base cluster action of which this action is a part.
  36. //
  37. // Return Value:
  38. // None.
  39. //
  40. // Exceptions Thrown:
  41. // Any exceptions thrown by underlying functions
  42. //
  43. //--
  44. //////////////////////////////////////////////////////////////////////////////
  45. CClusSvcCreate::CClusSvcCreate(
  46. CBaseClusterAddNode * pbcanParentActionIn
  47. )
  48. : BaseClass( pbcanParentActionIn )
  49. {
  50. TraceFunc( "" );
  51. SetRollbackPossible( true );
  52. TraceFuncExit();
  53. } //*** CClusSvcCreate::CClusSvcCreate
  54. //////////////////////////////////////////////////////////////////////////////
  55. //++
  56. //
  57. // CClusSvcCreate::~CClusSvcCreate
  58. //
  59. // Description:
  60. // Destructor of the CClusSvcCreate class.
  61. //
  62. // Arguments:
  63. // None.
  64. //
  65. // Return Value:
  66. // None.
  67. //
  68. // Exceptions Thrown:
  69. // Any exceptions thrown by underlying functions
  70. //
  71. //--
  72. //////////////////////////////////////////////////////////////////////////////
  73. CClusSvcCreate::~CClusSvcCreate( void )
  74. {
  75. TraceFunc( "" );
  76. TraceFuncExit();
  77. } //*** CClusSvcCreate::~CClusSvcCreate
  78. //////////////////////////////////////////////////////////////////////////////
  79. //++
  80. //
  81. // CClusSvcCreate::Commit
  82. //
  83. // Description:
  84. // Create and start the service.
  85. //
  86. // Arguments:
  87. // None.
  88. //
  89. // Return Value:
  90. // None.
  91. //
  92. // Exceptions Thrown:
  93. // CAssert
  94. // If the base parent of this action is not CBaseClusterAddNode.
  95. //
  96. // Any that are thrown by the contained actions.
  97. //
  98. //--
  99. //////////////////////////////////////////////////////////////////////////////
  100. void
  101. CClusSvcCreate::Commit( void )
  102. {
  103. TraceFunc( "" );
  104. // Get the parent action pointer.
  105. HRESULT hr = S_OK;
  106. CBaseClusterAddNode * pcanClusterAddNode = dynamic_cast< CBaseClusterAddNode *>( PbcaGetParent() );
  107. CBString bstrPassword;
  108. // If the parent action of this action is not CBaseClusterForm
  109. if ( pcanClusterAddNode == NULL )
  110. {
  111. THROW_ASSERT( E_POINTER, "The parent action of this action is not CBaseClusterAddNode." );
  112. } // an invalid pointer was passed in.
  113. hr = THR( pcanClusterAddNode->GetServiceAccountCredentials().GetPassword( &bstrPassword ) );
  114. TraceMemoryAddBSTR( static_cast< BSTR >( bstrPassword ) );
  115. if ( FAILED( hr ) )
  116. {
  117. THROW_EXCEPTION( hr );
  118. }
  119. // Call the base class commit method.
  120. BaseClass::Commit();
  121. try
  122. {
  123. CStr strAccountUserPrincipalName( pcanClusterAddNode->StrGetServiceAccountUPN() );
  124. // Create the service.
  125. ConfigureService(
  126. strAccountUserPrincipalName.PszData()
  127. , bstrPassword
  128. , pcanClusterAddNode->PszGetNodeIdString()
  129. , pcanClusterAddNode->FIsVersionCheckingDisabled()
  130. , pcanClusterAddNode->DwGetClusterIPAddress()
  131. );
  132. } // try:
  133. catch( ... )
  134. {
  135. // If we are here, then something went wrong with the create.
  136. LogMsg( "[BC] Caught exception during commit." );
  137. //
  138. // Cleanup anything that the failed create might have done.
  139. // Catch any exceptions thrown during Cleanup to make sure that there
  140. // is no collided unwind.
  141. //
  142. try
  143. {
  144. CleanupService();
  145. }
  146. catch( ... )
  147. {
  148. //
  149. // The rollback of the committed action has failed.
  150. // There is nothing that we can do.
  151. // We certainly cannot rethrow this exception, since
  152. // the exception that caused the rollback is more important.
  153. //
  154. TW32( ERROR_CLUSCFG_ROLLBACK_FAILED );
  155. LogMsg( "[BC] THIS COMPUTER MAY BE IN AN INVALID STATE. Caught an exception during cleanup." );
  156. } // catch: all
  157. // Rethrow the exception thrown by commit.
  158. throw;
  159. } // catch: all
  160. // If we are here, then everything went well.
  161. SetCommitCompleted( true );
  162. TraceFuncExit();
  163. } //*** CClusSvcCreate::Commit
  164. //////////////////////////////////////////////////////////////////////////////
  165. //++
  166. //
  167. // CClusSvcCreate::Rollback
  168. //
  169. // Description:
  170. // Cleanup the service.
  171. //
  172. // Arguments:
  173. // None.
  174. //
  175. // Return Value:
  176. // None.
  177. //
  178. // Exceptions Thrown:
  179. // Any that are thrown by the underlying functions.
  180. //
  181. //--
  182. //////////////////////////////////////////////////////////////////////////////
  183. void
  184. CClusSvcCreate::Rollback( void )
  185. {
  186. TraceFunc( "" );
  187. // Call the base class rollback method.
  188. BaseClass::Rollback();
  189. // Cleanup the service.
  190. CleanupService();
  191. SetCommitCompleted( false );
  192. TraceFuncExit();
  193. } //*** CClusSvcCreate::Rollback