Exemple #1
0
def test_hop_repr_str():
    hop = Hop(
        "node1",
        [
            Step(EnterInputIfaceStepDetail("in_iface1", "in_vrf1"), "SENT_IN"),
            Step(
                RoutingStepDetail(
                    [
                        {
                            "network": "1.1.1.1/24",
                            "protocol": "bgp",
                            "nextHopIp": "1.2.3.4",
                        },
                        {
                            "network": "1.1.1.2/24",
                            "protocol": "static",
                            "nextHopIp": "1.2.3.5",
                        },
                    ],
                    "12.123.1.2",
                    "iface1",
                ),
                "FORWARDED",
            ),
            Step(FilterStepDetail("preSourceNat_filter", "PRENAT", "", ""),
                 "PERMITTED"),
            Step(ExitOutputIfaceStepDetail("out_iface1", None), "SENT_OUT"),
        ],
    )

    assert (
        str(hop) == "node: node1\n  SENT_IN(in_iface1)\n"
        "  FORWARDED(ARP IP: 12.123.1.2, Output Interface: iface1, Routes: [bgp (Network: 1.1.1.1/24, Next Hop IP:1.2.3.4),static (Network: 1.1.1.2/24, Next Hop IP:1.2.3.5)])\n  "
        "PERMITTED(preSourceNat_filter (PRENAT))\n  SENT_OUT(out_iface1)")
Exemple #2
0
def test_hop_repr_str():
    hop = Hop(
        "node1",
        [
            Step(EnterInputIfaceStepDetail("in_iface1", "in_vrf1"), "SENT_IN"),
            Step(
                RoutingStepDetail(
                    [
                        RouteInfo("bgp", "1.1.1.1/24", NextHopIp("1.2.3.4"),
                                  None, 1, 1),
                        RouteInfo("static", "1.1.1.2/24", NextHopIp("1.2.3.5"),
                                  None, 1, 1),
                    ],
                    ForwardedOutInterface("iface1", "12.123.1.2"),
                    "12.123.1.2",
                    "iface1",
                ),
                "FORWARDED",
            ),
            Step(FilterStepDetail("preSourceNat_filter", "PRENAT", "", ""),
                 "PERMITTED"),
            Step(ExitOutputIfaceStepDetail("out_iface1", None), "SENT_OUT"),
        ],
    )

    assert (
        str(hop) == "node: node1\n  SENT_IN(in_iface1)\n"
        "  FORWARDED(Forwarded out interface: iface1 with resolved next-hop IP: 12.123.1.2, Routes: [bgp (Network: 1.1.1.1/24, Next Hop: ip 1.2.3.4),static (Network: 1.1.1.2/24, Next Hop: ip 1.2.3.5)])\n  "
        "PERMITTED(preSourceNat_filter (PRENAT))\n  SENT_OUT(out_iface1)")
Exemple #3
0
def test_hop_repr_str():
    hop = Hop("node1", [
        Step(
            EnterInputIfaceStepDetail("in_iface1", "in_vrf1", "in_filter1"),
            "SENT_IN"),
        Step(RoutingStepDetail(
            [{"network": "1.1.1.1/24", "protocol": "bgp",
              "nextHopIp": "1.2.3.4"},
             {"network": "1.1.1.2/24", "protocol": "static",
              "nextHopIp": "1.2.3.5"}]), "FORWARDED"),
        Step(ExitOutputIfaceStepDetail("out_iface1", "out_filter1", None),
             "SENT_OUT")
    ])

    assert str(
        hop) == "node: node1\n  SENT_IN(in_iface1: in_filter1)\n  FORWARDED(Routes: bgp [Network: 1.1.1.1/24, Next Hop IP:1.2.3.4],static [Network: 1.1.1.2/24, Next Hop IP:1.2.3.5])\n  SENT_OUT(out_iface1: out_filter1)"
Exemple #4
0
def test_exit_output_iface_step_detail_str():
    detail = ExitOutputIfaceStepDetail("iface", None)

    step = Step(detail, "ACTION")
    assert str(step) == "ACTION(iface)"