Wednesday, March 16, 2011

Script for creating nodes in OMW

Copy and paste the script below as createNodes.vbs
If Wscript.Arguments.Count < 1 Then
'Check that you spacified the nodes filename
wscript.echo "Usage cscript createNodes.vbs ""filename"" "
wscript.echo "Ex:"
wscript.echo "cscript createNodes.vbs ""c:\nodelist.txt"""
Set args = WScript.Arguments
arg1 = WScript.Arguments.Item(0)

Set CSVoFS = CreateObject("Scripting.FileSystemObject")
nodesFile = arg1
Set file = CSVoFS.GetFile(nodesFile)
Set line = file.OpenAsTextStream(1,TristateUseDefault)
Do While line.AtEndOfStream <> True
myLine = Split(line.ReadLine,",")
nodeName= myLine(0)
call createNode()

End if

Function createNode()
Command = """D:\Program Files\HP\HP BTO Software\bin\ovownodeutil.cmd"" -add_nodewithtype -node_name " & nodename & " -ostype ""AIX"" -osversion ""5L 5.3"" -systemtype ""Power PC Family"" -osbits ""32"" -agent_bin_format ""PowerPC"" "
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec(Command)
Wscript.Echo "The output of the command: " & Command
Do While Not oExec.StdOut.AtEndOfStream
commandoutput = oExec.StdOut.ReadLine()
Wscript.Echo commandOutput
End Function

Create a text file for example nodes.txt


To ensure the script will work in your OMW version, change the path for ovownodeutil.cmd  located on line 22

The sample script is for creating AIX nodes only

To create any nodes open the Node Properties for a node with the same version and get the values located in the system tab and modify line 22 as per the red marks.



cscript createNodes.vbs nodes.txt