def test_show_vlan_id(self, t):
        enable(t)

        add_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")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1000   VLAN1000                                        Static")
        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#")

        configuring(t, do="no vlan 1000")
    def test_show_vlan_with_ports(self, t):
        enable(t)

        add_vlan(t, 10)
        add_vlan(t, 11)

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport mode trunk")

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport trunk allowed vlan 10-11")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport trunk allowed vlan 10")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport trunk allowed vlan 11")

        t.write("show vlan")
        t.readln("")
        t.readln("VLAN   Name                             Ports          Type")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1      default                                         Default")
        t.readln("10     VLAN10                           Te0/0/1-2      Static")
        t.readln("11     VLAN11                           Te0/0/1,       Static")
        t.readln("                                        Te1/0/2        ")
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "tengigabitethernet 0/0/1", "no switchport mode")
        configuring_interface(t, "tengigabitethernet 0/0/2", "no switchport mode")
        configuring_interface(t, "tengigabitethernet 1/0/2", "no switchport mode")

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport trunk allowed vlan remove 10,11")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport trunk allowed vlan remove 10")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport trunk allowed vlan remove 11")

        configuring(t, do="no vlan 10")
        configuring(t, do="no vlan 11")
    def test_show_vlan_id(self, t):
        enable(t)

        add_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")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1000   VLAN1000                                        Static")
        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#")

        configuring(t, do="no vlan 1000")
    def test_show_vlan_with_ports(self, t):
        enable(t)

        add_vlan(t, 10)
        add_vlan(t, 11)

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport mode trunk")

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport trunk allowed vlan 10-11")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport trunk allowed vlan 10")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport trunk allowed vlan 11")

        t.write("show vlan")
        t.readln("")
        t.readln("VLAN   Name                             Ports          Type")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1      default                                         Default")
        t.readln("10     VLAN10                           Te0/0/1-2      Static")
        t.readln("11     VLAN11                           Te0/0/1,       Static")
        t.readln("                                        Te1/0/2        ")
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "tengigabitethernet 0/0/1", "no switchport mode")
        configuring_interface(t, "tengigabitethernet 0/0/2", "no switchport mode")
        configuring_interface(t, "tengigabitethernet 1/0/2", "no switchport mode")

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport trunk allowed vlan remove 10,11")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport trunk allowed vlan remove 10")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport trunk allowed vlan remove 11")

        configuring(t, do="no vlan 10")
        configuring(t, do="no vlan 11")
    def test_switchport_mode(self, t):
        enable(t)

        add_vlan(t, 1264)
        add_vlan(t, 1265)

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

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

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport access vlan 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport access vlan 1264"
        ])

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

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode general")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport access vlan 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general pvid 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport access vlan 1264",
            "switchport general pvid 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport access vlan")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general allowed vlan add 1265")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport general pvid 1264",
            "switchport general allowed vlan add 1265",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general pvid")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general allowed vlan")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode trunk")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk"
        ])

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

        configuring(t, do="no vlan 1265")
        configuring(t, do="no vlan 1264")
    def test_switchport_mode(self, t):
        enable(t)

        add_vlan(t, 1264)
        add_vlan(t, 1265)

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

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

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport access vlan 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport access vlan 1264"
        ])

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

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode general")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport access vlan 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general pvid 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport access vlan 1264",
            "switchport general pvid 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport access vlan")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general allowed vlan add 1265")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport general pvid 1264",
            "switchport general allowed vlan add 1265",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general pvid")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general allowed vlan")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode trunk")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk"
        ])

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

        configuring(t, do="no vlan 1265")
        configuring(t, do="no vlan 1264")
    def test_switchport_general_pvid(self, t):
        enable(t)

        add_vlan(t, 1264)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

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

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

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

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

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

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

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

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general pvid 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport general pvid 1264",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general pvid")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "",
        ])

        configuring(t, do="no vlan 1264")
    def test_switchport_general_pvid(self, t):
        enable(t)

        add_vlan(t, 1264)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

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

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

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

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

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

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

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

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general pvid 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport general pvid 1264",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general pvid")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "",
        ])

        configuring(t, do="no vlan 1264")
    def test_switchport_add_trunk_trunk_vlans_special_cases(self, t):
        enable(t)

        add_vlan(t, 1200)
        add_vlan(t, 1201)

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode trunk")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ["switchport mode trunk"])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1200")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ["switchport mode trunk"])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan 1200")
        assert_interface_configuration(
            t, "tengigabitethernet 0/0/1", ["switchport mode trunk", "switchport trunk allowed vlan 1200"]
        )

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1201")
        assert_interface_configuration(
            t, "tengigabitethernet 0/0/1", ["switchport mode trunk", "switchport trunk allowed vlan 1200-1201"]
        )

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1202")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1203")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1200")
        assert_interface_configuration(
            t, "tengigabitethernet 0/0/1", ["switchport mode trunk", "switchport trunk allowed vlan 1201-1202"]
        )

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport trunk allowed vlan")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ["switchport mode trunk"])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport mode")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [""])

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("switchport trunk allowed vlan add 1202 1201")
        t.readln("                                                                 ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

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

        configuring(t, do="no vlan 1200")
        configuring(t, do="no vlan 1201")
    def test_switchport_add_remove_trunk_trunk_vlans(self, t):
        enable(t)

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

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan 1200")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1200,1201")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1201-1203,1205")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1203,1205",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1202")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201,1203,1205",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1203,1205")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1200-1203")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
        ])

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

        configuring(t, do="no vlan 1200")
        configuring(t, do="no vlan 1201")
        configuring(t, do="no vlan 1202")
        configuring(t, do="no vlan 1203")
        configuring(t, do="no vlan 1205")
    def test_switchport_add_remove_trunk_trunk_vlans(self, t):
        enable(t)

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

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan 1200")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1200,1201")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1201-1203,1205")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1203,1205",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1202")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201,1203,1205",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1203,1205")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1200-1203")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
        ])

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

        configuring(t, do="no vlan 1200")
        configuring(t, do="no vlan 1201")
        configuring(t, do="no vlan 1202")
        configuring(t, do="no vlan 1203")
        configuring(t, do="no vlan 1205")
    def test_access_vlan(self, t):
        enable(t)

        add_vlan(t, 1264)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("switchport access vlan 1264")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

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

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport access vlan 1264",
        ])

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("no switchport access vlan")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

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

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

        configuring(t, do="no vlan 1264")
    def test_access_vlan(self, t):
        enable(t)

        add_vlan(t, 1264)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("switchport access vlan 1264")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

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

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport access vlan 1264",
        ])

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("no switchport access vlan")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

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

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

        configuring(t, do="no vlan 1264")
    def test_configuring_a_vlan(self, t):
        enable(t)

        add_vlan(t, 1000)
        add_vlan(t, 1001)
        add_vlan(t, 2000)
        configuring_vlan(t, 2000, do="name shizzle")
        assert_running_config_contains_in_order(t, [
            "vlan 2000",
            "name shizzle",
            "exit",
            "vlan 1,1000-1001",
            "exit",
        ])

        configuring(t, do="no vlan 1000")
        configuring(t, do="no vlan 1001")
        configuring(t, do="no vlan 2000")
Exemple #15
0
    def test_switchport_add_general_trunk_vlans_special_cases(self, t):
        enable(t)

        add_vlan(t, 1201)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

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

        t.write("switchport general allowed vlan add 1200")
        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-Te0/0/1)#")

        t.write("switchport general allowed vlan add 1200-1202")
        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-Te0/0/1)#")

        t.write("switchport general allowed vlan remove 1200")
        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-Te0/0/1)#")

        t.write("switchport general allowed vlan remove 1200-1202")
        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-Te0/0/1)#")

        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-Te0/0/1)#")

        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-Te0/0/1)#")

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

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

        configuring(t, do="no vlan 1201")
Exemple #16
0
    def test_switchport_add_trunk_trunk_vlans_special_cases(self, t):
        enable(t)

        add_vlan(t, 1200)
        add_vlan(t, 1201)

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

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan add 1200")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan 1200")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan add 1201")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan add 1202")
        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan remove 1203")
        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan remove 1200")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1201-1202",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="no switchport trunk allowed vlan")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="no switchport mode")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [""])

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("switchport trunk allowed vlan add 1202 1201")
        t.readln(
            "                                                                 ^"
        )
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

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

        configuring(t, do="no vlan 1200")
        configuring(t, do="no vlan 1201")
    def test_switchport_add_general_trunk_vlans_special_cases(self, t):
        enable(t)

        add_vlan(t, 1201)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

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

        t.write("switchport general allowed vlan add 1200")
        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-Te0/0/1)#")

        t.write("switchport general allowed vlan add 1200-1202")
        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-Te0/0/1)#")

        t.write("switchport general allowed vlan remove 1200")
        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-Te0/0/1)#")

        t.write("switchport general allowed vlan remove 1200-1202")
        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-Te0/0/1)#")

        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-Te0/0/1)#")

        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-Te0/0/1)#")

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

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

        configuring(t, do="no vlan 1201")
    def test_show_vlan(self, t):
        enable(t)

        add_vlan(t, 10)
        add_vlan(t, 11)
        add_vlan(t, 12)
        configuring_vlan(t, 17, do="name this-name-is-too-long-buddy-budd")
        add_vlan(t, 100)
        add_vlan(t, 1000)

        t.write("show vlan")
        t.readln("")
        t.readln("VLAN   Name                             Ports          Type")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1      default                                         Default")
        t.readln("10     VLAN10                                          Static")
        t.readln("11     VLAN11                                          Static")
        t.readln("12     VLAN12                                          Static")
        t.readln("17     this-name-is-too-long-buddy-budd                Static")
        t.readln("100    VLAN100                                         Static")
        t.readln("1000   VLAN1000                                        Static")
        t.readln("")
        t.read("my_switch#")

        configuring(t, do="no vlan 10")
        configuring(t, do="no vlan 11")
        configuring(t, do="no vlan 12")
        configuring(t, do="no vlan 17")
        configuring(t, do="no vlan 100")
        configuring(t, do="no vlan 1000")
    def test_show_vlan(self, t):
        enable(t)

        add_vlan(t, 10)
        add_vlan(t, 11)
        add_vlan(t, 12)
        configuring_vlan(t, 17, do="name this-name-is-too-long-buddy-budd")
        add_vlan(t, 100)
        add_vlan(t, 1000)

        t.write("show vlan")
        t.readln("")
        t.readln("VLAN   Name                             Ports          Type")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1      default                                         Default")
        t.readln("10     VLAN10                                          Static")
        t.readln("11     VLAN11                                          Static")
        t.readln("12     VLAN12                                          Static")
        t.readln("17     this-name-is-too-long-buddy-budd                Static")
        t.readln("100    VLAN100                                         Static")
        t.readln("1000   VLAN1000                                        Static")
        t.readln("")
        t.read("my_switch#")

        configuring(t, do="no vlan 10")
        configuring(t, do="no vlan 11")
        configuring(t, do="no vlan 12")
        configuring(t, do="no vlan 17")
        configuring(t, do="no vlan 100")
        configuring(t, do="no vlan 1000")