2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-27 19:37:44 +00:00

Obey custom ports in SOL client and server

Rather than hard baking 623, use the same port that was passed in
on init.

Change-Id: I82b837051144fec7421f6f1f37c059390f2ac5ec
This commit is contained in:
Jarrod Johnson 2018-01-02 11:10:27 -05:00
parent 7d0df42298
commit 02b5f2e653
2 changed files with 8 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import pyghmi.ipmi.command as ipmicommand
import pyghmi.ipmi.console as console
import pyghmi.ipmi.private.serversession as serversession
import pyghmi.ipmi.private.session as ipmisession
import struct
import traceback
__author__ = 'jjohnson2@lenovo.com'
@ -65,8 +66,9 @@ class Bmc(serversession.IpmiServer):
session.send_ipmi_response(code=0x80)
else:
self.activated = True
solport = list(struct.unpack('BB', struct.pack('!H', self.port)))
session.send_ipmi_response(
data=[0, 0, 0, 0, 1, 0, 1, 0, 2, 0x6f, 0xff, 0xff])
data=[0, 0, 0, 0, 1, 0, 1, 0] + solport + [0xff, 0xff])
self.sol = console.ServerConsole(session, self.iohandler)
def deactivate_payload(self, request, session):

View File

@ -56,6 +56,7 @@ class Console(object):
self.awaitingack = False
self.activated = False
self.force_session = force
self.port = port
self.ipmi_session = session.Session(bmc=bmc,
userid=userid,
password=password,
@ -126,7 +127,10 @@ class Console(object):
# BMC tells us this is the maximum allowed size
# data[6:7] is the promise of how small packets are going to be, but we
# don't have any reason to worry about it
if (data[8] + (data[9] << 8)) not in (623, 28418):
# some BMCs disagree on the endianness, so do both
valid_ports = (self.port, struct.unpack(
'<H', struct.pack('>H', self.port))[0])
if (data[8] + (data[9] << 8)) not in valid_ports:
# TODO(jbjohnso): support atypical SOL port number
raise NotImplementedError("Non-standard SOL Port Number")
# ignore data[10:11] for now, the vlan detail, shouldn't matter to this