diff --git a/bz1781357-fence_aws-improve-logging-and-metadata-usage-text.patch b/bz1781357-fence_aws-improve-logging-and-metadata-usage-text.patch
new file mode 100644
index 0000000000000000000000000000000000000000..33f4298a830a0e729097fad6545696ef290be1a5
--- /dev/null
+++ b/bz1781357-fence_aws-improve-logging-and-metadata-usage-text.patch
@@ -0,0 +1,120 @@
+diff --git a/agents/aws/fence_aws.py b/agents/aws/fence_aws.py
+index 647b66fc..74321e8e 100644
+--- a/agents/aws/fence_aws.py
++++ b/agents/aws/fence_aws.py
+@@ -5,7 +5,7 @@
+ import atexit
+ sys.path.append("@FENCEAGENTSLIBDIR@")
+ from fencing import *
+-from fencing import fail, fail_usage, EC_TIMED_OUT, run_delay
++from fencing import fail, fail_usage, run_delay, EC_STATUS
+
+ import boto3
+ from botocore.exceptions import ClientError, EndpointConnectionError, NoRegionError
+@@ -19,6 +19,8 @@ def get_nodes_list(conn, options):
+ fail_usage("Failed: Incorrect Access Key or Secret Key.")
+ except EndpointConnectionError:
+ fail_usage("Failed: Incorrect Region.")
++ except Exception as e:
++ logging.error("Failed to get node list: %s", e)
+
+ return result
+
+@@ -38,20 +40,26 @@ def get_power_status(conn, options):
+ except EndpointConnectionError:
+ fail_usage("Failed: Incorrect Region.")
+ except IndexError:
+- return "fail"
++ fail(EC_STATUS)
++ except Exception as e:
++ logging.error("Failed to get power status: %s", e)
++ fail(EC_STATUS)
+
+ def set_power_status(conn, options):
+- if (options["--action"]=="off"):
+- conn.instances.filter(InstanceIds=[options["--plug"]]).stop(Force=True)
+- elif (options["--action"]=="on"):
+- conn.instances.filter(InstanceIds=[options["--plug"]]).start()
+-
++ try:
++ if (options["--action"]=="off"):
++ conn.instances.filter(InstanceIds=[options["--plug"]]).stop(Force=True)
++ elif (options["--action"]=="on"):
++ conn.instances.filter(InstanceIds=[options["--plug"]]).start()
++ except Exception as e:
++ logging.error("Failed to power %s %s: %s", \
++ options["--action"], options["--plug"], e)
+
+ def define_new_opts():
+ all_opt["region"] = {
+ "getopt" : "r:",
+ "longopt" : "region",
+- "help" : "-r, --region=[name] Region, e.g. us-east-1",
++ "help" : "-r, --region=[region] Region, e.g. us-east-1",
+ "shortdesc" : "Region.",
+ "required" : "0",
+ "order" : 2
+@@ -59,7 +67,7 @@ def define_new_opts():
+ all_opt["access_key"] = {
+ "getopt" : "a:",
+ "longopt" : "access-key",
+- "help" : "-a, --access-key=[name] Access Key",
++ "help" : "-a, --access-key=[key] Access Key",
+ "shortdesc" : "Access Key.",
+ "required" : "0",
+ "order" : 3
+@@ -67,7 +75,7 @@ def define_new_opts():
+ all_opt["secret_key"] = {
+ "getopt" : "s:",
+ "longopt" : "secret-key",
+- "help" : "-s, --secret-key=[name] Secret Key",
++ "help" : "-s, --secret-key=[key] Secret Key",
+ "shortdesc" : "Secret Key.",
+ "required" : "0",
+ "order" : 4
+@@ -107,16 +115,16 @@ def main():
+ conn = boto3.resource('ec2', region_name=region,
+ aws_access_key_id=access_key,
+ aws_secret_access_key=secret_key)
+- except:
+- fail_usage("Failed: Unable to connect to AWS. Check your configuration.")
++ except Exception as e:
++ fail_usage("Failed: Unable to connect to AWS: " + str(e))
+ else:
+ # If setup with "aws configure" or manually in
+ # ~/.aws/credentials
+ try:
+ conn = boto3.resource('ec2')
+- except:
++ except Exception as e:
+ # If any of region/access/secret are missing
+- fail_usage("Failed: Unable to connect to AWS. Check your configuration.")
++ fail_usage("Failed: Unable to connect to AWS: " + str(e))
+
+ # Operate the fencing device
+ result = fence_action(conn, options, set_power_status, get_power_status, get_nodes_list)
+diff --git a/tests/data/metadata/fence_aws.xml b/tests/data/metadata/fence_aws.xml
+index 4dea4418..5e5d5d99 100644
+--- a/tests/data/metadata/fence_aws.xml
++++ b/tests/data/metadata/fence_aws.xml
+@@ -22,17 +22,17 @@ For instructions see: https://boto3.readthedocs.io/en/latest/guide/quickstart.ht
+ Physical plug number on device, UUID or identification of machine
+
+
+-
++
+
+ Region.
+
+
+-
++
+
+ Access Key.
+
+
+-
++
+
+ Secret Key.
+
diff --git a/fence-agents.spec b/fence-agents.spec
index 7239688d0caa3e0756e02dfdfc8097f356d21ad1..2c0af04ffccf19672176e2cc01e28bcc00a14ca1 100644
--- a/fence-agents.spec
+++ b/fence-agents.spec
@@ -29,7 +29,7 @@
Name: fence-agents
Summary: Set of unified programs capable of host isolation ("fencing")
Version: 4.2.1
-Release: 33
+Release: 34
License: GPLv2+ and LGPLv2+ and ASL 2.0 and BSD and MIT and Python-2.0 and Artistic-1.0-Perl
Group: System Environment/Base
URL: https://github.com/ClusterLabs/fence-agents
@@ -77,6 +77,7 @@ Patch37: bz1732773-fence_vmware_rest-fix-keyerror-suspended-vms.patch
Patch38: bz1748443-fence_zvmip-python3-fixes.patch
Patch39: bz1762432-fence_compute-disable-service-after-force-down.patch
Patch40: bz1751704-fence_mpath-fix-watchdog-trigger-multipath-disconnect.patch
+Patch41: bz1781357-fence_aws-improve-logging-and-metadata-usage-text.patch
%if 0%{?fedora} || 0%{?rhel} > 7
%global supportedagents amt_ws apc apc_snmp bladecenter brocade cisco_mds cisco_ucs compute drac5 eaton_snmp emerson eps evacuate hpblade ibmblade ifmib ilo ilo_moonshot ilo_mp ilo_ssh intelmodular ipdu ipmilan mpath kdump redfish rhevm rsa rsb sbd scsi vmware_rest vmware_soap wti
@@ -193,7 +194,7 @@ BuildRequires: python3-google-api-client
%patch38 -p1
%patch39 -p1
%patch40 -p1
-
+%patch41 -p1
# prevent compilation of something that won't get used anyway
sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
@@ -965,6 +966,9 @@ Fence agent for IBM z/VM over IP.
%endif
%changelog
+* Mon Jul 25 2022 zhaochaoxiang - 4.2.1-34
+- improve logging and metadata/usage text
+
* Mon Jul 25 2022 zhaochaoxiang - 4.2.1-33
- fix watchdog trigger multipath disconnect