fence-agents/RHEL-35663-2-fence_hpblade-fence_mpath-fence_scsi-use-r-for-regex.patch

96 lines
4.1 KiB
Diff
Raw Normal View History

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")