1 Star 0 Fork 18

yueyuankun/fence-agents

forked from src-openEuler/fence-agents 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-azure_fence-use-correct-credential_scope-and-profile.patch 2.64 KB
一键复制 编辑 原始数据 按行查看 历史
From 9087760db005abfd9b3e07319846232214d8dae2 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Fri, 16 Jun 2023 16:03:11 +0200
Subject: [PATCH 15/46] azure_fence: use correct credential_scope and profile
for stack hub
---
lib/azure_fence.py.py | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/lib/azure_fence.py.py b/lib/azure_fence.py.py
index 6f1eee5b..ab40b483 100644
--- a/lib/azure_fence.py.py
+++ b/lib/azure_fence.py.py
@@ -353,11 +353,19 @@ def get_azure_compute_client(config):
fail_usage("metadata-endpoint not specified")
try:
+ from azure.profiles import KnownProfiles
+ if (config.Cloud.lower() == "stack"):
+ client_profile = KnownProfiles.v2020_09_01_hybrid
+ credential_scope = cloud_environment.endpoints.active_directory_resource_id + "/.default"
+ else:
+ client_profile = KnownProfiles.default
+ credential_scope = cloud_environment.endpoints.resource_manager + "/.default"
compute_client = ComputeManagementClient(
credentials,
config.SubscriptionId,
base_url=cloud_environment.endpoints.resource_manager,
- credential_scopes=[cloud_environment.endpoints.resource_manager + "/.default"]
+ profile=client_profile,
+ credential_scopes=[credential_scope],
)
except TypeError:
compute_client = ComputeManagementClient(
@@ -383,11 +391,19 @@ def get_azure_network_client(config):
fail_usage("metadata-endpoint not specified")
try:
+ from azure.profiles import KnownProfiles
+ if (config.Cloud.lower() == "stack"):
+ client_profile = KnownProfiles.v2020_09_01_hybrid
+ credential_scope = cloud_environment.endpoints.active_directory_resource_id + "/.default"
+ else:
+ client_profile = KnownProfiles.default
+ credential_scope = cloud_environment.endpoints.resource_manager + "/.default"
network_client = NetworkManagementClient(
credentials,
config.SubscriptionId,
base_url=cloud_environment.endpoints.resource_manager,
- credential_scopes=[cloud_environment.endpoints.resource_manager + "/.default"]
+ profile=client_profile,
+ credential_scopes=[credential_scope],
)
except TypeError:
network_client = NetworkManagementClient(
--
2.25.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yue-yuankun/fence-agents.git
git@gitee.com:yue-yuankun/fence-agents.git
yue-yuankun
fence-agents
fence-agents
master

搜索帮助