예제 #1
0
 def _cli_error_check(self, command_response):
     error = command_response.get(u'error')
     if error:
         command = command_response.get(u'command')
         if u'data' in error:
             raise CLIError(command, error[u'data'][u'msg'])
         else:
             raise CLIError(command, 'Invalid command.')
예제 #2
0
    def test_bad_config(self):
        command = "asdf poknw"
        self.device.native.config.side_effect = CLIError(
            command, "Invalid command.")

        with self.assertRaisesRegex(CommandError, command):
            self.device.config(command)
예제 #3
0
    def test_bad_config_list(self):
        commands = ["interface Eth1", "apons"]
        self.device.native.config_list.side_effect = CLIError(
            commands[1], "Invalid command.")

        with self.assertRaisesRegex(CommandListError, commands[1]):
            self.device.config_list(commands)
예제 #4
0
    def test_bad_config_list(self):
        commands = ['interface Eth1', 'apons']
        self.device.native.config_list.side_effect = CLIError(
            commands[1], 'Invalid command.')

        with self.assertRaisesRegexp(CommandListError, commands[1]):
            self.device.config_list(commands)
예제 #5
0
파일: __init__.py 프로젝트: xuys50/pyntc
def show(command, raw_text=False):
    command = command.replace(" ", "_")
    command = command.replace("/", "_")

    if raw_text:
        path = os.path.join(CURRNENT_DIR, "show_raw", command)
    else:
        path = os.path.join(CURRNENT_DIR, "show", command)

    if not os.path.isfile(path):
        raise CLIError(command, "Invalid command.")

    with open(path, "r") as f:
        response = f.read()

    if raw_text:
        return response
    else:
        return json.loads(response)
예제 #6
0
def show(command, raw_text=False):
    command = command.replace(' ', '_')
    command = command.replace('/', '_')

    if raw_text:
        path = os.path.join(CURRNENT_DIR, 'show_raw', command)
    else:
        path = os.path.join(CURRNENT_DIR, 'show', command)

    if not os.path.isfile(path):
        raise CLIError(command, 'Invalid command.')

    with open(path, 'r') as f:
        response = f.read()

    if raw_text:
        return response
    else:
        return json.loads(response)
예제 #7
0
    def test_bad_rollback(self):
        self.device.native.rollback.side_effect = CLIError(
            "rollback", "bad rollback command")

        with self.assertRaises(RollbackError):
            self.device.rollback("bad_checkpoint")
예제 #8
0
    def test_bad_rollback(self):
        self.device.native.rollback.side_effect = CLIError(
            'rollback', 'bad rollback command')

        with self.assertRaises(RollbackError):
            self.device.rollback('bad_checkpoint')