Ejemplo n.º 1
0
 def get_default_ports():
     return [
         Port("tengigabitethernet 0/0/1"),
         Port("tengigabitethernet 0/0/2"),
         Port("tengigabitethernet 1/0/1"),
         Port("tengigabitethernet 1/0/2")
     ]
Ejemplo n.º 2
0
 def get_default_ports():
     return [
         Port("ethernet 1/1"),
         Port("ethernet 1/2"),
         Port("ethernet 1/3"),
         Port("ethernet 1/4")
     ]
Ejemplo n.º 3
0
 def get_default_ports():
     return [
         Port("xe-0/0/1"),
         Port("xe-0/0/2"),
         Port("xe-0/0/3"),
         Port("xe-0/0/4")
     ]
    def test_basic_parsing(self, tftp_reader_mock):
        tftp_reader_mock.return_value = """
!
vlan 1000
name VLAN_1_0_0_0
!
!
vlan 2000
name VLAN_2_0_0_0
!
"""
        config = SwitchConfiguration("127.0.0.1",
                                     name="my_switch",
                                     ports=[Port("GigabitEthernet0/1")])

        parser = SwitchTftpParser(config)
        config_processor = ConfigCommandProcessor(
            config_vlan=ConfigVlanCommandProcessor(),
            config_vrf=None,
            config_interface=None)
        parser.parse("hostname", "filename", config_processor)

        tftp_reader_mock.assert_called_with("hostname", "filename")

        vlan1000 = config.get_vlan(1000)
        assert_that(vlan1000.name, equal_to("VLAN_1_0_0_0"))

        vlan2000 = config.get_vlan(2000)
        assert_that(vlan2000.name, equal_to("VLAN_2_0_0_0"))
    def test_longer_parsing(self, tftp_reader_mock):
        tftp_reader_mock.return_value = """
!
vlan 1000
name VLAN_1_0_0_0
!
!
interface GigabitEthernet0/1
no switchport access vlan 1
switchport access vlan 1000
!
!
interface GigabitEthernet0/1
description "Gigabit Ethernet 1 desc"
switchport
load-interval 30
switchport mode access
switchport access vlan 1000
switchport nonegotiate
spanning-tree portfast
spanning-tree bpdufilter enable
spanning-tree bpduguard enable
no loopback
no keepalive
!
"""

        config = SwitchConfiguration("127.0.0.1",
                                     name="my_switch",
                                     ports=[Port("GigabitEthernet0/1")])

        parser = SwitchTftpParser(config)
        config_processor = ConfigCommandProcessor(
            config_vlan=ConfigVlanCommandProcessor(),
            config_vrf=None,
            config_interface=ConfigInterfaceCommandProcessor())
        parser.parse("hostname", "filename", config_processor)

        vlan1000 = config.get_vlan(1000)
        assert_that(vlan1000.name, equal_to("VLAN_1_0_0_0"))

        eth01 = config.get_port("GigabitEthernet0/1")
        assert_that(eth01.description, equal_to("Gigabit Ethernet 1 desc"))
        assert_that(eth01.mode, equal_to("access"))
        assert_that(eth01.access_vlan, equal_to(1000))
Ejemplo n.º 6
0
available_models = [
    {
        "switch_descriptor": SwitchDescriptor(
            model="cisco",
            hostname="127.0.0.1",
            port=11002,
            username="******",
            password="******",
        ),
        "test_port_name": "FastEthernet0/3",
        "test_vrrp_track_id": "101",
        "core_class": CiscoSwitchCore,
        "service_class": SwitchSshService,
        "ports": [
            Port("FastEthernet0/1"),
            Port("FastEthernet0/2"),
            Port("FastEthernet0/3"),
            Port("FastEthernet0/4"),
        ]
    },
    {
        "switch_descriptor": SwitchDescriptor(
            model="cisco",
            hostname="127.0.0.1",
            port=11014,
            username="******",
            password="******",
        ),
        "test_port_name": "FastEthernet0/4",
        "test_vrrp_track_id": "102",
Ejemplo n.º 7
0
 def get_default_ports():
     return [Port("FastEthernet0/{0}".format(p + 1)) for p in range(24)] + \
            [Port("GigabitEthernet0/{0}".format(p + 1)) for p in range(2)]
Ejemplo n.º 8
0
 def get_default_ports():
     return [
         Port("FastEthernet0/1"),
         Port("FastEthernet0/2"),
         Port("FastEthernet0/3"),
         Port("FastEthernet0/4"),
         Port("FastEthernet0/5"),
         Port("FastEthernet0/6"),
         Port("FastEthernet0/7"),
         Port("FastEthernet0/8"),
         Port("FastEthernet0/9"),
         Port("FastEthernet0/10"),
         Port("FastEthernet0/11"),
         Port("FastEthernet0/12")
     ]
Ejemplo n.º 9
0
 def get_default_ports():
     return [Port("ge-0/0/{}".format(i)) for i in range(1, 5)] + \
            [AggregatedPort("ae{}".format(i)) for i in range(1, 24)]
Ejemplo n.º 10
0
 def get_default_ports():
     return [Port("Ethernet1"), Port("Ethernet2")]
Ejemplo n.º 11
0
    def start_reactor(cls):
        cls._threaded_reactor = ThreadedReactor()

        switch_core = CiscoSwitchCore(
            SwitchConfiguration(cisco_switch_ip, name="my_switch", privileged_passwords=[cisco_privileged_password],
                                ports=[
                                    Port("FastEthernet0/1"),
                                    Port("FastEthernet0/2"),
                                    Port("FastEthernet0/3"),
                                    Port("FastEthernet0/4"),
                                ]))
        SwitchTelnetService(cisco_switch_ip, telnet_port=cisco_switch_telnet_port, switch_core=switch_core,
                            users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)
        SwitchSshService(cisco_switch_ip, ssh_port=cisco_switch_ssh_port, switch_core=switch_core,
                         users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)

        auto_enabled_switch_core = CiscoSwitchCore(
            SwitchConfiguration(cisco_switch_ip, name="my_switch", auto_enabled=True))
        SwitchTelnetService(cisco_switch_ip, telnet_port=cisco_auto_enabled_switch_telnet_port,
                            switch_core=auto_enabled_switch_core, users={'root': 'root'}).hook_to_reactor(
            cls._threaded_reactor.reactor)
        SwitchSshService(cisco_switch_ip, ssh_port=cisco_auto_enabled_switch_ssh_port,
                         switch_core=auto_enabled_switch_core, users={'root': 'root'}).hook_to_reactor(
            cls._threaded_reactor.reactor)

        switch_core = BrocadeSwitchCore(
            SwitchConfiguration(brocade_switch_ip, name="my_switch", privileged_passwords=[brocade_privileged_password],
                                ports=[
                                    Port("ethernet 1/1"),
                                    Port("ethernet 1/2"),
                                    Port("ethernet 1/3"),
                                    Port("ethernet 1/4")
                                ]))
        SwitchSshService(brocade_switch_ip, ssh_port=brocade_switch_ssh_port, switch_core=switch_core,
                         users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)

        switch_core = JuniperSwitchCore(SwitchConfiguration(juniper_switch_ip, name="ju_ju_ju_juniper", ports=[
            Port("ge-0/0/1"),
            Port("ge-0/0/2"),
            Port("ge-0/0/3"),
            Port("ge-0/0/4")
        ]))
        SwitchSshService(juniper_switch_ip, ssh_port=juniper_switch_netconf_port, switch_core=switch_core,
                         users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)

        switch_core = JuniperQfxCopperSwitchCore(
            SwitchConfiguration(juniper_qfx_copper_switch_ip, name="ju_ju_ju_juniper_qfx_copper", ports=[
                Port("ge-0/0/1"),
                Port("ge-0/0/2"),
                Port("ge-0/0/3"),
                Port("ge-0/0/4")
            ]))
        SwitchSshService(juniper_qfx_copper_switch_ip, ssh_port=juniper_qfx_copper_switch_netconf_port,
                         switch_core=switch_core, users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)

        switch_core = DellSwitchCore(
            SwitchConfiguration(dell_switch_ip, name="my_switch", privileged_passwords=[dell_privileged_password],
                                ports=[
                                    Port("ethernet 1/g1"),
                                    Port("ethernet 1/g2"),
                                    Port("ethernet 2/g1"),
                                    Port("ethernet 2/g2"),
                                    Port("ethernet 1/xg1"),
                                    Port("ethernet 2/xg1")
                                ]))
        SwitchTelnetService(dell_switch_ip, telnet_port=dell_switch_telnet_port, switch_core=switch_core,
                            users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)
        SwitchSshService(dell_switch_ip, ssh_port=dell_switch_ssh_port, switch_core=switch_core,
                         users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)

        switch_core = Dell10GSwitchCore(
            SwitchConfiguration(dell10g_switch_ip, name="my_switch", privileged_passwords=[dell10g_privileged_password],
                                ports=[
                                    Port("tengigabitethernet 0/0/1"),
                                    Port("tengigabitethernet 0/0/2"),
                                    Port("tengigabitethernet 1/0/1"),
                                    Port("tengigabitethernet 1/0/2")
                                ]))
        SwitchTelnetService(dell10g_switch_ip, telnet_port=dell10g_switch_telnet_port, switch_core=switch_core,
                            users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)
        SwitchSshService(dell10g_switch_ip, ssh_port=dell10g_switch_ssh_port, switch_core=switch_core,
                         users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)

        switch_core = Dell10GSwitchCore(
            SwitchConfiguration(dell10g_switch_ip, name="my_switch", privileged_passwords=[dell10g_privileged_password],
                                ports=[
                                    Port("tengigabitethernet 0/0/1"),
                                    Port("tengigabitethernet 0/0/2"),
                                    Port("tengigabitethernet 1/0/1"),
                                    Port("tengigabitethernet 1/0/2")
                                ], commit_delay=COMMIT_DELAY))
        SwitchSshService(dell10g_switch_ip, ssh_port=dell10g_switch_with_commit_delay_ssh_port, switch_core=switch_core,
                         users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)





        # SWITCHES WITH COMMIT DELAYS

        switch_core = CiscoSwitchCore(
            SwitchConfiguration(cisco_switch_ip, name="my_switch", privileged_passwords=[cisco_privileged_password],
                                ports=[
                                    Port("FastEthernet0/1"),
                                    Port("FastEthernet0/2"),
                                    Port("FastEthernet0/3"),
                                    Port("FastEthernet0/4"),
                                    ], commit_delay=COMMIT_DELAY))
        SwitchSshService(cisco_switch_ip, ssh_port=cisco_switch_ssh_with_commit_delay_port, switch_core=switch_core,
                         users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)

        switch_core = BrocadeSwitchCore(
            SwitchConfiguration(brocade_switch_ip, name="my_switch", privileged_passwords=[brocade_privileged_password],
                                ports=[
                                    Port("ethernet 1/1"),
                                    Port("ethernet 1/2"),
                                    Port("ethernet 1/3"),
                                    Port("ethernet 1/4")
                                ], commit_delay=COMMIT_DELAY))
        SwitchSshService(brocade_switch_ip, ssh_port=brocade_switch_with_commit_delay_ssh_port, switch_core=switch_core,
                         users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)

        switch_core = JuniperSwitchCore(SwitchConfiguration(juniper_switch_ip, name="ju_ju_ju_juniper", ports=[
            Port("ge-0/0/1"),
            Port("ge-0/0/2"),
            Port("ge-0/0/3"),
            Port("ge-0/0/4")
        ], commit_delay=COMMIT_DELAY))
        SwitchSshService(juniper_switch_ip, ssh_port=juniper_switch_netconf_with_commit_delay_port, switch_core=switch_core,
                         users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)

        switch_core = DellSwitchCore(
            SwitchConfiguration(dell_switch_ip, name="my_switch", privileged_passwords=[dell_privileged_password],
                                ports=[
                                    Port("ethernet 1/g1"),
                                    Port("ethernet 1/g2"),
                                    Port("ethernet 2/g1"),
                                    Port("ethernet 2/g2"),
                                    Port("ethernet 1/xg1"),
                                    Port("ethernet 2/xg1")
                                ], commit_delay=COMMIT_DELAY))
        SwitchSshService(dell_switch_ip, ssh_port=dell_switch_with_commit_delay_ssh_port, switch_core=switch_core,
                         users={'root': 'root'}).hook_to_reactor(cls._threaded_reactor.reactor)

        cls._threaded_reactor.start()
Ejemplo n.º 12
0
def _juniper_ports_with_less_ae():
    return [Port("ge-0/0/{}".format(i)) for i in range(1, 5)] + \
           [AggregatedPort("ae{}".format(i)) for i in range(1, 5)]