Skip to content

Commit e7aa7da

Browse files
authored
Merge pull request ceph#66184 from imran-imtiaz/dashboard
mgr/dashboard: add API endpoint to list consistency groups
2 parents be8a046 + 42c75ff commit e7aa7da

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
"pool_name": (str, 'pool name')
4141
}]
4242

43+
RBD_GROUP_LIST_SCHEMA = [{
44+
"group": (str, 'group name'),
45+
"num_images": (int, '')
46+
}]
47+
4348

4449
# pylint: disable=not-callable
4550
def RbdTask(name, metadata, wait_for): # noqa: N802
@@ -457,3 +462,27 @@ def list(self, pool_name):
457462
'num_images': len(images) if images else 0
458463
})
459464
return result
465+
466+
467+
@APIRouter('/block/pool/{pool_name}/group', Scope.RBD_IMAGE)
468+
@APIDoc("RBD Group Management API", "RbdGroup")
469+
class RbdGroup(RESTController):
470+
def __init__(self):
471+
super().__init__()
472+
self.rbd_inst = rbd.RBD()
473+
474+
@EndpointDoc("Display RBD Groups by pool name",
475+
parameters={
476+
'pool_name': (str, 'Name of the pool'),
477+
},
478+
responses={200: RBD_GROUP_LIST_SCHEMA})
479+
def list(self, pool_name):
480+
with mgr.rados.open_ioctx(pool_name) as ioctx:
481+
result = []
482+
groups = self.rbd_inst.group_list(ioctx)
483+
for group in groups:
484+
result.append({
485+
'group': group,
486+
'num_images': len(list(rbd.Group(ioctx, group).list_images()))
487+
})
488+
return result

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,48 @@ paths:
15901590
- jwt: []
15911591
tags:
15921592
- RbdMirroringSummary
1593+
/api/block/pool/{pool_name}/group:
1594+
get:
1595+
parameters:
1596+
- description: Name of the pool
1597+
in: path
1598+
name: pool_name
1599+
required: true
1600+
schema:
1601+
type: string
1602+
responses:
1603+
'200':
1604+
content:
1605+
application/vnd.ceph.api.v1.0+json:
1606+
schema:
1607+
items:
1608+
properties:
1609+
group:
1610+
description: group name
1611+
type: string
1612+
num_images:
1613+
description: ''
1614+
type: integer
1615+
type: object
1616+
required:
1617+
- group
1618+
- num_images
1619+
type: array
1620+
description: OK
1621+
'400':
1622+
description: Operation exception. Please check the response body for details.
1623+
'401':
1624+
description: Unauthenticated access. Please login first.
1625+
'403':
1626+
description: Unauthorized access. Please check your permissions.
1627+
'500':
1628+
description: Unexpected error. Please check the response body for the stack
1629+
trace.
1630+
security:
1631+
- jwt: []
1632+
summary: Display RBD Groups by pool name
1633+
tags:
1634+
- RbdGroup
15931635
/api/block/pool/{pool_name}/namespace:
15941636
get:
15951637
parameters:
@@ -19305,6 +19347,8 @@ tags:
1930519347
name: RGW Topic Management
1930619348
- description: RBD Management API
1930719349
name: Rbd
19350+
- description: RBD Group Management API
19351+
name: RbdGroup
1930819352
- description: RBD Mirroring Management API
1930919353
name: RbdMirroring
1931019354
- description: RBD Mirroring Pool Bootstrap Management API

0 commit comments

Comments
 (0)