Skip to content

Commit

Permalink
Merge pull request ceph#53018 from rhcs-dashboard/rm-cephfs-subvolume…
Browse files Browse the repository at this point in the history
…-group

mgr/dashboard: cephfs remove subvolume group

Reviewed-by: Avan Thakkar <[email protected]>
Reviewed-by: cloudbehl <NOT@FOUND>
Reviewed-by: Nizamudeen A <[email protected]>
  • Loading branch information
nizamial09 authored Aug 16, 2023
2 parents 796164c + 0628c69 commit f5c7c5f
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/pybind/mgr/dashboard/controllers/cephfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,3 +786,13 @@ def set(self, vol_name: str, group_name: str, size: str):
f'Failed to update subvolume group {group_name}: {err}'
)
return f'Subvolume group {group_name} updated successfully'

def delete(self, vol_name: str, group_name: str):
error_code, _, err = mgr.remote(
'volumes', '_cmd_fs_subvolumegroup_rm', None, {
'vol_name': vol_name, 'group_name': group_name})
if error_code != 0:
raise DashboardException(
f'Failed to delete subvolume group {group_name}: {err}'
)
return f'Subvolume group {group_name} removed successfully'
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CephfsSubvolumeGroupComponent } from './cephfs-subvolume-group.component';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ToastrModule } from 'ngx-toastr';
import { RouterTestingModule } from '@angular/router/testing';
import { SharedModule } from '~/app/shared/shared.module';

describe('CephfsSubvolumeGroupComponent', () => {
let component: CephfsSubvolumeGroupComponent;
Expand All @@ -10,7 +13,7 @@ describe('CephfsSubvolumeGroupComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [CephfsSubvolumeGroupComponent],
imports: [HttpClientTestingModule]
imports: [HttpClientTestingModule, SharedModule, ToastrModule.forRoot(), RouterTestingModule]
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
import { ModalService } from '~/app/shared/services/modal.service';
import { Permissions } from '~/app/shared/models/permissions';
import { CriticalConfirmationModalComponent } from '~/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component';
import { FinishedTask } from '~/app/shared/models/finished-task';
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';

@Component({
selector: 'cd-cephfs-subvolume-group',
Expand Down Expand Up @@ -55,7 +58,8 @@ export class CephfsSubvolumeGroupComponent implements OnInit, OnChanges {
private cephfsSubvolumeGroup: CephfsSubvolumeGroupService,
private actionLabels: ActionLabelsI18n,
private modalService: ModalService,
private authStorageService: AuthStorageService
private authStorageService: AuthStorageService,
private taskWrapper: TaskWrapperService
) {
this.permissions = this.authStorageService.getPermissions();
}
Expand Down Expand Up @@ -111,6 +115,12 @@ export class CephfsSubvolumeGroupComponent implements OnInit, OnChanges {
permission: 'update',
icon: Icons.edit,
click: () => this.openModal(true)
},
{
name: this.actionLabels.REMOVE,
permission: 'delete',
icon: Icons.destroy,
click: () => this.removeSubVolumeModal()
}
];

Expand Down Expand Up @@ -151,4 +161,18 @@ export class CephfsSubvolumeGroupComponent implements OnInit, OnChanges {
{ size: 'lg' }
);
}

removeSubVolumeModal() {
const name = this.selection.first().name;
this.modalService.show(CriticalConfirmationModalComponent, {
itemDescription: 'subvolume group',
itemNames: [name],
actionDescription: 'remove',
submitActionObservable: () =>
this.taskWrapper.wrapTaskAroundCall({
task: new FinishedTask('cephfs/subvolume/group/remove', { subvolumegroupName: name }),
call: this.cephfsSubvolumeGroup.remove(this.fsName, name)
})
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ export class CephfsSubvolumeListComponent implements OnInit, OnChanges {
{ size: 'lg' }
)
},
{
name: this.actionLabels.EDIT,
permission: 'update',
icon: Icons.edit,
click: () => this.openModal(true)
},
{
name: this.actionLabels.REMOVE,
permission: 'delete',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,13 @@ export class CephfsSubvolumeGroupService {
size: size
});
}

remove(volName: string, groupName: string) {
return this.http.delete(`${this.baseURL}/${volName}`, {
params: {
group_name: groupName
},
observe: 'response'
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ export class TaskMessageService {
),
'cephfs/subvolume/group/edit': this.newTaskMessage(this.commonOperations.update, (metadata) =>
this.subvolumegroup(metadata)
),
'cephfs/subvolume/group/remove': this.newTaskMessage(this.commonOperations.remove, (metadata) =>
this.subvolumegroup(metadata)
)
};

Expand Down
36 changes: 36 additions & 0 deletions src/pybind/mgr/dashboard/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,42 @@ paths:
tags:
- CephfsSubvolumeGroup
/api/cephfs/subvolume/group/{vol_name}:
delete:
parameters:
- in: path
name: vol_name
required: true
schema:
type: string
- in: query
name: group_name
required: true
schema:
type: string
responses:
'202':
content:
application/vnd.ceph.api.v1.0+json:
type: object
description: Operation is still executing. Please check the task queue.
'204':
content:
application/vnd.ceph.api.v1.0+json:
type: object
description: Resource deleted.
'400':
description: Operation exception. Please check the response body for details.
'401':
description: Unauthenticated access. Please login first.
'403':
description: Unauthorized access. Please check your permissions.
'500':
description: Unexpected error. Please check the response body for the stack
trace.
security:
- jwt: []
tags:
- CephfsSubvolumeGroup
get:
parameters:
- in: path
Expand Down

0 comments on commit f5c7c5f

Please sign in to comment.