Replace nova attach volume to server with shade client.
[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 YardstickBannedModuleImported(YardstickException):
77     # pragma: no cover
78     message = 'Module "%(module)s" cannnot be imported. Reason: "%(reason)s"'
79
80
81 class HeatTemplateError(YardstickException):
82     """Error in Heat during the stack deployment"""
83     message = ('Error in Heat during the creation of the OpenStack stack '
84                '"%(stack_name)s"')
85
86
87 class IPv6RangeError(YardstickException):
88     message = 'Start IP "%(start_ip)s" is greater than end IP "%(end_ip)s"'
89
90
91 class TrafficProfileNotImplemented(YardstickException):
92     message = 'No implementation for traffic profile %(profile_class)s.'
93
94
95 class DPDKSetupDriverError(YardstickException):
96     message = '"igb_uio" driver is not loaded'
97
98
99 class OVSUnsupportedVersion(YardstickException):
100     message = ('Unsupported OVS version "%(ovs_version)s". Please check the '
101                'config. OVS to DPDK version map: %(ovs_to_dpdk_map)s.')
102
103
104 class OVSHugepagesInfoError(YardstickException):
105     message = 'MemInfo cannnot be retrieved.'
106
107
108 class OVSHugepagesNotConfigured(YardstickException):
109     message = 'HugePages are not configured in this system.'
110
111
112 class OVSHugepagesZeroFree(YardstickException):
113     message = ('There are no HugePages free in this system. Total HugePages '
114                'configured: %(total_hugepages)s')
115
116
117 class OVSDeployError(YardstickException):
118     message = 'OVS deploy tool failed with error: %(stderr)s.'
119
120
121 class OVSSetupError(YardstickException):
122     message = 'OVS setup error. Command: %(command)s. Error: %(error)s.'
123
124
125 class LibvirtCreateError(YardstickException):
126     message = 'Error creating the virtual machine. Error: %(error)s.'
127
128
129 class SSHError(YardstickException):
130     message = '%(error_msg)s'
131
132
133 class SSHTimeout(SSHError):
134     pass
135
136
137 class IncorrectConfig(YardstickException):
138     message = '%(error_msg)s'
139
140
141 class IncorrectSetup(YardstickException):
142     message = '%(error_msg)s'
143
144
145 class IncorrectNodeSetup(IncorrectSetup):
146     pass
147
148
149 class ScenarioConfigContextNameNotFound(YardstickException):
150     message = 'Context for host name "%(host_name)s" not found'
151
152
153 class StackCreationInterrupt(YardstickException):
154     message = 'Stack create interrupted.'
155
156
157 class TaskRenderArgumentError(YardstickException):
158     message = 'Error reading the task input arguments'
159
160
161 class TaskReadError(YardstickException):
162     message = 'Failed to read task %(task_file)s'
163
164
165 class TaskRenderError(YardstickException):
166     message = 'Failed to render template:\n%(input_task)s'
167
168
169 class TimerTimeout(YardstickException):
170     message = 'Timer timeout expired, %(timeout)s seconds'
171
172
173 class WaitTimeout(YardstickException):
174     message = 'Wait timeout while waiting for condition'
175
176
177 class ScenarioCreateNetworkError(YardstickException):
178     message = 'Create Neutron Network Scenario failed'
179
180
181 class ScenarioCreateSubnetError(YardstickException):
182     message = 'Create Neutron Subnet Scenario failed'
183
184
185 class ScenarioDeleteRouterError(YardstickException):
186     message = 'Delete Neutron Router Scenario failed'
187
188
189 class MissingPodInfoError(YardstickException):
190     message = 'Missing pod args, please check'
191
192
193 class UnsupportedPodFormatError(YardstickException):
194     message = 'Failed to load pod info, unsupported format'
195
196
197 class ScenarioCreateRouterError(YardstickException):
198     message = 'Create Neutron Router Scenario failed'
199
200
201 class ScenarioRemoveRouterIntError(YardstickException):
202     message = 'Remove Neutron Router Interface Scenario failed'
203
204
205 class ScenarioCreateFloatingIPError(YardstickException):
206     message = 'Create Neutron Floating IP Scenario failed'
207
208
209 class ScenarioDeleteFloatingIPError(YardstickException):
210     message = 'Delete Neutron Floating IP Scenario failed'
211
212
213 class ScenarioCreateSecurityGroupError(YardstickException):
214     message = 'Create Neutron Security Group Scenario failed'
215
216
217 class ScenarioDeleteNetworkError(YardstickException):
218     message = 'Delete Neutron Network Scenario failed'
219
220
221 class ScenarioCreateServerError(YardstickException):
222     message = 'Nova Create Server Scenario failed'
223
224
225 class ScenarioDeleteServerError(YardstickException):
226     message = 'Delete Server Scenario failed'
227
228
229 class ScenarioCreateKeypairError(YardstickException):
230     message = 'Nova Create Keypair Scenario failed'
231
232
233 class ScenarioDeleteKeypairError(YardstickException):
234     message = 'Nova Delete Keypair Scenario failed'
235
236
237 class ScenarioAttachVolumeError(YardstickException):
238     message = 'Nova Attach Volume Scenario failed'
239
240
241 class ApiServerError(YardstickException):
242     message = 'An unkown exception happened to Api Server!'
243
244
245 class UploadOpenrcError(ApiServerError):
246     message = 'Upload openrc ERROR!'
247
248
249 class UpdateOpenrcError(ApiServerError):
250     message = 'Update openrc ERROR!'
251
252
253 class IxNetworkClientNotConnected(YardstickException):
254     message = 'IxNetwork client not connected to a TCL server'
255
256
257 class IxNetworkFlowNotPresent(YardstickException):
258     message = 'Flow Group "%(flow_group)s" is not present'
259
260
261 class IxNetworkFieldNotPresentInStackItem(YardstickException):
262     message = 'Field "%(field_name)s" not present in stack item %(stack_item)s'
263
264
265 class AclMissingActionArguments(YardstickException):
266     message = ('Missing ACL action parameter '
267                '[action=%(action_name)s parameter=%(action_param)s]')
268
269
270 class AclUknownActionTemplate(YardstickException):
271     message = 'No ACL CLI template found for "%(action_name)s" action'