Debian Codegraph @

infoblox_client/exceptions.py

raw symbols SCIP
1 # Copyright 2015 Infoblox Inc.
2 # All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # 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, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16
17 class BaseExc(Exception):
18 """Base Exception
19
20 To correctly use this class, inherit from it and define
21 a 'message' property. That message will get printf'd
22 with the keyword arguments provided to the constructor.
23 """
24 message = "An unknown exception occurred."
25
26 def __init__(self, **kwargs):
27 super(BaseExc, self).__init__(self.message % kwargs)
28 self.msg = self.message % kwargs
29 self.kwargs = kwargs
30
31
32 class InfobloxException(BaseExc):
33 """Generic Infoblox Exception."""
34
35 def __init__(self, response, **kwargs):
36 self.response = response
37 super(InfobloxException, self).__init__(**kwargs)
38
39
40 class InfobloxSearchError(InfobloxException):
41 message = "Cannot search '%(obj_type)s' object(s): " \
42 "%(content)s [code %(code)s]"
43
44
45 class InfobloxFileDownloadFailed(InfobloxException):
46 message = "Unable to download file from '%(url)s'" \
47 "\n '%(content)s' [code %(code)s]"
48
49
50 class InfobloxFileUploadFailed(InfobloxException):
51 message = "Unable to upload file to '%(url)s '\n %(content)s' '%(code)s'"
52
53
54 class InfobloxCannotCreateObject(InfobloxException):
55 message = "Cannot create '%(obj_type)s' object(s): " \
56 "%(content)s [code %(code)s]"
57
58
59 class InfobloxMemberAlreadyAssigned(InfobloxCannotCreateObject):
60 pass
61
62
63 class InfobloxCannotDeleteObject(InfobloxException):
64 message = "Cannot delete object with ref %(ref)s: " \
65 "%(content)s [code %(code)s]"
66
67
68 class InfobloxCannotUpdateObject(InfobloxException):
69 message = "Cannot update object with ref %(ref)s: " \
70 "%(content)s [code %(code)s]"
71
72
73 class InfobloxFuncException(InfobloxException):
74 message = "Error occurred during function's '%(func_name)s' call: " \
75 "ref %(ref)s: %(content)s [code %(code)s]"
76
77
78 class InfobloxHostRecordIpAddrNotCreated(BaseExc):
79 message = "Infoblox host record ipv4addr/ipv6addr has not been " \
80 "created for IP %(ip)s, mac %(mac)s"
81
82
83 class InfobloxCannotAllocateIp(BaseExc):
84 message = "Cannot allocate IP %(ip_data)s"
85
86
87 class InfobloxDidNotReturnCreatedIPBack(BaseExc):
88 message = "Infoblox did not return created IP back"
89
90
91 class InfobloxNetworkNotAvailable(BaseExc):
92 message = "No network view %(network_view)s for %(cidr)s"
93
94
95 class InfobloxObjectParsingError(BaseExc):
96 message = "Infoblox object cannot be parsed from dict: %(data)s"
97
98
99 class HostRecordNotPresent(InfobloxObjectParsingError):
100 message = "Cannot parse Host Record object from dict because " \
101 "'ipv4addrs'/'ipv6addrs' is absent."
102
103
104 class InfobloxInvalidIp(InfobloxObjectParsingError):
105 message = "Bad IP address: %(ip)s"
106
107
108 class InfobloxConnectionError(BaseExc):
109 message = "Infoblox HTTP request failed with: %(reason)s"
110
111
112 class InfobloxConfigException(BaseExc):
113 """Generic Infoblox Config Exception."""
114 message = "Config error: %(msg)s"
115
116
117 class InfobloxBadWAPICredential(InfobloxException):
118 message = "Infoblox IPAM is misconfigured: " \
119 "infoblox_username and infoblox_password are incorrect." \
120 "\n %(content)s [code %(code)s]"
121
122
123 class InfobloxTimeoutError(InfobloxException):
124 message = "Connection to NIOS timed out: %(reason)s"
125
126
127 class InfobloxGridTemporaryUnavailable(InfobloxException):
128 message = "Cannot perform operation %(operation)s with ref %(ref)s: " \
129 "%(content)s [code %(code)s]"
130
131
132 class InfobloxFetchGotMultipleObjects(BaseExc):
133 message = "Fetch got multiple objects from the API. Unable to " \
134 "deserialize multiple API objects into one InfobloxObject."
135
136
137 class InfobloxFieldNotSearchable(BaseExc):
138 message = "Field is not searchable: %(field)s"