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
17 from yardstick.common import constants
20 class ProcessExecutionError(RuntimeError):
21 def __init__(self, message, returncode):
22 super(ProcessExecutionError, self).__init__(message)
23 self.returncode = returncode
26 class ErrorClass(object):
28 def __init__(self, *args, **kwargs):
29 if 'test' not in kwargs:
32 def __getattr__(self, item):
36 class YardstickException(Exception):
37 """Base Yardstick Exception.
39 To correctly use this class, inherit from it and define
40 a 'message' property. That message will get printf'd
41 with the keyword arguments provided to the constructor.
43 Based on NeutronException class.
45 message = "An unknown exception occurred."
47 def __init__(self, **kwargs):
49 super(YardstickException, self).__init__(self.message % kwargs)
50 self.msg = self.message % kwargs
51 except Exception: # pylint: disable=broad-except
52 with excutils.save_and_reraise_exception() as ctxt:
53 if not self.use_fatal_exceptions():
55 # at least get the core message out if something happened
56 super(YardstickException, self).__init__(self.message)
61 def use_fatal_exceptions(self):
62 """Is the instance using fatal exceptions.
64 :returns: Always returns False.
69 class ResourceCommandError(YardstickException):
70 message = 'Command: "%(command)s" Failed, stderr: "%(stderr)s"'
73 class ContextUpdateCollectdForNodeError(YardstickException):
74 message = 'Cannot find node %(attr_name)s'
77 class FunctionNotImplemented(YardstickException):
78 message = ('The function "%(function_name)s" is not implemented in '
79 '"%(class_name)" class.')
82 class InfluxDBConfigurationMissing(YardstickException):
83 message = ('InfluxDB configuration is not available. Add "influxdb" as '
84 'a dispatcher and the configuration section')
87 class YardstickBannedModuleImported(YardstickException):
89 message = 'Module "%(module)s" cannnot be imported. Reason: "%(reason)s"'
92 class PayloadMissingAttributes(YardstickException):
93 message = ('Error instantiating a Payload class, missing attributes: '
94 '%(missing_attributes)s')
97 class HeatTemplateError(YardstickException):
98 """Error in Heat during the stack deployment"""
99 message = ('Error in Heat during the creation of the OpenStack stack '
103 class IPv6RangeError(YardstickException):
104 message = 'Start IP "%(start_ip)s" is greater than end IP "%(end_ip)s"'
107 class TrafficProfileNotImplemented(YardstickException):
108 message = 'No implementation for traffic profile %(profile_class)s.'
111 class DPDKSetupDriverError(YardstickException):
112 message = '"igb_uio" driver is not loaded'
115 class OVSUnsupportedVersion(YardstickException):
116 message = ('Unsupported OVS version "%(ovs_version)s". Please check the '
117 'config. OVS to DPDK version map: %(ovs_to_dpdk_map)s.')
120 class OVSHugepagesInfoError(YardstickException):
121 message = 'MemInfo cannnot be retrieved.'
124 class OVSHugepagesNotConfigured(YardstickException):
125 message = 'HugePages are not configured in this system.'
128 class OVSHugepagesZeroFree(YardstickException):
129 message = ('There are no HugePages free in this system. Total HugePages '
130 'configured: %(total_hugepages)s')
133 class OVSDeployError(YardstickException):
134 message = 'OVS deploy tool failed with error: %(stderr)s.'
137 class OVSSetupError(YardstickException):
138 message = 'OVS setup error. Command: %(command)s. Error: %(error)s.'
141 class LibvirtCreateError(YardstickException):
142 message = 'Error creating the virtual machine. Error: %(error)s.'
145 class LibvirtQemuImageBaseImageNotPresent(YardstickException):
146 message = ('Error creating the qemu image for %(vm_image)s. Base image: '
147 '%(base_image)s. Base image not present in execution host or '
151 class LibvirtQemuImageCreateError(YardstickException):
152 message = ('Error creating the qemu image for %(vm_image)s. Base image: '
153 '%(base_image)s. Error: %(error)s.')
156 class SSHError(YardstickException):
157 message = '%(error_msg)s'
160 class SSHTimeout(SSHError):
164 class IncorrectConfig(YardstickException):
165 message = '%(error_msg)s'
168 class IncorrectSetup(YardstickException):
169 message = '%(error_msg)s'
172 class IncorrectNodeSetup(IncorrectSetup):
176 class ScenarioConfigContextNameNotFound(YardstickException):
177 message = 'Context for host name "%(host_name)s" not found'
180 class StackCreationInterrupt(YardstickException):
181 message = 'Stack create interrupted.'
184 class TaskRenderArgumentError(YardstickException):
185 message = 'Error reading the task input arguments'
188 class TaskReadError(YardstickException):
189 message = 'Failed to read task %(task_file)s'
192 class TaskRenderError(YardstickException):
193 message = 'Failed to render template:\n%(input_task)s'
196 class TimerTimeout(YardstickException):
197 message = 'Timer timeout expired, %(timeout)s seconds'
200 class WaitTimeout(YardstickException):
201 message = 'Wait timeout while waiting for condition'
204 class KubernetesApiException(YardstickException):
205 message = ('Kubernetes API errors. Action: %(action)s, '
206 'resource: %(resource)s')
209 class KubernetesConfigFileNotFound(YardstickException):
210 message = 'Config file (%s) not found' % constants.K8S_CONF_FILE
213 class KubernetesTemplateInvalidVolumeType(YardstickException):
214 message = 'No valid "volume" types present in %(volume)s'
217 class KubernetesCRDObjectDefinitionError(YardstickException):
218 message = ('Kubernetes Custom Resource Definition Object error, missing '
219 'parameters: %(missing_parameters)s')
222 class KubernetesNetworkObjectDefinitionError(YardstickException):
223 message = ('Kubernetes Network object definition error, missing '
224 'parameters: %(missing_parameters)s')
227 class KubernetesNetworkObjectKindMissing(YardstickException):
228 message = 'Kubernetes kind "Network" is not defined'
231 class ScenarioCreateNetworkError(YardstickException):
232 message = 'Create Neutron Network Scenario failed'
235 class ScenarioCreateSubnetError(YardstickException):
236 message = 'Create Neutron Subnet Scenario failed'
239 class ScenarioDeleteRouterError(YardstickException):
240 message = 'Delete Neutron Router Scenario failed'
243 class MissingPodInfoError(YardstickException):
244 message = 'Missing pod args, please check'
247 class UnsupportedPodFormatError(YardstickException):
248 message = 'Failed to load pod info, unsupported format'
251 class ScenarioCreateRouterError(YardstickException):
252 message = 'Create Neutron Router Scenario failed'
255 class ScenarioRemoveRouterIntError(YardstickException):
256 message = 'Remove Neutron Router Interface Scenario failed'
259 class ScenarioCreateFloatingIPError(YardstickException):
260 message = 'Create Neutron Floating IP Scenario failed'
263 class ScenarioDeleteFloatingIPError(YardstickException):
264 message = 'Delete Neutron Floating IP Scenario failed'
267 class ScenarioCreateSecurityGroupError(YardstickException):
268 message = 'Create Neutron Security Group Scenario failed'
271 class ScenarioDeleteNetworkError(YardstickException):
272 message = 'Delete Neutron Network Scenario failed'
275 class ScenarioCreateServerError(YardstickException):
276 message = 'Nova Create Server Scenario failed'
279 class ScenarioDeleteServerError(YardstickException):
280 message = 'Delete Server Scenario failed'
283 class ScenarioCreateKeypairError(YardstickException):
284 message = 'Nova Create Keypair Scenario failed'
287 class ScenarioDeleteKeypairError(YardstickException):
288 message = 'Nova Delete Keypair Scenario failed'
291 class ScenarioAttachVolumeError(YardstickException):
292 message = 'Nova Attach Volume Scenario failed'
295 class ScenarioGetServerError(YardstickException):
296 message = 'Nova Get Server Scenario failed'
299 class ScenarioGetFlavorError(YardstickException):
300 message = 'Nova Get Falvor Scenario failed'
303 class ScenarioCreateVolumeError(YardstickException):
304 message = 'Cinder Create Volume Scenario failed'
307 class ScenarioDeleteVolumeError(YardstickException):
308 message = 'Cinder Delete Volume Scenario failed'
311 class ScenarioDetachVolumeError(YardstickException):
312 message = 'Cinder Detach Volume Scenario failed'
315 class ApiServerError(YardstickException):
316 message = 'An unkown exception happened to Api Server!'
319 class UploadOpenrcError(ApiServerError):
320 message = 'Upload openrc ERROR!'
323 class UpdateOpenrcError(ApiServerError):
324 message = 'Update openrc ERROR!'
327 class ScenarioCreateImageError(YardstickException):
328 message = 'Glance Create Image Scenario failed'
331 class ScenarioDeleteImageError(YardstickException):
332 message = 'Glance Delete Image Scenario failed'
335 class IxNetworkClientNotConnected(YardstickException):
336 message = 'IxNetwork client not connected to a TCL server'
339 class IxNetworkFlowNotPresent(YardstickException):
340 message = 'Flow Group "%(flow_group)s" is not present'
343 class IxNetworkFieldNotPresentInStackItem(YardstickException):
344 message = 'Field "%(field_name)s" not present in stack item %(stack_item)s'
347 class SLAValidationError(YardstickException):
348 message = '%(case_name)s SLA validation failed. Error: %(error_msg)s'
351 class AclMissingActionArguments(YardstickException):
352 message = ('Missing ACL action parameter '
353 '[action=%(action_name)s parameter=%(action_param)s]')
356 class AclUknownActionTemplate(YardstickException):
357 message = 'No ACL CLI template found for "%(action_name)s" action'