GithubHelp home page GithubHelp logo

shapeblue / ipmisim Goto Github PK

View Code? Open in Web Editor NEW
30.0 18.0 17.0 31 KB

Fake IPMI server based on conpot and pyghmi

Home Page: https://pypi.python.org/pypi/ipmisim

License: Apache License 2.0

Makefile 0.20% Python 99.80%

ipmisim's Introduction

ipmisim

A fake ipmi server for testing purposes both as a tool and a library. The code is forked from Conpot and based on pyghmi.

version badge download badge

This was created for testing IPMI related features in Apache CloudStack.

The tool ships with default sets of users for ease of use:

ID  Name       Callin  Link Auth  IPMI Msg   Channel Priv Limit
1   admin            true    true       true       ADMINISTRATOR
2   operator         true    false      false      OPERATOR
3   user             true    true       true       USER

The default passwords are:

admin  : password
opuser : oppassword
user   : userpassword

Installation:

pip install --upgrade ipmisim

Running:

ipmisim 3000  # Runs on custom port 3000, else 9001 by default

For, usage in integration tests you can import the server module and create a server:

from ipmisim.ipmisim import IpmiServer
import socketserver

port = 3000
server = SocketServer.UDPServer(('0.0.0.0', port), IpmiServer)
server.serve_forever()

For testing BMC power state, you can inspect IpmiServerContext().bmc.powerstate For more details see server usage ipmisim/ipmisim.py

Testing with ipmitool:

ipmitool -I lanplus -H localhost -p 9001 -R1 -U admin -P password chassis power status

ipmisim's People

Contributors

daanhoogland avatar firesoules avatar gzock avatar rohityadavcloud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ipmisim's Issues

Multiple Simultaneous Sessions

There seems to be a problem with handling multiple sessions. I simulate multiple sessions by opening up multiple ipmi shells. Once I connect a second client, it establishes a session but then neither client receive responses for their requests (ie. mc info). I tried using different users for each session, still nothing. The IPMI server is meant to be multithreaded but are the methods thread safe? Aren't at least 4 simultaneous sessions supposed to supported on a given channel?

Update
It seems the session closes because of the condition at line 108 of fakesession.py. The authcode and expectedauthcode don't match so the session gets closed.

Ported to Python 3 Compatible

Thank you for the cool tool. I often use ipmisim.
I have ported ipmisim to python3.
Can I fork this repositoriy and publish it as ipmisim3?
Or is a pull request better?

Zaid Qureshi, who previously develop it work on python3, seems not to publish it.

Not reachable with ipmitool?

Maybe I'm just doing something wrong here, but I start the server:
$ ipmisim
2017-09-08 15:05:26,549 - ipmisim - INFO - IPMI BMC initialized.
2017-09-08 15:05:26,549 - ipmisim - INFO - CloudStack IPMI Sim BMC initialized
2017-09-08 15:05:26,549 - ipmisim - INFO - Started IPMI Server on 0.0.0.0:9001

and in another terminal:
$ ipmitool -I lanplus -H localhost -p 9001 -R1 -U admin -P password chassis power status
Error: Unable to establish IPMI v2 / RMCP+ session

Any ideas what's going on here?

Regarding Python 3 Support

Hi,

So I am tying to port your library to Python 3 (using 2to3 and some library changes like SocketServer to socketserver) but am coming across a weird problem.
When I run ipmisim.py with python2 everything runs fine. The server responds to commands from ipmitool.
With python3, the server initilizes and even establishes the session when a command from ipmitool is initiated, but ipmitool gets an error with trying to get Get Auth Capabilities, reporting:
"Get Auth Capabilities error.
Error issuing Get Channel Authentication Capabilities request
Error: Unable to establish IPMI v2 /RMCP+ session"
The server reports that a new IPMI session has been initialized for this client. So I am not sure where the problem is.

Update
So there were some python 2 and python 3 conflicts having to do with bytes and strings. I believe I fixed them but now the ipmitool client isn't receiving the rakp2 payload from the IPMI server, the client tries to get this 4 times but never receives it. I am sure the server is receiving the appropriate rakp1 request and sends a packet of length 94 back each of the 4 times (checked via wireshark). I am not sure what is missing. I looked over the send_payload method in fakesession.py but there doesn't seem to any byte and strings conflicts.

freeipmi can not operate the sim BMC

[root@gv101 ipmisim]# /opt/autogridview/freeipmi/sbin/ipmipower -h 10.0.41.101 -u admin -p password --debug --stat
10.0.41.101: =====================================================
10.0.41.101: IPMI 1.5 Get Channel Authentication Capabilities Request
10.0.41.101: =====================================================
10.0.41.101: RMCP Header:
10.0.41.101: ------------
10.0.41.101: [               6h] = version[ 8b]
10.0.41.101: [               0h] = reserved[ 8b]
10.0.41.101: [              FFh] = sequence_number[ 8b]
10.0.41.101: [               7h] = message_class.class[ 5b]
10.0.41.101: [               0h] = message_class.reserved[ 2b]
10.0.41.101: [               0h] = message_class.ack[ 1b]
10.0.41.101: IPMI Session Header:
10.0.41.101: --------------------
10.0.41.101: [               0h] = authentication_type[ 8b]
10.0.41.101: [               0h] = session_sequence_number[32b]
10.0.41.101: [               0h] = session_id[32b]
10.0.41.101: [               9h] = ipmi_msg_len[ 8b]
10.0.41.101: IPMI Message Header:
10.0.41.101: --------------------
10.0.41.101: [              20h] = rs_addr[ 8b]
10.0.41.101: [               0h] = rs_lun[ 2b]
10.0.41.101: [               6h] = net_fn[ 6b]
10.0.41.101: [              C8h] = checksum1[ 8b]
10.0.41.101: [              81h] = rq_addr[ 8b]
10.0.41.101: [               0h] = rq_lun[ 2b]
10.0.41.101: [               9h] = rq_seq[ 6b]
10.0.41.101: IPMI Command Data:
10.0.41.101: ------------------
10.0.41.101: [              38h] = cmd[ 8b]
10.0.41.101: [               Eh] = channel_number[ 4b]
10.0.41.101: [               0h] = reserved1[ 3b]
10.0.41.101: [               0h] = get_ipmi_v2.0_extended_data[ 1b]
10.0.41.101: [               3h] = maximum_privilege_level[ 4b]
10.0.41.101: [               0h] = reserved2[ 4b]
10.0.41.101: IPMI Trailer:
10.0.41.101: --------------
10.0.41.101: [              12h] = checksum2[ 8b]
(ipmipower_powercmd.c, _retry_packets, 1383): host = 10.0.41.101; p = 1; Sending retry, retry count=1

please help to resolve this issue, thanks very much.

Example from README does not work

Used versions:

ipmitool version 1.8.18-csv
ipmisim==0.10

Commands:

Screen A

$ ipmisim 3000
2022-02-24 16:00:46,854 - ipmisim - INFO - IPMI BMC initialized.
2022-02-24 16:00:46,854 - ipmisim - INFO - CloudStack IPMI Sim BMC initialized
2022-02-24 16:00:46,854 - ipmisim - INFO - Started IPMI Server on 0.0.0.0:3000

Screen B

$ ipmitool -I lanplus -H localhost -p 3000 -R1 -U admin -P password chassis power status -vvv
Testing wlp4s0 interface address: 2a02:a318:8246:8d00:7a41:6b11:ab91:dc4d scope=0
Successful connected on wlp4s0 interface with scope id 0

>> Sending IPMI command payload
>>    netfn   : 0x06
>>    command : 0x38
>>    data    : 0x8e 0x04 

BUILDING A v1.5 COMMAND
>> IPMI Request Session Header
>>   Authtype   : NONE
>>   Sequence   : 0x00000000
>>   Session ID : 0x00000000
>> IPMI Request Message Header
>>   Rs Addr    : 20
>>   NetFn      : 06
>>   Rs LUN     : 0
>>   Rq Addr    : 81
>>   Rq Seq     : 00
>>   Rq Lun     : 0
>>   Command    : 38

>> Sending IPMI command payload
>>    netfn   : 0x06
>>    command : 0x38
>>    data    : 0x0e 0x04 

BUILDING A v1.5 COMMAND
>> IPMI Request Session Header
>>   Authtype   : NONE
>>   Sequence   : 0x00000000
>>   Session ID : 0x00000000
>> IPMI Request Message Header
>>   Rs Addr    : 20
>>   NetFn      : 06
>>   Rs LUN     : 0
>>   Rq Addr    : 81
>>   Rq Seq     : 00
>>   Rq Lun     : 0
>>   Command    : 38
Get Auth Capabilities error
Error issuing Get Channel Authentication Capabilities request
Error: Unable to establish IPMI v2 / RMCP+ session

Similarly for opuser and user. Is there any initial step I'm missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.