Skip to content

Commit

Permalink
Revert "Merge branch 'feature-native-rmcp' into merge"
Browse files Browse the repository at this point in the history
This reverts commit fc8c0e8, reversing
changes made to 5e84dda.
  • Loading branch information
hthiery committed Oct 3, 2018
1 parent fc8c0e8 commit 93ddd94
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 27 deletions.
7 changes: 5 additions & 2 deletions pyipmi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
from . import sdr
from . import sel
from . import sensor
from . import messaging
from . import msgs

from .errors import IpmiTimeoutError, CompletionCodeError, RetryError
from .msgs.registry import create_request_by_name
from .session import Session
from .utils import check_completion_code, is_string

Expand All @@ -49,6 +50,7 @@ def create_connection(interface):
ipmi = Ipmi()
ipmi.interface = interface
ipmi.session = session
ipmi.requester = NullRequester()
return ipmi


Expand Down Expand Up @@ -191,6 +193,7 @@ def send_message(self, req, retry=3):
continue
else:
raise RetryError()

return rsp

def send_message_with_name(self, name, *args, **kwargs):
Expand Down Expand Up @@ -244,4 +247,4 @@ def _set_target(self, target):

target = property(_get_target, _set_target)
interface = property(_get_interface, _set_interface)
session = property(_get_session, _set_session)
session = property(_get_session, _set_session)
4 changes: 2 additions & 2 deletions pyipmi/interfaces/aardvark.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _send_and_receive(self, target, lun, netfn, cmdid, payload):
retries = 0
while retries < self.max_retries:
try:
self._send_raw(header, raw_bytes)
self._send_raw(header, payload)
rx_data = self._receive_raw(header)
break
except IpmiTimeoutError:
Expand Down Expand Up @@ -198,4 +198,4 @@ def send_and_receive(self, req):

log().debug('IPMI Response [%s])', rsp)

return rsp
return rsp
7 changes: 2 additions & 5 deletions pyipmi/interfaces/ipmb.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
encode_message, decode_message, constants)
from ..utils import check_completion_code

from ..logger import log
from ..msgs import create_message, create_request_by_name, \
encode_message, decode_message, constants
from ..utils import check_completion_code

def checksum(data):
csum = 0
Expand Down Expand Up @@ -53,7 +49,7 @@ def encode(self):
data.append(self.cmd_id)
return data.tostring()


def encode_ipmb_msg(header, data):
"""Encode an IPMB message.
Expand Down Expand Up @@ -112,6 +108,7 @@ def encode_bridged_message(routing, header, payload, seq):
Returns the encoded send message as bytestring
"""

# change header requester addresses for bridging
header.rq_sa = routing[-1].rq_sa
header.rs_sa = routing[-1].rs_sa
Expand Down
2 changes: 1 addition & 1 deletion pyipmi/interfaces/ipmitool.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def _build_ipmitool_cmd(self, target, lun, netfn, raw_bytes):
cmd += (' -p %s' % self._session.rmcp_port)

if self._session.auth_type == Session.AUTH_TYPE_NONE:
cmd += (' -A NONE')
cmd += ' -P ""'
elif self._session.auth_type == Session.AUTH_TYPE_PASSWORD:
cmd += (' -U "%s"' % self._session.auth_username)
cmd += (' -P "%s"' % self._session.auth_password)
Expand Down
6 changes: 4 additions & 2 deletions pyipmi/interfaces/rmcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import hashlib
import random
import threading

from array import array
from queue import Queue

Expand All @@ -19,6 +18,7 @@
rx_filter)
from ..utils import check_completion_code


CLASS_NORMAL_MSG = 0x00
CLASS_ACK_MSG = 0x80

Expand Down Expand Up @@ -69,6 +69,7 @@ def unpack(self, pdu):

if self.version != self.ASF_RMCP_V_1_0:
raise DecodingError('invalid RMCP version field')

return sdu


Expand Down Expand Up @@ -109,6 +110,7 @@ def unpack(self, sdu):
header = sdu[:header_len]
(self.iana_enterprise_number, self.asf_type, self.tag, data_len) = \
struct.unpack(self.ASF_HEADER_FORMAT, header)

if len(sdu) < header_len + data_len:
raise DecodingError('short SDU')
elif len(sdu) > header_len + data_len:
Expand Down Expand Up @@ -560,4 +562,4 @@ def send_and_receive(self, req):

r = Rmcp(host)
r.ping()
r.establish_session(session)
r.establish_session(session)
2 changes: 1 addition & 1 deletion pyipmi/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ def __str__(self):
s += ' IPMI v2.0: %s\n' % self.ipmi_2_0
s += ' Auth. types: %s\n' % ' '.join(self.auth_types)
s += ' Max Auth. type: %s\n' % self.get_max_auth_type()
return s
return s
1 change: 0 additions & 1 deletion pyipmi/msgs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
(CC_UNSPECIFIED_ERROR, 'Unspecified error'),
)


# network functions
NETFN_CHASSIS = 0x00
NETFN_BRIDGE = 0x02
Expand Down
4 changes: 2 additions & 2 deletions pyipmi/msgs/device_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class ActivateSessionReq(Message):
UnsignedInt('initial_outbound_sequence_number', 4),
)


@register_message_class
class ActivateSessionRsp(Message):
__cmdid__ = constants.CMDID_ACTIVATE_SESSION
Expand Down Expand Up @@ -377,4 +377,4 @@ class CloseSessionRsp(Message):
__netfn__ = constants.NETFN_APP | 1
__fields__ = (
CompletionCode(),
)
)
2 changes: 0 additions & 2 deletions pyipmi/msgs/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ class String(BaseField):
def encode(self, obj, data):
value = getattr(obj, self.name)
data.push_string(value)
# fill with 0
data.push_unsigned_int(0, self.length - len(value))

def decode(self, obj, data):
value = data.pop_string(self.length)
Expand Down
2 changes: 1 addition & 1 deletion pyipmi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ def __str__(self):
return string

interface = property(_get_interface, _set_interface)
auth_type = property(_get_auth_type, _set_auth_type)
auth_type = property(_get_auth_type, _set_auth_type)
2 changes: 1 addition & 1 deletion tests/interfaces/test_ipmb.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ def test_decode_bridged_message():


def test_rx_filter():
pass
pass
2 changes: 1 addition & 1 deletion tests/interfaces/test_ipmitool.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_send_and_receive_raw_no_auth(self):
target = Target(0x20)
self._interface.send_and_receive_raw(target, 0, 0x6, b'\x01')

mock.assert_called_once_with('ipmitool -I lan -H 10.0.1.1 -p 623 -A NONE -t 0x20 -l 0 raw 0x06 0x01 2>&1')
mock.assert_called_once_with('ipmitool -I lan -H 10.0.1.1 -p 623 -P "" -t 0x20 -l 0 raw 0x06 0x01 2>&1')

def test_send_and_receive_raw_return_value(self):
mock = MagicMock()
Expand Down
2 changes: 1 addition & 1 deletion tests/interfaces/test_rmcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ def test_ipmimsg_unpack_auth(self):
# rmcp._send_ipmi_msg.assert_called_with(1)
#
# def test_send_and_receive(self):
# pass
# pass
2 changes: 1 addition & 1 deletion tests/msgs/test_bmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ def test_getselftestresults_decode_test_fail_corrupted_fru_rsp():
eq_(m.status.sdr_repository_empty, 0)
eq_(m.status.internal_use_area_corrupted, 0)
eq_(m.status.controller_bootblock_corrupted, 0)
eq_(m.status.controller_firmware_corrupted, 0)
eq_(m.status.controller_firmware_corrupted, 0)
3 changes: 2 additions & 1 deletion tests/msgs/test_device_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,10 @@ def test_get_session_challenge_req():
eq_(m.netfn, 6)
eq_(data,
b'\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

m.authentication.type = 1
m.user_name = '0123456789abcdef'
data = encode_message(m)
eq_(m.cmdid, 0x39)
eq_(m.netfn, 6)
eq_(data, b'\x010123456789abcdef')
eq_(data, b'\x010123456789abcdef')
2 changes: 1 addition & 1 deletion tests/msgs/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def test_geteventreceiver_decode_lun3_rsp():
decode_message(m, b'\x00\x20\x03')
eq_(m.completion_code, 0x00)
eq_(m.event_receiver.ipmb_i2c_slave_address, 0x10)
eq_(m.event_receiver.lun, 3)
eq_(m.event_receiver.lun, 3)
4 changes: 2 additions & 2 deletions tests/msgs/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def test_unsignedint_decode():


def test_string_encode():
t = TestMessage(String('test', 8))
t = TestMessage(String('test', 10))
t.test = '1234'
byte_buffer = t.encode()
eq_(byte_buffer.array, array('B', [0x31, 0x32, 0x33, 0x34, 0, 0, 0, 0]))
eq_(byte_buffer.array, array('B', [0x31, 0x32, 0x33, 0x34]))


def test_string_decode():
Expand Down

0 comments on commit 93ddd94

Please sign in to comment.