Fix print statement in console scripts

Change-Id: Ibafcdde71542485b8141f2a16f049d76c74b50ab
This commit is contained in:
Ilya Etingof 2018-08-10 12:52:46 +02:00
parent 9e443c8135
commit 38395b2307
3 changed files with 24 additions and 22 deletions

View File

@ -45,7 +45,7 @@ class FakeBmc(bmc.Bmc):
def cold_reset(self):
# 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)
def get_power_state(self):
@ -54,18 +54,18 @@ class FakeBmc(bmc.Bmc):
def power_off(self):
# this should be power down without waiting for clean shutdown
self.powerstate = 'off'
print 'abruptly remove power'
print('abruptly remove power')
def power_on(self):
self.powerstate = 'on'
print 'powered on'
print('powered on')
def power_reset(self):
pass
def power_shutdown(self):
# should attempt a clean shutdown
print 'politely shut down the system'
print('politely shut down the system')
self.powerstate = 'off'
def is_active(self):

View File

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

View File

@ -60,7 +60,7 @@ class LibvirtBmc(bmc.Bmc):
def cold_reset(self):
# 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)
def get_power_state(self):