Esempio n. 1
0
    def test_no_switchport_mode_in_general_mode(self, t):
        enable(t)

        configuring_vlan(t, 1264)

        configure(t)
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("switchport mode general")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("switchport general pvid 1264")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1264")

        t.readln(
            "Warning: The use of large numbers of VLANs or interfaces may cause significant"
        )
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general pvid 1264",
            "switchport general allowed vlan add 1264",
        ])

        configure(t)
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("no switchport mode")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'ethernet 1/g1', [
            "",
        ])

        unconfigure_vlan(t, 1264)
Esempio n. 2
0
    def test_show_vlan_id(self, t):
        enable(t)

        configuring_vlan(t, 1000)

        t.write("show vlan id 500")
        t.readln("")
        t.readln("ERROR: This VLAN does not exist.")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id 1000")
        t.readln("")
        t.readln("VLAN       Name                         Ports          Type      Authorization")
        t.readln("-----  ---------------                  -------------  -----     -------------")
        t.readln("1000                                                   Static    Required     ")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id bleh")
        t.readln("                     ^")
        t.readln("Invalid input. Please specify an integer in the range 1 to 4093.")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id")
        t.readln("")
        t.readln("Command not found / Incomplete command. Use ? to list commands.")
        t.readln("")
        t.read("my_switch#")

        unconfigure_vlan(t, 1000)
Esempio n. 3
0
    def test_editing_vlan(self, t):
        enable(t)
        configure(t)

        t.write("interface vlan 1260")
        t.readln("VLAN ID not found.")
        t.readln("")

        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        configuring_vlan(t, 1260)

        configure(t)
        t.write("interface vlan 1260")
        t.readln("")
        t.read("my_switch(config-if-vlan1260)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        unconfigure_vlan(t, 1260)
Esempio n. 4
0
    def test_editing_vlan(self, t):
        enable(t)
        configure(t)

        t.write("interface vlan 1260")
        t.readln("VLAN ID not found.")
        t.readln("")

        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        configuring_vlan(t, 1260)

        configure(t)
        t.write("interface vlan 1260")
        t.readln("")
        t.read("my_switch(config-if-vlan1260)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        unconfigure_vlan(t, 1260)
    def test_no_switchport_mode_in_general_mode(self, t):
        enable(t)

        configuring_vlan(t, 1264)

        configure(t)
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("switchport mode general")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("switchport general pvid 1264")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1264")

        t.readln("Warning: The use of large numbers of VLANs or interfaces may cause significant")
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general pvid 1264",
            "switchport general allowed vlan add 1264",
        ])

        configure(t)
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("no switchport mode")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'ethernet 1/g1', [
            "",
        ])

        unconfigure_vlan(t, 1264)
Esempio n. 6
0
    def test_switchport_mode(self, t):
        enable(t)

        configuring_vlan(t, 1264)
        configuring_vlan(t, 1265)

        assert_interface_configuration(t, 'ethernet 1/g1', [""])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        assert_interface_configuration(t, 'ethernet 1/g1', [""])

        configuring_a_vlan_on_interface(t,
                                        "ethernet 1/g1",
                                        do="switchport access vlan 1264")
        assert_interface_configuration(t, 'ethernet 1/g1',
                                       ["switchport access vlan 1264"])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        assert_interface_configuration(t, 'ethernet 1/g1',
                                       ["switchport access vlan 1264"])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode general")
        assert_interface_configuration(t, 'ethernet 1/g1',
                                       ["switchport mode general"])

        configuring_interface(t,
                              "ethernet 1/g1",
                              do="switchport general pvid 1264")
        assert_interface_configuration(
            t, 'ethernet 1/g1',
            ["switchport mode general", "switchport general pvid 1264"])

        configuring_a_vlan_on_interface(
            t, "ethernet 1/g1", do="switchport general allowed vlan add 1265")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general pvid 1264",
            "switchport general allowed vlan add 1265",
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode trunk")
        assert_interface_configuration(t, 'ethernet 1/g1',
                                       ["switchport mode trunk"])

        configuring_a_vlan_on_interface(
            t, "ethernet 1/g1", do="switchport trunk allowed vlan add 1265")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan add 1265",
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        assert_interface_configuration(t, 'ethernet 1/g1', [""])

        unconfigure_vlan(t, 1265)
        unconfigure_vlan(t, 1264)
Esempio n. 7
0
    def test_switchport_general_pvid(self, t):
        enable(t)

        configuring_vlan(t, 1264)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general pvid 1264")
        t.readln("")
        t.readln("Port is not general port.")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport mode general")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general pvid 1500")
        t.readln("Could not configure pvid.")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general pvid 1264")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(
            t, 'ethernet 1/g1',
            ["switchport mode general", "switchport general pvid 1264"])

        configuring_interface(t,
                              "ethernet 1/g1",
                              do="no switchport general pvid")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "",
        ])

        unconfigure_vlan(t, 1264)
    def test_switchport_general_pvid(self, t):
        enable(t)

        configuring_vlan(t, 1264)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general pvid 1264")
        t.readln("")
        t.readln("Port is not general port.")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport mode general")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general pvid 1500")
        t.readln("Could not configure pvid.")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general pvid 1264")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general pvid 1264"
        ])

        configuring_interface(t, "ethernet 1/g1", do="no switchport general pvid")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "",
        ])

        unconfigure_vlan(t, 1264)
Esempio n. 9
0
    def test_configuring_a_vlan(self, t):
        enable(t)

        configuring_vlan(t, 1234)

        assert_running_config_contains_in_order(
            t, ["vlan database", "vlan 1,1234", "exit"])

        unconfigure_vlan(t, 1234)

        assert_running_config_contains_in_order(
            t, ["vlan database", "vlan 1", "exit"])
Esempio n. 10
0
    def test_access_vlan(self, t):
        enable(t)

        configuring_vlan(t, 1264)

        configure(t)
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("switchport access vlan 1264")
        t.readln(
            "Warning: The use of large numbers of VLANs or interfaces may cause significant"
        )
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport access vlan 1264",
        ])

        configure(t)
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("no switchport access vlan")
        t.readln(
            "Warning: The use of large numbers of VLANs or interfaces may cause significant"
        )
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'ethernet 1/g1', [""])

        unconfigure_vlan(t, 1264)
    def test_switchport_add_remove_general_trunk_vlans(self, t):
        enable(t)

        configuring_vlan(t, 1200)
        configuring_vlan(t, 1201)
        configuring_vlan(t, 1202)
        configuring_vlan(t, 1203)
        configuring_vlan(t, 1205)

        configuring_interface(t, "ethernet 1/g1", do="switchport mode general")
        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan add 1200")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general allowed vlan add 1200",
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan add 1200,1201")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general allowed vlan add 1200-1201",
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan add 1201-1203,1205")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general allowed vlan add 1200-1203,1205",
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan remove 1202")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general allowed vlan add 1200-1201,1203,1205",
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan remove 1203,1205")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general allowed vlan add 1200-1201",
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan remove 1200-1203")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")

        unconfigure_vlan(t, 1200)
        unconfigure_vlan(t, 1201)
        unconfigure_vlan(t, 1202)
        unconfigure_vlan(t, 1203)
        unconfigure_vlan(t, 1205)
    def test_switchport_add_remove_general_trunk_vlans(self, t):
        enable(t)

        configuring_vlan(t, 1200)
        configuring_vlan(t, 1201)
        configuring_vlan(t, 1202)
        configuring_vlan(t, 1203)
        configuring_vlan(t, 1205)

        configuring_interface(t, "ethernet 1/g1", do="switchport mode general")
        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan add 1200")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general allowed vlan add 1200",
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan add 1200,1201")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general allowed vlan add 1200-1201",
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan add 1201-1203,1205")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general allowed vlan add 1200-1203,1205",
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan remove 1202")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general allowed vlan add 1200-1201,1203,1205",
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan remove 1203,1205")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general allowed vlan add 1200-1201",
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan remove 1200-1203")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")

        unconfigure_vlan(t, 1200)
        unconfigure_vlan(t, 1201)
        unconfigure_vlan(t, 1202)
        unconfigure_vlan(t, 1203)
        unconfigure_vlan(t, 1205)
Esempio n. 13
0
    def test_show_vlan_id_with_ports(self, t):
        enable(t)

        configuring_vlan(t, 1000)
        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport access vlan 1000")

        t.write("show vlan id 1000")
        t.readln("")
        t.readln("VLAN       Name                         Ports          Type      Authorization")
        t.readln("-----  ---------------                  -------------  -----     -------------")
        t.readln("1000                                    1/g1           Static    Required     ")
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "ethernet 1/g1", do="switchport mode trunk")
        t.write("show vlan id 1000")
        t.readln("")
        t.readln("VLAN       Name                         Ports          Type      Authorization")
        t.readln("-----  ---------------                  -------------  -----     -------------")
        t.readln("1000                                                   Static    Required     ")
        t.readln("")
        t.read("my_switch#")

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport trunk allowed vlan add 1000")
        configuring_interface(t, "ethernet 1/g2", do="switchport mode trunk")
        configuring_a_vlan_on_interface(t, "ethernet 1/g2", do="switchport trunk allowed vlan add 1000")
        t.write("show vlan id 1000")
        t.readln("")
        t.readln("VLAN       Name                         Ports          Type      Authorization")
        t.readln("-----  ---------------                  -------------  -----     -------------")
        t.readln("1000                                    1/g1-1/g2      Static    Required     ")
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "ethernet 1/xg1", do="switchport mode trunk")
        configuring_a_vlan_on_interface(t, "ethernet 1/xg1", do="switchport trunk allowed vlan add 1000")
        t.write("show vlan id 1000")
        t.readln("")
        t.readln("VLAN       Name                         Ports          Type      Authorization")
        t.readln("-----  ---------------                  -------------  -----     -------------")
        t.readln("1000                                    1/g1-1/g2,     Static    Required     ")
        t.readln("                                        1/xg1                                 ")
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        configuring_interface(t, "ethernet 1/g2", do="switchport mode access")
        configuring_interface(t, "ethernet 1/xg1", do="switchport mode access")

        unconfigure_vlan(t, 1000)
    def test_access_vlan(self, t):
        enable(t)

        configuring_vlan(t, 1264)

        configure(t)
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("switchport access vlan 1264")
        t.readln("Warning: The use of large numbers of VLANs or interfaces may cause significant")
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport access vlan 1264",
        ])

        configure(t)
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("no switchport access vlan")
        t.readln("Warning: The use of large numbers of VLANs or interfaces may cause significant")
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'ethernet 1/g1', [
            ""
        ])

        unconfigure_vlan(t, 1264)
Esempio n. 15
0
    def test_configuring_a_vlan(self, t):
        enable(t)

        configuring_vlan(t, 1234)

        assert_running_config_contains_in_order(t, [
            "vlan database",
            "vlan 1,1234",
            "exit"
        ])

        unconfigure_vlan(t, 1234)

        assert_running_config_contains_in_order(t, [
            "vlan database",
            "vlan 1",
            "exit"
        ])
Esempio n. 16
0
    def test_configuring_a_vlan_name(self, t):
        enable(t)

        configuring_vlan(t, 1234)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface vlan 1234")
        t.readln("")
        t.read("my_switch(config-if-vlan1234)#")
        t.write("name")
        t.readln("")
        t.readln(
            "Command not found / Incomplete command. Use ? to list commands.")
        t.readln("")
        t.read("my_switch(config-if-vlan1234)#")
        t.write("name one two")
        t.readln("                                     ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-vlan1234)#")
        t.write("name this-name-is-too-long-buddy-buddy")
        t.readln("Name must be 32 characters or less.")
        t.readln("")
        t.read("my_switch(config-if-vlan1234)#")
        t.write("name this-name-is-too-long-buddy-budd")
        t.readln("")
        t.read("my_switch(config-if-vlan1234)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, "vlan 1234", [
            "interface vlan 1234",
            "name \"this-name-is-too-long-buddy-budd\"",
            "exit",
        ])

        unconfigure_vlan(t, 1234)
Esempio n. 17
0
    def test_configuring_a_vlan_name(self, t):
        enable(t)

        configuring_vlan(t, 1234)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface vlan 1234")
        t.readln("")
        t.read("my_switch(config-if-vlan1234)#")
        t.write("name")
        t.readln("")
        t.readln("Command not found / Incomplete command. Use ? to list commands.")
        t.readln("")
        t.read("my_switch(config-if-vlan1234)#")
        t.write("name one two")
        t.readln("                                     ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-vlan1234)#")
        t.write("name this-name-is-too-long-buddy-buddy")
        t.readln("Name must be 32 characters or less.")
        t.readln("")
        t.read("my_switch(config-if-vlan1234)#")
        t.write("name this-name-is-too-long-buddy-budd")
        t.readln("")
        t.read("my_switch(config-if-vlan1234)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, "vlan 1234", [
            "interface vlan 1234",
            "name \"this-name-is-too-long-buddy-budd\"",
            "exit",
        ])

        unconfigure_vlan(t, 1234)
Esempio n. 18
0
    def test_show_vlan_id(self, t):
        enable(t)

        configuring_vlan(t, 1000)

        t.write("show vlan id 500")
        t.readln("")
        t.readln("ERROR: This VLAN does not exist.")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id 1000")
        t.readln("")
        t.readln(
            "VLAN       Name                         Ports          Type      Authorization"
        )
        t.readln(
            "-----  ---------------                  -------------  -----     -------------"
        )
        t.readln(
            "1000                                                   Static    Required     "
        )
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id bleh")
        t.readln("                     ^")
        t.readln(
            "Invalid input. Please specify an integer in the range 1 to 4093.")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id")
        t.readln("")
        t.readln(
            "Command not found / Incomplete command. Use ? to list commands.")
        t.readln("")
        t.read("my_switch#")

        unconfigure_vlan(t, 1000)
    def test_switchport_add_general_trunk_vlans_special_cases(self, t):
        enable(t)

        configuring_vlan(t, 1201)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1200")
        t.readln("Interface not in General Mode.")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport mode general")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1200")
        t.readln("Warning: The use of large numbers of VLANs or interfaces may cause significant")
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 1")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1200-1202")
        t.readln("Warning: The use of large numbers of VLANs or interfaces may cause significant")
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 2")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.readln("VLAN      1202 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan remove 1200")
        t.readln("Warning: The use of large numbers of VLANs or interfaces may cause significant")
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 1")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan remove 1200-1202")
        t.readln("Warning: The use of large numbers of VLANs or interfaces may cause significant")
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 2")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.readln("VLAN      1202 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1202-1201")
        t.readln("VLAN range - separate non-consecutive IDs with ',' and no spaces.  Use '-' for range.")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1202 1201")
        t.readln("                                                                 ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport mode access")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        unconfigure_vlan(t, 1201)
    def test_switchport_mode(self, t):
        enable(t)

        configuring_vlan(t, 1264)
        configuring_vlan(t, 1265)

        assert_interface_configuration(t, 'ethernet 1/g1', [
            ""
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            ""
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport access vlan 1264")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport access vlan 1264"
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport access vlan 1264"
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode general")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general"
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport general pvid 1264")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general pvid 1264"
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport general allowed vlan add 1265")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode general",
            "switchport general pvid 1264",
            "switchport general allowed vlan add 1265",
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode trunk")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode trunk"
        ])

        configuring_a_vlan_on_interface(t, "ethernet 1/g1", do="switchport trunk allowed vlan add 1265")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan add 1265",
        ])

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        assert_interface_configuration(t, 'ethernet 1/g1', [
            ""
        ])

        unconfigure_vlan(t, 1265)
        unconfigure_vlan(t, 1264)
Esempio n. 21
0
    def test_show_vlan_id_with_ports(self, t):
        enable(t)

        configuring_vlan(t, 1000)
        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        configuring_a_vlan_on_interface(t,
                                        "ethernet 1/g1",
                                        do="switchport access vlan 1000")

        t.write("show vlan id 1000")
        t.readln("")
        t.readln(
            "VLAN       Name                         Ports          Type      Authorization"
        )
        t.readln(
            "-----  ---------------                  -------------  -----     -------------"
        )
        t.readln(
            "1000                                    1/g1           Static    Required     "
        )
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "ethernet 1/g1", do="switchport mode trunk")
        t.write("show vlan id 1000")
        t.readln("")
        t.readln(
            "VLAN       Name                         Ports          Type      Authorization"
        )
        t.readln(
            "-----  ---------------                  -------------  -----     -------------"
        )
        t.readln(
            "1000                                                   Static    Required     "
        )
        t.readln("")
        t.read("my_switch#")

        configuring_a_vlan_on_interface(
            t, "ethernet 1/g1", do="switchport trunk allowed vlan add 1000")
        configuring_interface(t, "ethernet 1/g2", do="switchport mode trunk")
        configuring_a_vlan_on_interface(
            t, "ethernet 1/g2", do="switchport trunk allowed vlan add 1000")
        t.write("show vlan id 1000")
        t.readln("")
        t.readln(
            "VLAN       Name                         Ports          Type      Authorization"
        )
        t.readln(
            "-----  ---------------                  -------------  -----     -------------"
        )
        t.readln(
            "1000                                    1/g1-1/g2      Static    Required     "
        )
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "ethernet 1/xg1", do="switchport mode trunk")
        configuring_a_vlan_on_interface(
            t, "ethernet 1/xg1", do="switchport trunk allowed vlan add 1000")
        t.write("show vlan id 1000")
        t.readln("")
        t.readln(
            "VLAN       Name                         Ports          Type      Authorization"
        )
        t.readln(
            "-----  ---------------                  -------------  -----     -------------"
        )
        t.readln(
            "1000                                    1/g1-1/g2,     Static    Required     "
        )
        t.readln(
            "                                        1/xg1                                 "
        )
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "ethernet 1/g1", do="switchport mode access")
        configuring_interface(t, "ethernet 1/g2", do="switchport mode access")
        configuring_interface(t, "ethernet 1/xg1", do="switchport mode access")

        unconfigure_vlan(t, 1000)
Esempio n. 22
0
    def test_show_vlan(self, t):
        enable(t)

        configuring_vlan(t, 10)
        configuring_vlan(t, 11)
        configuring_vlan(t, 12)
        configuring_vlan(t, 13)
        configuring_vlan(t, 14)
        configuring_vlan(t, 15)
        configuring_vlan(t, 16)
        configuring_vlan(t, 17)
        configuring_interface_vlan(t,
                                   17,
                                   do="name this-name-is-too-long-buddy-budd")
        configuring_vlan(t, 18)
        configuring_vlan(t, 19)
        configuring_vlan(t, 20)
        configuring_vlan(t, 21)
        configuring_vlan(t, 22)
        configuring_vlan(t, 23)
        configuring_vlan(t, 24)
        configuring_vlan(t, 25)
        configuring_vlan(t, 26)
        configuring_vlan(t, 27)
        configuring_vlan(t, 28)
        configuring_vlan(t, 29)
        configuring_vlan(t, 300)
        configuring_vlan(t, 4000)
        configuring_interface_vlan(t, 300, do="name shizzle")

        t.write("show vlan")
        t.readln("")
        t.readln(
            "VLAN       Name                         Ports          Type      Authorization"
        )
        t.readln(
            "-----  ---------------                  -------------  -----     -------------"
        )
        t.readln(
            "1      Default                                         Default   Required     "
        )
        t.readln(
            "10                                                     Static    Required     "
        )
        t.readln(
            "11                                                     Static    Required     "
        )
        t.readln(
            "12                                                     Static    Required     "
        )
        t.readln(
            "13                                                     Static    Required     "
        )
        t.readln(
            "14                                                     Static    Required     "
        )
        t.readln(
            "15                                                     Static    Required     "
        )
        t.readln(
            "16                                                     Static    Required     "
        )
        t.readln(
            "17     this-name-is-too-long-buddy-budd                Static    Required     "
        )
        t.readln(
            "18                                                     Static    Required     "
        )
        t.readln(
            "19                                                     Static    Required     "
        )
        t.readln(
            "20                                                     Static    Required     "
        )
        t.readln(
            "21                                                     Static    Required     "
        )
        t.readln(
            "22                                                     Static    Required     "
        )
        t.readln(
            "23                                                     Static    Required     "
        )
        t.readln(
            "24                                                     Static    Required     "
        )
        t.readln(
            "25                                                     Static    Required     "
        )
        t.readln(
            "26                                                     Static    Required     "
        )
        t.readln("")
        t.read("--More-- or (q)uit")
        t.write_raw("m")
        t.readln("\r                     ")
        t.readln("")
        t.readln("")
        t.readln(
            "VLAN       Name                         Ports          Type      Authorization"
        )
        t.readln(
            "-----  ---------------                  -------------  -----     -------------"
        )
        t.readln(
            "27                                                     Static    Required     "
        )
        t.readln(
            "28                                                     Static    Required     "
        )
        t.readln(
            "29                                                     Static    Required     "
        )
        t.readln(
            "300    shizzle                                         Static    Required     "
        )
        t.readln(
            "4000                                                   Static    Required     "
        )
        t.readln("")
        t.read("my_switch#")

        unconfigure_vlan(t, 10)
        unconfigure_vlan(t, 11)
        unconfigure_vlan(t, 12)
        unconfigure_vlan(t, 13)
        unconfigure_vlan(t, 14)
        unconfigure_vlan(t, 15)
        unconfigure_vlan(t, 16)
        unconfigure_vlan(t, 17)
        unconfigure_vlan(t, 18)
        unconfigure_vlan(t, 19)
        unconfigure_vlan(t, 20)
        unconfigure_vlan(t, 21)
        unconfigure_vlan(t, 22)
        unconfigure_vlan(t, 23)
        unconfigure_vlan(t, 24)
        unconfigure_vlan(t, 25)
        unconfigure_vlan(t, 26)
        unconfigure_vlan(t, 27)
        unconfigure_vlan(t, 28)
        unconfigure_vlan(t, 29)
        unconfigure_vlan(t, 300)
        unconfigure_vlan(t, 4000)
Esempio n. 23
0
    def test_show_vlan(self, t):
        enable(t)

        configuring_vlan(t, 10)
        configuring_vlan(t, 11)
        configuring_vlan(t, 12)
        configuring_vlan(t, 13)
        configuring_vlan(t, 14)
        configuring_vlan(t, 15)
        configuring_vlan(t, 16)
        configuring_vlan(t, 17)
        configuring_interface_vlan(t, 17, do="name this-name-is-too-long-buddy-budd")
        configuring_vlan(t, 18)
        configuring_vlan(t, 19)
        configuring_vlan(t, 20)
        configuring_vlan(t, 21)
        configuring_vlan(t, 22)
        configuring_vlan(t, 23)
        configuring_vlan(t, 24)
        configuring_vlan(t, 25)
        configuring_vlan(t, 26)
        configuring_vlan(t, 27)
        configuring_vlan(t, 28)
        configuring_vlan(t, 29)
        configuring_vlan(t, 300)
        configuring_vlan(t, 4000)
        configuring_interface_vlan(t, 300, do="name shizzle")

        t.write("show vlan")
        t.readln("")
        t.readln("VLAN       Name                         Ports          Type      Authorization")
        t.readln("-----  ---------------                  -------------  -----     -------------")
        t.readln("1      Default                                         Default   Required     ")
        t.readln("10                                                     Static    Required     ")
        t.readln("11                                                     Static    Required     ")
        t.readln("12                                                     Static    Required     ")
        t.readln("13                                                     Static    Required     ")
        t.readln("14                                                     Static    Required     ")
        t.readln("15                                                     Static    Required     ")
        t.readln("16                                                     Static    Required     ")
        t.readln("17     this-name-is-too-long-buddy-budd                Static    Required     ")
        t.readln("18                                                     Static    Required     ")
        t.readln("19                                                     Static    Required     ")
        t.readln("20                                                     Static    Required     ")
        t.readln("21                                                     Static    Required     ")
        t.readln("22                                                     Static    Required     ")
        t.readln("23                                                     Static    Required     ")
        t.readln("24                                                     Static    Required     ")
        t.readln("25                                                     Static    Required     ")
        t.readln("26                                                     Static    Required     ")
        t.readln("")
        t.read("--More-- or (q)uit")
        t.write_raw("m")
        t.readln("\r                     ")
        t.readln("")
        t.readln("")
        t.readln("VLAN       Name                         Ports          Type      Authorization")
        t.readln("-----  ---------------                  -------------  -----     -------------")
        t.readln("27                                                     Static    Required     ")
        t.readln("28                                                     Static    Required     ")
        t.readln("29                                                     Static    Required     ")
        t.readln("300    shizzle                                         Static    Required     ")
        t.readln("4000                                                   Static    Required     ")
        t.readln("")
        t.read("my_switch#")

        unconfigure_vlan(t, 10)
        unconfigure_vlan(t, 11)
        unconfigure_vlan(t, 12)
        unconfigure_vlan(t, 13)
        unconfigure_vlan(t, 14)
        unconfigure_vlan(t, 15)
        unconfigure_vlan(t, 16)
        unconfigure_vlan(t, 17)
        unconfigure_vlan(t, 18)
        unconfigure_vlan(t, 19)
        unconfigure_vlan(t, 20)
        unconfigure_vlan(t, 21)
        unconfigure_vlan(t, 22)
        unconfigure_vlan(t, 23)
        unconfigure_vlan(t, 24)
        unconfigure_vlan(t, 25)
        unconfigure_vlan(t, 26)
        unconfigure_vlan(t, 27)
        unconfigure_vlan(t, 28)
        unconfigure_vlan(t, 29)
        unconfigure_vlan(t, 300)
        unconfigure_vlan(t, 4000)
Esempio n. 24
0
    def test_switchport_add_general_trunk_vlans_special_cases(self, t):
        enable(t)

        configuring_vlan(t, 1201)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface ethernet 1/g1")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1200")
        t.readln("Interface not in General Mode.")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport mode general")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1200")
        t.readln(
            "Warning: The use of large numbers of VLANs or interfaces may cause significant"
        )
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 1")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1200-1202")
        t.readln(
            "Warning: The use of large numbers of VLANs or interfaces may cause significant"
        )
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 2")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.readln("VLAN      1202 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan remove 1200")
        t.readln(
            "Warning: The use of large numbers of VLANs or interfaces may cause significant"
        )
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 1")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan remove 1200-1202")
        t.readln(
            "Warning: The use of large numbers of VLANs or interfaces may cause significant"
        )
        t.readln("delays in applying the configuration.")
        t.readln("")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 2")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.readln("VLAN      1202 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1202-1201")
        t.readln(
            "VLAN range - separate non-consecutive IDs with ',' and no spaces.  Use '-' for range."
        )
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport general allowed vlan add 1202 1201")
        t.readln(
            "                                                                 ^"
        )
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("switchport mode access")
        t.readln("")
        t.read("my_switch(config-if-1/g1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        unconfigure_vlan(t, 1201)