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 YardstickBannedModuleImported(YardstickException):
78 message = 'Module "%(module)s" cannnot be imported. Reason: "%(reason)s"'
81 class HeatTemplateError(YardstickException):
82 """Error in Heat during the stack deployment"""
83 message = ('Error in Heat during the creation of the OpenStack stack '
87 class IPv6RangeError(YardstickException):
88 message = 'Start IP "%(start_ip)s" is greater than end IP "%(end_ip)s"'
91 class TrafficProfileNotImplemented(YardstickException):
92 message = 'No implementation for traffic profile %(profile_class)s.'
95 class DPDKSetupDriverError(YardstickException):
96 message = '"igb_uio" driver is not loaded'
99 class OVSUnsupportedVersion(YardstickException):
100 message = ('Unsupported OVS version "%(ovs_version)s". Please check the '
101 'config. OVS to DPDK version map: %(ovs_to_dpdk_map)s.')
104 class OVSHugepagesInfoError(YardstickException):
105 message = 'MemInfo cannnot be retrieved.'
108 class OVSHugepagesNotConfigured(YardstickException):
109 message = 'HugePages are not configured in this system.'
112 class OVSHugepagesZeroFree(YardstickException):
113 message = ('There are no HugePages free in this system. Total HugePages '
114 'configured: %(total_hugepages)s')
117 class OVSDeployError(YardstickException):
118 message = 'OVS deploy tool failed with error: %(stderr)s.'
121 class OVSSetupError(YardstickException):
122 message = 'OVS setup error. Command: %(command)s. Error: %(error)s.'
125 class LibvirtCreateError(YardstickException):
126 message = 'Error creating the virtual machine. Error: %(error)s.'
129 class SSHError(YardstickException):
130 message = '%(error_msg)s'
133 class SSHTimeout(SSHError):
137 class IncorrectConfig(YardstickException):
138 message = '%(error_msg)s'
141 class IncorrectSetup(YardstickException):
142 message = '%(error_msg)s'
145 class IncorrectNodeSetup(IncorrectSetup):
149 class ScenarioConfigContextNameNotFound(YardstickException):
150 message = 'Context for host name "%(host_name)s" not found'
153 class StackCreationInterrupt(YardstickException):
154 message = 'Stack create interrupted.'
157 class TaskRenderArgumentError(YardstickException):
158 message = 'Error reading the task input arguments'
161 class TaskReadError(YardstickException):
162 message = 'Failed to read task %(task_file)s'
165 class TaskRenderError(YardstickException):
166 message = 'Failed to render template:\n%(input_task)s'
169 class ScenarioCreateNetworkError(YardstickException):
170 message = 'Create Neutron Network Scenario failed'
173 class ScenarioCreateSubnetError(YardstickException):
174 message = 'Create Neutron Subnet Scenario failed'
177 class ScenarioDeleteRouterError(YardstickException):
178 message = 'Delete Neutron Router Scenario failed'
181 class MissingPodInfoError(YardstickException):
182 message = 'Missing pod args, please check'
185 class UnsupportedPodFormatError(YardstickException):
186 message = 'Failed to load pod info, unsupported format'
189 class ScenarioCreateRouterError(YardstickException):
190 message = 'Create Neutron Router Scenario failed'
193 class ScenarioRemoveRouterIntError(YardstickException):
194 message = 'Remove Neutron Router Interface Scenario failed'
197 class ScenarioCreateFloatingIPError(YardstickException):
198 message = 'Create Neutron Floating IP Scenario failed'
201 class ScenarioDeleteFloatingIPError(YardstickException):
202 message = 'Delete Neutron Floating IP Scenario failed'
205 class ApiServerError(YardstickException):
206 message = 'An unkown exception happened to Api Server!'
209 class UploadOpenrcError(ApiServerError):
210 message = 'Upload openrc ERROR!'
213 class UpdateOpenrcError(ApiServerError):
214 message = 'Update openrc ERROR!'