$ get_field() {
- > rbd info --format=json $1 | python -c "import sys, json; print json.load(sys.stdin)['$2']"
+ > rbd info --format=json $1 | python3 -c "import sys, json; print(json.load(sys.stdin)['$2'])"
> }
Write to first and last sectors and make sure we hit the right objects:
$ get_block_name_prefix() {
- > rbd info --format=json $1 | python -c "import sys, json; print json.load(sys.stdin)['block_name_prefix']"
+ > rbd info --format=json $1 | python3 -c "import sys, json; print(json.load(sys.stdin)['block_name_prefix'])"
> }
Short segments:
$ get_block_name_prefix() {
- > rbd info --format=json $1 | python -c "import sys, json; print json.load(sys.stdin)['block_name_prefix']"
+ > rbd info --format=json $1 | python3 -c "import sys, json; print(json.load(sys.stdin)['block_name_prefix'])"
> }
$ rbd create --size 200M img
local pool=$1
rados -p $pool --format=json df |
- python -c 'import sys, json; print json.load(sys.stdin)["pools"][0]["num_object_clones"]'
+ python3 -c 'import sys, json; print(json.load(sys.stdin)["pools"][0]["num_object_clones"])'
}
ceph osd pool create repdata 24 24
rbd create --size 200 --data-pool ecdata $pool/img3
done
-IMAGE_SIZE=$(rbd info --format=json img1 | python -c 'import sys, json; print json.load(sys.stdin)["size"]')
-OBJECT_SIZE=$(rbd info --format=json img1 | python -c 'import sys, json; print json.load(sys.stdin)["object_size"]')
+IMAGE_SIZE=$(rbd info --format=json img1 | python3 -c 'import sys, json; print(json.load(sys.stdin)["size"])')
+OBJECT_SIZE=$(rbd info --format=json img1 | python3 -c 'import sys, json; print(json.load(sys.stdin)["object_size"])')
NUM_OBJECTS=$((IMAGE_SIZE / OBJECT_SIZE))
[[ $((IMAGE_SIZE % OBJECT_SIZE)) -eq 0 ]]
local actual
actual="$(rados -p rbd --format=json lock info rbd_header.$IMAGE_ID rbd_lock |
- python -m json.tool)"
+ python3 -m json.tool)"
local expected
- expected="$(cat <<EOF | python -m json.tool
+ expected="$(cat <<EOF | python3 -m json.tool
{
"lockers": [
{
rbd create --size 1 --image-feature '' $IMAGE_NAME
IMAGE_ID="$(rbd info --format=json $IMAGE_NAME |
- python -c "import sys, json; print json.load(sys.stdin)['block_name_prefix'].split('.')[1]")"
+ python3 -c "import sys, json; print(json.load(sys.stdin)['block_name_prefix'].split('.')[1])")"
DEV=$(sudo rbd map $IMAGE_NAME)
assert_unlocked
function py_blkdiscard() {
local offset=$1
- python <<EOF
+ python3 <<EOF
import fcntl, struct
BLKDISCARD = 0x1277
with open('$DEV', 'w') as dev:
local mode=$1
local offset=$2
- python <<EOF
+ python3 <<EOF
import os, ctypes, ctypes.util
FALLOC_FL_KEEP_SIZE = 0x01
FALLOC_FL_PUNCH_HOLE = 0x02
rbd create --size 200 $IMAGE_NAME
-IMAGE_SIZE=$(rbd info --format=json $IMAGE_NAME | python -c 'import sys, json; print json.load(sys.stdin)["size"]')
-OBJECT_SIZE=$(rbd info --format=json $IMAGE_NAME | python -c 'import sys, json; print json.load(sys.stdin)["object_size"]')
+IMAGE_SIZE=$(rbd info --format=json $IMAGE_NAME | python3 -c 'import sys, json; print(json.load(sys.stdin)["size"])')
+OBJECT_SIZE=$(rbd info --format=json $IMAGE_NAME | python3 -c 'import sys, json; print(json.load(sys.stdin)["object_size"])')
NUM_OBJECTS=$((IMAGE_SIZE / OBJECT_SIZE))
[[ $((IMAGE_SIZE % OBJECT_SIZE)) -eq 0 ]]
IMAGE_ID="$(rbd info --format=json $IMAGE_NAME |
- python -c "import sys, json; print json.load(sys.stdin)['block_name_prefix'].split('.')[1]")"
+ python3 -c "import sys, json; print(json.load(sys.stdin)['block_name_prefix'].split('.')[1])")"
DEV=$(sudo rbd map $IMAGE_NAME)
set -ex
function get_block_name_prefix() {
- rbd info --format=json $1 | python -c "import sys, json; print json.load(sys.stdin)['block_name_prefix']"
+ rbd info --format=json $1 | python3 -c "import sys, json; print(json.load(sys.stdin)['block_name_prefix'])"
}
function do_pwrite() {