File: exceptions.py

package info (click to toggle)
pyiosxr 0.52-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 168 kB
  • sloc: python: 841; makefile: 3
file content (112 lines) | stat: -rw-r--r-- 2,670 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python
# coding=utf-8
"""Exceptions for pyiosxr, a module to interact with Cisco devices running IOS-XR."""

# Copyright 2015 Netflix. All rights reserved.
# Copyright 2016 BigWaveIT. All rights reserved.
#
# The contents of this file are licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.


class IOSXRException(Exception):


    def __init__(self, msg=None, dev=None):

        super(IOSXRException, self).__init__(msg)
        if dev:
            self._xr = dev
            # release the XML agent
            if self._xr._xml_agent_locker.locked():
                self._xr._xml_agent_locker.release()


class ConnectError(IOSXRException):
    """Exception while openning the connection."""

    def __init__(self, msg=None, dev=None):
        super(ConnectError, self).__init__(msg=msg, dev=dev)
        if dev:
            self._xr = dev
            self._xr._xml_agent_alive = False


class CommitError(IOSXRException):

    """Raised when unable to commit. Mostly due to ERROR 0x41866c00"""

    pass


class LockError(IOSXRException):
    """Throw this exception when unable to lock the config DB."""

    pass


class UnlockError(IOSXRException):
    """Throw this exception when unable to unlock the config DB."""

    pass


class CompareConfigError(IOSXRException):
    """Throw this exception when unable to compare config."""

    pass


class UnknownError(IOSXRException):
    """UnknownError Exception."""

    pass


class InvalidInputError(IOSXRException):
    """InvalidInputError Exception."""

    pass


class XMLCLIError(IOSXRException):
    """XMLCLIError Exception."""

    pass


class InvalidXMLResponse(IOSXRException):
    """Raised when unable to process properly the XML reply from the device."""

    pass


class TimeoutError(IOSXRException):
    """TimeoutError Exception."""

    def __init__(self, msg=None, dev=None):
        super(TimeoutError, self).__init__(msg=msg, dev=dev)
        if dev:
            self._xr = dev
            self._xr._xml_agent_alive = False


class EOFError(IOSXRException):
    """EOFError Exception."""

    pass


class IteratorIDError(IOSXRException):
    """IteratorIDError Exception."""

    pass