Skip to content

Commit 067a93c

Browse files
authored
Merge pull request ceph#58167 from rhcs-dashboard/multi-cluster-cleanup
mgr/dashboard: Multi-cluster cleanup Reviewed-by: Aashish Sharma <[email protected]> Reviewed-by: Ankush Behl <[email protected]> Reviewed-by: Nizamudeen A <[email protected]>
2 parents bb1c7cb + 23c2cda commit 067a93c

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,13 @@ def reconnect_cluster(self, url: str, username=None, password=None,
268268
@Endpoint('PUT')
269269
@UpdatePermission
270270
# pylint: disable=unused-variable
271-
def edit_cluster(self, url, cluster_alias, username, verify=False, ssl_certificate=None):
271+
def edit_cluster(self, name, url, cluster_alias, username, verify=False, ssl_certificate=None):
272272
multicluster_config = self.load_multi_cluster_config()
273273
if "config" in multicluster_config:
274274
for key, cluster_details in multicluster_config["config"].items():
275275
for cluster in cluster_details:
276-
if cluster["url"] == url and cluster["user"] == username:
276+
if cluster["name"] == name and cluster["user"] == username:
277+
cluster['url'] = url
277278
cluster['cluster_alias'] = cluster_alias
278279
cluster['ssl_verify'] = verify
279280
cluster['ssl_certificate'] = ssl_certificate if verify else ''

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster-form/multi-cluster-form.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
</cd-copy-2-clipboard-button>
118118
</span>
119119
<span class="invalid-feedback"
120-
*ngIf="remoteClusterForm.showError('password', frm, 'required')"
120+
*ngIf="remoteClusterForm.showError('password', frm, 'requiredNotEdit')"
121121
i18n>This field is required.
122122
</span>
123123
</div>

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster-form/multi-cluster-form.component.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
5252
ngOnInit(): void {
5353
if (this.action === 'edit') {
5454
this.remoteClusterForm.get('remoteClusterUrl').setValue(this.cluster.url);
55-
this.remoteClusterForm.get('remoteClusterUrl').disable();
5655
this.remoteClusterForm.get('clusterAlias').setValue(this.cluster.cluster_alias);
5756
this.remoteClusterForm.get('ssl').setValue(this.cluster.ssl_verify);
5857
this.remoteClusterForm.get('ssl_cert').setValue(this.cluster.ssl_certificate);
@@ -76,7 +75,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
7675

7776
createForm() {
7877
this.remoteClusterForm = new CdFormGroup({
79-
// showToken: new FormControl(false),
8078
username: new FormControl('', [
8179
CdValidators.custom('uniqueUrlandUser', (username: string) => {
8280
let remoteClusterUrl = '';
@@ -96,7 +94,12 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
9694
);
9795
})
9896
]),
99-
password: new FormControl('', []),
97+
password: new FormControl(
98+
null,
99+
CdValidators.custom('requiredNotEdit', (value: string) => {
100+
return this.action !== 'edit' && !value;
101+
})
102+
),
100103
remoteClusterUrl: new FormControl(null, {
101104
validators: [
102105
CdValidators.custom('endpoint', (value: string) => {
@@ -116,19 +119,16 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
116119
Validators.required
117120
]
118121
}),
119-
// apiToken: new FormControl('', [
120-
// CdValidators.requiredIf({
121-
// showToken: true
122-
// })
123-
// ]),
124122
clusterAlias: new FormControl(null, {
125123
validators: [
126124
Validators.required,
127125
CdValidators.custom('uniqueName', (clusterAlias: string) => {
128126
return (
129127
(this.action === 'connect' || this.action === 'edit') &&
130128
this.clusterAliasNames &&
131-
this.clusterAliasNames.indexOf(clusterAlias) !== -1
129+
this.clusterAliasNames.indexOf(clusterAlias) !== -1 &&
130+
this.cluster?.cluster_alias &&
131+
this.cluster.cluster_alias !== clusterAlias
132132
);
133133
})
134134
]
@@ -197,7 +197,14 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
197197
case 'edit':
198198
this.subs.add(
199199
this.multiClusterService
200-
.editCluster(this.cluster.url, clusterAlias, this.cluster.user, ssl, ssl_certificate)
200+
.editCluster(
201+
this.cluster.name,
202+
url,
203+
clusterAlias,
204+
this.cluster.user,
205+
ssl,
206+
ssl_certificate
207+
)
201208
.subscribe({
202209
...commonSubscribtion,
203210
complete: () => this.handleSuccess($localize`Cluster updated successfully`)

src/pybind/mgr/dashboard/frontend/src/app/shared/api/multi-cluster.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ export class MultiClusterService {
125125
}
126126

127127
editCluster(
128+
name: string,
128129
url: any,
129130
clusterAlias: string,
130131
username: string,
131132
verify = false,
132133
ssl_certificate = ''
133134
) {
134135
return this.http.put('api/multi-cluster/edit_cluster', {
136+
name: name,
135137
url,
136138
cluster_alias: clusterAlias,
137139
username: username,

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7303,6 +7303,8 @@ paths:
73037303
properties:
73047304
cluster_alias:
73057305
type: string
7306+
name:
7307+
type: string
73067308
ssl_certificate:
73077309
type: string
73087310
url:
@@ -7313,6 +7315,7 @@ paths:
73137315
default: false
73147316
type: boolean
73157317
required:
7318+
- name
73167319
- url
73177320
- cluster_alias
73187321
- username

0 commit comments

Comments
 (0)