From: Maxim Chicherin <maximc@xxxxxxxxxxxx> This example provides basic information about existing IB devices: device name, node type, transport type and node GUID, in similar way to ibv_devices example in libibverbs. Signed-off-by: Maxim Chicherin <maximc@xxxxxxxxxxxx> Signed-off-by: Noa Osherovich <noaos@xxxxxxxxxxxx> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- pyverbs/examples/ib_devices.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 pyverbs/examples/ib_devices.py diff --git a/pyverbs/examples/ib_devices.py b/pyverbs/examples/ib_devices.py new file mode 100755 index 00000000..c38164b4 --- /dev/null +++ b/pyverbs/examples/ib_devices.py @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) +# Copyright (c) 2018, Mellanox Technologies. All rights reserved. See COPYING file + +from pyverbs import device as d +import sys + + +lst = d.get_device_list() +dev = 'Device' +node = 'Node Type' +trans = 'Transport Type' +guid = 'Node GUID' +print_format = '{:^20}{:^20}{:^20}{:^20}' +print (print_format.format(dev, node, trans, guid)) +print (print_format.format('-'*len(dev), '-'*len(node), '-'*len(trans), + '-'*len(guid))) +for i in lst: + print (print_format.format(i.name.decode(), d.translate_node_type(i.node_type), + d.translate_transport_type(i.transport_type), + d.guid_to_hex(i.guid))) -- 2.19.1