rbd-nbd: provide a way to map snapshots by id
Currently we don't have a way to map arbitrary snapshots,
this commit provides --snap-id option to all such snapshots
$ rbd --cluster=site-a snap ls pool1/test_image --all --format=json --pretty-format
[
{
"id": 4,
"name": ".mirror.primary.
c6fe94fd-3f9b-4ce0-aecc-
e9d07472fd46.
528a3f48-1b5c-4abb-9089-
5a454328aeb3",
"size":
1073741824,
"protected": "false",
"timestamp": "Thu Oct 27 22:09:12 2022",
"namespace": {
"type": "mirror",
"state": "primary",
"mirror_peer_uuids": [
"
3e99dc15-78ca-46bd-8934-
93d8063c0081"
],
"complete": true
}
}
]
$ rbd-nbd --cluster=site-a map --snap-id=4 pool1/test_image
/dev/nbd0
$ rbd-nbd list-mapped
id pool namespace image snap device cookie
511989 pool1 test_image @4 /dev/nbd0
68de2ef3-1d22-43b9-8318-
03f3d31ec8b5
513439 pool1 test_image @5 /dev/nbd1
f3222c04-4048-4c61-a0b1-
28536c4a29a7
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
(cherry picked from commit
75226f1be27cfde36370f4b4253b28fa7954a65f)