Compare commits
No commits in common. "main" and "master" have entirely different histories.
9 changed files with 41 additions and 134 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
hosts-in.csv
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
This repository contains a number of scripts that are designed to interact with HPE iLO BMCs (Hewlett Packard Enterprises, integrated Lights Out, Baseboard Management Controllers ) to access information and provide limited actuation. If usage information is not provided through the help text for each script, care should be taken when determining what the script will do before running.
|
|
||||||
|
|
||||||
Recommend to set up a virtual env for python to load appropriate modules (with e.g. `python3 -m venv venv`)
|
|
||||||
|
|
||||||
load the venv by sourcing the activate file (e.g. `source venv/bin/activate`)
|
|
||||||
|
|
||||||
install requirements manually
|
|
||||||
|
|
||||||
`python3 -m pip install paramiko`
|
|
|
@ -1,34 +1,29 @@
|
||||||
import csv
|
import csv
|
||||||
import argparse
|
|
||||||
import paramiko
|
import paramiko
|
||||||
import getpass
|
import getpass
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
#Configure and commence logging
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
||||||
logger.debug('logging start')
|
logger.debug('logging start')
|
||||||
|
with open('ceph-license-keys.csv',encoding='utf8') as csvfile:
|
||||||
|
|
||||||
|
|
||||||
with open('hosts-in.csv',encoding='utf8') as csvfile:
|
|
||||||
csvreader = csv.reader(csvfile, delimiter=',')
|
csvreader = csv.reader(csvfile, delimiter=',')
|
||||||
next(csvreader)
|
next(csvreader)
|
||||||
USER_NAME = input("Please enter BMC username:")
|
|
||||||
PASSWORD=getpass.getpass()
|
PASSWORD=getpass.getpass()
|
||||||
i = 1
|
i = 1
|
||||||
for row in csvreader:
|
for row in csvreader:
|
||||||
print(i)
|
print(i)
|
||||||
i += 1
|
i += 1
|
||||||
BMC_NAME = (row[1])
|
HOST_NAME = ("ceph01-block02-"+row[0]+"-bmc")
|
||||||
HOST_NAME = (row[0])
|
SYSTEM_NAME = ("ceph01-block02-"+row[0])
|
||||||
print(BMC_NAME)
|
print(HOST_NAME)
|
||||||
|
print(SYSTEM_NAME)
|
||||||
|
USER_NAME = "admin"
|
||||||
if i > 0:
|
if i > 0:
|
||||||
client = paramiko.SSHClient()
|
client = paramiko.SSHClient()
|
||||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
client.connect(hostname=BMC_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
client.connect(hostname=HOST_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
||||||
command = ("set system1 oemHPE_server_name="+HOST_NAME)
|
command = ("set system1 oemHPE_server_name="+SYSTEM_NAME)
|
||||||
|
#command = ("show /system1/")
|
||||||
stdin, stdout, stderr = client.exec_command(command)
|
stdin, stdout, stderr = client.exec_command(command)
|
||||||
print(stdout.read())
|
print(stdout.read())
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,28 @@
|
||||||
import csv
|
import csv
|
||||||
import argparse
|
|
||||||
import paramiko
|
import paramiko
|
||||||
import getpass
|
import getpass
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
#Configure and commence logging
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
||||||
logger.debug('logging start')
|
logger.debug('logging start')
|
||||||
|
with open('ceph-license-keys.csv',encoding='utf8') as csvfile:
|
||||||
with open('hosts-in.csv',encoding='utf8') as csvfile:
|
|
||||||
csvreader = csv.reader(csvfile, delimiter=',')
|
csvreader = csv.reader(csvfile, delimiter=',')
|
||||||
next(csvreader)
|
next(csvreader)
|
||||||
USER_NAME = input("Please enter BMC username:")
|
|
||||||
PASSWORD=getpass.getpass()
|
PASSWORD=getpass.getpass()
|
||||||
i = 1
|
i = 1
|
||||||
for row in csvreader:
|
for row in csvreader:
|
||||||
print(i)
|
print(i)
|
||||||
i += 1
|
i += 1
|
||||||
BMC_NAME = (row[1])
|
HOST_NAME = ("ceph01-block01-"+row[0]+"-bmc")
|
||||||
#This is legacy and needs a new column setting, depending on how implemented in future case. Should be quick to determine so leaving to do until relevant.
|
LICENSE_KEY = (row[7])
|
||||||
#LICENSE_KEY = (row[7])
|
print(HOST_NAME)
|
||||||
print(BMC_NAME)
|
#print(LICENSE_KEY)
|
||||||
|
USER_NAME = "admin"
|
||||||
if i > 0:
|
if i > 0:
|
||||||
client = paramiko.SSHClient()
|
client = paramiko.SSHClient()
|
||||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
client.connect(hostname=BMC_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
client.connect(hostname=HOST_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
||||||
|
#command = ("OemHPE_licenseinstall /map1/oemHPE_license1 "+LICENSE_KEY)
|
||||||
command = ("show /map1/oemHPE_license1")
|
command = ("show /map1/oemHPE_license1")
|
||||||
stdin, stdout, stderr = client.exec_command(command)
|
stdin, stdout, stderr = client.exec_command(command)
|
||||||
print(stdout.read())
|
print(stdout.read())
|
||||||
|
|
19
get-MACs.py
19
get-MACs.py
|
@ -1,21 +1,15 @@
|
||||||
import csv
|
import csv
|
||||||
import argparse
|
|
||||||
import paramiko
|
import paramiko
|
||||||
import getpass
|
import getpass
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
#Configure and commence logging
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
||||||
logger.debug('logging start')
|
logger.debug('logging start')
|
||||||
|
with open('ceph-license-keys.csv',encoding='utf8') as csvfile,open('MACs.csv','w') as csvfile_out:
|
||||||
with open('hosts-in.csv',encoding='utf8') as csvfile,open('MACs.csv','w') as csvfile_out:
|
|
||||||
csvreader = csv.reader(csvfile, delimiter=',')
|
csvreader = csv.reader(csvfile, delimiter=',')
|
||||||
csvwriter = csv.writer(csvfile_out)
|
csvwriter = csv.writer(csvfile_out)
|
||||||
next(csvreader)
|
next(csvreader)
|
||||||
USER_NAME = input("Please enter BMC username:")
|
|
||||||
PASSWORD=getpass.getpass()
|
PASSWORD=getpass.getpass()
|
||||||
i = 1
|
i = 1
|
||||||
P1_PATTERN=re.compile('Port1NIC_MACAddress=\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}')
|
P1_PATTERN=re.compile('Port1NIC_MACAddress=\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}')
|
||||||
|
@ -23,13 +17,14 @@ with open('hosts-in.csv',encoding='utf8') as csvfile,open('MACs.csv','w') as csv
|
||||||
P3_PATTERN=re.compile('Port3NIC_MACAddress=\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}')
|
P3_PATTERN=re.compile('Port3NIC_MACAddress=\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}')
|
||||||
for row in csvreader:
|
for row in csvreader:
|
||||||
print(i)
|
print(i)
|
||||||
BMC_NAME = (row[1])
|
HOST_NAME = ("ceph01-block02-"+row[0]+"-bmc")
|
||||||
SYSTEM_NAME = (row[0])
|
SYSTEM_HOST_NAME = ("ceph01-block02-"+row[0])
|
||||||
print(BMC_NAME)
|
print(HOST_NAME)
|
||||||
|
USER_NAME = "admin"
|
||||||
if i > 0:
|
if i > 0:
|
||||||
client = paramiko.SSHClient()
|
client = paramiko.SSHClient()
|
||||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
client.connect(hostname=BMC_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
client.connect(hostname=HOST_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
||||||
#command = ("OemHPE_licenseinstall /map1/oemHPE_license1 "+LICENSE_KEY)
|
#command = ("OemHPE_licenseinstall /map1/oemHPE_license1 "+LICENSE_KEY)
|
||||||
command = ("show /system1/network1/Integrated_NICs")
|
command = ("show /system1/network1/Integrated_NICs")
|
||||||
stdin, stdout, stderr = client.exec_command(command)
|
stdin, stdout, stderr = client.exec_command(command)
|
||||||
|
@ -37,6 +32,6 @@ with open('hosts-in.csv',encoding='utf8') as csvfile,open('MACs.csv','w') as csv
|
||||||
P1_MAC=(str(P1_PATTERN.findall(str(NET_INFO)))[-19:-2])
|
P1_MAC=(str(P1_PATTERN.findall(str(NET_INFO)))[-19:-2])
|
||||||
P2_MAC=(str(P2_PATTERN.findall(str(NET_INFO)))[-19:-2])
|
P2_MAC=(str(P2_PATTERN.findall(str(NET_INFO)))[-19:-2])
|
||||||
P3_MAC=(str(P3_PATTERN.findall(str(NET_INFO)))[-19:-2])
|
P3_MAC=(str(P3_PATTERN.findall(str(NET_INFO)))[-19:-2])
|
||||||
csvwriter.writerow([SYSTEM_NAME,P1_MAC,P2_MAC,P3_MAC])
|
csvwriter.writerow([SYSTEM_HOST_NAME,P1_MAC,P2_MAC,P3_MAC])
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
|
@ -1,43 +1,35 @@
|
||||||
import csv
|
import csv
|
||||||
import argparse
|
|
||||||
import paramiko
|
import paramiko
|
||||||
import getpass
|
import getpass
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
#Configure and commence logging
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
||||||
logger.debug('logging start')
|
logger.debug('logging start')
|
||||||
|
with open('ceph-license-keys.csv',encoding='utf8') as csvfile,open('serials.csv','w') as csvfile_out:
|
||||||
#Set up argument parsing
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser("get-serials.py")
|
|
||||||
parser.add_argument(help="This script will access every host BMC in the hosts-in.csv list and retrieve the serial number for them, writing them out to a csv file, along with the system host name for identification.")
|
|
||||||
|
|
||||||
with open('hosts-in.csv',encoding='utf8') as csvfile,open('serials.csv','w') as csvfile_out:
|
|
||||||
csvreader = csv.reader(csvfile, delimiter=',')
|
csvreader = csv.reader(csvfile, delimiter=',')
|
||||||
csvwriter = csv.writer(csvfile_out)
|
csvwriter = csv.writer(csvfile_out)
|
||||||
next(csvreader)
|
next(csvreader)
|
||||||
USER_NAME = input("Please enter BMC username:")
|
|
||||||
PASSWORD=getpass.getpass()
|
PASSWORD=getpass.getpass()
|
||||||
i = 1
|
i = 1
|
||||||
SN_PATTERN=re.compile('number=\w{10}')
|
SN_PATTERN=re.compile('number=\w{10}')
|
||||||
for row in csvreader:
|
for row in csvreader:
|
||||||
print(i)
|
print(i)
|
||||||
BMC_NAME = (row[1])
|
HOST_NAME = ("ceph01-block02-"+row[0]+"-bmc")
|
||||||
SYSTEM_NAME = (row[0])
|
LICENSE_KEY = (row[7])
|
||||||
print(BMC_NAME)
|
SYSTEM_HOST_NAME = ("ceph01-block02-"+row[0])
|
||||||
|
print(HOST_NAME)
|
||||||
|
#print(LICENSE_KEY)
|
||||||
|
USER_NAME = "admin"
|
||||||
if i > 0:
|
if i > 0:
|
||||||
client = paramiko.SSHClient()
|
client = paramiko.SSHClient()
|
||||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
client.connect(hostname=BMC_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
client.connect(hostname=HOST_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
||||||
#command = ("OemHPE_licenseinstall /map1/oemHPE_license1 "+LICENSE_KEY)
|
#command = ("OemHPE_licenseinstall /map1/oemHPE_license1 "+LICENSE_KEY)
|
||||||
command = ("show /system1 number")
|
command = ("show /system1 number")
|
||||||
stdin, stdout, stderr = client.exec_command(command)
|
stdin, stdout, stderr = client.exec_command(command)
|
||||||
SERIAL_NUMBER_OUT=stdout.read()
|
SERIAL_NUMBER_OUT=stdout.read()
|
||||||
SERIAL_NUMBER=(str(SN_PATTERN.findall(str(SERIAL_NUMBER_OUT)))[-12:-2])
|
SERIAL_NUMBER=(str(SN_PATTERN.findall(str(SERIAL_NUMBER_OUT)))[-12:-2])
|
||||||
csvwriter.writerow([SYSTEM_NAME,SERIAL_NUMBER])
|
csvwriter.writerow([SYSTEM_HOST_NAME,SERIAL_NUMBER])
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
hostname,bmc_name
|
|
|
52
set-DNS.py
52
set-DNS.py
|
@ -1,52 +0,0 @@
|
||||||
import csv
|
|
||||||
import sys
|
|
||||||
import argparse
|
|
||||||
import paramiko
|
|
||||||
import getpass
|
|
||||||
import logging
|
|
||||||
|
|
||||||
#Configure and commence logging
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
|
||||||
logger.debug('logging start')
|
|
||||||
|
|
||||||
#Set up argument parsing
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(prog="set-DNS.py", description="set DNS on iLO")
|
|
||||||
|
|
||||||
parser.add_argument('-o', '--read', help="Read only mode. Does not make changes. Currently the only mode that does anything", action='store_true')
|
|
||||||
parser.add_argument('-v', '--verbose')
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
print(args)
|
|
||||||
print(args.read)
|
|
||||||
|
|
||||||
with open('hosts-in.csv',encoding='utf8') as csvfile:
|
|
||||||
csvreader = csv.reader(csvfile, delimiter=',')
|
|
||||||
next(csvreader)
|
|
||||||
USER_NAME = input("Please enter BMC username:")
|
|
||||||
PASSWORD=getpass.getpass()
|
|
||||||
i = 1
|
|
||||||
for row in csvreader:
|
|
||||||
print(i)
|
|
||||||
i += 1
|
|
||||||
BMC_NAME = (row[1])
|
|
||||||
print(BMC_NAME)
|
|
||||||
if i > 0:
|
|
||||||
client = paramiko.SSHClient()
|
|
||||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
||||||
client.connect(hostname=BMC_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
|
||||||
DNSout = ("show map1/settings1/DNSSettings1")
|
|
||||||
#SetDNS = ("set map1/settings1/DNSSettings1 DNSServerAddress=0.0.0.0")
|
|
||||||
#SetDNSDomain = ("set map1/settings1/DNSSettings1 DomainName=")
|
|
||||||
|
|
||||||
if args.read:
|
|
||||||
stdin, stdout, stderr = client.exec_command(DNSout)
|
|
||||||
print(stdout.read())
|
|
||||||
#else:
|
|
||||||
#stdin, stdout, stderr = client.exec_command(SetDNS)
|
|
||||||
#print(stdout.read())
|
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,29 @@
|
||||||
import csv
|
import csv
|
||||||
import argparse
|
|
||||||
import paramiko
|
import paramiko
|
||||||
import getpass
|
import getpass
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
#Configure and commence logging
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
logging.basicConfig(filename='python.log', level=logging.DEBUG)
|
||||||
logger.debug('logging start')
|
logger.debug('logging start')
|
||||||
|
with open('ceph-license-keys.csv',encoding='utf8') as csvfile:
|
||||||
#Set up argument parsing
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser("set-ipmi-enabled.py")
|
|
||||||
parser.add_argument(help="This script will take every host BMC in the hosts-in.csv list and set map1/config1 oemHPE_ipmi_dcmi_overlan_enable=yes on it.")
|
|
||||||
|
|
||||||
with open('hosts-in.csv',encoding='utf8') as csvfile:
|
|
||||||
csvreader = csv.reader(csvfile, delimiter=',')
|
csvreader = csv.reader(csvfile, delimiter=',')
|
||||||
next(csvreader)
|
next(csvreader)
|
||||||
USER_NAME = input("Please enter BMC username:")
|
|
||||||
PASSWORD=getpass.getpass()
|
PASSWORD=getpass.getpass()
|
||||||
i = 1
|
i = 1
|
||||||
for row in csvreader:
|
for row in csvreader:
|
||||||
print(i)
|
print(i)
|
||||||
i += 1
|
i += 1
|
||||||
BMC_NAME = (row[1])
|
HOST_NAME = ("ceph01-block02-"+row[0]+"-bmc")
|
||||||
print(BMC_NAME)
|
SYSTEM_NAME = ("ceph01-block02-"+row[0])
|
||||||
|
print(HOST_NAME)
|
||||||
|
print(SYSTEM_NAME)
|
||||||
|
USER_NAME = "admin"
|
||||||
if i > 0:
|
if i > 0:
|
||||||
client = paramiko.SSHClient()
|
client = paramiko.SSHClient()
|
||||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
client.connect(hostname=BMC_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
client.connect(hostname=HOST_NAME, look_for_keys=False, port=22, username=USER_NAME, password=PASSWORD, disabled_algorithms={'pubkeys': ['rsa-sha2-256', 'rsa-sha2-512']})
|
||||||
command = ("set map1/config1 oemHPE_ipmi_dcmi_overlan_enable=yes")
|
command = ("set map1/config1 oemHPE_ipmi_dcmi_overlan_enable=yes")
|
||||||
|
#command = ("show map1/config1 oemHPE_ipmi_dcmi_overlan_enable")
|
||||||
stdin, stdout, stderr = client.exec_command(command)
|
stdin, stdout, stderr = client.exec_command(command)
|
||||||
print(stdout.read())
|
print(stdout.read())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue