- new upstream release

Resolves: RHEL-45835
This commit is contained in:
Oyvind Albrigtsen 2024-07-02 09:43:56 +02:00
parent d73f335ced
commit 82be7637d1
5 changed files with 14 additions and 637 deletions

View File

@ -1,531 +0,0 @@
From 55c7c987bd5e377db9bcaeb9a4f487397c12a128 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Wed, 20 Mar 2024 12:21:48 +0100
Subject: [PATCH] lib/all agents: use r"" for all regular expressions to avoid
SyntaxWarning errors
---
agents/alom/fence_alom.py | 2 +-
agents/amt/fence_amt.py | 2 +-
agents/apc/fence_apc.py | 18 +++++++++---------
agents/azure_arm/fence_azure_arm.py | 2 +-
agents/cdu/fence_cdu.py | 8 ++++----
agents/cisco_ucs/fence_cisco_ucs.py | 14 +++++++-------
agents/gce/fence_gce.py | 6 +++---
agents/ilo/fence_ilo.py | 2 +-
agents/ilo_mp/fence_ilo_mp.py | 2 +-
agents/ilo_ssh/fence_ilo_ssh.py | 2 +-
agents/ipmilan/fence_ipmilan.py | 6 +++---
agents/ironic/fence_ironic.py | 4 ++--
agents/lpar/fence_lpar.py | 10 +++++-----
agents/netio/fence_netio.py | 2 +-
agents/raritan/fence_raritan.py | 2 +-
agents/rhevm/fence_rhevm.py | 10 +++++-----
agents/rsa/fence_rsa.py | 2 +-
agents/wti/fence_wti.py | 6 +++---
lib/azure_fence.py.py | 2 +-
lib/fencing.py.py | 12 ++++++------
lib/fencing_snmp.py.py | 2 +-
21 files changed, 58 insertions(+), 58 deletions(-)
diff --git a/agents/alom/fence_alom.py b/agents/alom/fence_alom.py
index a8e216f3f..e593f16b5 100644
--- a/agents/alom/fence_alom.py
+++ b/agents/alom/fence_alom.py
@@ -13,7 +13,7 @@
def get_power_status(conn, options):
conn.send_eol("showplatform")
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
- status = re.search("standby", conn.before.lower())
+ status = re.search(r"standby", conn.before.lower())
result = (status != None and "off" or "on")
return result
diff --git a/agents/amt/fence_amt.py b/agents/amt/fence_amt.py
index 183bbc713..67e2112d3 100644
--- a/agents/amt/fence_amt.py
+++ b/agents/amt/fence_amt.py
@@ -13,7 +13,7 @@
def get_power_status(_, options):
output = amt_run_command(options, create_command(options, "status"))
- match = re.search('Powerstate:[\\s]*(..)', str(output))
+ match = re.search(r'Powerstate:[\s]*(..)', str(output))
status = match.group(1) if match else None
if status == None:
diff --git a/agents/apc/fence_apc.py b/agents/apc/fence_apc.py
index bc52aa244..805b83141 100644
--- a/agents/apc/fence_apc.py
+++ b/agents/apc/fence_apc.py
@@ -36,21 +36,21 @@ def get_power_status(conn, options):
admin = 0
switch = 0
- if None != re.compile('.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before):
+ if None != re.compile(r'.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before):
switch = 1
- if None != re.compile('.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before):
+ if None != re.compile(r'.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before):
if "--switch" not in options:
fail_usage("Failed: You have to enter physical switch number")
else:
if "--switch" not in options:
options["--switch"] = "1"
- if None == re.compile('.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before):
+ if None == re.compile(r'.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before):
version = 2
else:
version = 3
- if None == re.compile('.*Outlet Control/Configuration.*', re.IGNORECASE | re.S).match(conn.before):
+ if None == re.compile(r'.*Outlet Control/Configuration.*', re.IGNORECASE | re.S).match(conn.before):
admin = 0
else:
admin = 1
@@ -109,26 +109,26 @@ def set_power_status(conn, options):
admin3 = 0
switch = 0
- if None != re.compile('.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before):
+ if None != re.compile(r'.* MasterSwitch plus.*', re.IGNORECASE | re.S).match(conn.before):
switch = 1
## MasterSwitch has different schema for on/off actions
action = {
'on' : "1",
'off': "3"
}[options["--action"]]
- if None != re.compile('.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before):
+ if None != re.compile(r'.* MasterSwitch plus 2', re.IGNORECASE | re.S).match(conn.before):
if "--switch" not in options:
fail_usage("Failed: You have to enter physical switch number")
else:
if "--switch" not in options:
options["--switch"] = 1
- if None == re.compile('.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before):
+ if None == re.compile(r'.*Outlet Management.*', re.IGNORECASE | re.S).match(conn.before):
version = 2
else:
version = 3
- if None == re.compile('.*Outlet Control/Configuration.*', re.IGNORECASE | re.S).match(conn.before):
+ if None == re.compile(r'.*Outlet Control/Configuration.*', re.IGNORECASE | re.S).match(conn.before):
admin2 = 0
else:
admin2 = 1
@@ -142,7 +142,7 @@ def set_power_status(conn, options):
else:
conn.send_eol("2")
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
- if None == re.compile('.*2- Outlet Restriction.*', re.IGNORECASE | re.S).match(conn.before):
+ if None == re.compile(r'.*2- Outlet Restriction.*', re.IGNORECASE | re.S).match(conn.before):
admin3 = 0
else:
admin3 = 1
diff --git a/agents/azure_arm/fence_azure_arm.py b/agents/azure_arm/fence_azure_arm.py
index 0dca8f30d..227a7c2e2 100755
--- a/agents/azure_arm/fence_azure_arm.py
+++ b/agents/azure_arm/fence_azure_arm.py
@@ -251,7 +251,7 @@ def main():
except ImportError:
fail_usage("Azure Resource Manager Python SDK not found or not accessible")
except Exception as e:
- fail_usage("Failed: %s" % re.sub("^, ", "", str(e)))
+ fail_usage("Failed: %s" % re.sub(r"^, ", r"", str(e)))
if "--network-fencing" in options:
# use off-action to quickly return off once network is fenced instead of
diff --git a/agents/cdu/fence_cdu.py b/agents/cdu/fence_cdu.py
index ba76e6d76..6373158e9 100644
--- a/agents/cdu/fence_cdu.py
+++ b/agents/cdu/fence_cdu.py
@@ -51,11 +51,11 @@ def get_power_status(conn, options):
if options["api-version"] == "8":
# AA13 Arm-Console3 Wake On On Normal
# AA14 Master_Outlet_14 Wake On On Normal
- show_re = re.compile('(\w+)\s+(\S+)\s+(On|Idle On|Off|Wake On)\s+(On|Off)')
+ show_re = re.compile(r'(\w+)\s+(\S+)\s+(On|Idle On|Off|Wake On)\s+(On|Off)')
else:
# .A12 TowerA_Outlet12 On Idle On
# .A12 test-01 On Idle On
- show_re = re.compile('(\.\w+)\s+(\w+|\w+\W\w+)\s+(On|Off)\s+(On|Idle On|Off|Wake On)')
+ show_re = re.compile(r'(\.\w+)\s+(\w+|\w+\W\w+)\s+(On|Off)\s+(On|Idle On|Off|Wake On)')
for line in lines:
res = show_re.search(line)
if res != None:
@@ -89,7 +89,7 @@ def set_power_status(conn, options):
# else:
# .A12 TowerA_Outlet12
# .A12 test-01
- show_re = re.compile('(\S+)\s+(\w+|\w+\W\w+)\s+')
+ show_re = re.compile(r'(\S+)\s+(\w+|\w+\W\w+)\s+')
for line in lines:
res = show_re.search(line)
if res != None:
@@ -112,7 +112,7 @@ def get_version(conn, options):
conn.send("VERSION\r\n")
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
lines = conn.before.split("\n")
- show_re = re.compile('Sentry Switched [PC]DU Version (\d)(.\d|)(\w)\r')
+ show_re = re.compile(r'Sentry Switched [PC]DU Version (\d)(.\d|)(\w)\r')
for line in lines:
res = show_re.search(line)
if res != None:
diff --git a/agents/cisco_ucs/fence_cisco_ucs.py b/agents/cisco_ucs/fence_cisco_ucs.py
index cada20d5e..bcfabdbaa 100644
--- a/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/agents/cisco_ucs/fence_cisco_ucs.py
@@ -8,13 +8,13 @@
from fencing import *
from fencing import fail, EC_STATUS, EC_LOGIN_DENIED, run_delay
-RE_COOKIE = re.compile("<aaaLogin .* outCookie=\"(.*?)\"", re.IGNORECASE)
-RE_STATUS = re.compile("<lsPower .*? state=\"(.*?)\"", re.IGNORECASE)
-RE_GET_DN = re.compile(" dn=\"(.*?)\"", re.IGNORECASE)
-RE_GET_PNDN = re.compile(" pndn=\"(.*?)\"", re.IGNORECASE)
-RE_GET_DESC = re.compile(" descr=\"(.*?)\"", re.IGNORECASE)
-RE_GET_OPERPOWER = re.compile(" operPower=\"(.*?)\"", re.IGNORECASE)
-RE_GET_PRESENCE = re.compile(" presence=\"(.*?)\"", re.IGNORECASE)
+RE_COOKIE = re.compile(r"<aaaLogin .* outCookie=\"(.*?)\"", re.IGNORECASE)
+RE_STATUS = re.compile(r"<lsPower .*? state=\"(.*?)\"", re.IGNORECASE)
+RE_GET_DN = re.compile(r" dn=\"(.*?)\"", re.IGNORECASE)
+RE_GET_PNDN = re.compile(r" pndn=\"(.*?)\"", re.IGNORECASE)
+RE_GET_DESC = re.compile(r" descr=\"(.*?)\"", re.IGNORECASE)
+RE_GET_OPERPOWER = re.compile(r" operPower=\"(.*?)\"", re.IGNORECASE)
+RE_GET_PRESENCE = re.compile(r" presence=\"(.*?)\"", re.IGNORECASE)
options_global = None
diff --git a/agents/gce/fence_gce.py b/agents/gce/fence_gce.py
index b8871038e..759567c6f 100644
--- a/agents/gce/fence_gce.py
+++ b/agents/gce/fence_gce.py
@@ -85,8 +85,8 @@ def replace_api_uri(options, http_request):
uri_replacements.append(
{
"matchlength": 4,
- "match": "https://compute.googleapis.com/compute/v1/projects/(.*)/zones/(.*)/instances/(.*)/reset(.*)",
- "replace": "https://baremetalsolution.googleapis.com/v1/projects/\\1/locations/\\2/instances/\\3:resetInstance\\4"
+ "match": r"https://compute.googleapis.com/compute/v1/projects/(.*)/zones/(.*)/instances/(.*)/reset(.*)",
+ "replace": r"https://baremetalsolution.googleapis.com/v1/projects/\1/locations/\2/instances/\3:resetInstance\4"
})
for uri_replacement in uri_replacements:
# each uri_replacement should have matchlength, match, and replace
@@ -97,7 +97,7 @@ def replace_api_uri(options, http_request):
if match is None or len(match.groups()) != uri_replacement["matchlength"]:
continue
replaced_uri = re.sub(uri_replacement["match"], uri_replacement["replace"], http_request.uri)
- match = re.match("https:\/\/.*.googleapis.com", replaced_uri)
+ match = re.match(r"https:\/\/.*.googleapis.com", replaced_uri)
if match is None or match.start() != 0:
logging.warning("FENCE_GCE_URI_REPLACEMENTS replace is not "
"targeting googleapis.com, ignoring it: %s" % replaced_uri)
diff --git a/agents/ilo/fence_ilo.py b/agents/ilo/fence_ilo.py
index f30a1da28..9b9c08329 100644
--- a/agents/ilo/fence_ilo.py
+++ b/agents/ilo/fence_ilo.py
@@ -106,7 +106,7 @@ def main():
fail(EC_LOGIN_DENIED)
try:
- version = re.compile("<RIBCL VERSION=\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
+ version = re.compile(r"<RIBCL VERSION=\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
if "--ribcl-version" not in options:
options["--ribcl-version"] = float(version)
diff --git a/agents/ilo_mp/fence_ilo_mp.py b/agents/ilo_mp/fence_ilo_mp.py
index cc1c2decd..32530e947 100644
--- a/agents/ilo_mp/fence_ilo_mp.py
+++ b/agents/ilo_mp/fence_ilo_mp.py
@@ -8,7 +8,7 @@
def get_power_status(conn, options):
conn.send_eol("show /system1")
- re_state = re.compile('EnabledState=(.*)', re.IGNORECASE)
+ re_state = re.compile(r'EnabledState=(.*)', re.IGNORECASE)
conn.log_expect(re_state, int(options["--shell-timeout"]))
status = conn.match.group(1).lower()
diff --git a/agents/ilo_ssh/fence_ilo_ssh.py b/agents/ilo_ssh/fence_ilo_ssh.py
index 1d5be21ef..6f1d37688 100644
--- a/agents/ilo_ssh/fence_ilo_ssh.py
+++ b/agents/ilo_ssh/fence_ilo_ssh.py
@@ -9,7 +9,7 @@
def get_power_status(conn, options):
conn.send_eol("show /system1")
- re_state = re.compile('EnabledState=(.*)', re.IGNORECASE)
+ re_state = re.compile(r'EnabledState=(.*)', re.IGNORECASE)
conn.log_expect(re_state, int(options["--shell-timeout"]))
status = conn.match.group(1).lower()
diff --git a/agents/ipmilan/fence_ipmilan.py b/agents/ipmilan/fence_ipmilan.py
index a47fbdd82..083186201 100644
--- a/agents/ipmilan/fence_ipmilan.py
+++ b/agents/ipmilan/fence_ipmilan.py
@@ -13,7 +13,7 @@
def get_power_status(_, options):
output = _run_command(options, "status")
- match = re.search('[Cc]hassis [Pp]ower is [\\s]*([a-zA-Z]{2,3})', str(output))
+ match = re.search(r'[Cc]hassis [Pp]ower is [\s]*([a-zA-Z]{2,3})', str(output))
status = match.group(1) if match else None
return status
@@ -23,11 +23,11 @@ def set_power_status(_, options):
def reboot_cycle(_, options):
output = _run_command(options, "cycle")
- return bool(re.search('chassis power control: cycle', str(output).lower()))
+ return bool(re.search(r'chassis power control: cycle', str(output).lower()))
def reboot_diag(_, options):
output = _run_command(options, "diag")
- return bool(re.search('chassis power control: diag', str(output).lower()))
+ return bool(re.search(r'chassis power control: diag', str(output).lower()))
def _run_command(options, action):
cmd, log_cmd = create_command(options, action)
diff --git a/agents/ironic/fence_ironic.py b/agents/ironic/fence_ironic.py
index 76a9250f1..efccebd26 100644
--- a/agents/ironic/fence_ironic.py
+++ b/agents/ironic/fence_ironic.py
@@ -20,7 +20,7 @@ def get_name_or_uuid(options):
def get_power_status(_, options):
output = ironic_run_command(options, "status")
stdout = output[1]
- match = re.search('power[\\s]*([a-zA-Z]{2,3})', str(stdout))
+ match = re.search(r'power[\s]*([a-zA-Z]{2,3})', str(stdout))
status = match.group(1) if match else None
return status
@@ -40,7 +40,7 @@ def get_devices_list(_, options):
pass
if "UUID" in uuid:
continue # skip line header
- match = re.search('power[\\s]*([a-zA-Z]{2,3})', state)
+ match = re.search(r'power[\s]*([a-zA-Z]{2,3})', state)
status = match.group(1) if match else None
nodes[uuid] = (name, status)
diff --git a/agents/lpar/fence_lpar.py b/agents/lpar/fence_lpar.py
index a18e1c9ae..1703eb3e9 100644
--- a/agents/lpar/fence_lpar.py
+++ b/agents/lpar/fence_lpar.py
@@ -44,10 +44,10 @@ def get_power_status(conn, options):
try:
if options["--hmc-version"] == "3":
- status = re.compile("^" + options["--plug"] + ",(.*?),.*$",
+ status = re.compile(r"^" + options["--plug"] + r",(.*?),.*$",
re.IGNORECASE | re.MULTILINE).search(conn.before).group(1)
elif options["--hmc-version"] in ["4", "IVM"]:
- status = re.compile(",state=(.*?),", re.IGNORECASE).search(conn.before).group(1)
+ status = re.compile(r",state=(.*?),", re.IGNORECASE).search(conn.before).group(1)
except AttributeError as e:
logging.debug("Command on HMC failed: {}\n{}".format(command, str(e)))
fail(EC_STATUS_HMC)
@@ -60,7 +60,7 @@ def is_comanaged(conn, options):
conn.log_expect(options["--command-prompt"], int(options["--power-timeout"]))
try:
- cm = re.compile(",curr_master_mtms=(.*?),", re.IGNORECASE).search(conn.before).group(1)
+ cm = re.compile(r",curr_master_mtms=(.*?),", re.IGNORECASE).search(conn.before).group(1)
except AttributeError as e:
cm = False
@@ -106,7 +106,7 @@ def get_lpar_list(conn, options):
## We have to remove next 2 lines (header) and last line (part of new prompt)
####
- res = re.search("^(.+?\n){2}(.*)\n.*$", conn.before, re.S)
+ res = re.search(r"^(.+?\n){2}(.*)\n.*$", conn.before, re.S)
if res == None:
fail_usage("Unable to parse output of list command")
@@ -126,7 +126,7 @@ def get_lpar_list(conn, options):
## We have to remove last line (part of new prompt)
####
- res = re.search("^(.*)\n.*$", conn.before, re.S)
+ res = re.search(r"^(.*)\n.*$", conn.before, re.S)
if res == None:
fail_usage("Unable to parse output of list command")
diff --git a/agents/netio/fence_netio.py b/agents/netio/fence_netio.py
index fc3bf9d83..948fc4ce0 100755
--- a/agents/netio/fence_netio.py
+++ b/agents/netio/fence_netio.py
@@ -8,7 +8,7 @@
def get_power_status(conn, options):
conn.send_eol("port %s" % options["--plug"])
- re_status = re.compile("250 [01imt]")
+ re_status = re.compile(r"250 [01imt]")
conn.log_expect(re_status, int(options["--shell-timeout"]))
status = {
"0" : "off",
diff --git a/agents/raritan/fence_raritan.py b/agents/raritan/fence_raritan.py
index d3510e4a1..c78a7b30c 100644
--- a/agents/raritan/fence_raritan.py
+++ b/agents/raritan/fence_raritan.py
@@ -8,7 +8,7 @@
def get_power_status(conn, options):
conn.send_eol("show -d properties=powerState %s" % options["--plug"])
- re_status = re.compile(".*powerState is [12].*")
+ re_status = re.compile(r".*powerState is [12].*")
conn.log_expect(re_status, int(options["--shell-timeout"]))
status = {
#"0" : "off",
diff --git a/agents/rhevm/fence_rhevm.py b/agents/rhevm/fence_rhevm.py
index 1eb53bed0..87cd4cf45 100644
--- a/agents/rhevm/fence_rhevm.py
+++ b/agents/rhevm/fence_rhevm.py
@@ -9,10 +9,10 @@
from fencing import *
from fencing import fail, EC_FETCH_VM_UUID, run_delay
-RE_GET_ID = re.compile("<vm( .*)? id=\"(.*?)\"", re.IGNORECASE)
-RE_STATUS = re.compile("<status>(.*?)</status>", re.IGNORECASE)
-RE_STATE = re.compile("<state>(.*?)</state>", re.IGNORECASE)
-RE_GET_NAME = re.compile("<name>(.*?)</name>", re.IGNORECASE)
+RE_GET_ID = re.compile(r"<vm( .*)? id=\"(.*?)\"", re.IGNORECASE)
+RE_STATUS = re.compile(r"<status>(.*?)</status>", re.IGNORECASE)
+RE_STATE = re.compile(r"<state>(.*?)</state>", re.IGNORECASE)
+RE_GET_NAME = re.compile(r"<name>(.*?)</name>", re.IGNORECASE)
def get_power_status(conn, options):
del conn
@@ -80,7 +80,7 @@ def send_command(opt, command, method="GET"):
if opt["--api-version"] == "auto":
opt["--api-version"] = "4"
res = send_command(opt, "")
- if re.search("<title>Error</title>", res):
+ if re.search(r"<title>Error</title>", res):
opt["--api-version"] = "3"
logging.debug("auto-detected API version: " + opt["--api-version"])
diff --git a/agents/rsa/fence_rsa.py b/agents/rsa/fence_rsa.py
index 79ed109eb..6efde753c 100644
--- a/agents/rsa/fence_rsa.py
+++ b/agents/rsa/fence_rsa.py
@@ -16,7 +16,7 @@ def get_power_status(conn, options):
conn.send_eol("power state")
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
- match = re.compile("Power: (.*)", re.IGNORECASE).search(conn.before)
+ match = re.compile(r"Power: (.*)", re.IGNORECASE).search(conn.before)
if match != None:
status = match.group(1)
else:
diff --git a/agents/wti/fence_wti.py b/agents/wti/fence_wti.py
index ffa3d019c..9c16f364d 100644
--- a/agents/wti/fence_wti.py
+++ b/agents/wti/fence_wti.py
@@ -27,7 +27,7 @@ def get_listing(conn, options, listing_command):
re_all = list(options["--command-prompt"])
else:
re_all = [options["--command-prompt"]]
- re_next = re.compile("Enter: ", re.IGNORECASE)
+ re_next = re.compile(r"Enter: ", re.IGNORECASE)
re_all.append(re_next)
result = conn.log_expect(re_all, int(options["--shell-timeout"]))
@@ -208,8 +208,8 @@ def main():
conn.send("set binary\n")
conn.send("open %s -%s\n"%(options["--ip"], options["--ipport"]))
- re_login = re.compile("(login: )|(Login Name: )|(username: )|(User Name :)", re.IGNORECASE)
- re_prompt = re.compile("|".join(["(" + x + ")" for x in options["--command-prompt"]]), re.IGNORECASE)
+ re_login = re.compile(r"(login: )|(Login Name: )|(username: )|(User Name :)", re.IGNORECASE)
+ re_prompt = re.compile(r"|".join(["(" + x + ")" for x in options["--command-prompt"]]), re.IGNORECASE)
result = conn.log_expect([re_login, "Password: ", re_prompt], int(options["--shell-timeout"]))
if result == 0:
diff --git a/lib/azure_fence.py.py b/lib/azure_fence.py.py
index ab40b483a..fcbc40ab0 100644
--- a/lib/azure_fence.py.py
+++ b/lib/azure_fence.py.py
@@ -49,7 +49,7 @@ def get_from_metadata(parameter):
return None
def get_azure_resource(id):
- match = re.match('(/subscriptions/([^/]*)/resourceGroups/([^/]*))(/providers/([^/]*/[^/]*)/([^/]*))?((/([^/]*)/([^/]*))*)', id)
+ match = re.match(r'(/subscriptions/([^/]*)/resourceGroups/([^/]*))(/providers/([^/]*/[^/]*)/([^/]*))?((/([^/]*)/([^/]*))*)', id)
if not match:
fail_usage("{get_azure_resource} cannot parse resource id %s" % id)
diff --git a/lib/fencing.py.py b/lib/fencing.py.py
index 3a60f53ee..511eb2689 100644
--- a/lib/fencing.py.py
+++ b/lib/fencing.py.py
@@ -614,7 +614,7 @@ def metadata(options, avail_opt, docs):
sorted_list.sort(key=lambda x: (x[1]["order"], x[0]))
if options["--action"] == "metadata":
- docs["longdesc"] = re.sub("\\\\f[BPIR]|\.P|\.TP|\.br\n", "", docs["longdesc"])
+ docs["longdesc"] = re.sub(r"\\f[BPIR]|\.P|\.TP|\.br\n", r"", docs["longdesc"])
print("<?xml version=\"1.0\" ?>")
print("<resource-agent name=\"" + os.path.basename(sys.argv[0]) + \
@@ -649,7 +649,7 @@ def metadata(options, avail_opt, docs):
mixed = _encode_html_entities(mixed)
if not "shortdesc" in opt:
- shortdesc = re.sub(".*\s\s+", "", opt["help"][31:])
+ shortdesc = re.sub(r".*\s\s+", r"", opt["help"][31:])
else:
shortdesc = opt["shortdesc"]
@@ -1272,7 +1272,7 @@ def source_env(env_file):
executable="/bin/sh")
# replace env
os.environ.clear()
- os.environ.update(line.partition('=')[::2] for line in output.decode("utf-8").split('\0') if not re.match("^\s*$", line))
+ os.environ.update(line.partition('=')[::2] for line in output.decode("utf-8").split('\0') if not re.match(r"^\s*$", line))
# Convert array of format [[key1, value1], [key2, value2], ... [keyN, valueN]] to dict, where key is
# in format a.b.c.d...z and returned dict has key only z
@@ -1359,7 +1359,7 @@ def _login_ssh_with_identity_file(options):
def _login_telnet(options, re_login_string):
re_login = re.compile(re_login_string, re.IGNORECASE)
- re_pass = re.compile("(password)|(pass phrase)", re.IGNORECASE)
+ re_pass = re.compile(r"(password)|(pass phrase)", re.IGNORECASE)
conn = fspawn(options, options["--telnet-path"])
conn.send("set binary\n")
@@ -1400,7 +1400,7 @@ def _login_telnet(options, re_login_string):
def _login_ssh_with_password(options, re_login_string):
re_login = re.compile(re_login_string, re.IGNORECASE)
- re_pass = re.compile("(password)|(pass phrase)", re.IGNORECASE)
+ re_pass = re.compile(r"(password)|(pass phrase)", re.IGNORECASE)
if "--inet6-only" in options:
force_ipvx = "-6 "
@@ -1608,7 +1608,7 @@ def _parse_input_stdin(avail_opt):
(name, value) = (line + "=").split("=", 1)
value = value[:-1]
- value = re.sub("^\"(.*)\"$", "\\1", value)
+ value = re.sub(r"^\"(.*)\"$", r"\1", value)
if name.replace("-", "_") in mapping_longopt_names:
name = mapping_longopt_names[name.replace("-", "_")]
diff --git a/lib/fencing_snmp.py.py b/lib/fencing_snmp.py.py
index f9e576894..55f5db2ad 100644
--- a/lib/fencing_snmp.py.py
+++ b/lib/fencing_snmp.py.py
@@ -91,7 +91,7 @@ def run_command(self, command, additional_timeout=0):
logging.debug("%s\n", res_output)
- if (res_code != 0) or (re.search("^Error ", res_output, re.MULTILINE) != None):
+ if (res_code != 0) or (re.search(r"^Error ", res_output, re.MULTILINE) != None):
fail_usage("Returned %d: %s"% (res_code, res_output))
except pexpect.ExceptionPexpect:
fail_usage("Cannot run command %s"%(command))

View File

@ -1,95 +0,0 @@
From 0e3d970c367b222b4c757ba4757b45140da8bd54 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Tue, 7 May 2024 15:36:09 +0200
Subject: [PATCH] fence_hpblade/fence_mpath/fence_scsi: use r"" for all regular
expressions to avoid SyntaxWarning errors
---
agents/hpblade/fence_hpblade.py | 8 ++++----
agents/mpath/fence_mpath.py | 2 +-
agents/scsi/fence_scsi.py | 10 +++++-----
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/agents/hpblade/fence_hpblade.py b/agents/hpblade/fence_hpblade.py
index eb8f459b2..9381d2340 100644
--- a/agents/hpblade/fence_hpblade.py
+++ b/agents/hpblade/fence_hpblade.py
@@ -33,10 +33,10 @@ def get_enclosure_type(conn, options):
def get_power_status(conn, options):
if options["enc_type"] == "superdome":
cmd_send = "parstatus -M -p " + options["--plug"]
- powrestr = "^partition:\\d\\s+:\\w+\\s+/(\\w+)\\s.*$"
+ powrestr = r"^partition:\d\s+:\w+\s+/(\w+)\s.*$"
else:
cmd_send = "show server status " + options["--plug"]
- powrestr = "^\\s*Power: (.*?)\\s*$"
+ powrestr = r"^\s*Power: (.*?)\s*$"
conn.send_eol(cmd_send)
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
@@ -78,10 +78,10 @@ def get_instances_list(conn, options):
outlets = {}
if options["enc_type"] == "superdome":
cmd_send = "parstatus -P -M"
- listrestr = "^partition:(\\d+)\\s+:\\w+\\s+/(\\w+)\\s+:OK.*?:(\\w+)\\s*$"
+ listrestr = r"^partition:(\d+)\s+:\w+\s+/(\w+)\s+:OK.*?:(\w+)\s*$"
else:
cmd_send = "show server list"
- listrestr = "^\\s*(\\d+)\\s+(.*?)\\s+(.*?)\\s+OK\\s+(.*?)\\s+(.*?)\\s*$"
+ listrestr = r"^\s*(\d+)\s+(.*?)\s+(.*?)\s+OK\s+(.*?)\s+(.*?)\s*$"
conn.send_eol(cmd_send)
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
diff --git a/agents/mpath/fence_mpath.py b/agents/mpath/fence_mpath.py
index 0e5d9ed30..58450c2ce 100644
--- a/agents/mpath/fence_mpath.py
+++ b/agents/mpath/fence_mpath.py
@@ -331,7 +331,7 @@ def main():
if not ("--devices" in options and options["--devices"]):
fail_usage("Failed: No devices found")
- options["devices"] = [d for d in re.split("\s*,\s*|\s+", options["--devices"].strip()) if d]
+ options["devices"] = [d for d in re.split(r"\s*,\s*|\s+", options["--devices"].strip()) if d]
# Input control END
result = fence_action(None, options, set_status, get_status)
diff --git a/agents/scsi/fence_scsi.py b/agents/scsi/fence_scsi.py
index 5cb5dbee9..a1598411c 100644
--- a/agents/scsi/fence_scsi.py
+++ b/agents/scsi/fence_scsi.py
@@ -236,11 +236,11 @@ def get_node_id(options):
cmd = options["--corosync-cmap-path"] + " nodelist"
out = run_cmd(options, cmd)["out"]
- match = re.search(r".(\d+).name \(str\) = " + options["--plug"] + "\n", out)
+ match = re.search(r".(\d+).name \(str\) = " + options["--plug"] + r"\n", out)
# try old format before failing
if not match:
- match = re.search(r".(\d+).ring._addr \(str\) = " + options["--plug"] + "\n", out)
+ match = re.search(r".(\d+).ring._addr \(str\) = " + options["--plug"] + r"\n", out)
return match.group(1) if match else fail_usage("Failed: unable to parse output of corosync-cmapctl or node does not exist")
@@ -295,7 +295,7 @@ def dev_write(dev, options):
fail_usage("Failed: Cannot open file \""+ file_path + "\"")
f.seek(0)
out = f.read()
- if not re.search(r"^" + dev + "\s+", out, flags=re.MULTILINE):
+ if not re.search(r"^" + dev + r"\s+", out, flags=re.MULTILINE):
f.write(dev + "\n")
f.close()
@@ -613,10 +613,10 @@ def main():
options["--key"] = options["--key"].lstrip('0')
- if not ("--devices" in options and [d for d in re.split("\s*,\s*|\s+", options["--devices"].strip()) if d]):
+ if not ("--devices" in options and [d for d in re.split(r"\s*,\s*|\s+", options["--devices"].strip()) if d]):
options["devices"] = get_shared_devices(options)
else:
- options["devices"] = [d for d in re.split("\s*,\s*|\s+", options["--devices"].strip()) if d]
+ options["devices"] = [d for d in re.split(r"\s*,\s*|\s+", options["--devices"].strip()) if d]
if not options["devices"]:
fail_usage("Failed: No devices found")

View File

@ -12,8 +12,8 @@
Name: fence-agents
Summary: Set of unified programs capable of host isolation ("fencing")
Version: 4.13.1
Release: 8%{?alphatag:.%{alphatag}}%{?dist}
Version: 4.15.0
Release: 1%{?alphatag:.%{alphatag}}%{?dist}
License: GPL-2.0-or-later AND LGPL-2.0-or-later
URL: https://github.com/ClusterLabs/fence-agents
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.gz
@ -103,8 +103,6 @@ Patch4: ha-cloud-support-google.patch
Patch5: bundled-kubevirt.patch
Patch6: bundled-pycurl.patch
Patch7: bundled-suds.patch
Patch8: RHEL-35663-1-lib-all-agents-use-r-for-regex.patch
Patch9: RHEL-35663-2-fence_hpblade-fence_mpath-fence_scsi-use-r-for-regex.patch
%global supportedagents amt_ws apc apc_snmp bladecenter brocade cisco_mds cisco_ucs compute drac5 eaton_snmp emerson eps evacuate hpblade ibmblade ibm_powervs ibm_vpc ifmib ilo ilo_moonshot ilo_mp ilo_ssh intelmodular ipdu ipmilan kdump kubevirt lpar mpath redfish rhevm rsa rsb sbd scsi vmware_rest vmware_soap wti
%ifarch x86_64
@ -372,7 +370,7 @@ This package contains support files including the Python fencing library.
%dir %attr (1755, root, root) %{_var}/run/%{name}
%endif
%dir %{_usr}/lib/%{name}
%{_usr}/lib/%{name}/support/common
%{_usr}/lib/%{name}/support/common/lib*
%exclude %{_usr}/lib/%{name}/support/common/share
%ifarch x86_64
@ -426,7 +424,8 @@ Provides: bundled(python3-rsa) = 4.9
Support libraries for Fence Agents.
%files -n ha-cloud-support
%dir %{_usr}/lib/%{name}
%{_usr}/lib/%{name}/support
%{_usr}/lib/%{name}/support/*/lib
%{_usr}/lib/%{name}/support/aliyun/aliyun-cli
%exclude %{_usr}/lib/%{name}/support/common
%exclude %{_usr}/lib/%{name}/support/kubevirt
%endif
@ -667,8 +666,8 @@ BuildArch: noarch
Fence agent for ePowerSwitch 8M+ power switches that are accessed
via the HTTP(s) protocol.
%files eps
%{_sbindir}/fence_eps
%{_mandir}/man8/fence_eps.8*
%{_sbindir}/fence_eps*
%{_mandir}/man8/fence_eps*.8*
%ifarch x86_64
%package gce
@ -903,7 +902,7 @@ Fence agent for KubeVirt platform.
%{_sbindir}/fence_kubevirt
%{_mandir}/man8/fence_kubevirt.8*
# bundled libraries
%{_usr}/lib/%{name}/support/kubevirt
%{_usr}/lib/%{name}/support/kubevirt/lib
%exclude %{_usr}/lib/%{name}/support/kubevirt/README
%package lpar
@ -1179,6 +1178,10 @@ are located on corosync cluster nodes.
%endif
%changelog
* Tue Jul 2 2024 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.15.0-1
- new upstream release
Resolves: RHEL-45835
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 4.13.1-8
- Bump release for June 2024 mass rebuild

View File

@ -1,6 +1,6 @@
--- !Policy
product_versions:
- rhel-9
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

View File

@ -1,4 +1,4 @@
SHA512 (fence-agents-4.13.1.tar.gz) = ea3d7effea14b19a9a70a954f052469577a7a8f83ab380a23e83e888067f38b04a0b9142216c05c0965a2777e4804b9a2a3d839ae3fc8136f1c3282f325e3b8b
SHA512 (fence-agents-4.15.0.tar.gz) = 16871880b5d2286145608dd43ec8943b079238774de7539b0e86bbf1d9b2f1d4e3e17632bcb078b49aafbe9a4b2efab4c24196d9d0df9b318e26092465acd67b
SHA512 (requirements-common.txt) = 27efb8655b5cb949ddbdaa1ef8bb0787349ad3173ae46d47110779a7588f6b03e3a6bd717cc7b9182dda3a0ed474715da9ca378031fed288fb9fb4dcae4b15f1
SHA512 (requirements-aliyun.txt) = 74ae6b3f7bb0c25b532f606d7dea3cf4e3a0d1c1abdce78d01e2ab8e81c9f346162142679bad884b2fa110d4d6a8c4692b678017eb1fc7d092907c0c063b1c79
SHA512 (requirements-aws.txt) = ca39604d09f4b05589ddaa437be13b7f5d1868218745df107564d73a6c32efb7e4761436197a69653edc47a78f40dd7d5f0894935ec21b8f23b7c7bc71dfd0d1