Example #1
0
 def nornir_ping_job(self, args):
     task, node, results = args
     nornir_inventory = {node.name: {'nornir_ip': node.ip_address}}
     external = Nornir(inventory=Inventory(nornir_inventory), dry_run=True)
     ping_result = external.run(networking.tcp_ping, ports=[23, 443])
     results[node.name] = str(ping_result[node.name].result)
     return all(res for res in ping_result[node.name].result.keys())
Example #2
0
def job(args):
    # Script that uses Nornir to ping a device
    task, node, results = args
    nornir_inventory = {node.name: {'nornir_ip': node.ip_address}}
    external = Nornir(inventory=Inventory(nornir_inventory), dry_run=True)
    ping_result = external.run(networking.tcp_ping, ports=[23, 443])
    results[node.name] = {
        'success': all(res for res in ping_result[node.name].result.keys()),
        'logs': str(ping_result[node.name].result)
    }
Example #3
0
def job(script, task, device, results, incoming_payload):
    '''Script that uses Nornir to ping a device.'''
    nornir_inventory = {device.name: {'nornir_ip': device.ip_address}}
    external = Nornir(inventory=Inventory(nornir_inventory), dry_run=True)
    ping_result = external.run(networking.tcp_ping, ports=[23, 443])
    return (
        all(res for res in ping_result[device.name].result.keys()),
        str(ping_result[device.name].result),
        incoming_payload,
    )
Example #4
0
def test_tcp_ping_external_hosts():
    external = Nornir(inventory=SimpleInventory(ext_inv_file, ""),
                      dry_run=True)
    result = external.run(networking.tcp_ping, ports=[23, 443])

    assert result
    for h, r in result.items():
        if h == "www.github.com":
            assert r.result[23] is False
            assert r.result[443]
        else:
            assert r.result[23] is False
            assert r.result[443] is False