diff --color -uNr a/agents/azure_arm/fence_azure_arm.py b/agents/azure_arm/fence_azure_arm.py
--- a/agents/azure_arm/fence_azure_arm.py 2020-06-30 11:26:43.000000000 +0200
+++ b/agents/azure_arm/fence_azure_arm.py 2021-06-03 13:16:16.547120822 +0200
@@ -1,6 +1,11 @@
#!@PYTHON@ -tt
-import sys, re, pexpect
+import sys, re
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
import logging
import atexit
import xml.etree.ElementTree as ET
diff --color -uNr a/agents/hpblade/fence_hpblade.py b/agents/hpblade/fence_hpblade.py
--- a/agents/hpblade/fence_hpblade.py 2019-08-16 10:55:11.000000000 +0200
+++ b/agents/hpblade/fence_hpblade.py 2021-06-03 13:16:16.547120822 +0200
@@ -8,7 +8,11 @@
#####
import sys, re
-import pexpect
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
diff --color -uNr a/agents/ilo/fence_ilo.py b/agents/ilo/fence_ilo.py
--- a/agents/ilo/fence_ilo.py 2019-02-04 09:45:05.000000000 +0100
+++ b/agents/ilo/fence_ilo.py 2021-06-03 13:16:16.547120822 +0200
@@ -11,7 +11,12 @@
## iLO2 / firmware 1.50 / RIBCL 2.22
#####
-import sys, re, pexpect
+import sys, re
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
import atexit
from xml.sax.saxutils import quoteattr
sys.path.append("@FENCEAGENTSLIBDIR@")
diff --color -uNr a/agents/ldom/fence_ldom.py b/agents/ldom/fence_ldom.py
--- a/agents/ldom/fence_ldom.py 2019-02-04 09:45:05.000000000 +0100
+++ b/agents/ldom/fence_ldom.py 2021-06-03 13:16:16.547120822 +0200
@@ -7,7 +7,12 @@
##
#####
-import sys, re, pexpect
+import sys, re
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
diff --color -uNr a/agents/Makefile.am b/agents/Makefile.am
--- a/agents/Makefile.am 2021-03-16 12:26:37.000000000 +0100
+++ b/agents/Makefile.am 2021-06-03 13:16:16.547120822 +0200
@@ -112,10 +112,10 @@
cisco_mds/fence_cisco_mds.delay-check: cisco_mds/fence_cisco_mds
$(eval INPUT=$(subst .delay-check,,$@))
FENCE_TEST_ARGS_CISCO_MDS=$$(printf '$(FENCE_TEST_ARGS)' | sed 's#port=1#port=fc1/1#'); \
- test `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib /usr/bin/time -p \
+ test `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common /usr/bin/time -p \
sh -c "printf 'delay=10\n $$FENCE_TEST_ARGS_CISCO_MDS' | $(PYTHON) ./$(INPUT)" 2>&1 |\
awk -F"[. ]" -vOFS= '/real/ {print $$2,$$3}'` -ge 1000 || ( \
- PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib /usr/bin/time -p \
+ PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common /usr/bin/time -p \
sh -c "printf "delay=0\n $$FENCE_TEST_ARGS_CISCO_MDS" | $(PYTHON) ./$(INPUT)"; false )
include $(top_srcdir)/make/fencebuild.mk
diff --color -uNr a/agents/netio/fence_netio.py b/agents/netio/fence_netio.py
--- a/agents/netio/fence_netio.py 2019-02-04 09:45:05.000000000 +0100
+++ b/agents/netio/fence_netio.py 2021-06-03 13:16:16.547120822 +0200
@@ -1,6 +1,11 @@
#!@PYTHON@ -tt
-import sys, re, pexpect
+import sys, re
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
diff --color -uNr a/agents/raritan/fence_raritan.py b/agents/raritan/fence_raritan.py
--- a/agents/raritan/fence_raritan.py 2019-08-16 10:55:11.000000000 +0200
+++ b/agents/raritan/fence_raritan.py 2021-06-03 13:16:16.547120822 +0200
@@ -1,6 +1,11 @@
#!@PYTHON@ -tt
-import sys, re, pexpect
+import sys, re
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
diff --color -uNr a/agents/sanbox2/fence_sanbox2.py b/agents/sanbox2/fence_sanbox2.py
--- a/agents/sanbox2/fence_sanbox2.py 2019-02-11 13:05:48.000000000 +0100
+++ b/agents/sanbox2/fence_sanbox2.py 2021-06-03 13:16:16.547120822 +0200
@@ -8,7 +8,12 @@
## +-----------------+---------------------------+
#####
-import sys, re, pexpect
+import sys, re
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
import logging
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
diff --color -uNr a/agents/vmware/fence_vmware.py b/agents/vmware/fence_vmware.py
--- a/agents/vmware/fence_vmware.py 2019-02-04 09:45:05.000000000 +0100
+++ b/agents/vmware/fence_vmware.py 2021-06-03 13:16:16.547120822 +0200
@@ -22,7 +22,12 @@
# VMware vCenter 4.0.0
#
-import sys, re, pexpect
+import sys, re
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
import logging
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
diff --color -uNr a/agents/wti/fence_wti.py b/agents/wti/fence_wti.py
--- a/agents/wti/fence_wti.py 2019-02-04 09:45:05.000000000 +0100
+++ b/agents/wti/fence_wti.py 2021-06-03 13:17:33.435380703 +0200
@@ -11,12 +11,21 @@
## WTI IPS-800-CE v1.40h (no username) ('list' tested)
#####
-import sys, re, pexpect
+import sys, re
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
import atexit
import time
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fspawn, fail, fail_usage, EC_LOGIN_DENIED
+from fencing import fail, fail_usage, EC_LOGIN_DENIED
+try:
+ from fencing import fspawn
+except ImportError:
+ pass
def get_listing(conn, options, listing_command):
listing = ""
diff --color -uNr a/lib/fencing.py.py b/lib/fencing.py.py
--- a/lib/fencing.py.py 2021-06-03 10:34:00.000000000 +0200
+++ b/lib/fencing.py.py 2021-06-03 13:16:16.548120826 +0200
@@ -1,7 +1,12 @@
#!@PYTHON@ -tt
import sys, getopt, time, os, uuid, pycurl, stat
-import pexpect, re, syslog
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
+import re, syslog
import logging
import subprocess
import threading
@@ -491,29 +496,32 @@
"snmpset_path", "snmpget_path", "snmpwalk_path"]
}
-class fspawn(pexpect.spawn):
- def __init__(self, options, command, **kwargs):
- if sys.version_info[0] > 2:
- kwargs.setdefault('encoding', 'utf-8')
- logging.info("Running command: %s", command)
- pexpect.spawn.__init__(self, command, **kwargs)
- self.opt = options
-
- def log_expect(self, pattern, timeout):
- result = self.expect(pattern, timeout if timeout != 0 else None)
- logging.debug("Received: %s", self.before + self.after)
- return result
-
- def read_nonblocking(self, size, timeout):
- return pexpect.spawn.read_nonblocking(self, size=100, timeout=timeout if timeout != 0 else None)
-
- def send(self, message):
- logging.debug("Sent: %s", message)
- return pexpect.spawn.send(self, message)
-
- # send EOL according to what was detected in login process (telnet)
- def send_eol(self, message):
- return self.send(message + self.opt["eol"])
+try:
+ class fspawn(pexpect.spawn):
+ def __init__(self, options, command, **kwargs):
+ if sys.version_info[0] > 2:
+ kwargs.setdefault('encoding', 'utf-8')
+ logging.info("Running command: %s", command)
+ pexpect.spawn.__init__(self, command, **kwargs)
+ self.opt = options
+
+ def log_expect(self, pattern, timeout):
+ result = self.expect(pattern, timeout if timeout != 0 else None)
+ logging.debug("Received: %s", self.before + self.after)
+ return result
+
+ def read_nonblocking(self, size, timeout):
+ return pexpect.spawn.read_nonblocking(self, size=100, timeout=timeout if timeout != 0 else None)
+
+ def send(self, message):
+ logging.debug("Sent: %s", message)
+ return pexpect.spawn.send(self, message)
+
+ # send EOL according to what was detected in login process (telnet)
+ def send_eol(self, message):
+ return self.send(message + self.opt["eol"])
+except:
+ pass
def frun(command, timeout=30, withexitstatus=False, events=None,
extra_args=None, logfile=None, cwd=None, env=None, **kwargs):
diff --color -uNr a/lib/fencing_snmp.py.py b/lib/fencing_snmp.py.py
--- a/lib/fencing_snmp.py.py 2019-02-04 09:45:05.000000000 +0100
+++ b/lib/fencing_snmp.py.py 2021-06-03 13:16:16.548120826 +0200
@@ -2,7 +2,13 @@
# For example of use please see fence_cisco_mds
-import re, pexpect
+import sys
+sys.path.insert(0, '/usr/lib/fence-agents/support/common')
+try:
+ import pexpect
+except:
+ pass
+import re
import logging
from fencing import *
from fencing import fail, fail_usage, EC_TIMED_OUT, run_delay, frun
diff --color -uNr a/make/agentpycheck.mk b/make/agentpycheck.mk
--- a/make/agentpycheck.mk 2020-06-30 11:26:43.000000000 +0200
+++ b/make/agentpycheck.mk 2021-06-03 13:16:16.548120826 +0200
@@ -9,34 +9,34 @@
%.xml-check: %.8
$(eval INPUT=$(subst .xml-check,,$(@F)))
- for x in $(INPUT) `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $(@D)/$(INPUT) -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
+ for x in $(INPUT) `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $(@D)/$(INPUT) -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
TEMPFILE=$$(mktemp); \
- PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $(@D)/$$x -o metadata | $(AWK) $(AWK_VAL) > $$TEMPFILE && \
+ PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $(@D)/$$x -o metadata | $(AWK) $(AWK_VAL) > $$TEMPFILE && \
diff $$TEMPFILE $(DATADIR)/$$x.xml || exit 1 && \
rm $$TEMPFILE; \
done
%.xml-upload: %.8
$(eval INPUT=$(subst .xml-upload,,$(@F)))
- for x in $(INPUT) `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $(@D)/$(INPUT) -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
- PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $(@D)/$$x -o metadata | $(AWK) $(AWK_VAL) > $(DATADIR)/$$x.xml; \
+ for x in $(INPUT) `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $(@D)/$(INPUT) -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
+ PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $(@D)/$$x -o metadata | $(AWK) $(AWK_VAL) > $(DATADIR)/$$x.xml; \
done
# If test will fail, rerun fence agents to show problems
%.delay-check: %
$(eval INPUT=$(subst .delay-check,,$(@F)))
- for x in $(INPUT) `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $(@D)/$(INPUT) -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
- test `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib /usr/bin/time -p \
+ for x in $(INPUT) `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $(@D)/$(INPUT) -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
+ test `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common /usr/bin/time -p \
sh -c "printf 'delay=10\n $(FENCE_TEST_ARGS)' | $(PYTHON) $(@D)/$$x" 2>&1 |\
awk -F"[. ]" -vOFS= '/real/ {print $$2,$$3}'` -ge 1000 || ( \
- PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib /usr/bin/time -p \
+ PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common /usr/bin/time -p \
sh -c "printf 'delay=0\n $(FENCE_TEST_ARGS)' | $(PYTHON) $(@D)/$$x"; false ); \
done
%.rng-check: %
$(eval INPUT=$(subst .rng-check,,$(@F)))
- for x in $(INPUT) `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $(@D)/$(INPUT) -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
- PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $(@D)/$$x -o metadata | \
+ for x in $(INPUT) `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $(@D)/$(INPUT) -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
+ PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $(@D)/$$x -o metadata | \
xsltproc ${abs_top_srcdir}/lib/fence2rng.xsl - | \
sed -e 's/ rha:description=/ description=/g' -e 's/ rha:name=/ name=/g' | \
xmllint --nsclean --noout -; \
diff --color -uNr a/make/fencebuild.mk b/make/fencebuild.mk
--- a/make/fencebuild.mk 2021-03-16 09:32:22.000000000 +0100
+++ b/make/fencebuild.mk 2021-06-03 13:16:16.548120826 +0200
@@ -34,10 +34,10 @@
> $@
if [ 0 -eq `echo "$(@)" | grep fence_ > /dev/null 2>&1; echo $$?` ]; then \
- PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $(top_srcdir)/lib/check_used_options.py $@; \
+ PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $(top_srcdir)/lib/check_used_options.py $@; \
else true ; fi
- for x in `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $(@) -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
+for x in `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $(@) -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
cp -f $(@) $(@D)/$$x; \
$(MAKE) $(@D)/$$x.8; \
done
@@ -64,7 +64,7 @@
fi
for p in $(TARGET); do \
dir=`dirname $$p`; \
- for x in `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $$p -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
+ for x in `PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $$p -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"`; do \
echo " $(INSTALL_SCRIPT) $$dir/$$x '$(DESTDIR)$(sbindir)'"; \
$(INSTALL_SCRIPT) $$dir/$$x "$(DESTDIR)$(sbindir)" || exit $$?; \
echo " $(INSTALL_DATA) '$$dir/$$x.8' '$(DESTDIR)$(man8dir)'"; \
@@ -74,7 +74,7 @@
uninstall-hook: $(TARGET)
files=`for p in $(TARGET); do \
- for x in \`PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib $(PYTHON) $$p -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"\`; do \
+ for x in \`PYTHONPATH=$(abs_top_srcdir)/lib:$(abs_top_builddir)/lib:$(abs_top_builddir)/support/common $(PYTHON) $$p -o metadata | grep symlink | sed -e "s/.*\(fence.*\)\" .*/\1/g"\`; do \
echo " rm -f '$(DESTDIR)$(sbindir)/$$x'"; \
rm -f "$(DESTDIR)$(sbindir)/$$x"; \
echo " rm -f '$(DESTDIR)$(man8dir)/$$x.8'"; \
diff --color -uNr a/make/fenceman.mk b/make/fenceman.mk
--- a/make/fenceman.mk 2021-03-11 16:10:15.000000000 +0100
+++ b/make/fenceman.mk 2021-06-03 13:16:16.548120826 +0200
@@ -1,6 +1,6 @@
%.8: % $(top_srcdir)/lib/fence2man.xsl
set -e && \
- PYTHONPATH=$(abs_srcdir)/lib:$(abs_builddir)/../lib:$(abs_builddir)/lib \
+ PYTHONPATH=$(abs_srcdir)/lib:$(abs_builddir)/../lib:$(abs_builddir)/lib:$(abs_top_builddir)/support/common \
$(PYTHON) $* -o manpage > $(@D)/.$(@F).tmp && \
xmllint --noout --relaxng $(top_srcdir)/lib/metadata.rng $(@D)/.$(@F).tmp && \
xsltproc $(top_srcdir)/lib/fence2man.xsl $(@D)/.$(@F).tmp > $@