fence-agents/SOURCES/bz1810457-fence_aws-improve-parameter-logic.patch
2021-10-08 10:55:08 +00:00

49 lines
1.8 KiB
Diff

From 1c2f791b6b2be13bcceaa096df52654164b1f6cb Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 5 Mar 2020 14:10:29 +0100
Subject: [PATCH] fence_aws: improve connect parameter logic, so region can be
specified as parameter, while using role or keys from ~/.aws/config
---
agents/aws/fence_aws.py | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/agents/aws/fence_aws.py b/agents/aws/fence_aws.py
index 74321e8e..4a4d9de2 100644
--- a/agents/aws/fence_aws.py
+++ b/agents/aws/fence_aws.py
@@ -107,24 +107,15 @@ def main():
run_delay(options)
- if "--region" in options and "--access-key" in options and "--secret-key" in options:
- region = options["--region"]
- access_key = options["--access-key"]
- secret_key = options["--secret-key"]
- try:
- conn = boto3.resource('ec2', region_name=region,
- aws_access_key_id=access_key,
- aws_secret_access_key=secret_key)
- 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 Exception as e:
- # If any of region/access/secret are missing
- fail_usage("Failed: Unable to connect to AWS: " + str(e))
+ region = options.get("--region")
+ access_key = options.get("--access-key")
+ secret_key = options.get("--secret-key")
+ try:
+ conn = boto3.resource('ec2', region_name=region,
+ aws_access_key_id=access_key,
+ aws_secret_access_key=secret_key)
+ except Exception as e:
+ 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)