Freigeben über


Deploying Compute Cluster Pack by Script

Yet another common scenario: you want to avoid using RIS and have other applications that deploy a "golden image" of the operating system. All you need is a programmatic way of installing compute cluster pack. Well, I use this script - for which I claim no credit. It was developed by Phil Pennington. I found his toolkit very useful, so here's a link to it: https://philpen.officeisp.net/CCS/Forms/AllItems.aspx

' **************************************************************************************

' CcpSetup.vbs

'

' This script may be used to remotely invoke the Compute Cluster Pack node setup in

' an unattended installation.  The target compute node will be configured with the

' Node Management and MPI services and will join the specified cluster automatically.

'

' Prerequisites:

' 1.  The compute node is already configured with an OS.

' 2.  The compute node is already a domain member.

' 3.  The head node is already configured.

' 4.  The compute node has the CCP setup files located in the c:\CCP subdirectory.

'

' Usage:

' 1.  Run this script from the head node according to the command line usage

'           specified herein. 

' 2.  An accompanying 'servers.txt' file may be in the same directory as this

'           script.  Modify 'servers.txt' to indicate the compute node names on which

'           to install the CCP. 

'       3.  Alternatively, target a single node using the /N command line argument.

'       4.  To ensure the script output prints to the command window execute the

'           following command which selects the default script host:

' c:\> cscript.exe //H:Cscript

'       5.  To debug this script: 

' c:\> wscript.exe //d //x ccpsetup.vbs [arguments]

'

'

' Questions/Comments/Inquiry: philpen@microsoft.com

' **************************************************************************************

On Error Resume Next

' **** INITIALIZATION ****

const strThisScript = "CcpSetup.vbs"

' **** MODIFY THE FOLLOWING.  THIS IS THE HOSTNAME OF YOUR CLUSTER HEAD-NODE ****

strHeadNode = "CHANGE_ME_PLEASE"

' **** MODIFY THE FOLLOWING.  THIS IS THE FILE CONTAINING TARGET SERVER NAMES ****

strTargetNodeListFile = "servers.txt"

'strCommand = "cmd.exe /c set > c:\TEST.TXT"

strCommand = "c:\CCP\setup.exe -unattend -autologoff -computenode:" & strHeadNode

If (err.number <> 0) Then

     ErrorExit "Script Initialization Failed" & vbCrLf & "Reason: " & Err.Description

Else

     Call Main

End If

'-------------------------------   Main   ---------------------------------------

Sub Main()

  On Error Resume Next

 

  if (WScript.Arguments.Count < 1) then

     SetupCcpUsingHostNamesFromFile()   ' NO ARGS - RUN USING DEFAULTS

  end if

 

  ndx = 0

  Do While (ndx < WScript.Arguments.Count)

  LoArg = LCase(WScript.Arguments(ndx))

 

  If (LoArg = "/?") Or (LoArg = "-?") Then        ' DISPLAY USAGE

  Usage()

ElseIf (LoArg = "/h") Or (LoArg = "-h") Then ' SET strHeadNode

ndx = ndx + 1

If (ndx < WScript.Arguments.Count) Then

strHeadNode = WScript.Arguments(ndx)

End If

ElseIf (LoArg = "/f") Or (LoArg = "-f") Then ' SET strTargetNodeListFile

ndx = ndx + 1

If (ndx < WScript.Arguments.Count) Then

strTargetNodeListFile = WScript.Arguments(ndx)

SetupCcpUsingHostNamesFromFile

End If

 

  ElseIf (LoArg = "/n") Or (LoArg = "-n") Then ' RUN ON SPECIFIC NODE ONLY

  ndx = ndx + 1

If (ndx < WScript.Arguments.Count) Then

RemoteCommandExecute WScript.Arguments(ndx), strCommand

End If

Else

Usage()

  End If

 

  ndx = ndx + 1

  Loop

 

If (err.number <> 0) Then

     WScript.StdErr.WriteLine "ERROR : " & strThisScript & " : Main" & vbCrLf & "Reason: " & Err.Description

     Wscript.Quit(1)

End If

Wscript.Quit()

End Sub     ' **** END MAIN

'-------------------------------sub routines---------------------------------------

Sub Usage()

   On Error Resume Next

   WScript.StdErr.WriteLine ""

   WScript.StdErr.WriteLine "USAGE:"

   WScript.StdErr.WriteLine "c:\> cscript.exe " & strThisScript & " [options] [/H HeadNodeName] [/N ComputeNodeName] [/F NodeListFileName]"

   WScript.StdErr.WriteLine ""

   WScript.StdErr.WriteLine "where"

   WScript.StdErr.WriteLine "    arguments:"

   WScript.StdErr.WriteLine "        /H HeadNodeName    - Host name of the cluster headnode"

   WScript.StdErr.WriteLine "        /F NodeListFileName    - Text file with target compute node names (1 per line)."

   WScript.StdErr.WriteLine "        /N ComputeNodeName   - Just run it against this node only."  

   WScript.StdErr.WriteLine ""

   WScript.StdErr.WriteLine "        Note:  If these arguments are not present, then the "

   WScript.StdErr.WriteLine "               values are assumed to be hard-coded in this script."

   WScript.StdErr.WriteLine "               Edit the default values within this script file."

   WScript.StdErr.WriteLine ""

   WScript.StdErr.WriteLine "    options:"

   WScript.StdErr.WriteLine "        /? - Display this usage message."

   WScript.StdErr.WriteLine ""

   WScript.Quit(1)

End Sub

Sub ErrorExit(strMessage)

  On Error Resume Next

if (strComp(strMessage,"") <> 0) Then

WScript.StdErr.WriteLine strMessage

End if

Wscript.Quit(1)

End Sub

Sub SetupCcpUsingHostNamesFromFile()

  On Error Resume Next

  Const ForReading = 1

 

  Set objFSO = CreateObject("Scripting.FileSystemObject")

  Set objTextFile = objFSO.OpenTextFile(strTargetNodeListFile, ForReading)

 

  strComputers = objTextFile.ReadAll

  objTextFile.Close 

  arrComputers = Split(strComputers, vbCrLf)

 

  For Each strComputer In arrComputers   

  RemoteCommandExecute strComputer, strCommand

  Next

End Sub

Sub RemoteCommandExecute(strComputer, strCommand)

   On Error Resume Next

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")

   errReturn = objWMIService.Create(strCommand, Null, Null, intProcessID)

 

   If (errReturn <> 0) then

  WScript.StdErr.WriteLine strComputer & " : Error : "  & strCommand

   Else

  WScript.StdErr.WriteLine strComputer & " : " & strCommand 

   End If

End Sub