- fence_aws: add instance name and status to list/list-status actions
Resolves: RHEL-43235
This commit is contained in:
parent
c3c737aac3
commit
115971f805
99
RHEL-43235-fence_aws-1-list-add-instance-name-status.patch
Normal file
99
RHEL-43235-fence_aws-1-list-add-instance-name-status.patch
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
From a4502b3bf15a3be2ebd64b6829cd4f6641f2506b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
||||||
|
Date: Fri, 14 Jun 2024 15:28:28 +0200
|
||||||
|
Subject: [PATCH 1/2] fencing: use formatted strings to avoid failing when plug
|
||||||
|
is int
|
||||||
|
|
||||||
|
---
|
||||||
|
lib/fencing.py.py | 8 ++++----
|
||||||
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/fencing.py.py b/lib/fencing.py.py
|
||||||
|
index 66e2ff156..9c090100d 100644
|
||||||
|
--- a/lib/fencing.py.py
|
||||||
|
+++ b/lib/fencing.py.py
|
||||||
|
@@ -985,9 +985,9 @@
|
||||||
|
status = status.upper()
|
||||||
|
|
||||||
|
if options["--action"] == "list":
|
||||||
|
- print(outlet_id + options["--separator"] + alias)
|
||||||
|
+ print("{}{}{}".format(outlet_id, options["--separator"], alias))
|
||||||
|
elif options["--action"] == "list-status":
|
||||||
|
- print(outlet_id + options["--separator"] + alias + options["--separator"] + status)
|
||||||
|
+ print("{}{}{}{}{}".format(outlet_id, options["--separator"], alias, options["--separator"], status))
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
From f1ef26c885cdedb17eb366e4c8922ffb01aefc7c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
||||||
|
Date: Fri, 14 Jun 2024 15:29:12 +0200
|
||||||
|
Subject: [PATCH 2/2] fence_aws: improve list, list-status and status actions
|
||||||
|
|
||||||
|
---
|
||||||
|
agents/aws/fence_aws.py | 31 +++++++++++++++++++------------
|
||||||
|
1 file changed, 19 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/agents/aws/fence_aws.py b/agents/aws/fence_aws.py
|
||||||
|
index a9308dd9c..b8d38462e 100644
|
||||||
|
--- a/agents/aws/fence_aws.py
|
||||||
|
+++ b/agents/aws/fence_aws.py
|
||||||
|
@@ -22,6 +22,15 @@
|
||||||
|
logger.addHandler(SyslogLibHandler())
|
||||||
|
logging.getLogger('botocore.vendored').propagate = False
|
||||||
|
|
||||||
|
+status = {
|
||||||
|
+ "running": "on",
|
||||||
|
+ "stopped": "off",
|
||||||
|
+ "pending": "unknown",
|
||||||
|
+ "stopping": "unknown",
|
||||||
|
+ "shutting-down": "unknown",
|
||||||
|
+ "terminated": "unknown"
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
def get_instance_id(options):
|
||||||
|
try:
|
||||||
|
token = requests.put('http://169.254.169.254/latest/api/token', headers={"X-aws-ec2-metadata-token-ttl-seconds" : "21600"}).content.decode("UTF-8")
|
||||||
|
@@ -45,11 +54,14 @@ def get_nodes_list(conn, options):
|
||||||
|
filter_key = options["--filter"].split("=")[0].strip()
|
||||||
|
filter_value = options["--filter"].split("=")[1].strip()
|
||||||
|
filter = [{ "Name": filter_key, "Values": [filter_value] }]
|
||||||
|
- for instance in conn.instances.filter(Filters=filter):
|
||||||
|
- result[instance.id] = ("", None)
|
||||||
|
- else:
|
||||||
|
- for instance in conn.instances.all():
|
||||||
|
- result[instance.id] = ("", None)
|
||||||
|
+ logging.debug("Filter: {}".format(filter))
|
||||||
|
+
|
||||||
|
+ for instance in conn.instances.filter(Filters=filter if 'filter' in vars() else []):
|
||||||
|
+ instance_name = ""
|
||||||
|
+ for tag in instance.tags or []:
|
||||||
|
+ if tag.get("Key") == "Name":
|
||||||
|
+ instance_name = tag["Value"]
|
||||||
|
+ result[instance.id] = (instance_name, status[instance.state["Name"]])
|
||||||
|
except ClientError:
|
||||||
|
fail_usage("Failed: Incorrect Access Key or Secret Key.")
|
||||||
|
except EndpointConnectionError:
|
||||||
|
@@ -67,12 +79,7 @@ def get_power_status(conn, options):
|
||||||
|
instance = conn.instances.filter(Filters=[{"Name": "instance-id", "Values": [options["--plug"]]}])
|
||||||
|
state = list(instance)[0].state["Name"]
|
||||||
|
logger.debug("Status operation for EC2 instance %s returned state: %s",options["--plug"],state.upper())
|
||||||
|
- if state == "running":
|
||||||
|
- return "on"
|
||||||
|
- elif state == "stopped":
|
||||||
|
- return "off"
|
||||||
|
- else:
|
||||||
|
- return "unknown"
|
||||||
|
+ return status[state]
|
||||||
|
|
||||||
|
except ClientError:
|
||||||
|
fail_usage("Failed: Incorrect Access Key or Secret Key.")
|
||||||
|
@@ -146,7 +153,7 @@ def define_new_opts():
|
||||||
|
all_opt["filter"] = {
|
||||||
|
"getopt" : ":",
|
||||||
|
"longopt" : "filter",
|
||||||
|
- "help" : "--filter=[key=value] Filter (e.g. vpc-id=[vpc-XXYYZZAA]",
|
||||||
|
+ "help" : "--filter=[key=value] Filter (e.g. vpc-id=[vpc-XXYYZZAA])",
|
||||||
|
"shortdesc": "Filter for list-action",
|
||||||
|
"required": "0",
|
||||||
|
"order": 5
|
41
RHEL-43235-fence_aws-2-log-error-for-unknown-states.patch
Normal file
41
RHEL-43235-fence_aws-2-log-error-for-unknown-states.patch
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
From c2753c1882b5892b8b7a0fd093baded4a359b2a5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
||||||
|
Date: Mon, 17 Jun 2024 11:19:12 +0200
|
||||||
|
Subject: [PATCH] fence_aws: log error if unknown state returned
|
||||||
|
|
||||||
|
---
|
||||||
|
agents/aws/fence_aws.py | 14 +++++++++++---
|
||||||
|
1 file changed, 11 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/agents/aws/fence_aws.py b/agents/aws/fence_aws.py
|
||||||
|
index b8d38462e..5459a06c4 100644
|
||||||
|
--- a/agents/aws/fence_aws.py
|
||||||
|
+++ b/agents/aws/fence_aws.py
|
||||||
|
@@ -61,7 +61,12 @@ def get_nodes_list(conn, options):
|
||||||
|
for tag in instance.tags or []:
|
||||||
|
if tag.get("Key") == "Name":
|
||||||
|
instance_name = tag["Value"]
|
||||||
|
- result[instance.id] = (instance_name, status[instance.state["Name"]])
|
||||||
|
+ try:
|
||||||
|
+ result[instance.id] = (instance_name, status[instance.state["Name"]])
|
||||||
|
+ except KeyError as e:
|
||||||
|
+ if options.get("--original-action") == "list-status":
|
||||||
|
+ logger.error("Unknown status \"{}\" returned for {} ({})".format(instance.state["Name"], instance.id, instance_name))
|
||||||
|
+ result[instance.id] = (instance_name, "unknown")
|
||||||
|
except ClientError:
|
||||||
|
fail_usage("Failed: Incorrect Access Key or Secret Key.")
|
||||||
|
except EndpointConnectionError:
|
||||||
|
@@ -79,8 +84,11 @@ def get_power_status(conn, options):
|
||||||
|
instance = conn.instances.filter(Filters=[{"Name": "instance-id", "Values": [options["--plug"]]}])
|
||||||
|
state = list(instance)[0].state["Name"]
|
||||||
|
logger.debug("Status operation for EC2 instance %s returned state: %s",options["--plug"],state.upper())
|
||||||
|
- return status[state]
|
||||||
|
-
|
||||||
|
+ try:
|
||||||
|
+ return status[state]
|
||||||
|
+ except KeyError as e:
|
||||||
|
+ logger.error("Unknown status \"{}\" returned".format(state))
|
||||||
|
+ return "unknown"
|
||||||
|
except ClientError:
|
||||||
|
fail_usage("Failed: Incorrect Access Key or Secret Key.")
|
||||||
|
except EndpointConnectionError:
|
@ -59,7 +59,7 @@
|
|||||||
Name: fence-agents
|
Name: fence-agents
|
||||||
Summary: Set of unified programs capable of host isolation ("fencing")
|
Summary: Set of unified programs capable of host isolation ("fencing")
|
||||||
Version: 4.10.0
|
Version: 4.10.0
|
||||||
Release: 73%{?alphatag:.%{alphatag}}%{?dist}
|
Release: 74%{?alphatag:.%{alphatag}}%{?dist}
|
||||||
License: GPLv2+ and LGPLv2+
|
License: GPLv2+ and LGPLv2+
|
||||||
URL: https://github.com/ClusterLabs/fence-agents
|
URL: https://github.com/ClusterLabs/fence-agents
|
||||||
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.gz
|
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.gz
|
||||||
@ -253,6 +253,8 @@ Patch52: RHEL-14344-fence_zvmip-2-fix-manpage-formatting.patch
|
|||||||
Patch53: RHEL-31488-RHEL-31485-RHEL-31483-fence_aliyun-update.patch
|
Patch53: RHEL-31488-RHEL-31485-RHEL-31483-fence_aliyun-update.patch
|
||||||
Patch54: RHEL-35263-fence_eps-add-fence_epsr2-for-ePowerSwitch-R2-and-newer.patch
|
Patch54: RHEL-35263-fence_eps-add-fence_epsr2-for-ePowerSwitch-R2-and-newer.patch
|
||||||
Patch55: RHEL-25256-fence_vmware_rest-detect-user-sufficient-rights.patch
|
Patch55: RHEL-25256-fence_vmware_rest-detect-user-sufficient-rights.patch
|
||||||
|
Patch56: RHEL-43235-fence_aws-1-list-add-instance-name-status.patch
|
||||||
|
Patch57: RHEL-43235-fence_aws-2-log-error-for-unknown-states.patch
|
||||||
|
|
||||||
### HA support libs/utils ###
|
### HA support libs/utils ###
|
||||||
# all archs
|
# all archs
|
||||||
@ -429,6 +431,8 @@ BuildRequires: %{systemd_units}
|
|||||||
%patch -p1 -P 53
|
%patch -p1 -P 53
|
||||||
%patch -p1 -P 54 -F2
|
%patch -p1 -P 54 -F2
|
||||||
%patch -p1 -P 55
|
%patch -p1 -P 55
|
||||||
|
%patch -p1 -P 56
|
||||||
|
%patch -p1 -P 57
|
||||||
|
|
||||||
# prevent compilation of something that won't get used anyway
|
# prevent compilation of something that won't get used anyway
|
||||||
sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
|
sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
|
||||||
@ -1525,6 +1529,10 @@ are located on corosync cluster nodes.
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jun 19 2024 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-74
|
||||||
|
- fence_aws: add instance name and status to list/list-status actions
|
||||||
|
Resolves: RHEL-43235
|
||||||
|
|
||||||
* Thu May 23 2024 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-73
|
* Thu May 23 2024 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-73
|
||||||
- fence_vmware_rest: detect if the API user has sufficient rights to
|
- fence_vmware_rest: detect if the API user has sufficient rights to
|
||||||
manage the fence device
|
manage the fence device
|
||||||
|
Loading…
Reference in New Issue
Block a user