Added support for IPv6 address to send JSON request using rpc.py

modified:   scripts/rpc/client.py

Change-Id: I8d06ecde7222f482c6067cedf638a9e38567cdc7
Signed-off-by: suman chakraborty <suman.chakraborty@wdc.com>
Reviewed-on: https://review.gerrithub.io/400445
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
suman chakraborty 2018-02-19 12:39:47 +05:30 committed by Jim Harris
parent 5665dbd91f
commit 4990d65e2b

View File

@ -25,6 +25,11 @@ class JSONRPCClient(object):
if addr.startswith('/'):
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.connect(addr)
elif ':' in addr:
for res in socket.getaddrinfo(addr, port, socket.AF_INET6, socket.SOCK_STREAM, socket.SOL_TCP):
af, socktype, proto, canonname, sa = res
self.sock = socket.socket(af, socktype, proto)
self.sock.connect(sa)
else:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((addr, port))