@handle_rbd_error()
@handle_rados_error('pool')
- def get(self, image_spec):
- return RbdService.get_image(image_spec)
+ @EndpointDoc("Get Rbd Image Info",
+ parameters={
+ 'image_spec': (str, 'URL-encoded "pool/rbd_name". e.g. "rbd%2Ffoo"'),
+ 'omit_usage': (bool, 'When true, usage information is not returned'),
+ },
+ responses={200: RBD_SCHEMA})
+ def get(self, image_spec, omit_usage=False):
+ try:
+ omit_usage_bool = str_to_bool(omit_usage)
+ except ValueError:
+ omit_usage_bool = False
+ return RbdService.get_image(image_spec, omit_usage_bool)
@RbdTask('create',
{'pool_name': '{pool_name}', 'namespace': '{namespace}', 'image_name': '{name}'}, 2.0)
- Rbd
get:
parameters:
- - in: path
+ - description: URL-encoded "pool/rbd_name". e.g. "rbd%2Ffoo"
+ in: path
name: image_spec
required: true
schema:
type: string
+ - default: false
+ description: When true, usage information is not returned
+ in: query
+ name: omit_usage
+ schema:
+ type: boolean
responses:
'200':
content:
application/vnd.ceph.api.v1.0+json:
- type: object
+ schema:
+ items:
+ properties:
+ pool_name:
+ description: pool name
+ type: string
+ value:
+ description: ''
+ items:
+ type: string
+ type: array
+ type: object
+ required:
+ - value
+ - pool_name
+ type: array
description: OK
'400':
description: Operation exception. Please check the response body for details.
trace.
security:
- jwt: []
+ summary: Get Rbd Image Info
tags:
- Rbd
put:
return total_used_size, snap_map
@classmethod
- def _rbd_image(cls, ioctx, pool_name, namespace, image_name): # pylint: disable=R0912
+ def _rbd_image(cls, ioctx, pool_name, namespace, image_name, # pylint: disable=R0912
+ omit_usage=False):
with rbd.Image(ioctx, image_name) as img:
stat = img.stat()
mirror_mode = img.mirror_image_get_mode()
# disk usage
img_flags = img.flags()
- if 'fast-diff' in stat['features_name'] and \
+ if not omit_usage and 'fast-diff' in stat['features_name'] and \
not rbd.RBD_FLAG_FAST_DIFF_INVALID & img_flags and \
mirror_mode != rbd.RBD_MIRROR_IMAGE_MODE_SNAPSHOT:
snaps = [(s['id'], s['size'], s['name'])
return result, len(image_refs)
@classmethod
- def get_image(cls, image_spec):
+ def get_image(cls, image_spec, omit_usage=False):
pool_name, namespace, image_name = parse_image_spec(image_spec)
ioctx = mgr.rados.open_ioctx(pool_name)
if namespace:
ioctx.set_namespace(namespace)
try:
- return cls._rbd_image(ioctx, pool_name, namespace, image_name)
+ return cls._rbd_image(ioctx, pool_name, namespace, image_name, omit_usage)
except rbd.ImageNotFound:
raise cherrypy.HTTPError(404, 'Image not found')