Skip to content

Commit

Permalink
Merge pull request #521 from tasleson/megaraid_fix
Browse files Browse the repository at this point in the history
Megaraid fix
  • Loading branch information
tasleson authored Jan 25, 2023
2 parents 186a181 + 5150104 commit d8913be
Show file tree
Hide file tree
Showing 22 changed files with 59 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jobs:
trigger: pull_request
targets:
- fedora-all
- centos-stream-8-x86_64
- rhel-7-x86_64
- rhel-8-x86_64
- rhel-9-x86_64

srpm_build_deps:
- wget
Expand Down
1 change: 1 addition & 0 deletions plugin/arcconf_plugin/arcconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@


def _handle_errors(method):

def _wrapper(*args, **kwargs):
try:
return method(*args, **kwargs)
Expand Down
1 change: 1 addition & 0 deletions plugin/arcconf_plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def cmd_exec(cmds):


class ExecError(Exception):

def __init__(self, cmd, errno, stdout, stderr, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
self.cmd = cmd
Expand Down
5 changes: 2 additions & 3 deletions plugin/hpsa_plugin/hpsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
from lsm import (IPlugin, Client, Capabilities, VERSION, LsmError, ErrorNumber,
uri_parse, System, Pool, size_human_2_size_bytes,
search_property, Volume, Disk, LocalDisk, Battery, int_div)

from hpsa_plugin.utils import cmd_exec, ExecError


def _handle_errors(method):

def _wrapper(*args, **kwargs):
try:
return method(*args, **kwargs)
Expand All @@ -41,7 +41,7 @@ def _wrapper(*args, **kwargs):
except ExecError as exec_error:
if 'No controllers detected' in exec_error.stdout:
raise LsmError(ErrorNumber.NOT_FOUND_SYSTEM,
"No HP SmartArray deteceted by ssacli.")
"No HP SmartArray detected by ssacli.")
else:
raise LsmError(ErrorNumber.PLUGIN_BUG, str(exec_error))
except Exception as common_error:
Expand Down Expand Up @@ -719,7 +719,6 @@ def volumes(self,
for array_key_name in list(ctrl_data[key_name].keys()):
if not array_key_name.startswith("Logical Drive"):
continue

lsm_vols.append(
SmartArray._hp_ld_to_lsm_vol(
ctrl_data[key_name][array_key_name], pool_id,
Expand Down
1 change: 1 addition & 0 deletions plugin/hpsa_plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def cmd_exec(cmds):


class ExecError(Exception):

def __init__(self, cmd, errno, stdout, stderr, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
self.cmd = cmd
Expand Down
1 change: 1 addition & 0 deletions plugin/local_plugin/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@


def _handle_errors(method):

def _wrapper(*args, **kwargs):
try:
return method(*args, **kwargs)
Expand Down
24 changes: 18 additions & 6 deletions plugin/megaraid_plugin/megaraid.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@


def _handle_errors(method):

def _wrapper(*args, **kwargs):
try:
return method(*args, **kwargs)
Expand Down Expand Up @@ -531,13 +532,24 @@ def systems(self, flags=Client.FLAG_RSVD):
ctrl_show_all_output["Version"]["Bios Version"],
ctrl_show_all_output["Version"]["Firmware Version"])

if ctrl_show_all_output["Capabilities"]["Enable JBOD"] == "Yes":
mode = System.MODE_HBA
if "Capabilities" in ctrl_show_all_output and \
"Enable JBOD" in ctrl_show_all_output["Capabilities"]:

if ctrl_show_all_output["Capabilities"]["Enable JBOD"] == "Yes":
mode = System.MODE_HBA
else:
mode = System.MODE_HARDWARE_RAID
# Notes for JBOD/HBA mode of MegaRAID:
# "storcli /c0/e9/s1 set jbod" require "storcli /c0 set jbod=on"
# be executed first.
elif "Status" in ctrl_show_all_output and \
"Current Personality" in ctrl_show_all_output["Status"]:
if ctrl_show_all_output["Status"]["Current Personality"] == "HBA-Mode ":
mode = System.MODE_HBA
else:
mode = System.MODE_HBA
else:
mode = System.MODE_HARDWARE_RAID
# Notes for JBOD/HBA mode of MegaRAID:
# "storcli /c0/e9/s1 set jbod" require "storcli /c0 set jbod=on"
# be excuted first.
mode = System.MODE_UNKNOWN

rc_lsm_syss.append(
System(sys_id,
Expand Down
1 change: 1 addition & 0 deletions plugin/megaraid_plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def cmd_exec(cmds):


class ExecError(Exception):

def __init__(self, cmd, errno, stdout, stderr, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
self.cmd = cmd
Expand Down
1 change: 1 addition & 0 deletions plugin/sim_plugin/simarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@


def _handle_errors(method):

def wrapper(*args, **kargs):
try:
return method(*args, **kargs)
Expand Down
1 change: 1 addition & 0 deletions plugin/sim_plugin/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SimPlugin(INfs, IStorageAreaNetwork):
"""
Simple class that implements enough to allow the framework to be exercised.
"""

def __init__(self):
self.uri = None
self.password = None
Expand Down
1 change: 1 addition & 0 deletions plugin/smispy_plugin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def merge_list(list_a, list_b):


def handle_cim_errors(method):

def cim_wrapper(*args, **kwargs):
try:
return method(*args, **kwargs)
Expand Down
1 change: 1 addition & 0 deletions plugin/targetd_plugin/targetd.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@


def handle_errors(method):

def target_wrapper(*args, **kwargs):
try:
return method(*args, **kwargs)
Expand Down
4 changes: 4 additions & 0 deletions python_binding/lsm/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ class SocketEOF(Exception):
@default_property('msg', doc='Error message')
@default_property('data', doc='Optional error data')
class LsmError(Exception):

def __init__(self, code, message, data=None, *args, **kwargs):
"""
Class represents an error.
Expand Down Expand Up @@ -586,7 +587,9 @@ def return_requires(*types):
needs to be language agnostic, so making sure we have the correct types
is quite important.
"""

def outer(func):

@functools.wraps(func)
def inner(*args, **kwargs):
r = func(*args, **kwargs)
Expand All @@ -613,6 +616,7 @@ def inner(*args, **kwargs):


class TestCommon(unittest.TestCase):

def setUp(self):
pass

Expand Down
5 changes: 5 additions & 0 deletions python_binding/lsm/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class DataEncoder(json.JSONEncoder):
"""
Custom json encoder for objects derived form ILsmData
"""

def default(self, my_class):
if not isinstance(my_class, IData):
raise ValueError('incorrect class type:' + str(type(my_class)))
Expand All @@ -49,6 +50,7 @@ class DataDecoder(json.JSONDecoder):
"""
Custom json decoder for objects derived from ILsmData
"""

@staticmethod
def __process_dict(d):
"""
Expand Down Expand Up @@ -100,6 +102,7 @@ class IData(with_metaclass(_ABCMeta, object)):
Base class functionality of serializable
classes.
"""

def _to_dict(self):
"""
Represent the class as a dictionary
Expand Down Expand Up @@ -722,6 +725,7 @@ def __init__(self,
@default_property('ts', doc="Time stamp the snapshot was created")
@default_property("plugin_data", doc="Private plugin data")
class FsSnapshot(IData):

def __init__(self, _id, _name, _ts, _plugin_data=None):
self._id = _id
self._name = _name
Expand Down Expand Up @@ -777,6 +781,7 @@ def __init__(self,
@default_property('dest_block', doc="Destination logical block address")
@default_property('block_count', doc="Number of blocks")
class BlockRange(IData):

def __init__(self, _src_block, _dest_block, _block_count):
self._src_block = _src_block
self._dest_block = _dest_block
Expand Down
4 changes: 4 additions & 0 deletions python_binding/lsm/_iplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class IPlugin(with_metaclass(_ABCMeta, object)):
Plug-in interface that all plug-ins must implement for basic
operation.
"""

@_abstractmethod
def plugin_register(self, uri, password, timeout, flags=0):
"""
Expand Down Expand Up @@ -126,6 +127,7 @@ def systems(self, flags=0):


class IStorageAreaNetwork(IPlugin):

def volumes(self, search_key=None, search_value=None, flags=0):
"""
Returns an array of volume objects
Expand Down Expand Up @@ -333,6 +335,7 @@ class INetworkAttachedStorage(IPlugin):
"""
Class the represents Network attached storage (Common NFS/CIFS operations)
"""

def fs(self, search_key=None, search_value=None, flags=0):
"""
Returns a list of file systems on the controller. Raises LsmError on
Expand Down Expand Up @@ -474,6 +477,7 @@ def fs_child_dependency_rm(self, fs, files, flags=0):


class INfs(INetworkAttachedStorage):

def export_auth(self, flags=0):
"""
Returns the types of authentication that are available for NFS
Expand Down
1 change: 1 addition & 0 deletions python_binding/lsm/_local_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def _use_c_lib_function(func_ref, arg):


class LocalDisk(object):

@staticmethod
def vpd83_search(vpd83):
"""
Expand Down
1 change: 1 addition & 0 deletions python_binding/lsm/_pluginrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class PluginRunner(object):
Plug-in side common code which uses the passed in plugin to do meaningful
work.
"""

@staticmethod
def _is_number(val):
"""
Expand Down
1 change: 1 addition & 0 deletions python_binding/lsm/_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def _server(s):


class _TestTransport(unittest.TestCase):

def setUp(self):
(self.c, self.s) = socket.socketpair(socket.AF_UNIX,
socket.SOCK_STREAM)
Expand Down
2 changes: 2 additions & 0 deletions test/plugin_test.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def mb_in_bytes(mib):


def record_result(method):

def recorder(*args, **kwargs):
try:
result = method(*args, **kwargs)
Expand Down Expand Up @@ -119,6 +120,7 @@ def r_iqn():


class Duration(object):

def __init__(self):
self.start = 0
self.end = 0
Expand Down
2 changes: 2 additions & 0 deletions tools/basic_check/local_check.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def warn(vol, blk_paths, msg):


class LocalVol(object):

def __init__(self, vol, blk_paths, sys, cap):
self.vol = vol
self.blk_paths = blk_paths
Expand Down Expand Up @@ -76,6 +77,7 @@ SUGGEST: "{SUGGEST}"


class SanityCheck(unittest.TestCase):

def setUp(self):
uri = None
if os.getenv('LSMCLI_URI') is not None:
Expand Down
3 changes: 3 additions & 0 deletions tools/lsmcli/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ def _add_sd_paths(lsm_obj):

# This class represents a command line argument error
class ArgError(Exception):

def __init__(self, message, *args, **kwargs):
"""
Class represents an error.
Expand Down Expand Up @@ -452,6 +453,7 @@ def _check_network_host(addr):

class PluginFork:
"""Container for plugin fork data"""

def __init__(self, plugin_exe):
self.uds_dir = tempfile.mkdtemp(prefix="LSM_DEV_")
self.uds_socket_file = os.path.join(self.uds_dir, "uds_path")
Expand Down Expand Up @@ -1856,6 +1858,7 @@ def volume_replicate(self, args):
# Check to see if block ranges are overlapping
@staticmethod
def _check_overlap(ranges):

def _overlap(r, member):
for i in range(1, len(r)):
ps = getattr(r[i - 1], member) # Previous start
Expand Down
3 changes: 3 additions & 0 deletions tools/lsmcli/data_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ def disk_link_speed_to_str(link_speed):


class PlugData(object):

def __init__(self, description, plugin_version):
self.desc = description
self.version = plugin_version
Expand Down Expand Up @@ -398,6 +399,7 @@ def member_type_to_str(member_type):


class VcrCap(object):

def __init__(self, system_id, raid_types, strip_sizes):
self.system_id = system_id
self.raid_types = raid_types
Expand Down Expand Up @@ -503,6 +505,7 @@ def r_cache_status_to_str(r_cache_status):


class DisplayData(object):

def __init__(self):
pass

Expand Down

0 comments on commit d8913be

Please sign in to comment.