From fff7b3bd57fe94d7ac450da89d9a241ddc5c2f06 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 17 Jun 2013 16:55:44 -0400 Subject: [PATCH] Add an example chunk of code showing how to code in a synchronous way to the python library --- ipmi_syncexample.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 ipmi_syncexample.py diff --git a/ipmi_syncexample.py b/ipmi_syncexample.py new file mode 100755 index 00000000..2a3f25a4 --- /dev/null +++ b/ipmi_syncexample.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +from ipmi_command import ipmi_command +import os +import sys +password=os.environ['IPMIPASSWORD'] +os.environ['IPMIPASSWORD']="" +if (len(sys.argv) < 3): + print "Usage:" + print " IPMIPASSWORD=password %s bmc username "%sys.argv[0] + sys.exit(1) +bmc=sys.argv[1] +userid=sys.argv[2] +command=sys.argv[3] +arg=None +if len(sys.argv)==5: + arg=sys.argv[4] +ipmicmd = ipmi_command(bmc=bmc,userid=userid,password=password) +if command == 'power': + if arg: + print ipmicmd.set_power(arg,wait=True) + else: + print ipmicmd.get_power() +elif command == 'bootdev': + if arg: + print ipmicmd.set_bootdev(arg) + else: + print ipmicmd.get_bootdev() +