Remote Lights-Out Mgmt (iLO 2, iLO, RILOE II) Forum
cancel

RILOE - CPQLOCFG - Set DNS_NAME to Server name + "-RA" (i.e. server-ra)

SOLVED
Go to solution
Highlighted
Darren Z
Super Contributor.

RILOE - CPQLOCFG - Set DNS_NAME to Server name + "-RA" (i.e. server-ra)

We are trying to follow a standard naming convention for our RILOE cards. The naming convention is SERVERNAME-RA . The -RA signifies its a RILOE card. Now I am trying to do this using CPQLOCFG and the "Mod_Network_Settings.XML" script provided in the examples. Unfortunately I don't know how to store/manipulate variables within XML scripts.

So in affect I need to ask the RILOE what is the Server's Name and store that in a variable. Then when I get to this section of the XML script:



I need to say something like (servername being the variable holding the server name):



Any help would be appreciated.
8 REPLIES
acartes
Acclaimed Contributor.

Re: RILOE - CPQLOCFG - Set DNS_NAME to Server name + "-RA" (i.e. server-ra)

Currently, neither CPQLOCFG nor HPONCFG intrinsically support variable substitution.

You will have to look toward other scripting utilities like perl.
David Graham_8
Trusted Contributor.

Re: RILOE - CPQLOCFG - Set DNS_NAME to Server name + "-RA" (i.e. server-ra)

Darren,

I have written a script which will write out the xml file with the host name and then execute the cpqlocfg.

This is grabbed from a txt file of all of the servers you want to modify.

Are you interested?
Darren Z
Super Contributor.

Re: RILOE - CPQLOCFG - Set DNS_NAME to Server name + "-RA" (i.e. server-ra)

VERY Interested! Could you please attach the files to this thread?
David Graham_8
Trusted Contributor.

Re: RILOE - CPQLOCFG - Set DNS_NAME to Server name + "-RA" (i.e. server-ra)

Darren,

Did you want the ILO script to work out the host name of the server? I have not done this..... I am not sure this is possible with the rib commands that I am familiar with.

If you have a CSV file that had on each line

oldribname,newribname

My script with slight modification can help you...... and hit hundreds and thousands...

my ema1l is david dot graham at austrade dot gov dot au (spammers) lets talk more.
David Graham_8
Trusted Contributor.
Solution

Re: RILOE - CPQLOCFG - Set DNS_NAME to Server name + "-RA" (i.e. server-ra)

I have corresponded with Darren and I haqve since received a number of emails.

here is the munging of 2 scripts that I had that allow the renaming of the rib is you already know its name or IP

'
' Riloes.ini must be formatted %nameoripofriloe%,%newdnsnameofriloe% must be separted by comma
'
On error resume next

Set Filesys = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("Wscript.Shell")
Set WshNetwork = CreateObject("Wscript.Network")
ScriptPath = Left(wscript.ScriptFullName,instrrev(wscript.ScriptFullName,"\"))

'Input file
Infile = "RILOES.ini"
'Logfile
Logfile = "RILOE.xml"
'XML Input
RILOCMD = "insert.xml"
'Output File
Summary = "RILOES.LOG"
strRILOEUser = "insertusernamehere"
strRILOEPW = "replacewithrealpassword"

'Open Log File
Set Writefile = Filesys.CreateTextFile(Summary)

'Open the file
Set Readfile = Filesys.OpenTextFile(Infile, 1, false)

'Get a line from the input file, ignoring semi-colon

Do while Readfile.AtEndOfStream = False
MyString = Readfile.ReadLine
MyArray = split(MyString, "," , -1, 1)
RILOEName = MyArray (0)
NewName = MyArray (1)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWshShell = CreateObject("Wscript.Shell")
'Create Empty XML File
Set XMLWrite = objFSO.CreateTextFile(RILOCMD)
'Create XML File
XMLWrite.Write "" & vbcrlf
XMLWrite.Write "" & vbcrlf
XMLWrite.Write "" & vbcrlf
XMLWrite.Write "" & vbcrlf
XMLWrite.Write "" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf



'If not comment, then execute configurator - logging to temp file
wshShell.Run "cpqlocfg.exe -s " & RILOEName & " -l " & Logfile & " -f " & RILOCMD,1,1

'Open & Read Temp File
Set Tempfile = Filesys.OpenTextFile(Logfile, 1, false)
TempText= TempFile.Readall

if Instr(TempText,Scriptpath & "cpqlocfg.exe: Script succeeded on " & chr(34) & RILOENAME & ":443" & chr(34))>=1 Then
Writefile.Write RILOENAME & " Configured correctly." & vbcrlf
else
Writefile.Write RILOENAME & " configuration FAILED!" & vbcrlf
end if

'Close & Delete the temp file
TempFile.close
Filesys.deletefile(Logfile)
'Delete XML file to allow the Next one
XMLWrite.close
Filesys.deletefile(RILOCMD)
Loop

Readfile.close
Writefile.close

msgbox("Script Complete. Log files are located at " & scriptpath)

Wscript.quit
Darren Z
Super Contributor.

Re: RILOE - CPQLOCFG - Set DNS_NAME to Server name + "-RA" (i.e. server-ra)

Thank you for this great alternative!
mark q
Super Contributor.

Re: RILOE - CPQLOCFG - Set DNS_NAME to Server name + "-RA" (i.e. server-ra)

I like the script but I have a situation here.. I am trying to build a script that works dynamically based upon the computername

so here's what I have for a batch file so far (works great)

Inside the xml files I have the userid and %variable% for each one..

set server=%computername%
set iloname=%server%LO
hponcfg /f dns.xml /s iloname=%iloname%
hponcfg /f snmp.xml /s server=%server%
DEL *.XML

Now when I try to do this with vbscript here's what I have - I'm not a vbscript guy...

' read computername

DIM computername
DIM leftcomputername
DIM rightcomputername
DIM ilovariable
DIM finalname

'temp variable for hponline config iloname is in the xml flie
iloname = ("%iloname%")
server1= ("%server%")

'get the computername
Set WshNetwork = WScript.CreateObject("WScript.Network")
'WScript.Echo "Your Computer Name is = " & WshNetwork.ComputerName

'set the comptuername variable
COMPUTERNAME = WshNetwork.ComputerName
SERVER = WshNetwork.ComputerName
'set the ilo name that will be inserted
ilovariable = ("LO")
'WScript.Echo ilovariable

'make sure there's no spaces in the name
computername = Trim(computername)

'get the length of the computername
Count = Len(computername)
'WScript.Echo count
'WScript.Echo computername
count = count-2
'WScript.Echo count

'left trim string
leftcomputername = Left(computername,count)
'WScript.Echo leftcomputername
'WScript.echo UCase("leftcomputername")

'trim the right string and assign it to a variable
rightcomputername = Right(COMPUTERNAME,2)
'WScript.Echo rightcomputername
'WScript.echo UCase("rightcomputername")

finalname = leftcomputername
finalname = finalname & ilovariable
finalname = finalname & rightcomputername
WScript.Echo "Your Ilo Name would be = " & finalname

'time to execute hp online config utility

'Executes HPONCFG.exe in order to gather iLO config
Set objShell = CreateObject("Wscript.Shell")

'backup existing ilo config
'ObjShell.Run("%comspec% /c hponcfg /w %computername%.xml /l >%computername%iloconfig.log"), 1, True

'add the admin user
'only used on new builds
'ObjShell.Run("%comspec% /c hponcfg /f add_user.xml /l >>%computername%iloconfig.log"), 1, True

'write the ilo dns_name variable which sets the ilo name
WScript.Echo finalname
'ObjShell.Run("%comspec% /c hponcfg /f dns.xml /s server=%iloname% /l >>%computername%iloconfig.log"), 1, True

Evertything works great untill I try to shell out to run hponcfg /s...
mark q
Super Contributor.

Re: RILOE - CPQLOCFG - Set DNS_NAME to Server name + "-RA" (i.e. server-ra)

I've taken your idea and added a few lines of code to do the following

- generate the add_user.xml
- generate the Mod_Network_Settings.xml
- generate the Mod_SNMP_IM_Settings.xml
- generate the Import_Cert.xml
- generate the Mod_Directory.xml

You can customize the ilo name to whatever standard you want

- all things are variables so that you can change what you need and then generate the scripts dynamically.

I haven't ever played with reading a file but am working on a way to generate the certificate based upon an excel file/microsoft access database

I'm attaching the text file - rename to vbs

' read computername

DIM computername
DIM leftcomputername
DIM rightcomputername
DIM ilovariable
DIM finalname

'set the ilo username and password
strRILOEUser = "adminusername"
strRILOEPW = "adminpassword"

'set the settings for the network xml file
stripaddress = "192.168.1.1"
strsubnetmask = "255.255.255.0"
strgatewayip = "192.168.1.1"
strdomainname = "domainname.com"
strdhcpgateway = "192.168.1.1"
strdhcpdnsserver = "192.168.1.1"
strdhcpwinsserver = "192.168.1.1"
strdhcpstaticroute = "192.168.1.1"
strregwinsserver = "192.168.1.1"
strpridnsserver = "192.168.1.1"
strsecdnsserver = "192.168.1.1"
strterdnsserver = "192.168.1.1"
strpriwinsserver = "192.168.1.1"
strsecwinsserver = "192.168.1.1"
strstaticroute1 = "0.0.0.0"
strstaticroute2 = "0.0.0.0"
strstaticroute3 = "0.0.0.0"
strenclosureipenable = "YES"
strwebagentipaddress = "192.168.1.1"

'set the variable for snmp
strsnmpaddress1 = "192.168.1.1"
strsnmpaddress2 = "192.168.1.1"
strsnmpaddress3 = "192.168.1.1"
strostraps ="Y"
strsnmppass ="Y"
strribtraps ="Y"
strCIMSECURITYMASK ="3"

'set the variables for adding a user
'username to add
straddusername ="someuser"
'username to add's password
struserlogin ="someuser"
'usernames new password
strnewuserpassword ="somepassword"
stradminpriv = "Y"
strremoteconsolepriv = "Y"
strresetserverpriv = "Y"
strvirtualmediapriv = "Y"
sterconfigilopriv = "Y"
strconfigrilopriv = "Y"
strloginpriv = "Y"
'the settings for this are range and subnetmask
strclientrange = "10.10.10.1 - 254.255.255.255"
strviewlogspriv = "YES"
strclearlogspriv = "YES"
stremsprive = "YES"
strupdateilopriv = "YES"
strconfgirackpriv = "YES"
strdiagpriv = "YES"

'set the variables for generating certificate xml file

'set the variables for directory configuration xml files
'format for this is yes or no
stdirauthenabled ="YES"
strdirlocaluseracct ="YES"
strdirserveraddress ="192.168.1.1"
strdirserverportvalue ="636"
'format for the strdirobjectdn variable is like this CN=server1_rib, OU=RIB, DC=HPRIB, DC=LABS
strdirobjectdn = "CN=server1_rib, OU=RIB, DC=HPRIB, DC=LABS"
strdirobjectpassword = "password"
'format for the strdirusercontext is like this CN=Users, DC=HPRIB, DC=LABS
strdirusercontext1 ="CN=Users, DC=HPRIB, DC=LABS"
'format for this is yes or no
strdirenablegrpacct ="YES"

'get the computername
Set WshNetwork=WScript.CreateObject("WScript.Network")
'WScript.Echo "Your Computer Name is = " & WshNetwork.ComputerName

'set the comptuername variable
COMPUTERNAME=WshNetwork.ComputerName
'WScript.Echo computername
'set the ilo name that will be inserted
ilovariable=("LO")
'WScript.Echo ilovariable

'make sure there's no spaces in the name
computername = Trim(computername)

'get the length of the computername
Count=Len(computername)
'WScript.Echo count
'WScript.Echo computername
count=count-2
'WScript.Echo count

'left trim string
leftcomputername=Left(computername,count)
'WScript.Echo leftcomputername

'trim the right string and assign it to a variable
rightcomputername = Right(COMPUTERNAME,2)
'WScript.Echo rightcomputername

finalname=leftcomputername
finalname=finalname & ilovariable
finalname=finalname & rightcomputername
'WScript.Echo "Your Ilo Name would be = " & finalname

'time to execute hp online config utility
'Executes HPONCFG.exe in order to gather iLO config

'Generate the xml file sample

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWshShell = CreateObject("Wscript.Shell")
'Create Empty XML File
Set XMLWrite = objFSO.CreateTextFile("Mod_Network_Settings.xml")
'Create XML Files
'generate the ilo name xml
XMLWrite.Write "" & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
'XMLWrite.Write " " & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf

'generate the snmp xml configuration file
Set XMLWrite = objFSO.CreateTextFile("Mod_SNMP_IM_Settings.xml")
XMLWrite.Write "" & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf

'generate the add_user.xml
Set XMLWrite = objFSO.CreateTextFile("add_user.xml")
XMLWrite.Write "" & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " XMLWrite.Write " USER_NAME=" & straddusername & Chr(34) & "/>" & vbcrlf
XMLWrite.Write " USER_LOGIN=" & struserlogin & Chr(34) & "/>" & vbcrlf
XMLWrite.Write " PASSWORD=" & strnewuserpassword & Chr(34) & "/>" & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf

'xml generator for certificates import
Set XMLWrite = objFSO.CreateTextFile("Import_Cert.xml")
XMLWrite.Write "" & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " -----BEGIN CERTIFICATE-----" & vbcrlf
XMLWrite.Write " insert certificate here-----" & vbcrlf
XMLWrite.Write " -----END CERTIFICATE-------" & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf

'directory xml generator for setup of directory
Set XMLWrite = objFSO.CreateTextFile("Mod_Directory.xml")
XMLWrite.Write "" & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write " " & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf
XMLWrite.Write "
" & vbcrlf