2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-14 19:57:47 +00:00

Add a "--port" option to fakebmc

Change-Id: Id609034c1a23cc335ccd478df113b17e04e33cc5
This commit is contained in:
Peter Martini 2015-02-11 12:08:03 -08:00
parent 9f33418d2b
commit f44881a135

19
bin/fakebmc Normal file → Executable file
View File

@ -26,13 +26,14 @@ __author__ = 'jjohnson2@lenovo.com'
# # ipmitool -I lanplus -U admin -P password -H 127.0.0.1 mc reset cold
# Sent cold reset command to MC
# (fakebmc exits)
import argparse
import pyghmi.ipmi.bmc as bmc
import sys
class FakeBmc(bmc.Bmc):
def __init__(self, authdata):
super(FakeBmc, self).__init__(authdata)
def __init__(self, authdata, port):
super(FakeBmc, self).__init__(authdata, port)
self.powerstate = 'off'
self.bootdevice = 'default'
@ -68,5 +69,15 @@ class FakeBmc(bmc.Bmc):
self.powerstate = 'off'
if __name__ == '__main__':
mybmc = FakeBmc({'admin': 'password'})
mybmc.listen()
parser = argparse.ArgumentParser(
prog='fakebmc',
description='Pretend to be a BMC',
)
parser.add_argument('--port',
dest='port',
type=int,
default=623,
help='Port to listen on; defaults to 623')
args = parser.parse_args()
mybmc = FakeBmc({'admin': 'password'}, port=args.port)
mybmc.listen()