maas-devel team mailing list archive
-
maas-devel team
-
Mailing list archive
-
Message #01354
BMC detection
I've attached a prototype script that works out the IP addresses of all the
BMCs it can find in the network range that you specify.
It works by nmap probing the RMCP port in the IP range and if it sees a
response it's already likely to be a BMC, but then goes on to verify it by
issuing an ipmiping command.
Seems to work in the lab at least:
ubuntu@lenovo-RD230-01:~$ ./bmc-detect.py 192.168.21.255/24
['192.168.21.50', '192.168.21.51', '192.168.21.52', '192.168.21.53']
I'm sure we can use this as inspiration to do something better inside the
pserv process.
#!/usr/bin/env python2.7
from __future__ import (
absolute_import,
print_function,
unicode_literals,
)
str = None
__metaclass__ = type
import subprocess
import sys
try:
range = sys.argv[1]
except IndexError:
print("Please supply a scan range as the first arg, eg. 10.0.0.255/24")
exit(1)
nmap = ["sudo", "nmap", "-sU", "-p", "623", "-oG", "-", "--open", range]
nmap_result = subprocess.check_output(nmap)
ips = []
for line in nmap_result.splitlines():
if "623/open" in line:
ips.append(line.split()[1])
checked_ips = []
for ip in ips:
try:
subprocess.check_output(["ipmiping", "-c", "1", ip])
except subprocess.CalledProcessError:
pass
else:
checked_ips.append(ip)
print(checked_ips)
Follow ups