nbdsh
network block device (NBD) shell
- Provided by: python3-libnbd (Version: 1.2.2-1ubuntu2)
- Source: libnbd
- Report a bug
network block device (NBD) shell
$ nbdsh Welcome to nbdsh, the shell for interacting with Network Block Device (NBD) servers. The ‘nbd’ module has already been imported and there is an open NBD handle called ‘h’. nbd> h.connect_command (["nbdkit", "-s", "memory", "1G"]) nbd> h.get_size () 1073741824 nbd> buf = b"hello, world" nbd> h.pwrite (buf, 0, 0) nbd> exit()
nbdsh is a Python-based client shell for accessing Network Block Device (NBD) servers.
For documentation about the libnbd API please open the shell and type:
help (nbd)
The -u option connects to an NBD URI. The -c option lets you execute single Python statements from the command line. Combining these two options lets you print the size in bytes of an NBD export:
$ nbdsh -u nbd://localhost -c 'print (h.get_size ())' 1073741824
Using -c - you can feed a whole Python program to the standard input of nbdsh:
nbdsh -c - <<'EOF'
from subprocess import *
h.connect_uri ("nbd://localhost")
bootsect = h.pread (512, 0)
p = Popen ("hexdump -C", shell=True, stdin=PIPE)
p.stdin.write (bootsect)
EOF
Richard W.M. Jones
Copyright (C) 2019 Red Hat Inc.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA