예제 #1
0
 def test_console_execute(self):
     c = Connection(
         hostname='Firepower',
         start=['mock_device_cli --os fxos --state chassis_exec'],
         os='fxos',
         series='ftd',
         username='******',
         tacacs_password='******',
         enable_password='******',
         line_password='******')
     c.connect()
     c.switchto('ftd expert')
     c.execute(['sudo su -'],
               reply=Dialog([password_stmt, escape_char_stmt]),
               allow_state_change=True)
예제 #2
0
 def test_console_execute(self):
     c = Connection(
         hostname='Firepower',
         start=['mock_device_cli --os fxos --state chassis_exec'],
         os='fxos',
         platform='ftd',
         credentials=dict(default=dict(username='******',
                                       password='******',
                                       line_password='******'),
                          sudo=dict(password='******')))
     c.connect()
     c.spawn.timeout = 30
     c.switchto('ftd expert', timeout=60)
     c.execute(['sudo su -'],
               reply=Dialog([password_stmt, escape_char_stmt]),
               allow_state_change=True)
예제 #3
0
 def test_system_cli_transition(self):
     test_states = ['disable', 'enable', 'config']
     for initial_state in test_states:
         c = Connection(
             hostname='Firepower',
             start=[
                 'mock_device_cli --os fxos --state fp2k_ftd_exec_{}'.
                 format(initial_state)
             ],
             os='fxos',
             credentials=dict(
                 default=dict(username='******', password='******')),
         )
         c.connect()
         for state in test_states:
             c.switchto(state)
         c.disconnect()
 def test_switchto_states(self):
     states = [
         'chassis', 'chassis scope /system', 'fxos', 'local-mgmt', 'cimc',
         'cimc 1', 'module console', 'module 1 console', 'ftd console',
         'ftd expert', 'ftd expert root'
     ]
     c = Connection(hostname='Firepower',
                    start=['mock_device_cli --os fxos --state fxos_exec'],
                    os='fxos',
                    series='ftd',
                    username='******',
                    tacacs_password='******',
                    enable_password='******',
                    line_password='******')
     c.connect()
     for state in states:
         c.switchto(state)
예제 #5
0
 def test_switchto_states(self):
     states = [
         'chassis', 'chassis scope /system', 'fxos', 'local-mgmt', 'cimc',
         'cimc 1', 'module console', 'module 1 console', 'ftd console',
         'ftd expert', 'ftd expert root'
     ]
     c = Connection(hostname='Firepower',
                    start=['mock_device_cli --os fxos --state fxos_exec'],
                    os='fxos',
                    platform='ftd',
                    credentials=dict(default=dict(username='******',
                                                  password='******',
                                                  line_password='******'),
                                     sudo=dict(password='******')))
     c.connect()
     for state in states:
         c.switchto(state)
예제 #6
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()
class TestIosXrSpitfirePluginSwitchTo(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.c = Connection(
            hostname='Router',
            start=['mock_device_cli --os iosxr --state spitfire_enable'],
            os='iosxr',
            series='spitfire',
            username='******',
            enable_password='******',
        )
        self.c.connect()

    def test_switchto(self):
        self.c.switchto("config")
        self.assertEqual(
            self.c.spawn.match.match_output,
            'configure terminal\r\nRP/0/RP0/CPU0:Router(config)#')
        self.c.switchto('enable')
        self.assertEqual(self.c.spawn.match.match_output,
                         'end\r\nRP/0/RP0/CPU0:Router#')

    def test_switchto_xr_env(self):
        self.c.switchto("xr_run")
        self.assertEqual(self.c.spawn.match.match_output,
                         'run\r\n[node0_RP0_CPU0:~]$')
        self.c.switchto("xr_env")
        self.assertEqual(self.c.spawn.match.match_output,
                         'xrenv\r\nXR[ios:~]$')
        self.c.switchto('enable')
        self.assertEqual(self.c.spawn.match.match_output,
                         'exit\r\nRP/0/RP0/CPU0:Router#')
        self.c.switchto("xr_bash")
        self.assertEqual(self.c.spawn.match.match_output,
                         'bash\r\n[ios:/misc/scratch]$')
        self.c.switchto("xr_env")
        self.assertEqual(self.c.spawn.match.match_output,
                         'xrenv\r\nXR[ios:~]$')
        self.c.switchto('enable')
        self.assertEqual(self.c.spawn.match.match_output,
                         'exit\r\nRP/0/RP0/CPU0:Router#')

    @classmethod
    def tearDownClass(self):
        self.c.disconnect()