Statistics
| Branch: | Tag: | Revision:

root / ncclient / transport / errors.py @ 4f650d54

History | View | Annotate | Download (1.3 kB)

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