Skip to content

Commit

Permalink
Merge branch 'wip-rbd-import'
Browse files Browse the repository at this point in the history
  • Loading branch information
jdurgin committed Sep 17, 2012
2 parents 4251d78 + 78d6a60 commit f46a5f1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
45 changes: 45 additions & 0 deletions qa/workunits/rbd/copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,51 @@ test_remove() {
rbd ls | wc -l | grep "^0$"
}

test_pool_image_args() {
echo "testing pool and image args..."
remove_images

ceph osd pool delete test || true
ceph osd pool create test 100
truncate -s 1 /tmp/empty

rbd ls | wc -l | grep 0
rbd create -s 1 test1
rbd ls | grep -q test1
rbd import --image test2 /tmp/empty
rbd ls | grep -q test2
rbd --dest test3 import /tmp/empty
rbd ls | grep -q test3
rbd import /tmp/empty foo
rbd ls | grep -q foo

rbd ls test | wc -l | grep 0
rbd import /tmp/empty test/test1
rbd ls test | grep -q test1
rbd -p test import /tmp/empty test2
rbd ls test | grep -q test2
rbd --image test3 -p test import /tmp/empty
rbd ls test | grep -q test3
rbd --image test4 -p test import /tmp/empty
rbd ls test | grep -q test4
rbd --dest test5 -p test import /tmp/empty
rbd ls test | grep -q test5
rbd --dest test6 --dest-pool test import /tmp/empty
rbd ls test | grep -q test6
rbd --image test7 --dest-pool test import /tmp/empty
rbd ls test | grep -q test7
rbd --image test/test8 import /tmp/empty
rbd ls test | grep -q test8
rbd --dest test/test9 import /tmp/empty
rbd ls test | grep -q test9
rbd import --pool test /tmp/empty
rbd ls test | grep -q empty

rm -f /tmp/empty
ceph osd pool delete test
}

test_import_args
test_rename
test_ls
test_remove
Expand Down
12 changes: 6 additions & 6 deletions src/rbd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,11 @@ static void set_pool_image_name(const char *orig_pool, const char *orig_img,
if (orig_pool)
return;

if (!orig_img) {
*new_pool = strdup("rbd");
if (!orig_img)
return;
}

sep = strchr(orig_img, '/');
if (!sep) {
*new_pool= strdup("rbd");
*new_img = strdup(orig_img);
goto done_img;
}
Expand Down Expand Up @@ -1261,8 +1258,11 @@ int main(int argc, const char **argv)
return EXIT_FAILURE;
}

if (opt_cmd == OPT_IMPORT && !destname)
destname = imgname_from_path(path);
if (opt_cmd == OPT_IMPORT && !destname) {
destname = imgname;
if (!destname)
destname = imgname_from_path(path);
}

if (opt_cmd != OPT_LIST && opt_cmd != OPT_IMPORT && opt_cmd != OPT_UNMAP && opt_cmd != OPT_SHOWMAPPED &&
!imgname) {
Expand Down

0 comments on commit f46a5f1

Please sign in to comment.