Skip to content

Commit 626cee2

Browse files
authored
Merge pull request ceph#56847 from rhcs-dashboard/provide-hub-HA-multi-cluster
mgr/dashboard: provide hub Cluster HA for multi-cluster setup Reviewed-by: Nizamudeen A <[email protected]>
2 parents 5514010 + 44f04c0 commit 626cee2

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/pybind/mgr/dashboard/controllers/multi_cluster.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ def auth(self, url: str, cluster_alias: str, username: str,
7272
cluster_token = self.check_cluster_connection(url, payload, username,
7373
ssl_verify, ssl_certificate)
7474

75+
cors_endpoints_string = self.get_cors_endpoints_string(hub_url)
76+
7577
self._proxy('PUT', url, 'ui-api/multi-cluster/set_cors_endpoint',
76-
payload={'url': hub_url}, token=cluster_token, verify=ssl_verify,
77-
cert=ssl_certificate)
78+
payload={'url': cors_endpoints_string}, token=cluster_token,
79+
verify=ssl_verify, cert=ssl_certificate)
7880

7981
fsid = self._proxy('GET', url, 'api/health/get_cluster_fsid', token=cluster_token)
8082

@@ -104,6 +106,26 @@ def auth(self, url: str, cluster_alias: str, username: str,
104106

105107
return False
106108

109+
def get_cors_endpoints_string(self, hub_url):
110+
parsed_url = urlparse(hub_url)
111+
hostname = parsed_url.hostname
112+
cors_endpoints_set = set()
113+
cors_endpoints_set.add(hub_url)
114+
115+
orch = OrchClient.instance()
116+
inventory_hosts = [host.to_json() for host in orch.hosts.list()]
117+
118+
for host in inventory_hosts:
119+
host_addr = host['addr']
120+
host_ip_url = hub_url.replace(hostname, host_addr)
121+
host_hostname_url = hub_url.replace(hostname, host['hostname'])
122+
123+
cors_endpoints_set.add(host_ip_url)
124+
cors_endpoints_set.add(host_hostname_url)
125+
126+
cors_endpoints_string = ", ".join(cors_endpoints_set)
127+
return cors_endpoints_string
128+
107129
def check_cluster_connection(self, url, payload, username, ssl_verify, ssl_certificate):
108130
try:
109131
content = self._proxy('POST', url, 'api/auth', payload=payload,

0 commit comments

Comments
 (0)