Пример #1
0
 def test_ping_fail_no_vrf(self):
     c = Connection(hostname='Router',
                    start=['mock_device_cli --os iosxr --state enable'],
                    os='iosxr',
                    username='******',
                    tacacs_password='******',
                    enable_password='******')
     with self.assertRaises(SubCommandFailure):
         c.ping('10.0.0.1')
    def test_ping_success(self):
        c = Connection(hostname='Router',
                            start=['mock_device_cli --os ios --state exec'],
                            os='ios',
                            username='******',
                            tacacs_password='******',
                            enable_password='******')
        c.ping('1.1.1.1')
        self.assertEqual("\n".join(c.spawn.match.match_output.splitlines()), """n
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Router#""")
    def test_ping_fail(self):
        c = Connection(hostname='Router',
                            start=['mock_device_cli --os ios --state exec'],
                            os='ios',
                            username='******',
                            tacacs_password='******',
                            enable_password='******')
        try:
            c.ping('10.10.10.10')
        except SubCommandFailure:
            pass
        self.assertEqual("\n".join(c.spawn.match.match_output.splitlines()), """n
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.10, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Router#""")
Пример #4
0
    def test_ping_success_vrf(self):
        c = Connection(hostname='Router',
                       start=['mock_device_cli --os iosxr --state enable'],
                       os='iosxr',
                       username='******',
                       tacacs_password='******',
                       enable_password='******')
        r = c.ping('10.0.0.2', vrf='management')
        self.assertEqual(r.strip(), "\r\n".join("""ping vrf management 10.0.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/3 ms
RP/0/RP0/CPU0:""".splitlines()))  # noqa
Пример #5
0
    def test_ping_failed_protocol(self):
        md = MockDeviceTcpWrapperIOSXE(port=0,
                                       state='ping_fail',
                                       hostname='PE1')
        md.start()

        c = Connection(hostname='PE1',
                       start=['telnet 127.0.0.1 {}'.format(md.ports[0])],
                       os='iosxe',
                       connection_timeout=10,
                       mit=True)
        try:
            c.connect()
            try:
                c.ping('10.10.10.10')
            except Exception:
                pass
            c.configure()
        except Exception:
            raise
        finally:
            c.disconnect()
            md.stop()
Пример #6
0
    def test_ping_success_vrf(self):
        c = Connection(hostname='Router',
                       start=['mock_device_cli --os iosxr --state enable'],
                       os='iosxr',
                       username='******',
                       tacacs_password='******',
                       enable_password='******')
        r = c.ping('10.0.0.2', vrf='management')
        self.assertEqual(r.strip(), "\r\n".join("""ping vrf management
Protocol [ip]: 
Target IP address: 10.0.0.2
Repeat count [5]: 
Datagram size [100]: 
Timeout in seconds [2]: 
Extended commands? [no]: n
Sweep range of sizes? [no]: n
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/3 ms
RP/0/RP0/CPU0:""".splitlines()))  # noqa
Пример #7
0
    def test_ping_success_vrf(self):
        c = Connection(hostname='Router',
                       start=['mock_device_cli --os iosxe --state isr_exec'],
                       os='iosxe',
                       username='******',
                       tacacs_password='******',
                       enable_password='******')
        r = c.ping('192.0.0.6', vrf='test', count=30)
        self.assertEqual(r.strip(), "\r\n".join("""ping vrf test
Protocol [ip]: 
Target IP address: 192.0.0.6
Repeat count [5]: 30
Datagram size [100]: 
Timeout in seconds [2]: 
Extended commands [n]: n
Sweep range of sizes [n]: n
Type escape sequence to abort.
Sending 30, 100-byte ICMP Echos to 192.0.0.6, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (30/30), round-trip min/avg/max = 1/1/3 ms""".\
splitlines()))
    def test_ping_options(self):
        c = Connection(hostname='Router',
                            start=['mock_device_cli --os ios --state exec'],
                            os='ios',
                            username='******',
                            tacacs_password='******',
                            enable_password='******')
        r = c.ping('3.3.3.3', size=1500, count=5, ping_packet_timeout=2)
        self.assertEqual(r, "\r\n".join("""ping
Protocol [ip]: 
Target IP address: 3.3.3.3
Repeat count [5]: 5
Datagram size [100]: 1500
Timeout in seconds [2]: 2
Extended commands [n]: n
Sweep range of sizes [n]: n
Type escape sequence to abort.
Sending 5, 1500-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

""".splitlines()))