Improve IXIA IxNetwork library and traffic profile (2)
[yardstick.git] / yardstick / common / exceptions.py
1 # Copyright (c) 2017 Intel Corporation
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from oslo_utils import excutils
16
17
18 class ProcessExecutionError(RuntimeError):
19     def __init__(self, message, returncode):
20         super(ProcessExecutionError, self).__init__(message)
21         self.returncode = returncode
22
23
24 class ErrorClass(object):
25
26     def __init__(self, *args, **kwargs):
27         if 'test' not in kwargs:
28             raise RuntimeError
29
30     def __getattr__(self, item):
31         raise AttributeError
32
33
34 class YardstickException(Exception):
35     """Base Yardstick Exception.
36
37     To correctly use this class, inherit from it and define
38     a 'message' property. That message will get printf'd
39     with the keyword arguments provided to the constructor.
40
41     Based on NeutronException class.
42     """
43     message = "An unknown exception occurred."
44
45     def __init__(self, **kwargs):
46         try:
47             super(YardstickException, self).__init__(self.message % kwargs)
48             self.msg = self.message % kwargs
49         except Exception:  # pylint: disable=broad-except
50             with excutils.save_and_reraise_exception() as ctxt:
51                 if not self.use_fatal_exceptions():
52                     ctxt.reraise = False
53                     # at least get the core message out if something happened
54                     super(YardstickException, self).__init__(self.message)
55
56     def __str__(self):
57         return self.msg
58
59     def use_fatal_exceptions(self):
60         """Is the instance using fatal exceptions.
61
62         :returns: Always returns False.
63         """
64         return False
65
66
67 class ResourceCommandError(YardstickException):
68     message = 'Command: "%(command)s" Failed, stderr: "%(stderr)s"'
69
70
71 class FunctionNotImplemented(YardstickException):
72     message = ('The function "%(function_name)s" is not implemented in '
73                '"%(class_name)" class.')
74
75
76 class InfluxDBConfigurationMissing(YardstickException):
77     message = ('InfluxDB configuration is not available. Add "influxdb" as '
78                'a dispatcher and the configuration section')
79
80
81 class YardstickBannedModuleImported(YardstickException):
82     # pragma: no cover
83     message = 'Module "%(module)s" cannnot be imported. Reason: "%(reason)s"'
84
85
86 class PayloadMissingAttributes(YardstickException):
87     message = ('Error instantiating a Payload class, missing attributes: '
88                '%(missing_attributes)s')
89
90
91 class HeatTemplateError(YardstickException):
92     """Error in Heat during the stack deployment"""
93     message = ('Error in Heat during the creation of the OpenStack stack '
94                '"%(stack_name)s"')
95
96
97 class IPv6RangeError(YardstickException):
98     message = 'Start IP "%(start_ip)s" is greater than end IP "%(end_ip)s"'
99
100
101 class TrafficProfileNotImplemented(YardstickException):
102     message = 'No implementation for traffic profile %(profile_class)s.'
103
104
105 class DPDKSetupDriverError(YardstickException):
106     message = '"igb_uio" driver is not loaded'
107
108
109 class OVSUnsupportedVersion(YardstickException):
110     message = ('Unsupported OVS version "%(ovs_version)s". Please check the '
111                'config. OVS to DPDK version map: %(ovs_to_dpdk_map)s.')
112
113
114 class OVSHugepagesInfoError(YardstickException):
115     message = 'MemInfo cannnot be retrieved.'
116
117
118 class OVSHugepagesNotConfigured(YardstickException):
119     message = 'HugePages are not configured in this system.'
120
121
122 class OVSHugepagesZeroFree(YardstickException):
123     message = ('There are no HugePages free in this system. Total HugePages '
124                'configured: %(total_hugepages)s')
125
126
127 class OVSDeployError(YardstickException):
128     message = 'OVS deploy tool failed with error: %(stderr)s.'
129
130
131 class OVSSetupError(YardstickException):
132     message = 'OVS setup error. Command: %(command)s. Error: %(error)s.'
133
134
135 class LibvirtCreateError(YardstickException):
136     message = 'Error creating the virtual machine. Error: %(error)s.'
137
138
139 class LibvirtQemuImageBaseImageNotPresent(YardstickException):
140     message = ('Error creating the qemu image for %(vm_image)s. Base image: '
141                '%(base_image)s. Base image not present in execution host or '
142                'remote host.')
143
144
145 class LibvirtQemuImageCreateError(YardstickException):
146     message = ('Error creating the qemu image for %(vm_image)s. Base image: '
147                '%(base_image)s. Error: %(error)s.')
148
149
150 class SSHError(YardstickException):
151     message = '%(error_msg)s'
152
153
154 class SSHTimeout(SSHError):
155     pass
156
157
158 class IncorrectConfig(YardstickException):
159     message = '%(error_msg)s'
160
161
162 class IncorrectSetup(YardstickException):
163     message = '%(error_msg)s'
164
165
166 class IncorrectNodeSetup(IncorrectSetup):
167     pass
168
169
170 class ScenarioConfigContextNameNotFound(YardstickException):
171     message = 'Context name "%(context_name)s" not found'
172
173
174 class StackCreationInterrupt(YardstickException):
175     message = 'Stack create interrupted.'
176
177
178 class TaskRenderArgumentError(YardstickException):
179     message = 'Error reading the task input arguments'
180
181
182 class TaskReadError(YardstickException):
183     message = 'Failed to read task %(task_file)s'
184
185
186 class TaskRenderError(YardstickException):
187     message = 'Failed to render template:\n%(input_task)s'
188
189
190 class TimerTimeout(YardstickException):
191     message = 'Timer timeout expired, %(timeout)s seconds'
192
193
194 class WaitTimeout(YardstickException):
195     message = 'Wait timeout while waiting for condition'
196
197
198 class ScenarioCreateNetworkError(YardstickException):
199     message = 'Create Neutron Network Scenario failed'
200
201
202 class ScenarioCreateSubnetError(YardstickException):
203     message = 'Create Neutron Subnet Scenario failed'
204
205
206 class ScenarioDeleteRouterError(YardstickException):
207     message = 'Delete Neutron Router Scenario failed'
208
209
210 class MissingPodInfoError(YardstickException):
211     message = 'Missing pod args, please check'
212
213
214 class UnsupportedPodFormatError(YardstickException):
215     message = 'Failed to load pod info, unsupported format'
216
217
218 class ScenarioCreateRouterError(YardstickException):
219     message = 'Create Neutron Router Scenario failed'
220
221
222 class ScenarioRemoveRouterIntError(YardstickException):
223     message = 'Remove Neutron Router Interface Scenario failed'
224
225
226 class ScenarioCreateFloatingIPError(YardstickException):
227     message = 'Create Neutron Floating IP Scenario failed'
228
229
230 class ScenarioDeleteFloatingIPError(YardstickException):
231     message = 'Delete Neutron Floating IP Scenario failed'
232
233
234 class ScenarioCreateSecurityGroupError(YardstickException):
235     message = 'Create Neutron Security Group Scenario failed'
236
237
238 class ScenarioDeleteNetworkError(YardstickException):
239     message = 'Delete Neutron Network Scenario failed'
240
241
242 class ScenarioCreateServerError(YardstickException):
243     message = 'Nova Create Server Scenario failed'
244
245
246 class ScenarioDeleteServerError(YardstickException):
247     message = 'Delete Server Scenario failed'
248
249
250 class ScenarioCreateKeypairError(YardstickException):
251     message = 'Nova Create Keypair Scenario failed'
252
253
254 class ScenarioDeleteKeypairError(YardstickException):
255     message = 'Nova Delete Keypair Scenario failed'
256
257
258 class ScenarioAttachVolumeError(YardstickException):
259     message = 'Nova Attach Volume Scenario failed'
260
261
262 class ScenarioGetServerError(YardstickException):
263     message = 'Nova Get Server Scenario failed'
264
265
266 class ScenarioGetFlavorError(YardstickException):
267     message = 'Nova Get Falvor Scenario failed'
268
269
270 class ScenarioCreateVolumeError(YardstickException):
271     message = 'Cinder Create Volume Scenario failed'
272
273
274 class ScenarioDeleteVolumeError(YardstickException):
275     message = 'Cinder Delete Volume Scenario failed'
276
277
278 class ScenarioDetachVolumeError(YardstickException):
279     message = 'Cinder Detach Volume Scenario failed'
280
281
282 class ApiServerError(YardstickException):
283     message = 'An unkown exception happened to Api Server!'
284
285
286 class UploadOpenrcError(ApiServerError):
287     message = 'Upload openrc ERROR!'
288
289
290 class UpdateOpenrcError(ApiServerError):
291     message = 'Update openrc ERROR!'
292
293
294 class ScenarioCreateImageError(YardstickException):
295     message = 'Glance Create Image Scenario failed'
296
297
298 class ScenarioDeleteImageError(YardstickException):
299     message = 'Glance Delete Image Scenario failed'
300
301
302 class IxNetworkClientNotConnected(YardstickException):
303     message = 'IxNetwork client not connected to a TCL server'
304
305
306 class IxNetworkFlowNotPresent(YardstickException):
307     message = 'Flow Group "%(flow_group)s" is not present'
308
309
310 class IxNetworkFieldNotPresentInStackItem(YardstickException):
311     message = 'Field "%(field_name)s" not present in stack item %(stack_item)s'