Exemplo n.º 1
0
    def test_clear_single_intfs(self):
        runner = CliRunner()
        result = runner.invoke(clear.cli.commands["rifcounters"],
                               ["Ethernet20"])
        print(result.stdout)
        assert result.exit_code == 0
        result = runner.invoke(
            show.cli.commands["interfaces"].commands["counters"].
            commands["rif"], ["Ethernet20"])
        expected = """Ethernet20
----------

        RX:
                 0 packets 
                 0 bytes 
                 0 error packets
                 0 error bytes
        TX:
                 0 packets
                 0 bytes
                 0 error packets
                 0 error bytes
"""
        # remove the counters snapshot
        show.run_command("intfstat -D")
        assert expected in result.output
Exemplo n.º 2
0
def neighbors(ipaddress, info_type):
    """Show IPv6 BGP neighbors"""
    ipaddress = "" if ipaddress is None else ipaddress
    info_type = "" if info_type is None else info_type
    command = 'sudo vtysh -c "show bgp ipv6 neighbor {} {}"'.format(
        ipaddress, info_type)
    run_command(command)
Exemplo n.º 3
0
def summary():
    """Show summarized information of IPv6 BGP state"""
    try:
        device_output = run_command('sudo vtysh -c "show ipv6 bgp summary"', return_cmd=True)
        get_bgp_summary_extended(device_output)
    except Exception:
        run_command('sudo vtysh -c "show ipv6 bgp summary"')
Exemplo n.º 4
0
def network(ipaddress, info_type):
    """Show IP (IPv4) BGP network"""

    command = 'sudo vtysh -c "show ip bgp'

    if ipaddress is not None:
        if '/' in ipaddress:
            # For network prefixes then this all info_type(s) are available
            pass
        else:
            # For an ipaddress then check info_type, exit if specified option doesn't work.
            if info_type in ['longer-prefixes']:
                click.echo(
                    'The parameter option: "{}" only available if passing a network prefix'
                    .format(info_type))
                click.echo(
                    "EX: 'show ip bgp network 10.0.0.0/24 longer-prefixes'")
                raise click.Abort()

        command += ' {}'.format(ipaddress)

        # info_type is only valid if prefix/ipaddress is specified
        if info_type is not None:
            command += ' {}'.format(info_type)

    command += '"'

    run_command(command)
Exemplo n.º 5
0
def summary():
    """Show summarized information of IPv4 BGP state"""
    try:
        device_output = run_command('sudo {} -c "show ip bgp summary"'.format(constants.RVTYSH_COMMAND), return_cmd=True)
        get_bgp_summary_extended(device_output)
    except Exception:
        run_command('sudo {} -c "show ip bgp summary"'.format(constants.RVTYSH_COMMAND))
Exemplo n.º 6
0
    def test_clear_interface(self):
        runner = CliRunner()
        result = runner.invoke(clear.cli.commands["tunnelcounters"], [])
        print(result.stdout)
        assert result.exit_code == 0
        result = runner.invoke(show.cli.commands["vxlan"].commands["counters"], ["vtep1"])
        print(result.stdout)
        expected = show_vxlan_counters_clear_interface_output

        # remove the counters snapshot
        show.run_command("tunnelstat -D")
        for line in expected:
            assert line in result.output
Exemplo n.º 7
0
def neighbors(ipaddress, info_type):
    """Show IP (IPv4) BGP neighbors"""

    command = 'sudo vtysh -c "show ip bgp neighbor'

    if ipaddress is not None:
        command += ' {}'.format(ipaddress)

        # info_type is only valid if ipaddress is specified
        if info_type is not None:
            command += ' {}'.format(info_type)

    command += '"'

    run_command(command)
Exemplo n.º 8
0
def neighbors(ipaddress, info_type):
    """Show IP (IPv4) BGP neighbors"""

    command = 'sudo {} -c "show ip bgp neighbor'.format(constants.RVTYSH_COMMAND)

    if ipaddress is not None:
        command += ' {}'.format(ipaddress)

        # info_type is only valid if ipaddress is specified
        if info_type is not None:
            command += ' {}'.format(info_type)

    command += '"'

    run_command(command)
Exemplo n.º 9
0
    def test_clear(self):
        runner = CliRunner()
        result = runner.invoke(clear.cli.commands["rifcounters"], [])
        print(result.stdout)
        assert result.exit_code == 0
        result = runner.invoke(show.cli.commands["interfaces"].commands["counters"].commands["rif"], [])
        print(result.stdout)
        expected = ["Ethernet20        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0",
                    "PortChannel0001        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0",
                    "PortChannel0002        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0",
                    "PortChannel0003        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0",
                    "PortChannel0004        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0",
                    "Vlan1000        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0"]

        # remove the counters snapshot
        show.run_command("intfstat -D")
        for line in expected:
            assert line in result.output
Exemplo n.º 10
0
    def test_clear(self):
        runner = CliRunner()
        result = runner.invoke(clear.cli.commands["rifcounters"], [])
        print(result.stdout)
        assert result.exit_code == 0
        result = runner.invoke(show.cli.commands["interfaces"].commands["counters"].commands["rif"], [])
        print(result.stdout)
        expected = ["Ethernet20        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0",
                    "PortChannel0001        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0",
                    "PortChannel0002        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0",
                    "PortChannel0003        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0",
                    "PortChannel0004        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0",
                    "Vlan1000        0  0.00 B/s    0.00/s         0        0  0.00 B/s    0.00/s         0"]

        # remove the counters snapshot
        show.run_command("intfstat -D")
        for line in expected:
            assert line in result.output
Exemplo n.º 11
0
    def test_clear_single_intfs(self):
        runner = CliRunner()
        result = runner.invoke(clear.cli.commands["rifcounters"], ["Ethernet20"])
        print(result.stdout)
        assert result.exit_code == 0
        result = runner.invoke(show.cli.commands["interfaces"].commands["counters"].commands["rif"], ["Ethernet20"])
        expected = """Ethernet20
----------

        RX:
                 0 packets 
                 0 bytes 
                 0 error packets
                 0 error bytes
        TX:
                 0 packets
                 0 bytes
                 0 error packets
                 0 error bytes
"""
        # remove the counters snapshot
        show.run_command("intfstat -D")
        assert expected in result.output
Exemplo n.º 12
0
def neighbors(ipaddress, info_type):
    """Show IPv6 BGP neighbors"""
    command = 'sudo vtysh -c "show ipv6 bgp neighbor {} {}"'.format(ipaddress, info_type)
    run_command(command)
Exemplo n.º 13
0
def neighbors(ipaddress, info_type):
    """Show IPv6 BGP neighbors"""
    command = 'sudo {} -c "show ipv6 bgp neighbor {} {}"'.format(
        constants.RVTYSH_COMMAND, ipaddress, info_type)
    run_command(command)