def test_running_config_via_api(self, t, api):
        enable(t)

        create_vlan(t, "299")
        create_interface_vlan(t, "299")
        configuring_interface_vlan(t, "299", do="ip helper-address 1.1.1.1")
        configuring_interface_vlan(t, "299", do="ip helper-address 2.2.2.2")

        result = api.enable("show running-config interfaces Vlan299",
                            strict=True,
                            encoding="text")

        assert_that(
            result,
            is_([{
                "command": "show running-config interfaces Vlan299",
                "encoding": "text",
                "response": {
                    "output":
                    "interface Vlan299\n   ip helper-address 1.1.1.1\n   ip helper-address 2.2.2.2\n"
                },
                "result": {
                    "output":
                    "interface Vlan299\n   ip helper-address 1.1.1.1\n   ip helper-address 2.2.2.2\n"
                }
            }]))

        remove_interface_vlan(t, "299")
        remove_vlan(t, "299")
    def test_interface_with_no_mpls_ip(self, t):
        enable(t)

        configuring_interface_vlan(t, "299", do="no mpls ip")

        assert_interface_configuration(t, "Vlan299",
                                       ["interface Vlan299", "   no mpls ip"])
Example #3
0
    def test_overlapping_ips(self, t):
        enable(t)

        create_vlan(t, "1000")
        create_interface_vlan(t, "1000")
        create_vlan(t, "2000")
        create_interface_vlan(t, "2000")

        configuring_interface_vlan(t, "1000", do="ip address 2.2.2.2/24")
        configuring_interface_vlan(t, "1000", do="ip address 3.3.3.3/24 secondary")

        t.write("configure terminal")
        t.read("my_arista(config)#")
        t.write("interface vlan2000")
        t.read("my_arista(config-if-Vl2000)#")

        t.write("ip address 2.2.2.75/25")
        t.readln("% Subnet 2.2.2.0 overlaps with existing subnet 2.2.2.0 of interface Vlan1000")
        t.read("my_arista(config-if-Vl2000)#")

        t.write("exit")
        t.read("my_arista(config)#")
        t.write("exit")
        t.read("my_arista#")

        remove_interface_vlan(t, "2000")
        remove_vlan(t, "2000")
        remove_interface_vlan(t, "1000")
        remove_vlan(t, "1000")
Example #4
0
    def test_running_config_multiple_interfaces(self, t, api):
        enable(t)

        create_vlan(t, "1000")
        create_interface_vlan(t, "1000")

        create_vlan(t, "2000")
        create_interface_vlan(t, "2000")

        configuring_interface_vlan(t, "1000", do="ip address 1.1.1.1/27")
        configuring_interface_vlan(t, "2000", do="ip address 2.2.2.2/27")
        configuring_interface(t, "Et1", do="switchport trunk allowed vlan 123-124,127")
        configuring_interface(t, "Et2", do="switchport mode trunk")

        t.write("show running-config interfaces Et2 vla 2000 ETHERNET 1 vlan 1000")
        t.readln("interface Ethernet1")
        t.readln("   switchport trunk allowed vlan 123-124,127")
        t.readln("interface Ethernet2")
        t.readln("   switchport mode trunk")
        t.readln("interface Vlan1000")
        t.readln("   ip address 1.1.1.1/27")
        t.readln("interface Vlan2000")
        t.readln("   ip address 2.2.2.2/27")
        t.read("my_arista#")

        result = api.get_config(params="interfaces Vlan1000 Ethernet2 Ethernet1 Vlan2000")

        assert_that(result, is_([
            "interface Ethernet1",
            "   switchport trunk allowed vlan 123-124,127",
            "interface Ethernet2",
            "   switchport mode trunk",
            "interface Vlan1000",
            "   ip address 1.1.1.1/27",
            "interface Vlan2000",
            "   ip address 2.2.2.2/27",
            ""
        ]))

        configuring_interface(t, "Et1", do="no switchport trunk allowed vlan")
        configuring_interface(t, "Et2", do="no switchport mode")

        remove_interface_vlan(t, "1000")
        remove_vlan(t, "1000")

        remove_interface_vlan(t, "2000")
        remove_vlan(t, "2000")
    def test_running_config_with_load_interval_via_api(self, t, api):
        enable(t)
        configuring_interface_vlan(t, "299", do="load-interval 30")

        result = api.enable("show running-config interfaces Vlan299",
                            strict=True,
                            encoding="text")

        assert_that(
            result,
            is_([{
                "command": "show running-config interfaces Vlan299",
                "encoding": "text",
                "response": {
                    "output": "interface Vlan299\n   load-interval 30\n"
                },
                "result": {
                    "output": "interface Vlan299\n   load-interval 30\n"
                }
            }]))
    def test_show_interfaces(self, t, api):
        enable(t)

        create_vlan(t, "299")
        create_interface_vlan(t, "299")
        configuring_interface_vlan(t, "299", do="ip address 1.1.1.2/24")

        create_vlan(t, "777")
        create_interface_vlan(t, "777")
        configuring_interface_vlan(t, "777", do="ip address 7.7.7.7/24")

        t.write("show interfaces")
        t.readln("Ethernet1 is up, line protocol is up (connected)")
        t.readln("  Hardware is Ethernet, address is 0000.0000.0000 (bia 0000.0000.0000)")
        t.readln("  Ethernet MTU 9214 bytes")
        t.readln("  Full-duplex, Unconfigured, auto negotiation: off, uni-link: n/a")
        t.readln("  Up 0 minutes, 0 seconds")
        t.readln("  Loopback Mode : None")
        t.readln("  0 link status changes since last clear")
        t.readln("  Last clearing of \"show interface\" counters never")
        t.readln("  0 minutes input rate 0 bps (- with framing overhead), 0 packets/sec")
        t.readln("  0 minutes output rate 0 bps (- with framing overhead), 0 packets/sec")
        t.readln("     0 packets input, 0 bytes")
        t.readln("     Received 0 broadcasts, 0 multicast")
        t.readln("     0 runts, 0 giants")
        t.readln("     0 input errors, 0 CRC, 0 alignment, 0 symbol, 0 input discards")
        t.readln("     0 PAUSE input")
        t.readln("     0 packets output, 0 bytes")
        t.readln("     Sent 0 broadcasts, 0 multicast")
        t.readln("     0 output errors, 0 collisions")
        t.readln("     0 late collision, 0 deferred, 0 output discards")
        t.readln("     0 PAUSE output")
        t.readln("Ethernet2 is up, line protocol is up (connected)")
        t.readln("  Hardware is Ethernet, address is 0000.0000.0000 (bia 0000.0000.0000)")
        t.readln("  Ethernet MTU 9214 bytes")
        t.readln("  Full-duplex, Unconfigured, auto negotiation: off, uni-link: n/a")
        t.readln("  Up 0 minutes, 0 seconds")
        t.readln("  Loopback Mode : None")
        t.readln("  0 link status changes since last clear")
        t.readln("  Last clearing of \"show interface\" counters never")
        t.readln("  0 minutes input rate 0 bps (- with framing overhead), 0 packets/sec")
        t.readln("  0 minutes output rate 0 bps (- with framing overhead), 0 packets/sec")
        t.readln("     0 packets input, 0 bytes")
        t.readln("     Received 0 broadcasts, 0 multicast")
        t.readln("     0 runts, 0 giants")
        t.readln("     0 input errors, 0 CRC, 0 alignment, 0 symbol, 0 input discards")
        t.readln("     0 PAUSE input")
        t.readln("     0 packets output, 0 bytes")
        t.readln("     Sent 0 broadcasts, 0 multicast")
        t.readln("     0 output errors, 0 collisions")
        t.readln("     0 late collision, 0 deferred, 0 output discards")
        t.readln("     0 PAUSE output")
        t.readln("Vlan299 is up, line protocol is up (connected)")
        t.readln("  Hardware is Vlan, address is 0000.0000.0000 (bia 0000.0000.0000)")
        t.readln("  Internet address is 1.1.1.2/24")
        t.readln("  Broadcast address is 255.255.255.255")
        t.readln("  IP MTU 1500 bytes")
        t.readln("  Up 0 minutes, 0 seconds")
        t.readln("Vlan777 is up, line protocol is up (connected)")
        t.readln("  Hardware is Vlan, address is 0000.0000.0000 (bia 0000.0000.0000)")
        t.readln("  Internet address is 7.7.7.7/24")
        t.readln("  Broadcast address is 255.255.255.255")
        t.readln("  IP MTU 1500 bytes")
        t.readln("  Up 0 minutes, 0 seconds")
        t.read("my_arista#")

        result = api.enable("show interfaces")

        expected = [
            {
                "command": "show interfaces",
                "encoding": "json",
                "result": {
                    "sourceDetail": "",
                    "interfaces": {
                        "Ethernet1": {
                            "lastStatusChangeTimestamp": 0.0,
                            "name": "Ethernet1",
                            "interfaceStatus": "connected",
                            "autoNegotiate": "unknown",
                            "burnedInAddress": "00:00:00:00:00:00",
                            "loopbackMode": "loopbackNone",
                            "interfaceStatistics": {
                                "inBitsRate": 0.0,
                                "inPktsRate": 0.0,
                                "outBitsRate": 0.0,
                                "updateInterval": 0.0,
                                "outPktsRate": 0.0
                            },
                            "mtu": 9214,
                            "hardware": "ethernet",
                            "duplex": "duplexFull",
                            "bandwidth": 0,
                            "forwardingModel": "bridged",
                            "lineProtocolStatus": "up",
                            "interfaceCounters": {
                                "outBroadcastPkts": 0,
                                "outUcastPkts": 0,
                                "totalOutErrors": 0,
                                "inMulticastPkts": 0,
                                "counterRefreshTime": 0.0,
                                "inBroadcastPkts": 0,
                                "outputErrorsDetail": {
                                    "deferredTransmissions": 0,
                                    "txPause": 0,
                                    "collisions": 0,
                                    "lateCollisions": 0
                                },
                                "inOctets": 0,
                                "outDiscards": 0,
                                "outOctets": 0,
                                "inUcastPkts": 0,
                                "inTotalPkts": 0,
                                "inputErrorsDetail": {
                                    "runtFrames": 0,
                                    "rxPause": 0,
                                    "fcsErrors": 0,
                                    "alignmentErrors": 0,
                                    "giantFrames": 0,
                                    "symbolErrors": 0
                                },
                                "linkStatusChanges": 5,
                                "outMulticastPkts": 0,
                                "totalInErrors": 0,
                                "inDiscards": 0
                            },
                            "interfaceAddress": [],
                            "physicalAddress": "00:00:00:00:00:00",
                            "description": ""
                        },
                        "Ethernet2": {
                            "lastStatusChangeTimestamp": 0.0,
                            "name": "Ethernet2",
                            "interfaceStatus": "connected",
                            "autoNegotiate": "unknown",
                            "burnedInAddress": "00:00:00:00:00:00",
                            "loopbackMode": "loopbackNone",
                            "interfaceStatistics": {
                                "inBitsRate": 0.0,
                                "inPktsRate": 0.0,
                                "outBitsRate": 0.0,
                                "updateInterval": 0.0,
                                "outPktsRate": 0.0
                            },
                            "mtu": 9214,
                            "hardware": "ethernet",
                            "duplex": "duplexFull",
                            "bandwidth": 0,
                            "forwardingModel": "bridged",
                            "lineProtocolStatus": "up",
                            "interfaceCounters": {
                                "outBroadcastPkts": 0,
                                "outUcastPkts": 0,
                                "totalOutErrors": 0,
                                "inMulticastPkts": 0,
                                "counterRefreshTime": 0.0,
                                "inBroadcastPkts": 0,
                                "outputErrorsDetail": {
                                    "deferredTransmissions": 0,
                                    "txPause": 0,
                                    "collisions": 0,
                                    "lateCollisions": 0
                                },
                                "inOctets": 0,
                                "outDiscards": 0,
                                "outOctets": 0,
                                "inUcastPkts": 0,
                                "inTotalPkts": 0,
                                "inputErrorsDetail": {
                                    "runtFrames": 0,
                                    "rxPause": 0,
                                    "fcsErrors": 0,
                                    "alignmentErrors": 0,
                                    "giantFrames": 0,
                                    "symbolErrors": 0
                                },
                                "linkStatusChanges": 5,
                                "outMulticastPkts": 0,
                                "totalInErrors": 0,
                                "inDiscards": 0
                            },
                            "interfaceAddress": [],
                            "physicalAddress": "00:00:00:00:00:00",
                            "description": ""
                        },
                        "Vlan299": {
                            "bandwidth": 0,
                            "burnedInAddress": "00:00:00:00:00:00",
                            "description": "",
                            "forwardingModel": "routed",
                            "hardware": "vlan",
                            "interfaceAddress": [
                                {
                                    "broadcastAddress": "255.255.255.255",
                                    "dhcp": False,
                                    "primaryIp": {
                                        "address": "1.1.1.2",
                                        "maskLen": 24
                                    },
                                    "secondaryIps": {},
                                    "secondaryIpsOrderedList": [],
                                    "virtualIp": {
                                        "address": "0.0.0.0",
                                        "maskLen": 0
                                    },
                                    "virtualSecondaryIps": {},
                                    "virtualSecondaryIpsOrderedList": []
                                }
                            ],
                            "interfaceStatus": "connected",
                            "lastStatusChangeTimestamp": 0.0,
                            "lineProtocolStatus": "up",
                            "mtu": 1500,
                            "name": "Vlan299",
                            "physicalAddress": "00:00:00:00:00:00"
                        },
                        "Vlan777": {
                            "bandwidth": 0,
                            "burnedInAddress": "00:00:00:00:00:00",
                            "description": "",
                            "forwardingModel": "routed",
                            "hardware": "vlan",
                            "interfaceAddress": [
                                {
                                    "broadcastAddress": "255.255.255.255",
                                    "dhcp": False,
                                    "primaryIp": {
                                        "address": "7.7.7.7",
                                        "maskLen": 24
                                    },
                                    "secondaryIps": {},
                                    "secondaryIpsOrderedList": [],
                                    "virtualIp": {
                                        "address": "0.0.0.0",
                                        "maskLen": 0
                                    },
                                    "virtualSecondaryIps": {},
                                    "virtualSecondaryIpsOrderedList": []
                                }
                            ],
                            "interfaceStatus": "connected",
                            "lastStatusChangeTimestamp": 0.0,
                            "lineProtocolStatus": "up",
                            "mtu": 1500,
                            "name": "Vlan777",
                            "physicalAddress": "00:00:00:00:00:00"
                        }
                    }
                }
            }
        ]
        assert_that(result, is_(expected), "actual={}\nexpected={}".format(json.dumps(result), json.dumps(expected)))

        remove_interface_vlan(t, "299")
        remove_vlan(t, "299")

        remove_interface_vlan(t, "777")
        remove_vlan(t, "777")
    def test_setup_in_running_config(self, t):
        enable(t)

        create_vlan(t, "299")
        create_interface_vlan(t, "299")
        configuring_interface_vlan(t, "299", do="ip helper-address 1.1.1.1")

        assert_interface_configuration(
            t, "Vlan299",
            ["interface Vlan299", "   ip helper-address 1.1.1.1"])

        configuring_interface_vlan(t,
                                   "299",
                                   do="ip helper-address one.one.one.one")
        configuring_interface_vlan(t,
                                   "299",
                                   do="ip helper-address one-one-one-one")

        assert_interface_configuration(t, "Vlan299", [
            "interface Vlan299",
            "   ip helper-address 1.1.1.1",
            "   ip helper-address one.one.one.one",
            "   ip helper-address one-one-one-one",
        ])

        configuring_interface_vlan(t,
                                   "299",
                                   do="no ip helper-address one.one.one.one")

        assert_interface_configuration(t, "Vlan299", [
            "interface Vlan299",
            "   ip helper-address 1.1.1.1",
            "   ip helper-address one-one-one-one",
        ])

        configuring_interface_vlan(t, "299", do="ip helper-address 1.1.1.1")

        assert_interface_configuration(t, "Vlan299", [
            "interface Vlan299",
            "   ip helper-address 1.1.1.1",
            "   ip helper-address one-one-one-one",
        ])

        configuring_interface_vlan(t, "299", do="no ip helper-address")

        assert_interface_configuration(t, "Vlan299", ["interface Vlan299"])

        remove_interface_vlan(t, "299")
        remove_vlan(t, "299")
Example #8
0
    def test_ip_address_setup(self, t, api):
        enable(t)

        create_vlan(t, "299")
        create_interface_vlan(t, "299")
        assert_interface_configuration(t, "Vlan299", [
            "interface Vlan299"
        ])

        configuring_interface_vlan(t, "299", do="ip address 1.1.1.2/27")

        assert_interface_configuration(t, "Vlan299", [
            "interface Vlan299",
            "   ip address 1.1.1.2/27"
        ])

        configuring_interface_vlan(t, "299", do="ip address 1.1.1.3 255.255.255.0")

        assert_interface_configuration(t, "Vlan299", [
            "interface Vlan299",
            "   ip address 1.1.1.3/24"
        ])

        configuring_interface_vlan(t, "299", do="ip address 1.1.1.4/27 secondary")
        configuring_interface_vlan(t, "299", do="ip address 1.1.1.5/27 secondary")

        assert_interface_configuration(t, "Vlan299", [
            "interface Vlan299",
            "   ip address 1.1.1.3/24",
            "   ip address 1.1.1.4/27 secondary",
            "   ip address 1.1.1.5/27 secondary"
        ])

        t.write("show interfaces vlan 0299")
        t.readln("Vlan299 is up, line protocol is up (connected)")
        t.readln("  Hardware is Vlan, address is 0000.0000.0000 (bia 0000.0000.0000)")
        t.readln("  Internet address is 1.1.1.3/24")
        t.readln("  Secondary address is 1.1.1.4/27")
        t.readln("  Secondary address is 1.1.1.5/27")
        t.readln("  Broadcast address is 255.255.255.255")
        t.readln("  IP MTU 1500 bytes")
        t.readln("  Up 0 minutes, 0 seconds")
        t.read("my_arista#")

        result = api.enable("show interfaces VLAN0299")

        assert_that(result, is_([
            {
                "command": "show interfaces VLAN0299",
                "encoding": "json",
                "result": {
                    "sourceDetail": "",
                    "interfaces": {
                        "Vlan299": {
                            "bandwidth": 0,
                            "burnedInAddress": "00:00:00:00:00:00",
                            "description": "",
                            "forwardingModel": "routed",
                            "hardware": "vlan",
                            "interfaceAddress": [
                                {
                                    "broadcastAddress": "255.255.255.255",
                                    "dhcp": False,
                                    "primaryIp": {
                                        "address": "1.1.1.3",
                                        "maskLen": 24
                                    },
                                    "secondaryIps": {
                                        "1.1.1.4": {
                                            "address": "1.1.1.4",
                                            "maskLen": 27
                                        },
                                        "1.1.1.5": {
                                            "address": "1.1.1.5",
                                            "maskLen": 27
                                        }
                                    },
                                    "secondaryIpsOrderedList": [
                                        {
                                            "address": "1.1.1.4",
                                            "maskLen": 27
                                        },
                                        {
                                            "address": "1.1.1.5",
                                            "maskLen": 27
                                        }
                                    ],
                                    "virtualIp": {
                                        "address": "0.0.0.0",
                                        "maskLen": 0
                                    },
                                    "virtualSecondaryIps": {},
                                    "virtualSecondaryIpsOrderedList": []
                                }
                            ],
                            "interfaceStatus": "connected",
                            "lastStatusChangeTimestamp": 0.0,
                            "lineProtocolStatus": "up",
                            "mtu": 1500,
                            "name": "Vlan299",
                            "physicalAddress": "00:00:00:00:00:00"
                        }
                    }
                }
            }
        ]))

        configuring_interface_vlan(t, "299", do="no ip address")

        assert_interface_configuration(t, "Vlan299", [
            "interface Vlan299"
        ])

        remove_interface_vlan(t, "299")
        remove_vlan(t, "299")
Example #9
0
    def test_interface_vlan_with_removed_ip_has_an_empty_interface_address(self, t, api):
        enable(t)

        create_vlan(t, "299")
        create_interface_vlan(t, "299")
        configuring_interface_vlan(t, "299", do="ip address 1.1.1.2/24")
        configuring_interface_vlan(t, "299", do="no ip address")

        t.write("show interfaces Vlan299")
        t.readln("Vlan299 is up, line protocol is up (connected)")
        t.readln("  Hardware is Vlan, address is 0000.0000.0000 (bia 0000.0000.0000)")
        t.readln("  No Internet protocol address assigned")
        t.readln("  IP MTU 1500 bytes")
        t.readln("  Up 0 minutes, 0 seconds")
        t.read("my_arista#")

        result = api.enable("show interfaces Vlan299")
        assert_that(result, is_([
            {
                "command": "show interfaces Vlan299",
                "encoding": "json",
                "result": {
                    "sourceDetail": "",
                    "interfaces": {
                        "Vlan299": {
                            "lastStatusChangeTimestamp": 0.0,
                            "name": "Vlan299",
                            "interfaceStatus": "connected",
                            "burnedInAddress": "00:00:00:00:00:00",
                            "mtu": 1500,
                            "hardware": "vlan",
                            "bandwidth": 0,
                            "forwardingModel": "routed",
                            "lineProtocolStatus": "up",
                            "interfaceAddress": [
                                {
                                    "secondaryIpsOrderedList": [],
                                    "broadcastAddress": "255.255.255.255",
                                    "virtualSecondaryIps": {},
                                    "dhcp": False,
                                    "secondaryIps": {},
                                    "primaryIp": {
                                        "maskLen": 0,
                                        "address": "0.0.0.0"
                                    },
                                    "virtualSecondaryIpsOrderedList": [],
                                    "virtualIp": {
                                        "maskLen": 0,
                                        "address": "0.0.0.0"
                                    }
                                }
                            ],
                            "physicalAddress": "00:00:00:00:00:00",
                            "description": ""
                        }
                    }
                }
            }
        ]))

        remove_interface_vlan(t, "299")
        remove_vlan(t, "299")
    def test_no_load_interval(self, t):
        enable(t)
        configuring_interface_vlan(t, "299", do="load-interval 30")
        configuring_interface_vlan(t, "299", do="no load-interval")

        assert_interface_configuration(t, "Vlan299", ["interface Vlan299"])