mirror of
https://github.com/ceph/ceph
synced 2025-01-18 17:12:29 +00:00
Merge pull request #14754 from trociny/wip-19128
rbd: import needs to sanity check auto-generated image name Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
commit
b67c5c7aa4
@ -290,7 +290,7 @@ test_pool_image_args() {
|
||||
|
||||
ceph osd pool delete test test --yes-i-really-really-mean-it || true
|
||||
ceph osd pool create test 100
|
||||
truncate -s 1 /tmp/empty
|
||||
truncate -s 1 /tmp/empty /tmp/empty@snap
|
||||
|
||||
rbd ls | wc -l | grep 0
|
||||
rbd create -s 1 test1
|
||||
@ -302,6 +302,12 @@ test_pool_image_args() {
|
||||
rbd import /tmp/empty foo
|
||||
rbd ls | grep -q foo
|
||||
|
||||
# should fail due to "destination snapname specified"
|
||||
rbd import --dest test/empty@snap /tmp/empty && exit 1 || true
|
||||
rbd import /tmp/empty test/empty@snap && exit 1 || true
|
||||
rbd import --image test/empty@snap /tmp/empty && exit 1 || true
|
||||
rbd import /tmp/empty@snap && exit 1 || true
|
||||
|
||||
rbd ls test | wc -l | grep 0
|
||||
rbd import /tmp/empty test/test1
|
||||
rbd ls test | grep -q test1
|
||||
@ -336,7 +342,7 @@ test_pool_image_args() {
|
||||
rbd ls | grep test12
|
||||
rbd ls test | grep -qv test12
|
||||
|
||||
rm -f /tmp/empty
|
||||
rm -f /tmp/empty /tmp/empty@snap
|
||||
ceph osd pool delete test test --yes-i-really-really-mean-it
|
||||
|
||||
for f in foo test1 test10 test12 test2 test3 ; do
|
||||
|
@ -871,15 +871,21 @@ int execute(const po::variables_map &vm) {
|
||||
|
||||
std::string deprecated_image_name;
|
||||
if (vm.count(at::IMAGE_NAME)) {
|
||||
utils::extract_spec(vm[at::IMAGE_NAME].as<std::string>(),
|
||||
&deprecated_pool_name, &deprecated_image_name, nullptr,
|
||||
utils::SPEC_VALIDATION_FULL);
|
||||
deprecated_image_name = vm[at::IMAGE_NAME].as<std::string>();
|
||||
std::cerr << "rbd: --image is deprecated for import, use --dest"
|
||||
<< std::endl;
|
||||
} else {
|
||||
deprecated_image_name = path.substr(path.find_last_of("/") + 1);
|
||||
}
|
||||
|
||||
std::string deprecated_snap_name;
|
||||
r = utils::extract_spec(deprecated_image_name, &deprecated_pool_name,
|
||||
&deprecated_image_name, &deprecated_snap_name,
|
||||
utils::SPEC_VALIDATION_FULL);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
|
||||
size_t sparse_size = utils::RBD_DEFAULT_SPARSE_SIZE;
|
||||
if (vm.count(at::IMAGE_SPARSE_SIZE)) {
|
||||
sparse_size = vm[at::IMAGE_SPARSE_SIZE].as<size_t>();
|
||||
@ -888,7 +894,7 @@ int execute(const po::variables_map &vm) {
|
||||
size_t arg_index = 1;
|
||||
std::string pool_name = deprecated_pool_name;
|
||||
std::string image_name;
|
||||
std::string snap_name;
|
||||
std::string snap_name = deprecated_snap_name;
|
||||
r = utils::get_pool_image_snapshot_names(
|
||||
vm, at::ARGUMENT_MODIFIER_DEST, &arg_index, &pool_name, &image_name,
|
||||
&snap_name, utils::SNAPSHOT_PRESENCE_NONE, utils::SPEC_VALIDATION_FULL,
|
||||
|
Loading…
Reference in New Issue
Block a user