-
Notifications
You must be signed in to change notification settings - Fork 21
rbd-target-api: get image's exclusive lock owner and break it #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |
| from functools import wraps | ||
| from rpm import labelCompare | ||
| import rados | ||
| import rbd | ||
| from nose.tools import eq_ as eq | ||
|
|
||
| import werkzeug | ||
| from flask import Flask, jsonify, make_response, request | ||
|
|
@@ -948,6 +950,17 @@ def clientlun(client_iqn): | |
| # this is a delete request | ||
| if disk in lun_list: | ||
| lun_list.remove(disk) | ||
|
|
||
| pool_name, image_name = disk.split('.') | ||
| with rados.Rados(conffile=settings.config.cephconf) as cluster: | ||
| with cluster.open_ioctx(pool_name) as ioctx: | ||
| with rbd.Image(ioctx, image_name) as image: | ||
|
|
||
| if len(image.list_lockers()): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: no need, just invoke the line below but wrap it w/ a |
||
| lock_owners = list(image.lock_get_owners()) | ||
| eq(1, len(lock_owners)) | ||
| eq(rbd.RBD_LOCK_MODE_EXCLUSIVE, lock_owners[0]['mode']) | ||
| image.lock_break(rbd.RBD_LOCK_MODE_EXCLUSIVE, lock_owners[0]['owner']) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: wrap w/ |
||
| else: | ||
| return jsonify(message="disk not mapped to client"), 400 | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could collapse into a single
with: