Merge "Fix print statement in console scripts"

This commit is contained in:
Zuul 2018-08-10 13:23:03 +00:00 committed by Gerrit Code Review
commit 0b6730557f
3 changed files with 24 additions and 22 deletions

View File

@ -45,7 +45,7 @@ class FakeBmc(bmc.Bmc):
def cold_reset(self): def cold_reset(self):
# Reset of the BMC, not managed system, here we will exit the demo # Reset of the BMC, not managed system, here we will exit the demo
print 'shutting down in response to BMC cold reset request' print('shutting down in response to BMC cold reset request')
sys.exit(0) sys.exit(0)
def get_power_state(self): def get_power_state(self):
@ -54,18 +54,18 @@ class FakeBmc(bmc.Bmc):
def power_off(self): def power_off(self):
# this should be power down without waiting for clean shutdown # this should be power down without waiting for clean shutdown
self.powerstate = 'off' self.powerstate = 'off'
print 'abruptly remove power' print('abruptly remove power')
def power_on(self): def power_on(self):
self.powerstate = 'on' self.powerstate = 'on'
print 'powered on' print('powered on')
def power_reset(self): def power_reset(self):
pass pass
def power_shutdown(self): def power_shutdown(self):
# should attempt a clean shutdown # should attempt a clean shutdown
print 'politely shut down the system' print('politely shut down the system')
self.powerstate = 'off' self.powerstate = 'off'
def is_active(self): def is_active(self):

View File

@ -27,8 +27,9 @@ import sys
from pyghmi.ipmi import command from pyghmi.ipmi import command
if (len(sys.argv) < 3) or 'IPMIPASSWORD' not in os.environ: if (len(sys.argv) < 3) or 'IPMIPASSWORD' not in os.environ:
print "Usage:" print("Usage:")
print " IPMIPASSWORD=password %s bmc username <cmd> <optarg>" % sys.argv[0] print(" IPMIPASSWORD=password %s bmc username <cmd> <optarg>"
% sys.argv[0])
sys.exit(1) sys.exit(1)
password = os.environ['IPMIPASSWORD'] password = os.environ['IPMIPASSWORD']
@ -44,40 +45,41 @@ ipmicmd = None
def docommand(result, ipmisession): def docommand(result, ipmisession):
cmmand = sys.argv[3] cmmand = sys.argv[3]
print "Logged into %s" % ipmisession.bmc print("Logged into %s" % ipmisession.bmc)
if 'error' in result: if 'error' in result:
print result['error'] print(result['error'])
return return
if cmmand == 'power': if cmmand == 'power':
if args: if args:
print ipmisession.set_power(args[0], wait=True) print(ipmisession.set_power(args[0], wait=True))
else: else:
value = ipmisession.get_power() value = ipmisession.get_power()
print "%s: %s" % (ipmisession.bmc, value['powerstate']) print("%s: %s" % (ipmisession.bmc, value['powerstate']))
elif cmmand == 'bootdev': elif cmmand == 'bootdev':
if args: if args:
print ipmisession.set_bootdev(args[0]) print(ipmisession.set_bootdev(args[0]))
else: else:
print ipmisession.get_bootdev() print(ipmisession.get_bootdev())
elif cmmand == 'sensors': elif cmmand == 'sensors':
for reading in ipmisession.get_sensor_data(): for reading in ipmisession.get_sensor_data():
print repr(reading) print(reading)
elif cmmand == 'health': elif cmmand == 'health':
print repr(ipmisession.get_health()) print(ipmisession.get_health())
elif cmmand == 'inventory': elif cmmand == 'inventory':
for item in ipmisession.get_inventory(): for item in ipmisession.get_inventory():
print repr(item) print(item)
elif cmmand == 'leds': elif cmmand == 'leds':
for led in ipmisession.get_leds(): for led in ipmisession.get_leds():
print repr(led) print(led)
elif cmmand == 'graphical': elif cmmand == 'graphical':
print ipmisession.get_graphical_console() print(ipmisession.get_graphical_console())
elif cmmand == 'net': elif cmmand == 'net':
print ipmisession.get_net_configuration() print(ipmisession.get_net_configuration())
elif cmmand == 'raw': elif cmmand == 'raw':
print ipmisession.raw_command(netfn=int(args[0]), print(ipmisession.raw_command(
command=int(args[1]), netfn=int(args[0]),
data=map(lambda x: int(x, 16), args[2:])) command=int(args[1]),
data=map(lambda x: int(x, 16), args[2:])))
bmcs = string.split(bmc, ",") bmcs = string.split(bmc, ",")
for bmc in bmcs: for bmc in bmcs:

View File

@ -60,7 +60,7 @@ class LibvirtBmc(bmc.Bmc):
def cold_reset(self): def cold_reset(self):
# Reset of the BMC, not managed system, here we will exit the demo # Reset of the BMC, not managed system, here we will exit the demo
print 'shutting down in response to BMC cold reset request' print('shutting down in response to BMC cold reset request')
sys.exit(0) sys.exit(0)
def get_power_state(self): def get_power_state(self):