Skip to content

Commit 624f695

Browse files
authored
Merge pull request ceph#58719 from rhcs-dashboard/add-progress-multisite-automation
mgr/dashboard: Add progress step to multisite automation wizard Reviewed-by: afreen23 <NOT@FOUND> Reviewed-by: Ankush Behl <[email protected]> Reviewed-by: Nizamudeen A <[email protected]>
2 parents cfac7ef + e40b4c5 commit 624f695

File tree

19 files changed

+765
-408
lines changed

19 files changed

+765
-408
lines changed

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def create(self, username, password, ttl: Optional[int] = None):
6666
fsid = mgr.get('config')['fsid']
6767
except KeyError:
6868
fsid = ''
69-
if max_attempt == 0 or mgr.ACCESS_CTRL_DB.get_attempt(username) < max_attempt:
69+
if max_attempt == 0 or mgr.ACCESS_CTRL_DB.get_attempt(username) < max_attempt: # pylint: disable=R1702,line-too-long # noqa: E501
7070
if user_data:
7171
user_perms = user_data.get('permissions')
7272
pwd_expiration_date = user_data.get('pwdExpirationDate', None)
@@ -94,20 +94,26 @@ def create(self, username, password, ttl: Optional[int] = None):
9494
multicluster_config = Settings.MULTICLUSTER_CONFIG.copy()
9595
try:
9696
if fsid in multicluster_config['config']:
97-
existing_entries = multicluster_config['config'][fsid]
98-
if not any((entry['user'] == username or entry['cluster_alias'] == 'local-cluster') for entry in existing_entries): # noqa E501 #pylint: disable=line-too-long
99-
existing_entries.append({
97+
cluster_configurations = multicluster_config['config'][fsid]
98+
for config_item in cluster_configurations:
99+
if config_item['user'] == username or config_item['cluster_alias'] == 'local-cluster': # noqa E501 #pylint: disable=line-too-long
100+
config_item['token'] = token # Update token
101+
break
102+
else:
103+
cluster_configurations.append({
100104
"name": fsid,
101105
"url": origin,
102106
"cluster_alias": "local-cluster",
103-
"user": username
107+
"user": username,
108+
"token": token
104109
})
105110
else:
106111
multicluster_config['config'][fsid] = [{
107112
"name": fsid,
108113
"url": origin,
109114
"cluster_alias": "local-cluster",
110-
"user": username
115+
"user": username,
116+
"token": token
111117
}]
112118

113119
except KeyError:
@@ -121,7 +127,8 @@ def create(self, username, password, ttl: Optional[int] = None):
121127
"name": fsid,
122128
"url": origin,
123129
"cluster_alias": "local-cluster",
124-
"user": username
130+
"user": username,
131+
"token": token
125132
}
126133
]
127134
}

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
from ..security import Permission, Scope
1515
from ..services.auth import AuthManager, JwtManager
1616
from ..services.ceph_service import CephService
17-
from ..services.rgw_client import _SYNC_GROUP_ID, NoRgwDaemonsException, RgwClient, RgwMultisite
18-
from ..services.service import RgwServiceManager
17+
from ..services.rgw_client import _SYNC_GROUP_ID, NoRgwDaemonsException, \
18+
RgwClient, RgwMultisite, RgwMultisiteAutomation
19+
from ..services.service import RgwServiceManager, wait_for_daemon_to_start
1920
from ..tools import json_str_to_object, str_to_bool
2021
from . import APIDoc, APIRouter, BaseController, CreatePermission, \
2122
CRUDCollectionMethod, CRUDEndpoint, DeletePermission, Endpoint, \
@@ -118,20 +119,38 @@ def migrate(self, daemon_name=None, realm_name=None, zonegroup_name=None, zone_n
118119
# pylint: disable=W0102,W0613
119120
def setup_multisite_replication(self, daemon_name=None, realm_name=None, zonegroup_name=None,
120121
zonegroup_endpoints=None, zone_name=None, zone_endpoints=None,
121-
username=None, cluster_fsid=None):
122-
multisite_instance = RgwMultisite()
122+
username=None, cluster_fsid=None, replication_zone_name=None,
123+
cluster_details=None):
124+
multisite_instance = RgwMultisiteAutomation()
123125
result = multisite_instance.setup_multisite_replication(realm_name, zonegroup_name,
124126
zonegroup_endpoints, zone_name,
125127
zone_endpoints, username,
126-
cluster_fsid)
128+
cluster_fsid,
129+
replication_zone_name,
130+
cluster_details)
127131
return result
128132

129133
@RESTController.Collection(method='PUT', path='/setup-rgw-credentials')
130134
@allow_empty_body
131135
# pylint: disable=W0102,W0613
132136
def restart_rgw_daemons_and_set_credentials(self):
133137
rgw_service_manager_instance = RgwServiceManager()
134-
result = rgw_service_manager_instance.restart_rgw_daemons_and_set_credentials()
138+
result = rgw_service_manager_instance.configure_rgw_credentials()
139+
return result
140+
141+
@RESTController.Collection(method='GET', path='/available-ports')
142+
@allow_empty_body
143+
# pylint: disable=W0102,W0613
144+
def get_available_ports(self):
145+
rgw_service_manager_instance = RgwServiceManager()
146+
result = rgw_service_manager_instance.find_available_port()
147+
return result
148+
149+
@RESTController.Collection(method='GET', path='/check-daemons-status')
150+
@allow_empty_body
151+
# pylint: disable=W0102,W0613
152+
def check_daemons_status(self, service_name=None):
153+
result = wait_for_daemon_to_start(service_name=service_name)
135154
return result
136155

137156

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,15 @@
1-
<div class="d-flex flex-column justify-content-center align-items-center bold"
2-
*ngIf="upgradeStatus$ | async as upgradeStatus">
3-
<ng-container *ngIf="upgradeStatus.in_progress && !upgradeStatus.is_paused; else upgradePaused">
4-
<h3 class="text-center"
5-
i18n>
6-
<i [ngClass]="[icons.large, icons.spin, icons.spinner]"></i>
7-
</h3>
8-
9-
<h3 class="text-center mt-2">
10-
{{ executingTask?.description }}
11-
</h3>
12-
13-
<h5 class="text-center mt-3"
14-
i18n>{{ upgradeStatus.which }}</h5>
15-
</ng-container>
16-
17-
<div class="w-50 row h-100 d-flex justify-content-center align-items-center mt-4">
18-
<div class="text-center w-75">
19-
<ng-container *ngIf="upgradeStatus.services_complete.length > 0">
20-
Finished upgrading:
21-
<span class="text-success">
22-
{{ upgradeStatus.services_complete }}
23-
</span>
24-
</ng-container>
25-
<div class="mt-2">
26-
<ngb-progressbar type="info"
27-
[value]="executingTask?.progress"
28-
[striped]="true"
29-
[animated]="!upgradeStatus.is_paused"></ngb-progressbar>
30-
</div>
31-
32-
<p class="card-text text-muted">
33-
<span class="float-end">
34-
{{ executingTask?.progress || 0 }} %
35-
</span>
36-
</p>
37-
</div>
38-
<h4 class="text-center m-2"
39-
i18n>{{ upgradeStatus.progress}}</h4>
40-
41-
<h5 *ngIf="upgradeStatus.in_progress"
42-
class="text-center mt-2"
43-
i18n>
44-
{{ upgradeStatus.message }}
45-
</h5>
1+
<div *ngIf="upgradeStatus$ | async as upgradeStatus">
2+
<ng-container>
3+
<cd-progress [value]="executingTask?.progress"
4+
[label]="executingTask?.description"
5+
[status]="upgradeStatus.in_progress ? 'in-progress' : 'paused'"
6+
[subLabel]="upgradeStatus.which"
7+
[completedItems]="upgradeStatus.services_complete"
8+
[actionName]="'upgrading'"
9+
[helperText]="upgradeStatus.progress"
10+
[footerText]="upgradeStatus.message"
11+
[isPaused]="upgradeStatus.is_paused">
12+
</cd-progress>
4613

4714
<div class="text-center mt-3">
4815
<button class="btn btn-light"
@@ -65,7 +32,7 @@ <h3 class="text-center mt-2">
6532
aria-label="Stop Upgrade"
6633
i18n>Stop</button>
6734
</div>
68-
</div>
35+
</ng-container>
6936
</div>
7037

7138
<legend class="cd-header"
@@ -77,13 +44,3 @@ <h3 class="text-center mt-2">
7744
[showDownloadCopyButton]="false"
7845
defaultTab="cluster-logs"
7946
[scrollable]="true"></cd-logs>
80-
81-
<ng-template #upgradePaused>
82-
<h3 class="text-center mt-3">
83-
<i [ngClass]="[icons.large, icons.spinner]"></i>
84-
</h3>
85-
86-
<h3 class="text-center mt-3 mb-4">
87-
{{ executingTask?.description }}
88-
</h3>
89-
</ng-template>

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,25 @@
1717
routerLink="/services">
1818
Cluster->Services</a>
1919
</cd-alert-panel>
20-
<span *ngIf="!showMigrateAndReplicationActions; else migrateAndReplicationActionTpl">
21-
<cd-table-actions class="btn-group mb-4 me-2"
22-
[permission]="permission"
23-
[selection]="selection"
24-
[tableActions]="createTableActions"
25-
[primaryDropDown]="true">
26-
</cd-table-actions>
27-
</span>
28-
<ng-template #migrateAndReplicationActionTpl>
29-
<cd-table-actions class="btn-group mb-4 me-2"
30-
[permission]="permission"
31-
[selection]="selection"
32-
[tableActions]="multisiteReplicationActions">
33-
</cd-table-actions>
34-
<cd-table-actions class="btn-group mb-4 me-2 secondary"
35-
[permission]="permission"
36-
[btnColor]="'light'"
37-
[selection]="selection"
38-
[tableActions]="migrateTableAction">
39-
</cd-table-actions>
40-
</ng-template>
20+
<cd-table-actions class="btn-group mb-4 me-2"
21+
[permission]="permission"
22+
[selection]="selection"
23+
[tableActions]="multisiteReplicationActions">
24+
</cd-table-actions>
25+
<cd-table-actions *ngIf="showMigrateAndReplicationActions"
26+
class="btn-group mb-4 me-2 secondary"
27+
[permission]="permission"
28+
[btnColor]="'light'"
29+
[selection]="selection"
30+
[tableActions]="migrateTableAction">
31+
</cd-table-actions>
32+
<cd-table-actions *ngIf="!showMigrateAndReplicationActions"
33+
class="btn-group mb-4 me-2"
34+
[permission]="permission"
35+
[selection]="selection"
36+
[tableActions]="createTableActions"
37+
[primaryDropDown]="true">
38+
</cd-table-actions>
4139
<cd-table-actions class="btn-group mb-4 me-2"
4240
[permission]="permission"
4341
[btnColor]="'light'"

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,16 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit {
413413
this.zoneIds = [];
414414
this.evaluateMigrateAndReplicationActions();
415415
this.rgwDaemonService.list().subscribe((data: any) => {
416-
const realmName = data.map((item: { [x: string]: any }) => item['realm_name']);
416+
const hasEmptyRealmName = data.some(
417+
(item: { [x: string]: any }) =>
418+
item['realm_name'] === '' &&
419+
!data.some((i: { [x: string]: any }) => i['id'] === item['id'] && i['realm_name'] !== '')
420+
);
417421
if (
418-
this.defaultRealmId != '' &&
419-
this.defaultZonegroupId != '' &&
420-
this.defaultZoneId != '' &&
421-
realmName.includes('')
422+
this.defaultRealmId !== '' &&
423+
this.defaultZonegroupId !== '' &&
424+
this.defaultZoneId !== '' &&
425+
hasEmptyRealmName
422426
) {
423427
this.restartGatewayMessage = true;
424428
}
@@ -431,18 +435,16 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit {
431435
defaultZonegroupId: string,
432436
defaultZoneId: string
433437
): any {
434-
const defaultRealm = this.realms.find((x: { id: string }) => x.id === defaultRealmId);
435-
const defaultZonegroup = this.zonegroups.find(
438+
const defaultRealm = this.realms?.find((x: { id: string }) => x.id === defaultRealmId);
439+
const defaultZonegroup = this.zonegroups?.find(
436440
(x: { id: string }) => x.id === defaultZonegroupId
437441
);
438-
const defaultZone = this.zones.find((x: { id: string }) => x.id === defaultZoneId);
439-
const defaultRealmName = defaultRealm !== undefined ? defaultRealm.name : null;
440-
const defaultZonegroupName = defaultZonegroup !== undefined ? defaultZonegroup.name : null;
441-
const defaultZoneName = defaultZone !== undefined ? defaultZone.name : null;
442+
const defaultZone = this.zones?.find((x: { id: string }) => x.id === defaultZoneId);
443+
442444
return {
443-
defaultRealmName: defaultRealmName,
444-
defaultZonegroupName: defaultZonegroupName,
445-
defaultZoneName: defaultZoneName
445+
defaultRealmName: defaultRealm?.name,
446+
defaultZonegroupName: defaultZonegroup?.name,
447+
defaultZoneName: defaultZone?.name
446448
};
447449
}
448450

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export enum StepTitles {
2+
CreateRealmAndZonegroup = 'Create Realm & Zonegroup',
3+
CreateZone = 'Create Zone',
4+
SelectCluster = 'Select Cluster',
5+
Review = 'Review'
6+
}
7+
8+
export const STEP_TITLES_MULTI_CLUSTER_CONFIGURED = [
9+
StepTitles.CreateRealmAndZonegroup,
10+
StepTitles.CreateZone,
11+
StepTitles.SelectCluster,
12+
StepTitles.Review
13+
];
14+
15+
export const STEP_TITLES_SINGLE_CLUSTER = [
16+
StepTitles.CreateRealmAndZonegroup,
17+
StepTitles.CreateZone,
18+
StepTitles.Review
19+
];

0 commit comments

Comments
 (0)