Skip to content

Commit fe92127

Browse files
authored
Merge pull request ceph#66340 from imran-imtiaz/dashboard
mgr/dashboard: add GET API endpoint for consistency groups
2 parents f255e7f + d6dd7ce commit fe92127

File tree

2 files changed

+92
-6
lines changed

2 files changed

+92
-6
lines changed

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
"num_images": (int, '')
4646
}]
4747

48+
RBD_GROUP_GET_SCHEMA = [{
49+
"group": (str, 'group name'),
50+
"images": ([str], '')
51+
}]
52+
4853

4954
# pylint: disable=not-callable
5055
def RbdTask(name, metadata, wait_for): # noqa: N802
@@ -472,7 +477,7 @@ def __init__(self):
472477
self.rbd_inst = rbd.RBD()
473478

474479
@handle_rbd_error()
475-
@EndpointDoc("Display RBD Groups by pool name",
480+
@EndpointDoc("List groups by pool name",
476481
parameters={
477482
'pool_name': (str, 'Name of the pool'),
478483
},
@@ -491,7 +496,33 @@ def list(self, pool_name, namespace=None):
491496
return result
492497

493498
@handle_rbd_error()
494-
@EndpointDoc("Create an RBD Group",
499+
@EndpointDoc("Get the list of images in a group",
500+
parameters={
501+
'pool_name': (str, 'Name of the pool'),
502+
'group_name': (str, 'Name of the group'),
503+
},
504+
responses={200: RBD_GROUP_GET_SCHEMA})
505+
@RESTController.Collection('GET', path='/{group_name}')
506+
def get(self, pool_name, group_name, namespace=None):
507+
with mgr.rados.open_ioctx(pool_name) as ioctx:
508+
RbdService.validate_namespace(ioctx, namespace)
509+
ioctx.set_namespace(namespace)
510+
result = []
511+
groups = self.rbd_inst.group_list(ioctx)
512+
if group_name in groups:
513+
result.append({
514+
'group': group_name,
515+
'images': list(rbd.Group(ioctx, group_name).list_images())
516+
})
517+
else:
518+
raise DashboardException(
519+
msg='Group not found',
520+
code='group_not_found',
521+
component='rbd')
522+
return result
523+
524+
@handle_rbd_error()
525+
@EndpointDoc("Create a group",
495526
parameters={
496527
'pool_name': (str, 'Name of the pool'),
497528
'name': (str, 'Name of the group'),
@@ -504,7 +535,7 @@ def create(self, pool_name, name, namespace=None):
504535

505536
@RESTController.Collection('POST', path='/{group_name}/image')
506537
@handle_rbd_error()
507-
@EndpointDoc("Add an image to an RBD Group",
538+
@EndpointDoc("Add image to a group",
508539
parameters={
509540
'pool_name': (str, 'Name of the pool'),
510541
'group_name': (str, 'Name of the group'),

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ paths:
16341634
trace.
16351635
security:
16361636
- jwt: []
1637-
summary: Display RBD Groups by pool name
1637+
summary: List groups by pool name
16381638
tags:
16391639
- RbdGroup
16401640
post:
@@ -1680,7 +1680,62 @@ paths:
16801680
trace.
16811681
security:
16821682
- jwt: []
1683-
summary: Create an RBD Group
1683+
summary: Create a group
1684+
tags:
1685+
- RbdGroup
1686+
/api/block/pool/{pool_name}/group/{group_name}:
1687+
get:
1688+
parameters:
1689+
- description: Name of the pool
1690+
in: path
1691+
name: pool_name
1692+
required: true
1693+
schema:
1694+
type: string
1695+
- description: Name of the group
1696+
in: path
1697+
name: group_name
1698+
required: true
1699+
schema:
1700+
type: string
1701+
- allowEmptyValue: true
1702+
in: query
1703+
name: namespace
1704+
schema:
1705+
type: string
1706+
responses:
1707+
'200':
1708+
content:
1709+
application/vnd.ceph.api.v1.0+json:
1710+
schema:
1711+
items:
1712+
properties:
1713+
group:
1714+
description: group name
1715+
type: string
1716+
images:
1717+
description: ''
1718+
items:
1719+
type: string
1720+
type: array
1721+
type: object
1722+
required:
1723+
- group
1724+
- images
1725+
type: array
1726+
description: OK
1727+
'400':
1728+
description: Operation exception. Please check the response body for details.
1729+
'401':
1730+
description: Unauthenticated access. Please login first.
1731+
'403':
1732+
description: Unauthorized access. Please check your permissions.
1733+
'500':
1734+
description: Unexpected error. Please check the response body for the stack
1735+
trace.
1736+
security:
1737+
- jwt: []
1738+
summary: Get the list of images in a group
16841739
tags:
16851740
- RbdGroup
16861741
/api/block/pool/{pool_name}/group/{group_name}/image:
@@ -1733,7 +1788,7 @@ paths:
17331788
trace.
17341789
security:
17351790
- jwt: []
1736-
summary: Add an image to an RBD Group
1791+
summary: Add image to a group
17371792
tags:
17381793
- RbdGroup
17391794
/api/block/pool/{pool_name}/namespace:

0 commit comments

Comments
 (0)