1# Copyright 2009 Shikhar Bhushan
2# Copyright 2014 Leonidas Poulopoulos
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#    http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from ncclient import NCClientError
17
18class TransportError(NCClientError):
19    pass
20
21class SessionError(NCClientError):
22    pass
23
24class AuthenticationError(TransportError):
25    pass
26
27class PermissionError(TransportError):
28    pass
29
30class SessionCloseError(TransportError):
31
32    def __init__(self, in_buf, out_buf=None):
33        msg = 'Unexpected session close'
34        if in_buf:
35            msg += '\nIN_BUFFER: `%s`' % in_buf
36        if out_buf:
37            msg += ' OUT_BUFFER: `%s`' % out_buf
38        SSHError.__init__(self, msg)
39
40class SSHError(TransportError):
41    pass
42
43class SSHUnknownHostError(SSHError):
44
45    def __init__(self, host, fingerprint):
46        SSHError.__init__(self, 'Unknown host key [%s] for [%s]' % (fingerprint, host))
47        self.host = host
48        self.fingerprint = fingerprint
49
50class NetconfFramingError(TransportError):
51    pass
52