spdkcli: handle intialiazation error
Catch exceptions during RPC client initialization to display meaningful error message. Withouth this change, user gets stacktrace when e.g. SPDK application is not running. Before: ``` Traceback (most recent call last): File "scripts/rpc/client.py", line 53, in __init__ raise socket.error("Unix socket '%s' does not exist" % addr) OSError: Unix socket '/var/tmp/spdk.sock' does not exist During handling of the above exception, another exception occurred: Traceback (most recent call last): File "scripts/spdkcli.py", line 74, in <module> main() File "scripts/spdkcli.py", line 47, in main with rpc.client.JSONRPCClient(args.socket) as client: File "scripts/rpc/client.py", line 56, in __init__ "Error details: %s" % (addr, ex)) rpc.client.JSONRPCException: Error while connecting to /var/tmp/spdk.sock Error details: Unix socket '/var/tmp/spdk.sock' does not exist ``` After: ``` Error while connecting to /var/tmp/spdk.sock Error details: Unix socket '/var/tmp/spdk.sock' does not exist. SPDK not running? ``` Change-Id: I65862965b68acf3bd4709de598f04de49da27de2 Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462020 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Karol Latecki <karol.latecki@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
9b81498be8
commit
6ef78fe661
@ -44,7 +44,13 @@ def main():
|
||||
help="commands to execute by SPDKCli as one-line command")
|
||||
args = parser.parse_args()
|
||||
|
||||
with rpc.client.JSONRPCClient(args.socket) as client:
|
||||
try:
|
||||
client = rpc.client.JSONRPCClient(args.socket)
|
||||
except JSONRPCException as e:
|
||||
spdk_shell.log.error("%s. SPDK not running?" % e)
|
||||
sys.exit(1)
|
||||
|
||||
with client:
|
||||
root_node = UIRoot(client, spdk_shell)
|
||||
root_node.verbose = args.verbose
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user