1 # Copyright (c) 2017 Intel Corporation
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 from oslo_utils import excutils
18 class ProcessExecutionError(RuntimeError):
19 def __init__(self, message, returncode):
20 super(ProcessExecutionError, self).__init__(message)
21 self.returncode = returncode
24 class ErrorClass(object):
26 def __init__(self, *args, **kwargs):
27 if 'test' not in kwargs:
30 def __getattr__(self, item):
34 class YardstickException(Exception):
35 """Base Yardstick Exception.
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.
41 Based on NeutronException class.
43 message = "An unknown exception occurred."
45 def __init__(self, **kwargs):
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():
53 # at least get the core message out if something happened
54 super(YardstickException, self).__init__(self.message)
59 def use_fatal_exceptions(self):
60 """Is the instance using fatal exceptions.
62 :returns: Always returns False.
67 class ResourceCommandError(YardstickException):
68 message = 'Command: "%(command)s" Failed, stderr: "%(stderr)s"'
71 class FunctionNotImplemented(YardstickException):
72 message = ('The function "%(function_name)s" is not implemented in '
73 '"%(class_name)" class.')
76 class InfluxDBConfigurationMissing(YardstickException):
77 message = ('InfluxDB configuration is not available. Add "influxdb" as '
78 'a dispatcher and the configuration section')
81 class YardstickBannedModuleImported(YardstickException):
83 message = 'Module "%(module)s" cannnot be imported. Reason: "%(reason)s"'
86 class PayloadMissingAttributes(YardstickException):
87 message = ('Error instantiating a Payload class, missing attributes: '
88 '%(missing_attributes)s')
91 class HeatTemplateError(YardstickException):
92 """Error in Heat during the stack deployment"""
93 message = ('Error in Heat during the creation of the OpenStack stack '
97 class IPv6RangeError(YardstickException):
98 message = 'Start IP "%(start_ip)s" is greater than end IP "%(end_ip)s"'
101 class TrafficProfileNotImplemented(YardstickException):
102 message = 'No implementation for traffic profile %(profile_class)s.'
105 class DPDKSetupDriverError(YardstickException):
106 message = '"igb_uio" driver is not loaded'
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.')
114 class OVSHugepagesInfoError(YardstickException):
115 message = 'MemInfo cannnot be retrieved.'
118 class OVSHugepagesNotConfigured(YardstickException):
119 message = 'HugePages are not configured in this system.'
122 class OVSHugepagesZeroFree(YardstickException):
123 message = ('There are no HugePages free in this system. Total HugePages '
124 'configured: %(total_hugepages)s')
127 class OVSDeployError(YardstickException):
128 message = 'OVS deploy tool failed with error: %(stderr)s.'
131 class OVSSetupError(YardstickException):
132 message = 'OVS setup error. Command: %(command)s. Error: %(error)s.'
135 class LibvirtCreateError(YardstickException):
136 message = 'Error creating the virtual machine. Error: %(error)s.'
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 '
145 class LibvirtQemuImageCreateError(YardstickException):
146 message = ('Error creating the qemu image for %(vm_image)s. Base image: '
147 '%(base_image)s. Error: %(error)s.')
150 class SSHError(YardstickException):
151 message = '%(error_msg)s'
154 class SSHTimeout(SSHError):
158 class IncorrectConfig(YardstickException):
159 message = '%(error_msg)s'
162 class IncorrectSetup(YardstickException):
163 message = '%(error_msg)s'
166 class IncorrectNodeSetup(IncorrectSetup):
170 class ScenarioConfigContextNameNotFound(YardstickException):
171 message = 'Context name "%(context_name)s" not found'
174 class StackCreationInterrupt(YardstickException):
175 message = 'Stack create interrupted.'
178 class TaskRenderArgumentError(YardstickException):
179 message = 'Error reading the task input arguments'
182 class TaskReadError(YardstickException):
183 message = 'Failed to read task %(task_file)s'
186 class TaskRenderError(YardstickException):
187 message = 'Failed to render template:\n%(input_task)s'
190 class TimerTimeout(YardstickException):
191 message = 'Timer timeout expired, %(timeout)s seconds'
194 class WaitTimeout(YardstickException):
195 message = 'Wait timeout while waiting for condition'
198 class ScenarioCreateNetworkError(YardstickException):
199 message = 'Create Neutron Network Scenario failed'
202 class ScenarioCreateSubnetError(YardstickException):
203 message = 'Create Neutron Subnet Scenario failed'
206 class ScenarioDeleteRouterError(YardstickException):
207 message = 'Delete Neutron Router Scenario failed'
210 class MissingPodInfoError(YardstickException):
211 message = 'Missing pod args, please check'
214 class UnsupportedPodFormatError(YardstickException):
215 message = 'Failed to load pod info, unsupported format'
218 class ScenarioCreateRouterError(YardstickException):
219 message = 'Create Neutron Router Scenario failed'
222 class ScenarioRemoveRouterIntError(YardstickException):
223 message = 'Remove Neutron Router Interface Scenario failed'
226 class ScenarioCreateFloatingIPError(YardstickException):
227 message = 'Create Neutron Floating IP Scenario failed'
230 class ScenarioDeleteFloatingIPError(YardstickException):
231 message = 'Delete Neutron Floating IP Scenario failed'
234 class ScenarioCreateSecurityGroupError(YardstickException):
235 message = 'Create Neutron Security Group Scenario failed'
238 class ScenarioDeleteNetworkError(YardstickException):
239 message = 'Delete Neutron Network Scenario failed'
242 class ScenarioCreateServerError(YardstickException):
243 message = 'Nova Create Server Scenario failed'
246 class ScenarioDeleteServerError(YardstickException):
247 message = 'Delete Server Scenario failed'
250 class ScenarioCreateKeypairError(YardstickException):
251 message = 'Nova Create Keypair Scenario failed'
254 class ScenarioDeleteKeypairError(YardstickException):
255 message = 'Nova Delete Keypair Scenario failed'
258 class ScenarioAttachVolumeError(YardstickException):
259 message = 'Nova Attach Volume Scenario failed'
262 class ScenarioGetServerError(YardstickException):
263 message = 'Nova Get Server Scenario failed'
266 class ScenarioGetFlavorError(YardstickException):
267 message = 'Nova Get Falvor Scenario failed'
270 class ScenarioCreateVolumeError(YardstickException):
271 message = 'Cinder Create Volume Scenario failed'
274 class ScenarioDeleteVolumeError(YardstickException):
275 message = 'Cinder Delete Volume Scenario failed'
278 class ScenarioDetachVolumeError(YardstickException):
279 message = 'Cinder Detach Volume Scenario failed'
282 class ApiServerError(YardstickException):
283 message = 'An unkown exception happened to Api Server!'
286 class UploadOpenrcError(ApiServerError):
287 message = 'Upload openrc ERROR!'
290 class UpdateOpenrcError(ApiServerError):
291 message = 'Update openrc ERROR!'
294 class ScenarioCreateImageError(YardstickException):
295 message = 'Glance Create Image Scenario failed'
298 class ScenarioDeleteImageError(YardstickException):
299 message = 'Glance Delete Image Scenario failed'
302 class IxNetworkClientNotConnected(YardstickException):
303 message = 'IxNetwork client not connected to a TCL server'
306 class IxNetworkFlowNotPresent(YardstickException):
307 message = 'Flow Group "%(flow_group)s" is not present'
310 class IxNetworkFieldNotPresentInStackItem(YardstickException):
311 message = 'Field "%(field_name)s" not present in stack item %(stack_item)s'