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 ContextUpdateCollectdForNodeError(YardstickException):
72 message = 'Cannot find node %(attr_name)s'
75 class FunctionNotImplemented(YardstickException):
76 message = ('The function "%(function_name)s" is not implemented in '
77 '"%(class_name)" class.')
80 class InfluxDBConfigurationMissing(YardstickException):
81 message = ('InfluxDB configuration is not available. Add "influxdb" as '
82 'a dispatcher and the configuration section')
85 class YardstickBannedModuleImported(YardstickException):
87 message = 'Module "%(module)s" cannnot be imported. Reason: "%(reason)s"'
90 class PayloadMissingAttributes(YardstickException):
91 message = ('Error instantiating a Payload class, missing attributes: '
92 '%(missing_attributes)s')
95 class HeatTemplateError(YardstickException):
96 """Error in Heat during the stack deployment"""
97 message = ('Error in Heat during the creation of the OpenStack stack '
101 class IPv6RangeError(YardstickException):
102 message = 'Start IP "%(start_ip)s" is greater than end IP "%(end_ip)s"'
105 class TrafficProfileNotImplemented(YardstickException):
106 message = 'No implementation for traffic profile %(profile_class)s.'
109 class DPDKSetupDriverError(YardstickException):
110 message = '"igb_uio" driver is not loaded'
113 class OVSUnsupportedVersion(YardstickException):
114 message = ('Unsupported OVS version "%(ovs_version)s". Please check the '
115 'config. OVS to DPDK version map: %(ovs_to_dpdk_map)s.')
118 class OVSHugepagesInfoError(YardstickException):
119 message = 'MemInfo cannnot be retrieved.'
122 class OVSHugepagesNotConfigured(YardstickException):
123 message = 'HugePages are not configured in this system.'
126 class OVSHugepagesZeroFree(YardstickException):
127 message = ('There are no HugePages free in this system. Total HugePages '
128 'configured: %(total_hugepages)s')
131 class OVSDeployError(YardstickException):
132 message = 'OVS deploy tool failed with error: %(stderr)s.'
135 class OVSSetupError(YardstickException):
136 message = 'OVS setup error. Command: %(command)s. Error: %(error)s.'
139 class LibvirtCreateError(YardstickException):
140 message = 'Error creating the virtual machine. Error: %(error)s.'
143 class LibvirtQemuImageBaseImageNotPresent(YardstickException):
144 message = ('Error creating the qemu image for %(vm_image)s. Base image: '
145 '%(base_image)s. Base image not present in execution host or '
149 class LibvirtQemuImageCreateError(YardstickException):
150 message = ('Error creating the qemu image for %(vm_image)s. Base image: '
151 '%(base_image)s. Error: %(error)s.')
154 class SSHError(YardstickException):
155 message = '%(error_msg)s'
158 class SSHTimeout(SSHError):
162 class IncorrectConfig(YardstickException):
163 message = '%(error_msg)s'
166 class IncorrectSetup(YardstickException):
167 message = '%(error_msg)s'
170 class IncorrectNodeSetup(IncorrectSetup):
174 class ScenarioConfigContextNameNotFound(YardstickException):
175 message = 'Context for host name "%(host_name)s" not found'
178 class StackCreationInterrupt(YardstickException):
179 message = 'Stack create interrupted.'
182 class TaskRenderArgumentError(YardstickException):
183 message = 'Error reading the task input arguments'
186 class TaskReadError(YardstickException):
187 message = 'Failed to read task %(task_file)s'
190 class TaskRenderError(YardstickException):
191 message = 'Failed to render template:\n%(input_task)s'
194 class TimerTimeout(YardstickException):
195 message = 'Timer timeout expired, %(timeout)s seconds'
198 class WaitTimeout(YardstickException):
199 message = 'Wait timeout while waiting for condition'
202 class KubernetesTemplateInvalidVolumeType(YardstickException):
203 message = 'No valid "volume" types present in %(volume)s'
206 class ScenarioCreateNetworkError(YardstickException):
207 message = 'Create Neutron Network Scenario failed'
210 class ScenarioCreateSubnetError(YardstickException):
211 message = 'Create Neutron Subnet Scenario failed'
214 class ScenarioDeleteRouterError(YardstickException):
215 message = 'Delete Neutron Router Scenario failed'
218 class MissingPodInfoError(YardstickException):
219 message = 'Missing pod args, please check'
222 class UnsupportedPodFormatError(YardstickException):
223 message = 'Failed to load pod info, unsupported format'
226 class ScenarioCreateRouterError(YardstickException):
227 message = 'Create Neutron Router Scenario failed'
230 class ScenarioRemoveRouterIntError(YardstickException):
231 message = 'Remove Neutron Router Interface Scenario failed'
234 class ScenarioCreateFloatingIPError(YardstickException):
235 message = 'Create Neutron Floating IP Scenario failed'
238 class ScenarioDeleteFloatingIPError(YardstickException):
239 message = 'Delete Neutron Floating IP Scenario failed'
242 class ScenarioCreateSecurityGroupError(YardstickException):
243 message = 'Create Neutron Security Group Scenario failed'
246 class ScenarioDeleteNetworkError(YardstickException):
247 message = 'Delete Neutron Network Scenario failed'
250 class ScenarioCreateServerError(YardstickException):
251 message = 'Nova Create Server Scenario failed'
254 class ScenarioDeleteServerError(YardstickException):
255 message = 'Delete Server Scenario failed'
258 class ScenarioCreateKeypairError(YardstickException):
259 message = 'Nova Create Keypair Scenario failed'
262 class ScenarioDeleteKeypairError(YardstickException):
263 message = 'Nova Delete Keypair Scenario failed'
266 class ScenarioAttachVolumeError(YardstickException):
267 message = 'Nova Attach Volume Scenario failed'
270 class ScenarioGetServerError(YardstickException):
271 message = 'Nova Get Server Scenario failed'
274 class ScenarioGetFlavorError(YardstickException):
275 message = 'Nova Get Falvor Scenario failed'
278 class ScenarioCreateVolumeError(YardstickException):
279 message = 'Cinder Create Volume Scenario failed'
282 class ScenarioDeleteVolumeError(YardstickException):
283 message = 'Cinder Delete Volume Scenario failed'
286 class ScenarioDetachVolumeError(YardstickException):
287 message = 'Cinder Detach Volume Scenario failed'
290 class ApiServerError(YardstickException):
291 message = 'An unkown exception happened to Api Server!'
294 class UploadOpenrcError(ApiServerError):
295 message = 'Upload openrc ERROR!'
298 class UpdateOpenrcError(ApiServerError):
299 message = 'Update openrc ERROR!'
302 class ScenarioCreateImageError(YardstickException):
303 message = 'Glance Create Image Scenario failed'
306 class ScenarioDeleteImageError(YardstickException):
307 message = 'Glance Delete Image Scenario failed'
310 class IxNetworkClientNotConnected(YardstickException):
311 message = 'IxNetwork client not connected to a TCL server'
314 class IxNetworkFlowNotPresent(YardstickException):
315 message = 'Flow Group "%(flow_group)s" is not present'
318 class IxNetworkFieldNotPresentInStackItem(YardstickException):
319 message = 'Field "%(field_name)s" not present in stack item %(stack_item)s'
322 class SLAValidationError(YardstickException):
323 message = '%(case_name)s SLA validation failed. Error: %(error_msg)s'
326 class AclMissingActionArguments(YardstickException):
327 message = ('Missing ACL action parameter '
328 '[action=%(action_name)s parameter=%(action_param)s]')
331 class AclUknownActionTemplate(YardstickException):
332 message = 'No ACL CLI template found for "%(action_name)s" action'