Login with Facebook

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"""
Else
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()
Loop

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
Loop
End Function


Create a text file for example nodes.txt


node1.mahmoudthoughts.com
node2.mahmoudthoughts.com
node3.mahmoudthoughts.com

 

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.


image_thumb2


Run

cscript createNodes.vbs nodes.txt

2 comments:

Anonymous said...

Hi Mahmoud,

I want to write a batch/VB script to be used in policy on OMW .

Please let me know how to give exit status that can be understandable by OM that script o/p is failure or successful .

Thanks,
Shirish

Mahmoud Ibrahim said...

Hi,
In VB Script you can use the function of wscript.quit to specify the error code you want to exit with.

Post a Comment