예제 #1
0
    def test_disable_enable(self):
        d = Connection(
            hostname='Router',
            start=[
                'mock_device_cli --os iosxe --state quad_login',
                'mock_device_cli --os iosxe --state quad_ics_login',
                'mock_device_cli --os iosxe --state quad_stby_login',
                'mock_device_cli --os iosxe --state quad_ics_login'
            ],
            os='iosxe',
            chassis_type='quad',
            username='******',
            tacacs_password='******',
            enable_password='******')
        d.connect()

        d.disable()
        self.assertEqual(d.spawn.match.match_output, 'disable\r\nRouter>')

        d.enable()
        self.assertEqual(d.spawn.match.match_output, 'cisco\r\nRouter#')

        d.disable(target='standby')
        self.assertEqual(d.standby.spawn.match.match_output,
                         'disable\r\nRouter-stby>')

        d.enable(target='standby')
        self.assertEqual(d.standby.spawn.match.match_output,
                         'cisco\r\nRouter-stby#')

        d.disconnect()
예제 #2
0
class TestIosXrConfigPrompts(unittest.TestCase):
    """Tests for config prompt handling."""
    @classmethod
    def setUpClass(self):
        self._conn = Connection(
            hostname='Router',
            start=['mock_device_cli --os iosxr --state enable'],
            os='iosxr',
        )
        self._conn.connect()
        self._moonshine_conn = Connection(
            hostname='Router',
            start=['mock_device_cli --os iosxr --state moonshine_enable'],
            os='iosxr',
            platform='moonshine',
        )
        self._moonshine_conn.connect()

    def test_failed_config(self):
        """Check that we can successfully return to an enable prompt after entering failed config."""
        self._conn.execute("configure terminal", allow_state_change=True)
        self._conn.execute("test failed")
        self._conn.spawn.timeout = 60
        self._conn.enable()

    def test_failed_config_moonshine(self):
        """Check that we can successfully return to an enable prompt after entering failed config on moonshine."""
        self._moonshine_conn.execute("configure terminal",
                                     allow_state_change=True)
        self._moonshine_conn.execute("test failed")
        self._moonshine_conn.spawn.timeout = 60
        self._moonshine_conn.enable()
 def test_connect_asa_username_password(self):
     c = Connection(
         hostname='Firepower',
         start=[
             'mock_device_cli --os fxos --state fp4k_console_module_telnet_asa'
         ],
         os='fxos',
         platform='fp4k',
         connection_timeout=10,
         credentials=dict(default=dict(username='******', password='******'),
                          enable=dict(username='******', password='******')),
     )
     c.connect()
     c.enable()
     c.disconnect()
예제 #4
0
 def test_rommon(self):
     c = Connection(
         hostname='ASA',
         start=[
             'mock_device_cli --os asa --state asa_fp2k_console_enable_to_rommon'
         ],
         os='asa',
         platform='fp2k',
         credentials=dict(default=dict(username='******', password='******'),
                          enable=dict(password='******')),
     )
     c.connect()
     c.rommon()
     self.assertEqual(c.state_machine.current_state, 'rommon')
     c.enable()
     self.assertEqual(c.state_machine.current_state, 'enable')
     c.disconnect()
예제 #5
0
 def test_switchto(self):
     c = Connection(
         hostname='ASA',
         start=[
             'mock_device_cli --os asa --state asa_fp2k_console_disable'
         ],
         os='asa',
         platform='fp2k',
         credentials=dict(default=dict(username='******', password='******'),
                          enable=dict(password='******')),
     )
     c.connect()
     c.switchto('fxos')
     c.switchto(['enable', 'fxos', 'disable'])
     c.switchto('fxos mgmt')
     c.enable()
     c.switchto(['fxos admin', 'fxos root'])
     c.disconnect()
    def test_disable_enable(self):
        c = Connection(hostname='Router',
                       start=['mock_device_cli --os iosxe --state isr_exec'],
                       os='iosxe',
                       username='******',
                       tacacs_password='******',
                       enable_password='******')

        r = c.disable()
        self.assertEqual(c.spawn.match.match_output, 'disable\r\nRouter>')

        r = c.enable()
        self.assertEqual(c.spawn.match.match_output, 'cisco\r\nRouter#')

        r = c.disable()
        self.assertEqual(c.spawn.match.match_output, 'disable\r\nRouter>')

        r = c.enable(command='enable 7')
        self.assertEqual(c.spawn.match.match_output, 'cisco\r\nRouter#')
    def test_disable_enable(self):
        c = Connection(hostname='Router',
                       start = ['mock_device_cli --os iosxe --state stack_enable']*5,
                       os='iosxe',
                       chassis_type='stack',
                       username='******',
                       tacacs_password='******',
                       enable_password='******')
        c.connect()

        r = c.disable()
        self.assertEqual(c.spawn.match.match_output, 'disable\r\nRouter>')

        r = c.enable()
        self.assertEqual(c.spawn.match.match_output, 'cisco\r\nRouter#')

        r = c.disable(target='standby')
        self.assertEqual(c.standby.spawn.match.match_output, 'disable\r\nRouter>')

        r = c.enable(target='standby')
        self.assertEqual(c.standby.spawn.match.match_output, 'cisco\r\nRouter#')
예제 #8
0
    def test_disable_enable(self):
        c = Connection(
            hostname='Router',
            start=['mock_device_cli --os iosxe --state isr_exec'],
            os='iosxe',
            credentials=dict(default=dict(username='******', password='******')),
            log_buffer=True)

        r = c.disable()
        self.assertEqual(c.spawn.match.match_output, 'disable\r\nRouter>')

        r = c.enable()
        self.assertEqual(c.spawn.match.match_output, 'cisco\r\nRouter#')

        r = c.disable()
        self.assertEqual(c.spawn.match.match_output, 'disable\r\nRouter>')

        r = c.enable(command='enable 7')
        self.assertEqual(c.spawn.match.match_output, 'cisco\r\nRouter#')

        c.disconnect()
예제 #9
0
    def test_disable_enable(self):
        c = Connection(hostname='Router',
                       start=['mock_device_cli --os iosxe --state isr_exec'],
                       os='iosxe',
                       username='******',
                       tacacs_password='******',
                       enable_password='******',
                       settings=dict(POST_DISCONNECT_WAIT_SEC=0,
                                     GRACEFUL_DISCONNECT_WAIT_SEC=0.2),
                       log_buffer=True)

        r = c.disable()
        self.assertEqual(c.spawn.match.match_output, 'disable\r\nRouter>')

        r = c.enable()
        self.assertEqual(c.spawn.match.match_output, 'cisco\r\nRouter#')

        r = c.disable()
        self.assertEqual(c.spawn.match.match_output, 'disable\r\nRouter>')

        r = c.enable(command='enable 7')
        self.assertEqual(c.spawn.match.match_output, 'cisco\r\nRouter#')

        c.disconnect()