Skip to content

Commit

Permalink
Merge pull request #29 from hthiery/master
Browse files Browse the repository at this point in the history
change methods that could be a function
  • Loading branch information
hthiery committed Sep 16, 2018
2 parents 63d4c9e + 4a312ce commit af05503
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 23 deletions.
3 changes: 2 additions & 1 deletion pyipmi/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def __init__(self, cc):
def __str__(self):
return "%s cc=0x%02x desc=%s" % (self.__class__.__name__, self.cc, self.cc_desc)

def find_cc_desc(self, error_cc):
@staticmethod
def find_cc_desc(error_cc):
for cc in cc_err_desc:
if error_cc == cc[0]:
return cc[1]
Expand Down
24 changes: 15 additions & 9 deletions pyipmi/hpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@

class Hpm(object):

def _get_component_count(self, components):
@staticmethod
def _get_component_count(components):
"""Return the number of components"""
return bin(components).count('1')

Expand Down Expand Up @@ -140,7 +141,8 @@ def upload_firmware_block(self, block_number, data):
self.send_message_with_name('UploadFirmwareBlock', number=block_number,
data=data)

def _determine_max_block_size(self):
@staticmethod
def _determine_max_block_size():
#tbd
return 22

Expand Down Expand Up @@ -248,28 +250,32 @@ def initiate_manual_rollback_and_wait(self, timeout=2, interval=0.1):
# controller is in reset and flashed new firmware
pass

def open_upgrade_image(self, filename):
image = UpgradeImage(filename)
return image
@staticmethod
def open_upgrade_image(filename):
return UpgradeImage(filename)

def get_upgrade_version_from_file(self, filename):
@staticmethod
def get_upgrade_version_from_file(filename):
image = UpgradeImage(filename)
for action in image.actions:
if type(action) == UpgradeActionRecordUploadForUpgrade:
return action.firmware_version
return None

def _do_upgrade_action_backup(self, image):
@staticmethod
def _do_upgrade_action_backup(image):
for action in image.actions:
if type(action) == UpgradeActionRecordBackup:
pass

def _do_upgrade_action_prepare(self, image):
@staticmethod
def _do_upgrade_action_prepare(image):
for action in image.actions:
if type(action) == UpgradeActionRecordPrepare:
print("do ACTION_PREPARE_COMPONENT")

def _do_upgrade_action_upload(self, image):
@staticmethod
def _do_upgrade_action_upload(image):
for action in image.actions:
if type(action) == UpgradeActionRecordUploadForUpgrade:
print("do ACTION_UPLOAD_FOR_UPGRADE")
Expand Down
6 changes: 4 additions & 2 deletions pyipmi/interfaces/aardvark.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ def is_ipmc_accessible(self, target):
def _inc_sequence_number(self):
self.next_sequence_number = (self.next_sequence_number + 1) % 64

def _encode_ipmb_msg_req(self, header, cmd_data):
@staticmethod
def _encode_ipmb_msg_req(header, cmd_data):
data = header.encode()
data.extend(cmd_data)
data.append(checksum(data[2:]))

return data

def _rx_filter(self, header, rx_data):
@staticmethod
def _rx_filter(header, rx_data):

log().debug('[%s]' % ' '.join(['%02x' % b for b in rx_data]))

Expand Down
10 changes: 6 additions & 4 deletions pyipmi/interfaces/ipmitool.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ def send_and_receive(self, req):

return rsp

def _build_ipmitool_raw_data(self, lun, netfn, raw_bytes):
@staticmethod
def _build_ipmitool_raw_data(lun, netfn, raw_bytes):
cmd_data = ' -l %d raw 0x%02x ' % (lun, netfn)
cmd_data += ' '.join(['0x%02x' % ord(d) for d in raw_bytes])
return cmd_data

def _build_ipmitool_target(self, target):
@staticmethod
def _build_ipmitool_target(target):
cmd = ''
if hasattr(target, 'routing'):
# we have to do bridging here
Expand Down Expand Up @@ -205,7 +207,8 @@ def _build_serial_ipmitool_cmd(self, target, lun, netfn, raw_bytes):

return cmd

def _run_ipmitool(self, cmd):
@staticmethod
def _run_ipmitool(cmd):
"""Legacy call of ipmitool (will be removed in future).
"""

Expand All @@ -218,4 +221,3 @@ def _run_ipmitool(self, cmd):
output)

return output, child.returncode

3 changes: 2 additions & 1 deletion pyipmi/msgs/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ def encode(self, obj, data):
if getattr(obj, self._field.name) is not None:
self._field.encode(obj, data)

def create(self):
@staticmethod
def create():
return None


Expand Down
1 change: 1 addition & 0 deletions pyipmi/sdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ def l(self):
raise errors.DecodingError('unknown linearization %d' %
(self.linearization & 0x7f))

@staticmethod
def _convert_complement(self, value, size):
if (value & (1 << (size-1))):
value = -(1<<size) + value
Expand Down
13 changes: 7 additions & 6 deletions pyipmi/sel.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@ def __str__(self):
str.append(' Event Data: 0x%s' % self.event_data.encode('hex'))
return "\n".join(str)

def type_to_string(self, type):
@staticmethod
def type_to_string(entry_type):
s = None
if type == SelEntry.TYPE_SYSTEM_EVENT:
if entry_type == SelEntry.TYPE_SYSTEM_EVENT:
s = 'System Event'
elif type in SelEntry.TYPE_OEM_TIMESTAMPED_RANGE:
s = 'OEM timestamped (0x%02x)' % type
elif type in SelEntry.TYPE_OEM_NON_TIMESTAMPED_RANGE:
s = 'OEM non-timestamped (0x%02x)' % type
elif entry_type in SelEntry.TYPE_OEM_TIMESTAMPED_RANGE:
s = 'OEM timestamped (0x%02x)' % entry_type
elif entry_type in SelEntry.TYPE_OEM_NON_TIMESTAMPED_RANGE:
s = 'OEM non-timestamped (0x%02x)' % entry_type
return s

def _from_response(self, data):
Expand Down

0 comments on commit af05503

Please sign in to comment.