From 65c1ad0fc3e73ab82e6d433c6f80f25dfdef0533 Mon Sep 17 00:00:00 2001 From: Maciej Szwed Date: Thu, 4 Oct 2018 12:56:36 +0200 Subject: [PATCH] doc: add remote RPC access description Signed-off-by: Maciej Szwed Change-Id: I7dfd9ab4826583c6287b0270ecb919d59722c371 Reviewed-on: https://review.gerrithub.io/428007 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- doc/Doxyfile | 1 + doc/jsonrpc_proxy.md | 51 ++++++++++++++++++++++++++++++++++++++++++++ doc/user_guides.md | 1 + 3 files changed, 53 insertions(+) create mode 100644 doc/jsonrpc_proxy.md diff --git a/doc/Doxyfile b/doc/Doxyfile index 8b3204211..6e4632967 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -815,6 +815,7 @@ INPUT += \ ioat.md \ iscsi.md \ jsonrpc.md \ + jsonrpc_proxy.md \ lvol.md \ memory.md \ nvme.md \ diff --git a/doc/jsonrpc_proxy.md b/doc/jsonrpc_proxy.md new file mode 100644 index 000000000..f2beffbd3 --- /dev/null +++ b/doc/jsonrpc_proxy.md @@ -0,0 +1,51 @@ +# JSON-RPC Remote access {#jsonrpc_proxy} + +SPDK provides a sample python script `rpc_http_proxy.py`, that provides http server which listens for JSON objects from users. It uses HTTP POST method to receive JSON objects including methods and parameters described in this chapter. + +## Parameters + +Name | Optional | Type | Description +----------------------- | -------- | ----------- | ----------- +server IP | Required | string | IP address that JSON objects shall be received on +server port | Required | number | Port number that JSON objects shall be received on +user name | Required | string | User name that will be used for authentication +password | Required | string | Password that will be used for authentication +RPC listen address | Optional | string | Path to SPDK JSON RPC socket. Default: /var/tmp/spdk.sock + +## Example usage + +`spdk/scripts/rpc_http_proxy.py 192.168.0.2 8000 user password` + +## Returns + +Error 401 - missing or incorrect user and/or password. + +Error 400 - wrong JSON syntax or incorrect JSON method + +Status 200 with resultant JSON object included on success. + +## Client side + +Below is a sample python script acting as a client side. It sends `get_bdevs` method with optional `name` parameter and prints JSON object returned from remote_rpc script. + +~~~ +import json +import requests + +if __name__ == '__main__': + payload = {'method': 'get_bdevs', 'params': {'name': 'Malloc0'}} + url = 'http://192.168.0.2:8000/' + req = requests.post(url, + data=json.dumps(payload), + auth=('user', 'password'), + verify=False, + timeout=30) + print (req.json()) +~~~ + +Output: + +~~~ +python client.py +[{u'num_blocks': 2621440, u'name': u'Malloc0', u'uuid': u'fb57e59c-599d-42f1-8b89-3e46dbe12641', u'claimed': True, u'driver_specific': {}, u'supported_io_types': {u'reset': True, u'nvme_admin': False, u'unmap': True, u'read': True, u'nvme_io': False, u'write': True, u'flush': True, u'write_zeroes': True}, u'qos_ios_per_sec': 0, u'block_size': 4096, u'product_name': u'Malloc disk', u'aliases': []}] +~~~ diff --git a/doc/user_guides.md b/doc/user_guides.md index 77793a584..16dc737d3 100644 --- a/doc/user_guides.md +++ b/doc/user_guides.md @@ -7,3 +7,4 @@ - @subpage bdev - @subpage blobfs - @subpage jsonrpc +- @subpage jsonrpc_proxy