* New empty(no real function) plugin: HP SmartArray with URI 'hpsa://' and no password required.
* The hpsa plugin will use HP binary tool -- hpssacli to control localhost HP SmartArray cards. Hence root privilege required. * This patch contains: 1. Autotools update for new plugin. 2. RPM SPEC file update for new plugin package: libstoragemgmt-hpsa-plugin (Fedora/RHEL) libstoragemgmt1-hpsa-plugin (OpenSuSE) 3. New manpage: hpsa_lsmplugin.1 4. The lsm plugin configuration file for root privilege requirement. Changes in V3(no changes in V2): * Move the 'utils.py' files to next commit along with its rpm spec and automake file update. Signed-off-by: Gris Ge <f...@redhat.com> --- config/Makefile.am | 5 ++++ config/pluginconf.d/hpsa.conf | 1 + configure.ac | 14 +++++++++++ doc/man/Makefile.am | 4 ++++ doc/man/hpsa_lsmplugin.1.in | 50 ++++++++++++++++++++++++++++++++++++++ packaging/libstoragemgmt.spec.in | 38 +++++++++++++++++++++++++++++ plugin/Makefile.am | 2 +- plugin/hpsa/Makefile.am | 8 +++++++ plugin/hpsa/__init__.py | 1 + plugin/hpsa/hpsa.py | 52 ++++++++++++++++++++++++++++++++++++++++ plugin/hpsa/hpsa_lsmplugin | 37 ++++++++++++++++++++++++++++ 11 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 config/pluginconf.d/hpsa.conf create mode 100644 doc/man/hpsa_lsmplugin.1.in create mode 100644 plugin/hpsa/Makefile.am create mode 100644 plugin/hpsa/__init__.py create mode 100644 plugin/hpsa/hpsa.py create mode 100755 plugin/hpsa/hpsa_lsmplugin diff --git a/config/Makefile.am b/config/Makefile.am index 70ab97b..39fb224 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -11,3 +11,8 @@ if WITH_MEGARAID pluginconf_DATA += pluginconf.d/megaraid.conf EXTRA_DIST += pluginconf.d/megaraid.conf endif + +if WITH_HPSA +pluginconf_DATA += pluginconf.d/hpsa.conf +EXTRA_DIST += pluginconf.d/hpsa.conf +endif diff --git a/config/pluginconf.d/hpsa.conf b/config/pluginconf.d/hpsa.conf new file mode 100644 index 0000000..35b52d4 --- /dev/null +++ b/config/pluginconf.d/hpsa.conf @@ -0,0 +1 @@ +require-root-privilege = true; diff --git a/configure.ac b/configure.ac index db657bb..9315f35 100644 --- a/configure.ac +++ b/configure.ac @@ -193,6 +193,18 @@ AC_ARG_WITH([megaraid], AM_CONDITIONAL([WITH_MEGARAID], [test "x$with_megaraid" = "xyes"]) dnl ========================================================================== +dnl Add option '--without-hpsa' to exclude hpsa plugin. +dnl ========================================================================== + +AC_ARG_WITH([hpsa], + [AS_HELP_STRING([--without-hpsa], + [Do not build the HP SmartArray plugin])], + [], + [with_hpsa=yes]) + +AM_CONDITIONAL([WITH_HPSA], [test "x$with_hpsa" = "xyes"]) + +dnl ========================================================================== dnl Check for libconfig as it is needed for lsmd daemon dnl ========================================================================== PKG_CHECK_MODULES( @@ -221,6 +233,7 @@ AC_OUTPUT(libstoragemgmt.pc \ plugin/Makefile \ plugin/simc/Makefile \ plugin/megaraid/Makefile \ + plugin/hpsa/Makefile \ daemon/Makefile \ config/Makefile \ doc/Makefile \ @@ -229,6 +242,7 @@ AC_OUTPUT(libstoragemgmt.pc \ doc/doxygen.conf \ doc/man/lsmd.conf.5 \ doc/man/megaraid_lsmplugin.1 \ + doc/man/hpsa_lsmplugin.1 \ tools/Makefile \ tools/udev/Makefile \ tools/lsmcli/Makefile \ diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am index ccbcb38..19b536c 100644 --- a/doc/man/Makefile.am +++ b/doc/man/Makefile.am @@ -4,4 +4,8 @@ if WITH_MEGARAID notrans_dist_man1_MANS += megaraid_lsmplugin.1 endif +if WITH_HPSA +notrans_dist_man1_MANS += hpsa_lsmplugin.1 +endif + notrans_dist_man5_MANS = lsmd.conf.5.in diff --git a/doc/man/hpsa_lsmplugin.1.in b/doc/man/hpsa_lsmplugin.1.in new file mode 100644 index 0000000..79ff565 --- /dev/null +++ b/doc/man/hpsa_lsmplugin.1.in @@ -0,0 +1,50 @@ +.TH hpsa_lsmplugin "1" "March 2015" "hpsa_lsmplugin @VERSION@" "libStorageMgmt" +.SH NAME +hpsa_lsmplugin -- LibstorageMgmt HP SmartArray plugin + +.SH DESCRIPTION +LibstorageMgmt hpsa plugin allows user to manage HP SmartArray via vendor +tool \fBhpssacli\fR[1]. +The 'hpsa_lsmplugin' executable file is for libStorageMgmt +daemon to execute when client user specifies hpsa plugin in the URI. + +.SH URI +To use this plugin, users should set their URI to this format: +.nf + + \fBhpsa://\fR + or + \fBhpsa://?hpssacli=<path_of_hpssacli>\fR + +.fi + +.TP hpssacli +The 'hpssacli' URI parameter is used to specified the path of hpssacli tool. +By default, this plugin will try these paths used by hpssacli rpm: +\fB/usr/sbin/hpssacli\fR and \fB/opt/hp/hpssacli/bld/hpssacli\fR. + +.SH ROOT PRIVILEGE +This plugin requires both \fBlsmd\fR daemon and API client running as root +user. Please check manpage \fIlsmd.conf (5)\fR for detail. + +.SH SUPPORTED HARDWARES +Please refer to HP website for hardware support status of hpssacli. +Detailed support status can be queried via: + + * \fBlsm.Client.capabilities()\fR (Python API) + * \fBlsm_capabilities()\fR (C API) + * \fBlsmcli capabilities\fR (lsmcli command line). + +.SH FIREWALL RULES +This plugin only execute \fBhpssacli\fR on localhost. No network connection +required. + +.SH SEE ALSO +\fIlsmcli\fR(1), \fIlsmd\fR(1), [1]http://downloads.linux.hp.com/SDR/project/spp/ + +.SH BUGS +Please report bugs to +\fI<libstoragemgmt-devel@lists.sourceforge.net>\fR + +.SH AUTHOR +Gris Ge \fI<f...@redhat.com>\fR diff --git a/packaging/libstoragemgmt.spec.in b/packaging/libstoragemgmt.spec.in index 1ca0eea..9e24faa 100644 --- a/packaging/libstoragemgmt.spec.in +++ b/packaging/libstoragemgmt.spec.in @@ -1,5 +1,6 @@ %bcond_with rest_api %bcond_without megaraid +%bcond_without hpsa # Use one-line macro for OBS workaround: # https://bugzilla.novell.com/show_bug.cgi?id=864323 @@ -9,6 +10,9 @@ %{?_with_megaraid: %global with_megaraid 1 } %{?_without_megaraid: %global with_megaraid 0 } +%{?_with_hpsa: %global with_hpsa 1 } +%{?_without_hpsa: %global with_hpsa 0 } + %define libsoname libstoragemgmt %if 0%{?suse_version} || 0%{?fedora} >= 15 || 0%{?rhel} >= 7 @@ -224,6 +228,17 @@ The %{libstoragemgmt}-megaraid-plugin package contains the plugin for LSI MegaRAID storage management via storcli. %endif +%if 0%{?with_hpsa} +%package -n %{libstoragemgmt}-hpsa-plugin +Summary: Files for HP SmartArray support for %{libstoragemgmt} +Group: System Environment/Libraries +Requires: %{libstoragemgmt}%{?_isa} = %{version}-%{release} +BuildArch: noarch + +%description -n %{libstoragemgmt}-hpsa-plugin +The %{libstoragemgmt}-hpsa-plugin package contains the plugin for HP +SmartArray storage management via hpssacli. +%endif %prep %setup -q @@ -238,6 +253,9 @@ MegaRAID storage management via storcli. %if 0%{?with_megaraid} != 1 --without-megaraid \ %endif +%if 0%{?with_hpsa} != 1 + --without-hpsa \ +%endif --disable-static V=1 make %{?_smp_mflags} @@ -450,6 +468,15 @@ if [ $1 -eq 0 ]; then fi %endif +%if 0%{?with_hpsa} +%postun -n %{libstoragemgmt}-hpsa-plugin +if [ $1 -eq 0 ]; then + # Remove + /usr/bin/systemctl try-restart libstoragemgmt.service \ + >/dev/null 2>&1 || : +fi +%endif + %files -n %{libstoragemgmt} %defattr(-,root,root,-) %doc README COPYING.LIB @@ -557,6 +584,17 @@ fi %{_mandir}/man1/megaraid_lsmplugin.1* %endif +%if 0%{?with_hpsa} +%files -n %{libstoragemgmt}-hpsa-plugin +%defattr(-,root,root,-) +%dir %{python_sitelib}/lsm/plugin/hpsa +%{python_sitelib}/lsm/plugin/hpsa/__init__.* +%{python_sitelib}/lsm/plugin/hpsa/hpsa.* +%{_bindir}/hpsa_lsmplugin +%{_sysconfdir}/lsm/pluginconf.d/hpsa.conf +%{_mandir}/man1/hpsa_lsmplugin.1* +%endif + %files udev %defattr(-,root,root,-) %{udev_dir}/udev/scan-scsi-target diff --git a/plugin/Makefile.am b/plugin/Makefile.am index f9146a8..3c35fa4 100644 --- a/plugin/Makefile.am +++ b/plugin/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS=simc megaraid +SUBDIRS=simc megaraid hpsa plugindir = $(pythondir)/lsm/plugin diff --git a/plugin/hpsa/Makefile.am b/plugin/hpsa/Makefile.am new file mode 100644 index 0000000..46344c0 --- /dev/null +++ b/plugin/hpsa/Makefile.am @@ -0,0 +1,8 @@ +if WITH_HPSA +plugindir = $(pythondir)/lsm/plugin +hpsadir = $(plugindir)/hpsa + +hpsa_PYTHON = __init__.py hpsa.py + +dist_bin_SCRIPTS= hpsa_lsmplugin +endif diff --git a/plugin/hpsa/__init__.py b/plugin/hpsa/__init__.py new file mode 100644 index 0000000..61332b4 --- /dev/null +++ b/plugin/hpsa/__init__.py @@ -0,0 +1 @@ +from lsm.plugin.hpsa.hpsa import SmartArray diff --git a/plugin/hpsa/hpsa.py b/plugin/hpsa/hpsa.py new file mode 100644 index 0000000..46a093e --- /dev/null +++ b/plugin/hpsa/hpsa.py @@ -0,0 +1,52 @@ +# Copyright (C) 2015 Red Hat, Inc. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Author: Gris Ge <f...@redhat.com> + +from lsm import ( + IPlugin, Client, Capabilities, VERSION, LsmError, ErrorNumber) + + +class SmartArray(IPlugin): + def plugin_register(self, uri, password, timeout, flags=Client.FLAG_RSVD): + pass + + def plugin_unregister(self, flags=Client.FLAG_RSVD): + pass + + def job_status(self, job_id, flags=Client.FLAG_RSVD): + raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported yet") + + def job_free(self, job_id, flags=Client.FLAG_RSVD): + pass + + def plugin_info(self, flags=Client.FLAG_RSVD): + return "HP SmartArray Plugin", VERSION + + def time_out_set(self, ms, flags=Client.FLAG_RSVD): + raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported yet") + + def time_out_get(self, flags=Client.FLAG_RSVD): + raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported yet") + + def capabilities(self, system, flags=Client.FLAG_RSVD): + return Capabilities() + + def systems(self, flags=Client.FLAG_RSVD): + raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported yet") + + def pools(self, search_key=None, search_value=None, + flags=Client.FLAG_RSVD): + raise LsmError(ErrorNumber.NO_SUPPORT, "Not supported yet") diff --git a/plugin/hpsa/hpsa_lsmplugin b/plugin/hpsa/hpsa_lsmplugin new file mode 100755 index 0000000..07230f5 --- /dev/null +++ b/plugin/hpsa/hpsa_lsmplugin @@ -0,0 +1,37 @@ +#!/usr/bin/env python2 +# Copyright (C) 2015 Red Hat, Inc. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Author: tasleson +# Gris Ge <f...@redhat.com> + +import sys +import syslog +import traceback + +try: + from lsm import PluginRunner + from lsm.plugin.hpsa import SmartArray + + if __name__ == '__main__': + PluginRunner(SmartArray, sys.argv).run() +except Exception: + #This should be quite rare, but when it does happen this is pretty + #key in understanding what happened, especially when it happens when + #running from the daemon. + msg = str(traceback.format_exc()) + syslog.syslog(syslog.LOG_ERR, msg) + sys.stderr.write(msg) + sys.exit(1) -- 1.8.3.1 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Libstoragemgmt-devel mailing list Libstoragemgmt-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libstoragemgmt-devel