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 InvalidType(YardstickException):
83 message = 'Type "%(type_to_convert)s" is not valid'
86 class InvalidRxfFile(YardstickException):
87 message = 'Loaded rxf file has unexpected format'
90 class InfluxDBConfigurationMissing(YardstickException):
91 message = ('InfluxDB configuration is not available. Add "influxdb" as '
92 'a dispatcher and the configuration section')
95 class YardstickBannedModuleImported(YardstickException):
96 message = 'Module "%(module)s" cannnot be imported. Reason: "%(reason)s"'
99 class IXIAUnsupportedProtocol(YardstickException):
100 message = 'Protocol "%(protocol)" is not supported in IXIA'
103 class PayloadMissingAttributes(YardstickException):
104 message = ('Error instantiating a Payload class, missing attributes: '
105 '%(missing_attributes)s')
108 class HeatTemplateError(YardstickException):
109 message = ('Error in Heat during the creation of the OpenStack stack '
113 class IPv6RangeError(YardstickException):
114 message = 'Start IP "%(start_ip)s" is greater than end IP "%(end_ip)s"'
117 class TrafficProfileNotImplemented(YardstickException):
118 message = 'No implementation for traffic profile %(profile_class)s.'
121 class TrafficProfileRate(YardstickException):
122 message = 'Traffic profile rate must be "<number>[fps|%]"'
125 class DPDKSetupDriverError(YardstickException):
126 message = '"igb_uio" driver is not loaded'
129 class OVSUnsupportedVersion(YardstickException):
130 message = ('Unsupported OVS version "%(ovs_version)s". Please check the '
131 'config. OVS to DPDK version map: %(ovs_to_dpdk_map)s.')
134 class OVSHugepagesInfoError(YardstickException):
135 message = 'MemInfo cannnot be retrieved.'
138 class OVSHugepagesNotConfigured(YardstickException):
139 message = 'HugePages are not configured in this system.'
142 class OVSHugepagesZeroFree(YardstickException):
143 message = ('There are no HugePages free in this system. Total HugePages '
144 'configured: %(total_hugepages)s')
147 class OVSDeployError(YardstickException):
148 message = 'OVS deploy tool failed with error: %(stderr)s.'
151 class OVSSetupError(YardstickException):
152 message = 'OVS setup error. Command: %(command)s. Error: %(error)s.'
155 class LibvirtCreateError(YardstickException):
156 message = 'Error creating the virtual machine. Error: %(error)s.'
159 class LibvirtQemuImageBaseImageNotPresent(YardstickException):
160 message = ('Error creating the qemu image for %(vm_image)s. Base image: '
161 '%(base_image)s. Base image not present in execution host or '
165 class LibvirtQemuImageCreateError(YardstickException):
166 message = ('Error creating the qemu image for %(vm_image)s. Base image: '
167 '%(base_image)s. Error: %(error)s.')
170 class SSHError(YardstickException):
171 message = '%(error_msg)s'
174 class SSHTimeout(SSHError):
178 class IncorrectConfig(YardstickException):
179 message = '%(error_msg)s'
182 class IncorrectSetup(YardstickException):
183 message = '%(error_msg)s'
186 class IncorrectNodeSetup(IncorrectSetup):
190 class ScenarioConfigContextNameNotFound(YardstickException):
191 message = 'Context for host name "%(host_name)s" not found'
194 class StackCreationInterrupt(YardstickException):
195 message = 'Stack create interrupted.'
198 class TaskRenderArgumentError(YardstickException):
199 message = 'Error reading the task input arguments'
202 class TaskReadError(YardstickException):
203 message = 'Failed to read task %(task_file)s'
206 class TaskRenderError(YardstickException):
207 message = 'Failed to render template:\n%(input_task)s'
210 class RunnerIterationIPCSetupActionNeeded(YardstickException):
211 message = ('IterationIPC needs the "setup" action to retrieve the VNF '
212 'handling processes PIDs to receive the messages sent')
215 class RunnerIterationIPCNoCtxs(YardstickException):
216 message = 'Benchmark "setup" action did not return any VNF process PID'
219 class TimerTimeout(YardstickException):
220 message = 'Timer timeout expired, %(timeout)s seconds'
223 class WaitTimeout(YardstickException):
224 message = 'Wait timeout while waiting for condition'
227 class PktgenActionError(YardstickException):
228 message = 'Error in "%(action)s" action'
231 class KubernetesApiException(YardstickException):
232 message = ('Kubernetes API errors. Action: %(action)s, '
233 'resource: %(resource)s')
236 class KubernetesConfigFileNotFound(YardstickException):
237 message = 'Config file (%s) not found' % constants.K8S_CONF_FILE
240 class KubernetesTemplateInvalidVolumeType(YardstickException):
241 message = 'No valid "volume" types present in %(volume)s'
244 class KubernetesSSHPortNotDefined(YardstickException):
245 message = 'Port 22 needs to be defined'
248 class KubernetesServiceObjectNotDefined(YardstickException):
249 message = 'ServiceObject is not defined'
252 class KubernetesServiceObjectDefinitionError(YardstickException):
253 message = ('Kubernetes Service object definition error, missing '
254 'parameters: %(missing_parameters)s')
257 class KubernetesServiceObjectNameError(YardstickException):
258 message = ('Kubernetes Service object name "%(name)s" does not comply'
262 class KubernetesCRDObjectDefinitionError(YardstickException):
263 message = ('Kubernetes Custom Resource Definition Object error, missing '
264 'parameters: %(missing_parameters)s')
267 class KubernetesNetworkObjectDefinitionError(YardstickException):
268 message = ('Kubernetes Network object definition error, missing '
269 'parameters: %(missing_parameters)s')
272 class KubernetesNetworkObjectKindMissing(YardstickException):
273 message = 'Kubernetes kind "Network" is not defined'
276 class KubernetesWrongRestartPolicy(YardstickException):
277 message = 'Restart policy "%(rpolicy)s" is not valid'
280 class KubernetesContainerPortNotDefined(YardstickException):
281 message = 'Container port not defined in "%(port)s"'
284 class KubernetesContainerWrongImagePullPolicy(YardstickException):
285 message = 'Image pull policy must be "Always", "IfNotPresent" or "Never"'
288 class KubernetesContainerCommandType(YardstickException):
289 message = '"args" and "command" must be string or list of strings'
292 class ScenarioCreateNetworkError(YardstickException):
293 message = 'Create Neutron Network Scenario failed'
296 class ScenarioCreateSubnetError(YardstickException):
297 message = 'Create Neutron Subnet Scenario failed'
300 class ScenarioDeleteRouterError(YardstickException):
301 message = 'Delete Neutron Router Scenario failed'
304 class MissingPodInfoError(YardstickException):
305 message = 'Missing pod args, please check'
308 class UnsupportedPodFormatError(YardstickException):
309 message = 'Failed to load pod info, unsupported format'
312 class ScenarioCreateRouterError(YardstickException):
313 message = 'Create Neutron Router Scenario failed'
316 class ScenarioRemoveRouterIntError(YardstickException):
317 message = 'Remove Neutron Router Interface Scenario failed'
320 class ScenarioCreateFloatingIPError(YardstickException):
321 message = 'Create Neutron Floating IP Scenario failed'
324 class ScenarioDeleteFloatingIPError(YardstickException):
325 message = 'Delete Neutron Floating IP Scenario failed'
328 class ScenarioCreateSecurityGroupError(YardstickException):
329 message = 'Create Neutron Security Group Scenario failed'
332 class ScenarioDeleteNetworkError(YardstickException):
333 message = 'Delete Neutron Network Scenario failed'
336 class ScenarioCreateServerError(YardstickException):
337 message = 'Nova Create Server Scenario failed'
340 class ScenarioDeleteServerError(YardstickException):
341 message = 'Delete Server Scenario failed'
344 class ScenarioCreateKeypairError(YardstickException):
345 message = 'Nova Create Keypair Scenario failed'
348 class ScenarioDeleteKeypairError(YardstickException):
349 message = 'Nova Delete Keypair Scenario failed'
352 class ScenarioAttachVolumeError(YardstickException):
353 message = 'Nova Attach Volume Scenario failed'
356 class ScenarioGetServerError(YardstickException):
357 message = 'Nova Get Server Scenario failed'
360 class ScenarioGetFlavorError(YardstickException):
361 message = 'Nova Get Falvor Scenario failed'
364 class ScenarioCreateVolumeError(YardstickException):
365 message = 'Cinder Create Volume Scenario failed'
368 class ScenarioDeleteVolumeError(YardstickException):
369 message = 'Cinder Delete Volume Scenario failed'
372 class ScenarioDetachVolumeError(YardstickException):
373 message = 'Cinder Detach Volume Scenario failed'
376 class ApiServerError(YardstickException):
377 message = 'An unkown exception happened to Api Server!'
380 class UploadOpenrcError(ApiServerError):
381 message = 'Upload openrc ERROR!'
384 class UpdateOpenrcError(ApiServerError):
385 message = 'Update openrc ERROR!'
388 class ScenarioCreateImageError(YardstickException):
389 message = 'Glance Create Image Scenario failed'
392 class ScenarioDeleteImageError(YardstickException):
393 message = 'Glance Delete Image Scenario failed'
396 class IxNetworkClientNotConnected(YardstickException):
397 message = 'IxNetwork client not connected to a TCL server'
400 class IxNetworkFlowNotPresent(YardstickException):
401 message = 'Flow Group "%(flow_group)s" is not present'
404 class IxNetworkFieldNotPresentInStackItem(YardstickException):
405 message = 'Field "%(field_name)s" not present in stack item %(stack_item)s'
408 class SLAValidationError(YardstickException):
409 message = '%(case_name)s SLA validation failed. Error: %(error_msg)s'
412 class AclMissingActionArguments(YardstickException):
413 message = ('Missing ACL action parameter '
414 '[action=%(action_name)s parameter=%(action_param)s]')
417 class AclUnknownActionTemplate(YardstickException):
418 message = 'No ACL CLI template found for "%(action_name)s" action'
421 class InvalidMacAddress(YardstickException):
422 message = 'Mac address "%(mac_address)s" is invalid'
425 class ValueCheckError(YardstickException):
426 message = 'Constraint "%(value1)s %(operator)s %(value2)s" does not hold'