tcp_ping

Tests connection to a tcp port and tries to establish a three way handshake. To be used for network discovery or testing.

[1]:
from nornir import InitNornir
from nornir_utils.plugins.tasks.networking import tcp_ping
from nornir_utils.plugins.functions import print_result

nr = InitNornir(
    inventory={
        "plugin": "SimpleInventory",
        "options": {"host_file": "data/hosts.yaml", "group_file": "data/groups.yaml"},
    }
)
nr = nr.filter(name="dev1.group_1")
r = nr.run(task=tcp_ping, ports=[23, 65020], timeout=3)
print_result(r)
tcp_ping************************************************************************
* dev1.group_1 ** changed : False **********************************************
vvvv tcp_ping ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
{23: False, 65020: True}
^^^^ END tcp_ping ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^