Replace nova get flavor 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 YardstickException(Exception):
25     """Base Yardstick Exception.
26
27     To correctly use this class, inherit from it and define
28     a 'message' property. That message will get printf'd
29     with the keyword arguments provided to the constructor.
30
31     Based on NeutronException class.
32     """
33     message = "An unknown exception occurred."
34
35     def __init__(self, **kwargs):
36         try:
37             super(YardstickException, self).__init__(self.message % kwargs)
38             self.msg = self.message % kwargs
39         except Exception:  # pylint: disable=broad-except
40             with excutils.save_and_reraise_exception() as ctxt:
41                 if not self.use_fatal_exceptions():
42                     ctxt.reraise = False
43                     # at least get the core message out if something happened
44                     super(YardstickException, self).__init__(self.message)
45
46     def __str__(self):
47         return self.msg
48
49     def use_fatal_exceptions(self):
50         """Is the instance using fatal exceptions.
51
52         :returns: Always returns False.
53         """
54         return False
55
56
57 class FunctionNotImplemented(YardstickException):
58     message = ('The function "%(function_name)s" is not implemented in '
59                '"%(class_name)" class.')
60
61
62 class YardstickBannedModuleImported(YardstickException):
63     # pragma: no cover
64     message = 'Module "%(module)s" cannnot be imported. Reason: "%(reason)s"'
65
66
67 class PayloadMissingAttributes(YardstickException):
68     message = ('Error instantiating a Payload class, missing attributes: '
69                '%(missing_attributes)s')
70
71
72 class HeatTemplateError(YardstickException):
73     """Error in Heat during the stack deployment"""
74     message = ('Error in Heat during the creation of the OpenStack stack '
75                '"%(stack_name)s"')
76
77
78 class IPv6RangeError(YardstickException):
79     message = 'Start IP "%(start_ip)s" is greater than end IP "%(end_ip)s"'
80
81
82 class TrafficProfileNotImplemented(YardstickException):
83     message = 'No implementation for traffic profile %(profile_class)s.'
84
85
86 class DPDKSetupDriverError(YardstickException):
87     message = '"igb_uio" driver is not loaded'
88
89
90 class OVSUnsupportedVersion(YardstickException):
91     message = ('Unsupported OVS version "%(ovs_version)s". Please check the '
92                'config. OVS to DPDK version map: %(ovs_to_dpdk_map)s.')
93
94
95 class OVSHugepagesInfoError(YardstickException):
96     message = 'MemInfo cannnot be retrieved.'
97
98
99 class OVSHugepagesNotConfigured(YardstickException):
100     message = 'HugePages are not configured in this system.'
101
102
103 class OVSHugepagesZeroFree(YardstickException):
104     message = ('There are no HugePages free in this system. Total HugePages '
105                'configured: %(total_hugepages)s')
106
107
108 class OVSDeployError(YardstickException):
109     message = 'OVS deploy tool failed with error: %(stderr)s.'
110
111
112 class OVSSetupError(YardstickException):
113     message = 'OVS setup error. Command: %(command)s. Error: %(error)s.'
114
115
116 class LibvirtCreateError(YardstickException):
117     message = 'Error creating the virtual machine. Error: %(error)s.'
118
119
120 class LibvirtQemuImageBaseImageNotPresent(YardstickException):
121     message = ('Error creating the qemu image for %(vm_image)s. Base image: '
122                '%(base_image)s. Base image not present in execution host or '
123                'remote host.')
124
125
126 class LibvirtQemuImageCreateError(YardstickException):
127     message = ('Error creating the qemu image for %(vm_image)s. Base image: '
128                '%(base_image)s. Error: %(error)s.')
129
130
131 class ScenarioConfigContextNameNotFound(YardstickException):
132     message = 'Context name "%(context_name)s" not found'
133
134
135 class StackCreationInterrupt(YardstickException):
136     message = 'Stack create interrupted.'
137
138
139 class TaskRenderArgumentError(YardstickException):
140     message = 'Error reading the task input arguments'
141
142
143 class TaskReadError(YardstickException):
144     message = 'Failed to read task %(task_file)s'
145
146
147 class TaskRenderError(YardstickException):
148     message = 'Failed to render template:\n%(input_task)s'
149
150
151 class TimerTimeout(YardstickException):
152     message = 'Timer timeout expired, %(timeout)s seconds'
153
154
155 class WaitTimeout(YardstickException):
156     message = 'Wait timeout while waiting for condition'
157
158
159 class ScenarioCreateNetworkError(YardstickException):
160     message = 'Create Neutron Network Scenario failed'
161
162
163 class ScenarioCreateSubnetError(YardstickException):
164     message = 'Create Neutron Subnet Scenario failed'
165
166
167 class ScenarioDeleteRouterError(YardstickException):
168     message = 'Delete Neutron Router Scenario failed'
169
170
171 class MissingPodInfoError(YardstickException):
172     message = 'Missing pod args, please check'
173
174
175 class UnsupportedPodFormatError(YardstickException):
176     message = 'Failed to load pod info, unsupported format'
177
178
179 class ScenarioCreateRouterError(YardstickException):
180     message = 'Create Neutron Router Scenario failed'
181
182
183 class ScenarioRemoveRouterIntError(YardstickException):
184     message = 'Remove Neutron Router Interface Scenario failed'
185
186
187 class ScenarioCreateFloatingIPError(YardstickException):
188     message = 'Create Neutron Floating IP Scenario failed'
189
190
191 class ScenarioDeleteFloatingIPError(YardstickException):
192     message = 'Delete Neutron Floating IP Scenario failed'
193
194
195 class ScenarioCreateSecurityGroupError(YardstickException):
196     message = 'Create Neutron Security Group Scenario failed'
197
198
199 class ScenarioDeleteNetworkError(YardstickException):
200     message = 'Delete Neutron Network Scenario failed'
201
202
203 class ScenarioCreateServerError(YardstickException):
204     message = 'Nova Create Server Scenario failed'
205
206
207 class ScenarioDeleteServerError(YardstickException):
208     message = 'Delete Server Scenario failed'
209
210
211 class ScenarioCreateKeypairError(YardstickException):
212     message = 'Nova Create Keypair Scenario failed'
213
214
215 class ScenarioDeleteKeypairError(YardstickException):
216     message = 'Nova Delete Keypair Scenario failed'
217
218
219 class ScenarioAttachVolumeError(YardstickException):
220     message = 'Nova Attach Volume Scenario failed'
221
222
223 class ScenarioGetServerError(YardstickException):
224     message = 'Nova Get Server Scenario failed'
225
226
227 class ScenarioGetFlavorError(YardstickException):
228     message = 'Nova Get Falvor Scenario failed'