On 10/11/2011 04:02 PM, [email protected] wrote:
So I have some ipmitool raw commands i run remotely against a host's
bmc, and wanted to code them via the python bindings (so i can more
frequent polling and then do further processing w/o forking ipmitool
over and over).
However the documentation is a bit sparse and i can't honestly see how
do i construct some code to do this?
So i have to ask, is emulating raw requests something viable via
OpenIPMI? Is there any examples i can look at ? Even if it's just in C,
i figure the python bindings are pretty thinly swig'ified, but if i
could figure out if/how that's done, i'll tackle pythonifying it
afterwards.
Sure, that's easy. There is a file named "swig/python/sample.py" that
has a sample of a python interface. I've also attached a little
program that does a get device id command every 5 seconds. Run it with
"sample2.py smi 0" to talk to the local interface.
What are you trying to get, btw? OpenIPMI can do most of the
interpretation work for you.
-corey
import time
import sys
import OpenIPMI
class Handlers:
def __init__(self, name):
self.name = name
self.mc = None
return
def log(self, level, log):
print level + ": " + log
return
def conn_change_cb(self, domain, err, conn_num, port_num, still_connected):
print "Conn up"
return
def domain_close_done_cb(self):
self.name = "done"
return
def domain_iter_mc_cb(self, domain, mc):
print "MC: " + mc.get_name()
if mc.get_name() == "test(0.20)":
# This is the one we want
self.mc = mc.get_id();
return
# This is here due to a bug in the swig interface, it will go away in
# the next release. It doesn't actually do anything.
def mc_iter_cb(self, domain, mc):
print "MC2: " + mc.get_name()
return
def domain_up_cb(self, domain):
domain.iterate_mcs(self)
return
def mc_cmd_cb(self, mc, netfn, cmd, response):
print "got response: " + str(response)
return
def mc_cb(self, mc):
mc.send_command(0, 6, 1, [], self)
return
OpenIPMI.enable_debug_malloc()
OpenIPMI.init_posix()
main_handler = Handlers("hello")
OpenIPMI.set_log_handler(main_handler)
a = OpenIPMI.open_domain2("test", ["-noall",] + sys.argv[1:],
main_handler, main_handler)
if not a:
print "open failed"
sys.exit(1)
pass
nexttime = time.time()
while main_handler.name != "done":
OpenIPMI.wait_io(1000)
now = time.time()
if main_handler.mc and now >= nexttime:
nexttime += 5
main_handler.mc.to_mc(main_handler)
pass
OpenIPMI.shutdown_everything()
print "done"
sys.exit(0)
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Openipmi-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openipmi-developer