Tuesday, December 12, 2017

Python 3.6 Json

https://github.com/MrAmbiG/LearningPython

Cloning the Dell iDRAC configuration to others

Hopefully this is the last among-st my series of iDRAC configuration automation. This takes one source machine as reference, takes the xml and pushes it to all the others. Whatever changes that you want to edit or omit, you can when the script is paused for you to update the csv files.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$source = '10.1.211.222'
$user = 'root'
$pass = 'P@ssword'
$filename = "$source.xml"
$sourceXml = "$psscriptroot"+"$filename"
if (!$sourceXml) {
racadm -r $server -u $user -p $pass get -t xml -f $sourceXml
} else { Read-Host "There is an existing $sourceXml sourcefile configuration, Hit enter/return to use the same" }

Write-Host "
A CSV file will be opened (open in excel/spreadsheet)
populate the values,
save & close the file,
Hit Enter to proceed
" -ForegroundColor Blue -BackgroundColor White

$csv = "$PSScriptRoot/nameCompare.csv"
get-process | Select-Object idrac_ip_address| Export-Csv -Path $csv -Encoding ASCII -NoTypeInformation
Start-Process $csv
Read-Host "Hit Enter/Return to proceed"
Write-Host "processing your entries from the csv file...."
$csv = Import-Csv $csv
 foreach ($line in $csv) 
 {
    $server = $($line.server)
    racadm -r $server -u $user -p $pass set -t xml -f $sourceXml
 }








automating the configuration of snmp settings on Dell iDRAC

This is one of my many posts of automating individual tasks on dell iDRACs. It was intended for our VxRacks but otherwise useful for all iDRACs.
http://topics-cdn.dell.com/pdf/idrac7-8-lifecycle-controller-v2.40.40.40_reference%20guide_en-us.pdf


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<#
.SYNOPSIS
    set the snmp for dell iDRAC servers
.DESCRIPTION
    opens up a csv file. put the ip addresses of idrac, root password, snmp address
.NOTES
    File Name      : idracSetSnmp.ps1
    Author         : gajendra d ambi
    Date           : Dec 2017
    Prerequisite   : PowerShell v4+, Dell OpenManage DRAC Tools, includes Racadm (64bit) v8.1 or higher
    Copyright      - None
.LINK
    Script posted over: github.com/MrAmbiG/
#>
#Start of Script
Write-Host "
A CSV file will be opened (open in excel/spreadsheet)
populate the values,
save & close the file,
Hit Enter to proceed
" -ForegroundColor Blue -BackgroundColor White

$csv = "$PSScriptRoot/idracSetSnmp.csv"
get-process | Select-Object idrac_ip_address, root_password, snmpAddress, snmpString | Export-Csv -Path $csv -Encoding ASCII -NoTypeInformation
Start-Process $csv
Read-Host "Hit Enter/Return to proceed"
Write-Host "processing your entries from the csv file...."
$csv = Import-Csv $csv
foreach ($line in $csv)
{
    $idrac_ip_address = $($line.idrac_ip_address)
    $root_password = $($line.root_password)
    $snmpAddress = $($line.snmpAddress)
    $snmpString = $($line.snmpString)
    $user = 'root'
    # enable snmp
    write-host enabling snmp agent -ForegroundColor Green
    racadm -r $idrac_ip_address -u $user -p $root_password --nocertwarn set iDRAC.SNMP.AgentEnable 0
    write-host setting snmp TrapFormat v2 -ForegroundColor Green
    racadm -r $idrac_ip_address -u $user -p $root_password --nocertwarn set iDRAC.SNMP.TrapFormat 1
    write-host setting snmp target $snmpAddress
    racadm -r $idrac_ip_address -u $user -p $root_password --nocertwarn set iDRAC.SNMP.Alert.DestAddr $snmpAddress
    write-host setting snmp community string $snmpString
    racadm -r $idrac_ip_address -u $user -p $root_password --nocertwarn set iDRAC.SNMP.AgentCommunity $snmpString
    write-host enabling snmp alert -ForegroundColor Green
    racadm -r $idrac_ip_address -u $user -p $root_password --nocertwarn set iDRAC.SNMP.Alert.Enable 1
}


Automating the setting of NTPs on Dell iDRACs

This is a continuation of my series of posts about updating iDRAC configuration. This time is is the NTP servers.
http://topics-cdn.dell.com/pdf/idrac7-8-lifecycle-controller-v2.40.40.40_reference%20guide_en-us.pdf


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<#
.SYNOPSIS
    set the ntp for dell iDRAC servers
.DESCRIPTION
    opens up a csv file. put the ip addresses of idrac, root password and ntp
.NOTES
    File Name      : idracSetNtp.ps1
    Author         : gajendra d ambi
    Date           : Dec 2017
    Prerequisite   : PowerShell v4+, Dell OpenManage DRAC Tools, includes Racadm (64bit) v8.1 or higher
    Copyright      - None
.LINK
    Script posted over: github.com/MrAmbiG/
#>

#Start of Script

Write-Host "
A CSV file will be opened (open in excel/spreadsheet)
populate the values,
save & close the file,
Hit Enter to proceed
" -ForegroundColor Blue -BackgroundColor White

$csv = "$PSScriptRoot/idracSetNtp.csv"
get-process | Select-Object idrac_ip_address, root_password, ntp1, ntp2 | Export-Csv -Path $csv -Encoding ASCII -NoTypeInformation
Start-Process $csv
Read-Host "Hit Enter/Return to proceed"
Write-Host "processing your entries from the csv file...."
$csv = Import-Csv $csv
foreach ($line in $csv) 
 {
    $idrac_ip_address = $($line.idrac_ip_address)
    $root_password = $($line.root_password)
    $ntp1 = $($line.ntp1)
    $ntp2 = $($line.ntp2)
    $user = 'root'

    Write-Host setting $ntp1 as the ntp 
    racadm -r $idrac_ip_address -u $user -p $root_password --nocertwarn set iDRAC.NTPConfigGroup.NTP1 $ntp1

    if ($ntp2.Length -gt 2) {
    Write-Host settings $ntp2 as the ntp 
    racadm -r $idrac_ip_address -u $user -p $root_password --nocertwarn set iDRAC.NTPConfigGroup.NTP1 $ntp2
    }
 }


automation of updating hostname on Dell iDRACs

This is another post in a series of automation of individual tasks on iDRAC using racadm.
http://topics-cdn.dell.com/pdf/idrac7-8-lifecycle-controller-v2.40.40.40_reference%20guide_en-us.pdf
This time it is to update the hostname on all the iDRACs.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<#
.SYNOPSIS
    set the hostname for dell iDRAC servers
.DESCRIPTION
    opens up a csv file. put the ip addresses of idrac, hostname to be set
.NOTES
    File Name      : idracSetHostname.ps1
    Author         : gajendra d ambi
    Date           : Dec 2017
    Prerequisite   : PowerShell v4+, Dell OpenManage DRAC Tools, includes Racadm (64bit) v8.1 or higher
    Copyright      - None
.LINK
    Script posted over: github.com/MrAmbiG/
#>

#Start of Script

Write-Host "
A CSV file will be opened (open in excel/spreadsheet)
populate the values,
save & close the file,
Hit Enter to proceed
" -ForegroundColor Blue -BackgroundColor White

$csv = "$PSScriptRoot/idracSetHostname.csv"
get-process | Select-Object idrac_ip_address, root_password, hostname | Export-Csv -Path $csv -Encoding ASCII -NoTypeInformation
Start-Process $csv
Read-Host "Hit Enter/Return to proceed"
Write-Host "processing your entries from the csv file...."
$csv = Import-Csv $csv
foreach ($line in $csv) 
 {
    $idrac_ip_address = $($line.idrac_ip_address)
    $root_password = $($line.root_password)
    $hostname = $($line.hostname)
    Write-Host "setting $hostname as hostname on $idrac_ip_address"
    racadm -r $idrac_ip_address -u "root" -p $root_password --nocertwarn set iDRAC.NIC.DNSDomainName $domain    
 }