ilo-license-setter/set-ipmi-enabled.py

38 lines
1.3 KiB
Python
Raw Permalink Normal View History

2024-06-04 16:22:23 +01:00
import csv
import argparse
2024-06-04 16:22:23 +01:00
import paramiko
import getpass
import logging
2024-06-12 15:43:42 +01:00
#Configure and commence logging
2024-06-04 16:22:23 +01:00
logger = logging.getLogger(__name__)
logging.basicConfig(filename='python.log', level=logging.DEBUG)
logger.debug('logging start')
2024-06-12 15:43:42 +01:00
#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:
2024-06-04 16:22:23 +01:00
csvreader = csv.reader(csvfile, delimiter=',')
next(csvreader)
USER_NAME = input("Please enter BMC username:")
2024-06-04 16:22:23 +01:00
PASSWORD=getpass.getpass()
i = 1
for row in csvreader:
print(i)
i += 1
BMC_NAME = (row[1])
print(BMC_NAME)
2024-06-04 16:22:23 +01:00
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']})
2024-06-04 16:22:23 +01:00
command = ("set map1/config1 oemHPE_ipmi_dcmi_overlan_enable=yes")
stdin, stdout, stderr = client.exec_command(command)
print(stdout.read())