-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhp_gather_fw_details.py
53 lines (41 loc) · 1.63 KB
/
hp_gather_fw_details.py
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
48
49
50
51
52
53
#!/usr/bin/env python
# Purpose - To Gather HP Proliant Firmware Details using ILO4
# Amit Biyani - Aug 15, 2016
import hpilo
import sys
import argparse
def connect(host, user, pwd):
if not (host or user or pwd):
print("Could not connect! Parameters were not all provided")
ilo = hpilo.Ilo(host, login=user, password=pwd, timeout=120,
port=443, protocol=None)
return ilo
def get_fw_info(response):
print "-" * 100
print ("| {:63} | {:30} |".format("NAME", "VERSION"))
print "-" * 100
for fw_name, fw_version in response.iteritems():
try:
print ("| {:63} | {:30} |".format(fw_name, fw_version))
except ValueError:
continue
print "-" * 100
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='=> Get HP Proliant Servers \
Firmware Details')
parser.add_argument('-l', '--login', action='store', help='',
dest='ilo_user', required=True)
parser.add_argument('-p', '--password', action='store', help='',
dest='ilo_pass', required=True)
parser.add_argument('-s', '--serverilo', action='store', help='',
dest='ilo_host', required=True)
ilo_cred = parser.parse_args()
try:
ilo_conn = connect(ilo_cred.ilo_host, ilo_cred.ilo_user,
ilo_cred.ilo_pass)
fw_info = ilo_conn.get_embedded_health()['firmware_information']
except hpilo.IloLoginFailed:
print "Login Error Failed"
sys.exit(1)
get_fw_info(fw_info)
exit(0)