Accepting request 618996 from network:ha-clustering:Factory

- Unify spec file for python 2 and 3
- Enable build for python 2
  * Add 0002-Build-without-openwsman-installed.patch

OBS-URL: https://build.opensuse.org/request/show/618996
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/fence-agents?expand=0&rev=41
This commit is contained in:
Dominique Leuenberger 2018-06-27 08:21:45 +00:00 committed by Git OBS Bridge
commit a1c5ce041e
3 changed files with 163 additions and 14 deletions

View File

@ -0,0 +1,108 @@
From 36fe441cda4f59400b18f558a668d025123b1129 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <krig@koru.se>
Date: Mon, 25 Jun 2018 16:43:38 +0200
Subject: [PATCH] Build without openwsman installed
---
agents/amt_ws/fence_amt_ws.py | 21 +++++++++++++--------
configure.ac | 14 +++++++-------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/agents/amt_ws/fence_amt_ws.py b/agents/amt_ws/fence_amt_ws.py
index b99f20ad..bb0f58f5 100755
--- a/agents/amt_ws/fence_amt_ws.py
+++ b/agents/amt_ws/fence_amt_ws.py
@@ -24,9 +24,14 @@ sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
from fencing import run_delay, fail_usage, fail, EC_STATUS
-import pywsman
from xml.etree import ElementTree
+
+def _pywsman():
+ import pywsman
+ return pywsman
+
+
POWER_ON='2'
POWER_OFF='8'
POWER_CYCLE='10'
@@ -63,7 +68,7 @@ def _generate_power_action_input(action):
wsman = 'http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'
namespace = CIM_PowerManagementService
- doc = pywsman.XmlDoc(method_input)
+ doc = _pywsman().XmlDoc(method_input)
root = doc.root()
root.set_ns(namespace)
root.add(namespace, 'PowerState', action)
@@ -80,10 +85,10 @@ def _generate_power_action_input(action):
return doc
def get_power_status(_, options):
- client = pywsman.Client(options["--ip"], int(options["--ipport"]), \
+ client = _pywsman().Client(options["--ip"], int(options["--ipport"]), \
'/wsman', 'http', 'admin', options["--password"])
namespace = CIM_AssociatedPowerManagementService
- client_options = pywsman.ClientOptions()
+ client_options = _pywsman().ClientOptions()
doc = client.get(client_options, namespace)
_SOAP_ENVELOPE = 'http://www.w3.org/2003/05/soap-envelope'
item = 'Fault'
@@ -107,11 +112,11 @@ def get_power_status(_, options):
fail(EC_STATUS)
def set_power_status(_, options):
- client = pywsman.Client(options["--ip"], int(options["--ipport"]), \
+ client = _pywsman().Client(options["--ip"], int(options["--ipport"]), \
'/wsman', 'http', 'admin', options["--password"])
method = 'RequestPowerStateChange'
- client_options = pywsman.ClientOptions()
+ client_options = _pywsman().ClientOptions()
client_options.add_selector('Name', 'Intel(r) AMT Power Management Service')
if options["--action"] == "on":
@@ -156,11 +161,11 @@ def set_boot_order(_, client, options):
return
method = 'ChangeBootOrder'
- client_options = pywsman.ClientOptions()
+ client_options = _pywsman().ClientOptions()
client_options.add_selector('InstanceID', \
'Intel(r) AMT: Boot Configuration 0')
- doc = pywsman.XmlDoc(method_input)
+ doc = _pywsman().XmlDoc(method_input)
root = doc.root()
root.set_ns(namespace)
diff --git a/configure.ac b/configure.ac
index e8b24211..c4db8a47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -208,13 +208,13 @@ AC_PYTHON_MODULE(pexpect, 1)
AC_PYTHON_MODULE(pycurl, 1)
AC_PYTHON_MODULE(requests, 1)
-if echo "$AGENTS_LIST" | grep -q amt_ws; then
- AC_PYTHON_MODULE(pywsman)
- if test "x${HAVE_PYMOD_PYWSMAN}" != xyes; then
- AGENTS_LIST=$(echo "$AGENTS_LIST" | sed -E "s#amt_ws/fence_amt_ws.py( |$)##")
- AC_MSG_WARN("Not building fence_amt_ws")
- fi
-fi
+#if echo "$AGENTS_LIST" | grep -q amt_ws; then
+# AC_PYTHON_MODULE(pywsman)
+# if test "x${HAVE_PYMOD_PYWSMAN}" != xyes; then
+# AGENTS_LIST=$(echo "$AGENTS_LIST" | sed -E "s#amt_ws/fence_amt_ws.py( |$)##")
+# AC_MSG_WARN("Not building fence_amt_ws")
+# fi
+#fi
if echo "$AGENTS_LIST" | grep -q aws; then
AC_PYTHON_MODULE(boto3)
if test "x${HAVE_PYMOD_BOTO3}" != xyes; then
--
2.17.1

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Jun 25 14:44:46 UTC 2018 - kgronlund@suse.com
- Unify spec file for python 2 and 3
- Enable build for python 2
* Add 0002-Build-without-openwsman-installed.patch
-------------------------------------------------------------------
Wed Jun 20 09:06:43 UTC 2018 - kgronlund@suse.com

View File

@ -16,6 +16,12 @@
#
%if 0%{?suse_version} == 1315
%define python_version python2
%else
%define python_version python3
%endif
%global plugin_dir %{_libdir}/stonith/plugins/rhcs
%define agent_list alom amt amt_ws apc apc_snmp azure_arm bladecenter brocade cisco_mds cisco_ucs compute docker drac5 dummy eaton_snmp emerson eps evacuate gce hds_cb hpblade ibmblade ifmib ilo ilo_moonshot ilo_mp ilo_ssh intelmodular ipdu ipmilan ironic kdump ldom lpar mpath netio openstack powerman pve raritan rcd_serial rhevm rsa rsb sanbox2 sbd scsi vbox virsh vmware vmware_rest wti xenapi zvm
@ -28,8 +34,30 @@ Release: 0
Url: https://github.com/ClusterLabs/fence-agents
Source0: %{name}-%{version}.tar.xz
Patch1: 0001-Use-Python-3-for-all-scripts-bsc-1065966.patch
Patch2: 0002-Build-without-openwsman-installed.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: %{python_version}
%if %{python_version} == "python3"
BuildRequires: python3-google-api-python-client
BuildRequires: python3-keystoneclient
BuildRequires: python3-novaclient
BuildRequires: python3-oauth2client
BuildRequires: python3-openwsman
BuildRequires: python3-pexpect
BuildRequires: python3-pycurl
BuildRequires: python3-requests
BuildRequires: python3-xml
%else
BuildRequires: python-google-api-python-client
BuildRequires: python-keystoneclient
BuildRequires: python-novaclient
BuildRequires: python-oauth2client
BuildRequires: python-pexpect
BuildRequires: python-pycurl
BuildRequires: python-requests
BuildRequires: python-xml
%endif
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: fdupes
@ -42,24 +70,20 @@ BuildRequires: mozilla-nss-devel
BuildRequires: perl
BuildRequires: perl-Net-Telnet
BuildRequires: pkg-config
BuildRequires: python3
BuildRequires: python3-google-api-python-client
BuildRequires: python3-keystoneclient
BuildRequires: python3-novaclient
BuildRequires: python3-oauth2client
BuildRequires: python3-openwsman
BuildRequires: python3-pexpect
BuildRequires: python3-pycurl
BuildRequires: python3-requests
BuildRequires: python3-xml
BuildRequires: xz
Requires: net-snmp
Requires: openssh
Requires: perl-Net-Telnet
%if %{python_version} == "python3"
Requires: python3-pexpect
Requires: python3-pycurl
Requires: python3-requests
%else
Requires: python-pexpect
Requires: python-pycurl
Requires: python-requests
%endif
Requires: net-snmp
Requires: openssh
Requires: perl-Net-Telnet
Requires: sg3_utils
Requires: telnet
@ -71,7 +95,9 @@ Recommends: /usr/bin/virsh
# have changed Requires around. Make sure to get the right one.
Recommends: /usr/bin/ipmitool
%if %{python_version} == "python3"
Recommends: python3-openwsman
%endif
%if 0%{?with_regression_tests}
BuildRequires: time
@ -98,12 +124,20 @@ development.
%prep
%setup -q -n %{name}-%{version}
%if %{python_version} == "python3"
%patch1 -p1
%else
%patch2 -p1
%endif
%build
CFLAGS="${CFLAGS} ${RPM_OPT_FLAGS}"
export CFLAGS
%if %{python_version} == "python3"
PYTHON="%{_bindir}/python3"
%else
PYTHON="%{_bindir}/python2"
%endif
export PYTHON
./autogen.sh
%{configure} --with-agents='%{agent_list}'
@ -126,7 +160,7 @@ ln -s %{_sbindir}/fence_cisco_ucs %{buildroot}%{plugin_dir}
%if 0%{?with_regression_tests}
%check
make check
PYTHONPATH=fence/agents/lib python fence/agents/lib/tests/test_fencing.py
PYTHONPATH=fence/agents/lib %{python_version} fence/agents/lib/tests/test_fencing.py
%endif
%files