Commit 83795a16 authored by Karol Latecki's avatar Karol Latecki Committed by Daniel Verkamp
Browse files

spdkcli: initial version with bdev management



Initial version for SPDKCli
Possible basic management of:
- Bdevs: malloc, nvme, aio, lvol
	create / delete operations.
- Lvol stores:
	create / delete operations.

Adding dependency to pkgdep.sh.

Change-Id: I1a03d7660dad0335e25734b8ffb90592a5b337c2
Signed-off-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/405039


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 4ecb2e1d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -804,6 +804,7 @@ INPUT = ../include/spdk \
                         nvmf.md \
                         nvmf_tgt_pg.md \
                         peer_2_peer.md \
                         spdkcli.md \
                         ssd_internals.md \
                         userspace.md \
                         vagrant.md \
+4 −0
Original line number Diff line number Diff line
@@ -53,6 +53,10 @@

- @ref nvme-cli

# Experimental Tools {#experimental_tools}

- @ref spdkcli

# Performance Reports {#performancereports}

- [SPDK 17.07 vhost-scsi Performance Report](https://ci.spdk.io/download/performance-reports/SPDK17_07_vhost_scsi_performance_report.pdf)

doc/spdkcli.md

0 → 100644
+61 −0
Original line number Diff line number Diff line
# SPDK CLI {#spdkcli}

Spdkcli is a command-line management application for SPDK.
Spdkcli has support for a limited number of applications and bdev modules,
and should be considered experimental for the v18.04 release.
This experimental version was added for v18.04 to get early feedback
that can be incorporated as spdkcli becomes more fully-featured
for the next SPDK release.

### Install needed dependencies

All dependencies should be handled by scripts/pkgdep.sh script.
Package dependencies at the moment include:
 - configshell

### Run SPDK application instance

~~~{.sh}
./scripts/setup.sh
./app/vhost/vhost -c vhost.conf
~~~

### Run SPDK CLI

Spdkcli should be run with the same priviliges as SPDK application.
In order to use SPDK CLI in interactive mode please use:
~~~{.sh}
scripts/spdkcli.py
~~~
Use "help" command to get a list of available commands for each tree node.

It is also possible to use SPDK CLI to run just a single command,
just use the command as an argument to the application.
For example, to view current configuration and immediately exit:
 ~~~{.sh}
scripts/spdkcli.py ls
~~~

### Optional - create Python virtual environment

You can use Python virtual environment if you don't want to litter your
system Python installation.

First create the virtual environment:
~~~{.sh}
cd spdk
mkdir venv
virtualenv-3 ./venv
source ./venv/bin/activate
~~~

Then install the dependencies using pip. That way depedencies will be
installed only inside the virtual environment.
~~~{.sh}
(venv) pip install configshell-fb
~~~

Tip: if you are using "sudo" instead of root account, it is suggested to do
"sudo -s" before activating the environment. This is because venv might not work
correctly when calling spdkcli with sudo, like "sudo python spdkcli.py" -
some environment variables might not be passed and you will experience errors.
+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ if [ -s /etc/redhat-release ]; then
	yum install -y doxygen mscgen graphviz
	# Additional dependencies for building pmem based backends
	yum install -y libpmemblk-devel || true
	# Additional dependencies for SPDK CLI
	yum install -y python-configshell
elif [ -f /etc/debian_version ]; then
	# Includes Ubuntu, Debian
	apt-get install -y gcc g++ make libcunit1-dev libaio-dev libssl-dev \
@@ -30,6 +32,8 @@ elif [ -f /etc/debian_version ]; then
	apt-get install -y libnuma-dev
	# Additional dependencies for building docs
	apt-get install -y doxygen mscgen graphviz
	# Additional dependencies for SPDK CLI
	apt-get install -y "python-configshell*"
elif [ $SYSTEM = "FreeBSD" ] ; then
	pkg install gmake cunit openssl git devel/astyle bash devel/pep8 \
		python misc/e2fsprogs-libuuid sysutils/sg3_utils

scripts/spdkcli.py

0 → 100755
+38 −0
Original line number Diff line number Diff line
#!/usr/bin/env python
import sys
import argparse
from os import getuid
from configshell_fb import ConfigShell
from spdkcli import UIRoot


def main():
    """
    Start SPDK CLI
    :return:
    """
    shell = ConfigShell("~/.scripts")

    parser = argparse.ArgumentParser(description="SPDK command line interface")
    parser.add_argument("-s", dest="socket", help="RPC socket path", default="/var/tmp/spdk.sock")
    parser.add_argument("commands", metavar="command", type=str, nargs="*", default="",
                        help="commands to execute by SPDKCli as one-line command")
    args = parser.parse_args()

    root_node = UIRoot(args.socket, shell)
    try:
        root_node.refresh()
    except:
        pass

    if len(args.commands) > 0:
        shell.run_cmdline(" ".join(args.commands))
        sys.exit(0)

    shell.con.display("SPDK CLI v0.1")
    shell.con.display("")
    shell.run_interactive()


if __name__ == "__main__":
    main()
Loading