- fence_ibm_vpc: add apikey file support

Resolves: RHEL-107505
This commit is contained in:
Oyvind Albrigtsen 2025-08-12 15:11:52 +02:00
parent e644787e05
commit 6decc35a58
2 changed files with 57 additions and 1 deletions

View File

@ -0,0 +1,50 @@
From 9460728b18c648e390390d888ac856628366a521 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 7 Aug 2025 14:53:30 +0200
Subject: [PATCH] fence_ibm_vpc: add apikey file support
---
agents/ibm_vpc/fence_ibm_vpc.py | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/agents/ibm_vpc/fence_ibm_vpc.py b/agents/ibm_vpc/fence_ibm_vpc.py
index efda5eed7..a87e9e6dc 100755
--- a/agents/ibm_vpc/fence_ibm_vpc.py
+++ b/agents/ibm_vpc/fence_ibm_vpc.py
@@ -7,7 +7,7 @@
import hashlib
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fail, run_delay, EC_LOGIN_DENIED, EC_STATUS, EC_GENERIC_ERROR
+from fencing import fail, run_delay, EC_BAD_ARGS, EC_LOGIN_DENIED, EC_STATUS, EC_GENERIC_ERROR
state = {
"running": "on",
@@ -315,6 +315,27 @@ def main():
####
run_delay(options)
+ if options["--apikey"][0] == '@':
+ key_file = options["--apikey"][1:]
+ try:
+ # read the API key from a file
+ with open(key_file, "r") as f:
+ try:
+ keys = json.loads(f.read())
+ # data seems to be in json format
+ # return the value of the item with the key 'Apikey'
+ options["--apikey"] = keys.get("Apikey", "")
+ if not options["--apikey"]:
+ # backward compatibility: former key name was 'apikey'
+ options["--apikey"] = keys.get("apikey", "")
+ # data is text, return as is
+ except ValueError:
+ f.seek(0)
+ options["--apikey"] = f.read().strip()
+ except FileNotFoundError:
+ logging.error("Failed: Cannot open file {}".format(key_file))
+ sys.exit(EC_BAD_ARGS)
+
conn = connect(options)
atexit.register(disconnect, conn)

View File

@ -57,7 +57,7 @@
Name: fence-agents
Summary: Set of unified programs capable of host isolation ("fencing")
Version: 4.10.0
Release: 96%{?alphatag:.%{alphatag}}%{?dist}
Release: 97%{?alphatag:.%{alphatag}}%{?dist}
License: GPLv2+ and LGPLv2+
URL: https://github.com/ClusterLabs/fence-agents
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.gz
@ -252,6 +252,7 @@ Patch67: RHEL-68321-2-fence_nutanix_ahv-update-metadata.patch
Patch68: RHEL-88568-fence_ibm_powervs-fix-plaintext-token-file-support.patch
Patch69: RHEL-13088-fence_sbd-improve-error-handling.patch
Patch70: RHEL-82193-fence_kubevirt-force-off.patch
Patch71: RHEL-107505-fence_ibm_vpc-add-apikey-file-support.patch
### HA support libs/utils ###
# all archs
@ -444,6 +445,7 @@ BuildRequires: %{systemd_units}
%patch -p1 -P 68
%patch -p1 -P 69
%patch -p1 -P 70
%patch -p1 -P 71
# prevent compilation of something that won't get used anyway
sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
@ -1564,6 +1566,10 @@ are located on corosync cluster nodes.
%endif
%changelog
* Tue Aug 12 2025 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-97
- fence_ibm_vpc: add apikey file support
Resolves: RHEL-107505
* Thu Jun 26 2025 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-96
- bundled setuptools: fix CVE-2025-47273
Resolves: RHEL-95901