From 43386350129c8a2ee86ece08e9aa2ce0f7978b5f Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Wed, 5 Apr 2023 12:07:11 +0530 Subject: [PATCH] mgr/dashboard: add option to skip the create OSDs step Fixes: https://tracker.ceph.com/issues/59319 Signed-off-by: Nizamudeen A (cherry picked from commit caa0c456b1d0c33f6abb847b3c9259501d587004) --- .../create-cluster.component.html | 6 + .../create-cluster.component.spec.ts | 24 ++++ .../create-cluster.component.ts | 115 ++++++++++-------- 3 files changed, 95 insertions(+), 50 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.html index d738c4f2ca5..272b5b0b916 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.html @@ -85,6 +85,12 @@ aria-label="Close" (backAction)="onPreviousStep()" [name]="showCancelButtonLabel()"> + diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.spec.ts index 0563c4a803a..ca343553606 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.spec.ts @@ -151,4 +151,28 @@ describe('CreateClusterComponent', () => { component.onSubmit(); expect(hostServiceSpy).toHaveBeenCalledTimes(1); }); + + it('should show skip button in the Create OSDs Steps', () => { + component.createCluster(); + fixture.detectChanges(); + + component.onNextStep(); + fixture.detectChanges(); + const skipBtn = fixture.debugElement.query(By.css('#skipStepBtn')).nativeElement; + expect(skipBtn).not.toBe(null); + expect(skipBtn.innerHTML).toBe('Skip'); + }); + + it('should skip the Create OSDs Steps', () => { + component.createCluster(); + fixture.detectChanges(); + + component.onNextStep(); + fixture.detectChanges(); + const skipBtn = fixture.debugElement.query(By.css('#skipStepBtn')).nativeElement; + skipBtn.click(); + fixture.detectChanges(); + + expect(component.stepsToSkip['Create OSDs']).toBe(true); + }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.ts index 02333c39bf6..65eb2e4a6aa 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster.component.ts @@ -52,6 +52,7 @@ export class CreateClusterComponent implements OnInit, OnDestroy { deploymentOption: DeploymentOptions; selectedOption = {}; simpleDeployment = true; + stepsToSkip: { [steps: string]: boolean } = {}; @Output() submitAction = new EventEmitter(); @@ -82,6 +83,10 @@ export class CreateClusterComponent implements OnInit, OnDestroy { this.deploymentOption = options; this.selectedOption = { option: options.recommended_option }; }); + + this.stepTitles.forEach((stepTitle) => { + this.stepsToSkip[stepTitle] = false; + }); } createCluster() { @@ -113,71 +118,75 @@ export class CreateClusterComponent implements OnInit, OnDestroy { } onSubmit() { - this.hostService.list('false').subscribe((hosts) => { - hosts.forEach((host) => { - const index = host['labels'].indexOf('_no_schedule', 0); - if (index > -1) { - host['labels'].splice(index, 1); - this.observables.push(this.hostService.update(host['hostname'], true, host['labels'])); - } - }); - forkJoin(this.observables) - .pipe( - finalize(() => - this.clusterService.updateStatus('POST_INSTALLED').subscribe(() => { - this.notificationService.show( - NotificationType.success, - $localize`Cluster expansion was successful` - ); - this.router.navigate(['/dashboard']); - }) - ) - ) - .subscribe({ - error: (error) => error.preventDefault() + if (!this.stepsToSkip['Add Hosts']) { + this.hostService.list('false').subscribe((hosts) => { + hosts.forEach((host) => { + const index = host['labels'].indexOf('_no_schedule', 0); + if (index > -1) { + host['labels'].splice(index, 1); + this.observables.push(this.hostService.update(host['hostname'], true, host['labels'])); + } }); - }); - - if (this.driveGroup) { - const user = this.authStorageService.getUsername(); - this.driveGroup.setName(`dashboard-${user}-${_.now()}`); - this.driveGroups.push(this.driveGroup.spec); + forkJoin(this.observables) + .pipe( + finalize(() => + this.clusterService.updateStatus('POST_INSTALLED').subscribe(() => { + this.notificationService.show( + NotificationType.success, + $localize`Cluster expansion was successful` + ); + this.router.navigate(['/dashboard']); + }) + ) + ) + .subscribe({ + error: (error) => error.preventDefault() + }); + }); } - if (this.simpleDeployment) { - const title = this.deploymentOption?.options[this.selectedOption['option']].title; - const trackingId = $localize`${title} deployment`; - this.taskWrapper - .wrapTaskAroundCall({ - task: new FinishedTask('osd/' + URLVerbs.CREATE, { - tracking_id: trackingId - }), - call: this.osdService.create([this.selectedOption], trackingId, 'predefined') - }) - .subscribe({ - error: (error) => error.preventDefault(), - complete: () => { - this.submitAction.emit(); - } - }); - } else { - if (this.osdService.osdDevices['totalDevices'] > 0) { - this.driveGroup.setFeature('encrypted', this.selectedOption['encrypted']); - const trackingId = _.join(_.map(this.driveGroups, 'service_id'), ', '); + if (!this.stepsToSkip['Create OSDs']) { + if (this.driveGroup) { + const user = this.authStorageService.getUsername(); + this.driveGroup.setName(`dashboard-${user}-${_.now()}`); + this.driveGroups.push(this.driveGroup.spec); + } + + if (this.simpleDeployment) { + const title = this.deploymentOption?.options[this.selectedOption['option']].title; + const trackingId = $localize`${title} deployment`; this.taskWrapper .wrapTaskAroundCall({ task: new FinishedTask('osd/' + URLVerbs.CREATE, { tracking_id: trackingId }), - call: this.osdService.create(this.driveGroups, trackingId) + call: this.osdService.create([this.selectedOption], trackingId, 'predefined') }) .subscribe({ error: (error) => error.preventDefault(), complete: () => { this.submitAction.emit(); - this.osdService.osdDevices = []; } }); + } else { + if (this.osdService.osdDevices['totalDevices'] > 0) { + this.driveGroup.setFeature('encrypted', this.selectedOption['encrypted']); + const trackingId = _.join(_.map(this.driveGroups, 'service_id'), ', '); + this.taskWrapper + .wrapTaskAroundCall({ + task: new FinishedTask('osd/' + URLVerbs.CREATE, { + tracking_id: trackingId + }), + call: this.osdService.create(this.driveGroups, trackingId) + }) + .subscribe({ + error: (error) => error.preventDefault(), + complete: () => { + this.submitAction.emit(); + this.osdService.osdDevices = []; + } + }); + } } } } @@ -213,6 +222,12 @@ export class CreateClusterComponent implements OnInit, OnDestroy { } } + onSkip() { + const stepTitle = this.stepTitles[this.currentStep.stepIndex - 1]; + this.stepsToSkip[stepTitle] = true; + this.onNextStep(); + } + showSubmitButtonLabel() { return !this.wizardStepsService.isLastStep() ? this.actionLabels.NEXT -- 2.39.5