def locked_snapshot_operation(f):
    'Lock decorator for snapshot operations.\n\n    Takes a named lock prior to executing the operation. The lock is named with\n    the operation executed and the id of the snapshot. This lock can then be\n    used by other operations to avoid operation conflicts on shared snapshots.\n\n    Example use:\n\n    If a snapshot operation uses this decorator, it will block until the named\n    lock is free. This is used to protect concurrent operations on the same\n    snapshot e.g. delete SnapA while create volume VolA from SnapA is in\n    progress.\n    '

    def lso_inner1(inst, context, snapshot, **kwargs):

        @utils.synchronized(('%s-%s' % (snapshot.id, f.__name__)), external=True)
        def lso_inner2(*_args, **_kwargs):
            return f(*_args, **_kwargs)
        return lso_inner2(inst, context, snapshot, **kwargs)
    return lso_inner1
Lock decorator for snapshot operations.

Takes a named lock prior to executing the operation. The lock is named with
the operation executed and the id of the snapshot. This lock can then be
used by other operations to avoid operation conflicts on shared snapshots.

Example use:

If a snapshot operation uses this decorator, it will block until the named
lock is free. This is used to protect concurrent operations on the same
snapshot e.g. delete SnapA while create volume VolA from SnapA is in
progress.
def locked_snapshot_operation(f):
    'Lock decorator for snapshot operations.\n\n    Takes a named lock prior to executing the operation. The lock is named with\n    the operation executed and the id of the snapshot. This lock can then be\n    used by other operations to avoid operation conflicts on shared snapshots.\n\n    Example use:\n\n    If a snapshot operation uses this decorator, it will block until the named\n    lock is free. This is used to protect concurrent operations on the same\n    snapshot e.g. delete SnapA while create volume VolA from SnapA is in\n    progress.\n    '

    def lso_inner1(inst, context, snapshot, **kwargs):

        @utils.synchronized(('%s-%s' % (snapshot.id, f.__name__)), external=True)
        def lso_inner2(*_args, **_kwargs):
            return f(*_args, **_kwargs)
        return lso_inner2(inst, context, snapshot, **kwargs)
    return lso_inner1