diff --git a/SOURCES/bz1977819-fence_aws-add-filter-parameter.patch b/SOURCES/bz1977819-fence_aws-add-filter-parameter.patch new file mode 100644 index 0000000..18d457b --- /dev/null +++ b/SOURCES/bz1977819-fence_aws-add-filter-parameter.patch @@ -0,0 +1,91 @@ +From d920421ccb3abb42ecb9ea3ba56948db00fe1c80 Mon Sep 17 00:00:00 2001 +From: Oyvind Albrigtsen +Date: Tue, 23 Mar 2021 12:14:11 +0100 +Subject: [PATCH] fence_aws: add filter parameter to be able to limit which + nodes are listed + +--- + agents/aws/fence_aws.py | 27 +++++++++++++++++++++------ + tests/data/metadata/fence_aws.xml | 5 +++++ + 2 files changed, 26 insertions(+), 6 deletions(-) + +diff --git a/agents/aws/fence_aws.py b/agents/aws/fence_aws.py +index 8322df9ed..c947bf29c 100644 +--- a/agents/aws/fence_aws.py ++++ b/agents/aws/fence_aws.py +@@ -38,8 +38,15 @@ def get_nodes_list(conn, options): + logger.info("Starting monitor operation") + result = {} + try: +- for instance in conn.instances.all(): +- result[instance.id] = ("", None) ++ if "--filter" in 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) + except ClientError: + fail_usage("Failed: Incorrect Access Key or Secret Key.") + except EndpointConnectionError: +@@ -111,7 +118,7 @@ def define_new_opts(): + all_opt["region"] = { + "getopt" : "r:", + "longopt" : "region", +- "help" : "-r, --region=[region] Region, e.g. us-east-1", ++ "help" : "-r, --region=[region] Region, e.g. us-east-1", + "shortdesc" : "Region.", + "required" : "0", + "order" : 2 +@@ -132,21 +139,29 @@ def define_new_opts(): + "required" : "0", + "order" : 4 + } ++ all_opt["filter"] = { ++ "getopt" : ":", ++ "longopt" : "filter", ++ "help" : "--filter=[key=value] Filter (e.g. vpc-id=[vpc-XXYYZZAA]", ++ "shortdesc": "Filter for list-action", ++ "required": "0", ++ "order": 5 ++ } + all_opt["boto3_debug"] = { + "getopt" : "b:", + "longopt" : "boto3_debug", +- "help" : "-b, --boto3_debug=[option] Boto3 and Botocore library debug logging", ++ "help" : "-b, --boto3_debug=[option] Boto3 and Botocore library debug logging", + "shortdesc": "Boto Lib debug", + "required": "0", + "default": "False", +- "order": 5 ++ "order": 6 + } + + # Main agent method + def main(): + conn = None + +- device_opt = ["port", "no_password", "region", "access_key", "secret_key", "boto3_debug"] ++ device_opt = ["port", "no_password", "region", "access_key", "secret_key", "filter", "boto3_debug"] + + atexit.register(atexit_handler) + +diff --git a/tests/data/metadata/fence_aws.xml b/tests/data/metadata/fence_aws.xml +index 1f3ab3b97..a767e93c2 100644 +--- a/tests/data/metadata/fence_aws.xml ++++ b/tests/data/metadata/fence_aws.xml +@@ -36,6 +36,11 @@ For instructions see: https://boto3.readthedocs.io/en/latest/guide/quickstart.ht + + Secret Key. + ++ ++ ++ ++ Filter for list-action ++ + + + diff --git a/SPECS/fence-agents.spec b/SPECS/fence-agents.spec index a020e2d..aaf5475 100644 --- a/SPECS/fence-agents.spec +++ b/SPECS/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: 65%{?alphatag:.%{alphatag}}%{?dist} +Release: 65%{?alphatag:.%{alphatag}}%{?dist}.1 License: GPLv2+ and LGPLv2+ Group: System Environment/Base URL: https://github.com/ClusterLabs/fence-agents @@ -122,6 +122,7 @@ Patch80: bz1841087-fence_scsi-dont-write-key-device-to-file.patch Patch81: bz1896827-fence_aws-add-imdsv2-support.patch Patch82: bz1914313-fence_zvmip-fix-disable-timeout.patch Patch83: bz1906978-fence_gce-default-to-onoff.patch +Patch84: bz1977819-fence_aws-add-filter-parameter.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 kdump lpar mpath redfish rhevm rsa rsb sbd scsi vmware_rest vmware_soap wti @@ -283,6 +284,7 @@ BuildRequires: python3-google-api-client %patch81 -p1 %patch82 -p1 %patch83 -p1 +%patch84 -p1 -F1 # prevent compilation of something that won't get used anyway sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac @@ -1152,6 +1154,10 @@ Fence agent for IBM z/VM over IP. %endif %changelog +* Thu Jul 1 2021 Oyvind Albrigtsen - 4.2.1-65.1 +- fence_aws: add "filter" parameter + Resolves: rhbz#1977819 + * Tue Feb 2 2021 Oyvind Albrigtsen - 4.2.1-65 - fence_gce: default to onoff Resolves: rhbz#1906978