!60 [sync] PR-52: 回合上游patch:fence_aliyun改动

From: @openeuler-sync-bot 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
This commit is contained in:
openeuler-ci-bot 2024-06-07 05:58:23 +00:00 committed by Gitee
commit 59a13a9526
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 213 additions and 1 deletions

View File

@ -0,0 +1,94 @@
From 8dd4b65fb2c9b5f3db545f589a8914792f677cf2 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Tue, 2 Apr 2024 14:37:00 +0200
Subject: [PATCH 39/46] fence_aliyun: add credentials file support
---
agents/aliyun/fence_aliyun.py | 31 ++++++++++++++++++++++++++--
tests/data/metadata/fence_aliyun.xml | 9 ++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/agents/aliyun/fence_aliyun.py b/agents/aliyun/fence_aliyun.py
index 134cc5ab..b271eb0b 100644
--- a/agents/aliyun/fence_aliyun.py
+++ b/agents/aliyun/fence_aliyun.py
@@ -150,20 +150,37 @@ def define_new_opts():
"required": "0",
"order": 5
}
+ all_opt["credentials_file"] = {
+ "getopt": ":",
+ "longopt": "credentials-file",
+ "help": "--credentials-file=[path] Path to aliyun-cli credentials file",
+ "shortdesc": "Path to credentials file",
+ "required": "0",
+ "order": 6
+ }
+ all_opt["credentials_file_profile"] = {
+ "getopt": ":",
+ "longopt": "credentials-file-profile",
+ "help": "--credentials-file-profile=[profile] Credentials file profile",
+ "shortdesc": "Credentials file profile",
+ "required": "0",
+ "default": "default",
+ "order": 6
+ }
all_opt["filter"] = {
"getopt": ":",
"longopt": "filter",
"help": "--filter=[key=value] Filter (e.g. InstanceIds=[\"i-XXYYZZAA1\",\"i-XXYYZZAA2\"]",
"shortdesc": "Filter for list-action.",
"required": "0",
- "order": 6
+ "order": 7
}
# Main agent method
def main():
conn = None
- device_opt = ["port", "no_password", "region", "access_key", "secret_key", "ram_role", "filter"]
+ device_opt = ["port", "no_password", "region", "access_key", "secret_key", "ram_role", "credentials_file", "credentials_file_profile", "filter"]
atexit.register(atexit_handler)
@@ -191,6 +208,16 @@ def main():
ram_role = options["--ram-role"]
role = EcsRamRoleCredential(ram_role)
conn = client.AcsClient(region_id=region, credential=role)
+ elif "--credentials-file" in options and "--credentials-file-profile" in options:
+ import os, configparser
+ try:
+ config = configparser.ConfigParser()
+ config.read(os.path.expanduser(options["--credentials-file"]))
+ access_key = config.get(options["--credentials-file-profile"], "aliyun_access_key_id")
+ secret_key = config.get(options["--credentials-file-profile"], "aliyun_access_key_secret")
+ conn = client.AcsClient(access_key, secret_key, region)
+ except Exception as e:
+ fail_usage("Failed: failed to read credentials file: %s" % e)
else:
fail_usage("Failed: User credentials are not set. Please set the Access Key and the Secret Key, or configure the RAM role.")
diff --git a/tests/data/metadata/fence_aliyun.xml b/tests/data/metadata/fence_aliyun.xml
index a52de014..ea20f5f3 100644
--- a/tests/data/metadata/fence_aliyun.xml
+++ b/tests/data/metadata/fence_aliyun.xml
@@ -38,6 +38,15 @@
<content type="string" />
<shortdesc lang="en">Ram Role.</shortdesc>
</parameter>
+ <parameter name="credentials_file" unique="0" required="0">
+ <getopt mixed="--credentials-file=[path]" />
+ <shortdesc lang="en">Path to credentials file</shortdesc>
+ </parameter>
+ <parameter name="credentials_file_profile" unique="0" required="0">
+ <getopt mixed="--credentials-file-profile=[profile]" />
+ <content type="string" default="default" />
+ <shortdesc lang="en">Credentials file profile</shortdesc>
+ </parameter>
<parameter name="filter" unique="0" required="0">
<getopt mixed="--filter=[key=value]" />
<content type="string" />
--
2.25.1

View File

@ -0,0 +1,76 @@
From 525789dcdcb1e89f8b3dd2438b2fc3b2277f5cfe Mon Sep 17 00:00:00 2001
From: sunhui <wb-sh373163@alibaba-inc.com>
Date: Sun, 23 Apr 2023 14:58:36 +0800
Subject: [PATCH 07/46] fence_aliyun: support filter for list-action
---
agents/aliyun/fence_aliyun.py | 20 ++++++++++++++++++--
tests/data/metadata/fence_aliyun.xml | 5 +++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/agents/aliyun/fence_aliyun.py b/agents/aliyun/fence_aliyun.py
index 1e9c790c..c7785a2b 100644
--- a/agents/aliyun/fence_aliyun.py
+++ b/agents/aliyun/fence_aliyun.py
@@ -76,6 +76,14 @@ def get_nodes_list(conn, options):
result = {}
request = DescribeInstancesRequest()
request.set_PageSize(100)
+
+ if "--filter" in options:
+ filter_key = options["--filter"].split("=")[0].strip()
+ filter_value = options["--filter"].split("=")[1].strip()
+ params = request.get_query_params()
+ params[filter_key] = filter_value
+ request.set_query_params(params)
+
response = _send_request(conn, request)
if response is not None:
instance_list = response.get('Instances').get('Instance')
@@ -137,17 +145,25 @@ def define_new_opts():
all_opt["ram_role"] = {
"getopt": ":",
"longopt": "ram-role",
- "help": "--ram-role=[name] Ram Role",
+ "help": "--ram-role=[name] Ram Role",
"shortdesc": "Ram Role.",
"required": "0",
"order": 5
}
+ all_opt["filter"] = {
+ "getopt": ":",
+ "longopt": "filter",
+ "help": "--filter=[key=value] Filter (e.g. InstanceIds=[\"i-XXYYZZAA1\",\"i-XXYYZZAA2\"]",
+ "shortdesc": "Filter for list-action.",
+ "required": "0",
+ "order": 6
+ }
# Main agent method
def main():
conn = None
- device_opt = ["port", "no_password", "region", "access_key", "secret_key", "ram_role"]
+ device_opt = ["port", "no_password", "region", "access_key", "secret_key", "ram_role", "filter"]
atexit.register(atexit_handler)
diff --git a/tests/data/metadata/fence_aliyun.xml b/tests/data/metadata/fence_aliyun.xml
index 56d79204..b0671889 100644
--- a/tests/data/metadata/fence_aliyun.xml
+++ b/tests/data/metadata/fence_aliyun.xml
@@ -38,6 +38,11 @@
<content type="string" />
<shortdesc lang="en">Ram Role.</shortdesc>
</parameter>
+ <parameter name="filter" unique="0" required="0">
+ <getopt mixed="--filter=[key=value]" />
+ <content type="string" />
+ <shortdesc lang="en">Filter for list-action.</shortdesc>
+ </parameter>
<parameter name="quiet" unique="0" required="0">
<getopt mixed="-q, --quiet" />
<content type="boolean" />
--
2.25.1

View File

@ -0,0 +1,34 @@
From 860da80c03b4b154ca4495adb72b959e278d55b1 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Tue, 2 Apr 2024 16:46:16 +0200
Subject: [PATCH 40/46] fence_aliyun: update order for new parameters
---
agents/aliyun/fence_aliyun.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/agents/aliyun/fence_aliyun.py b/agents/aliyun/fence_aliyun.py
index b271eb0b..788ac647 100644
--- a/agents/aliyun/fence_aliyun.py
+++ b/agents/aliyun/fence_aliyun.py
@@ -165,7 +165,7 @@ def define_new_opts():
"shortdesc": "Credentials file profile",
"required": "0",
"default": "default",
- "order": 6
+ "order": 7
}
all_opt["filter"] = {
"getopt": ":",
@@ -173,7 +173,7 @@ def define_new_opts():
"help": "--filter=[key=value] Filter (e.g. InstanceIds=[\"i-XXYYZZAA1\",\"i-XXYYZZAA2\"]",
"shortdesc": "Filter for list-action.",
"required": "0",
- "order": 7
+ "order": 8
}
# Main agent method
--
2.25.1

View File

@ -6,7 +6,7 @@
Name: fence-agents
Summary: Set of unified programs capable of host isolation ("fencing")
Version: 4.12.1
Release: 10
Release: 11
License: GPLv2+ and LGPLv2+
Group: System Environment/Base
URL: https://github.com/ClusterLabs/fence-agents
@ -22,6 +22,9 @@ Patch7: backport-fence_azure_arm-add-stack-cloud-support.patch
Patch8: backport-azure_fence-use-correct-credential_scope-and-profile.patch
Patch9: backport-spec-Migrate-to-SPDX-license.patch
Patch10: backport-fence_eaton_ssh-new-fence-agent-for-Eaton-ePDU-G3-over-ssh.patch
Patch11: backport-fence_aliyun-support-filter-for-list-action.patch
Patch12: backport-fence_aliyun-add-credentials-file-support.patch
Patch13: backport-fence_aliyun-update-order-for-new-parameters.patch
# skipped: pve, raritan, rcd-serial, virsh
%global allfenceagents %(cat <<EOF
@ -1150,6 +1153,11 @@ are located on corosync cluster nodes.
%{_libdir}/fence-virt/cpg.so
%changelog
* Thu May 30 2024 liupei <liupei@kylinos.cn> - 4.12.1-11
- fence_aliyun: support filter for list-action
- fence_aliyun: add credentials file support
- fence_aliyun: update order for new parameters
* Wed May 29 2024 liupei <liupei@kylinos.cn> - 4.12.1-10
- spec: Migrate to SPDX license
- fence_eaton_ssh: new fence agent for Eaton ePDU G3 over SSH