"""
+ # resource id parameter for using in get, set, and delete methods
+ # should be overriden by subclasses.
+ # to specify a composite id (two parameters) use '/'. e.g., "param1/param2".
+ # If subclasses don't override this property we try to infer the structure of
+ # the resourse ID.
+ RESOURCE_ID = None
+
_method_mapping = collections.OrderedDict([
(('GET', False), ('list', 200)),
(('PUT', False), ('bulk_set', 200)),
(('POST', False), ('create', 201)),
(('DELETE', False), ('bulk_delete', 204)),
(('GET', True), ('get', 200)),
- (('PUT', True), ('set', 200)),
- (('PATCH', True), ('set', 200)),
(('DELETE', True), ('delete', 204)),
+ (('PUT', True), ('set', 200)),
+ (('PATCH', True), ('set', 200))
])
@classmethod
if k[1] and hasattr(cls, v[0]):
methods.append(k[0])
if not args:
- args = cls._parse_function_args(getattr(cls, v[0]))
+ if cls.RESOURCE_ID is None:
+ args = cls._parse_function_args(getattr(cls, v[0]))
+ else:
+ args = cls.RESOURCE_ID.split('/')
if methods:
result.append((methods, None, '_element', args))
@AuthRequired()
class Rbd(RESTController):
+ RESOURCE_ID = "pool_name/image_name"
+
# set of image features that can be enable on existing images
ALLOW_ENABLE_FEATURES = set(["exclusive-lock", "object-map", "fast-diff",
"journaling"])
@ApiController('block/image/:pool_name/:image_name/snap')
class RbdSnapshot(RESTController):
+ RESOURCE_ID = "snapshot_name"
+
@RbdTask('snap/create',
['{pool_name}', '{image_name}', '{snapshot_name}'], 2.0)
@RESTController.args_from_json