Replace neutron router creation with shade.
[yardstick.git] / yardstick / common / exceptions.py
1 # Copyright (c) 2017 Intel Corporation
2 #
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
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 from oslo_utils import excutils
16
17
18 class ProcessExecutionError(RuntimeError):
19     def __init__(self, message, returncode):
20         super(ProcessExecutionError, self).__init__(message)
21         self.returncode = returncode
22
23
24 class YardstickException(Exception):
25     """Base Yardstick Exception.
26
27     To correctly use this class, inherit from it and define
28     a 'message' property. That message will get printf'd
29     with the keyword arguments provided to the constructor.
30
31     Based on NeutronException class.
32     """
33     message = "An unknown exception occurred."
34
35     def __init__(self, **kwargs):
36         try:
37             super(YardstickException, self).__init__(self.message % kwargs)
38             self.msg = self.message % kwargs
39         except Exception:  # pylint: disable=broad-except
40             with excutils.save_and_reraise_exception() as ctxt:
41                 if not self.use_fatal_exceptions():
42                     ctxt.reraise = False
43                     # at least get the core message out if something happened
44                     super(YardstickException, self).__init__(self.message)
45
46     def __str__(self):
47         return self.msg
48
49     def use_fatal_exceptions(self):
50         """Is the instance using fatal exceptions.
51
52         :returns: Always returns False.
53         """
54         return False
55
56
57 class FunctionNotImplemented(YardstickException):
58     message = ('The function "%(function_name)s" is not implemented in '
59                '"%(class_name)" class.')
60
61
62 class YardstickBannedModuleImported(YardstickException):
63     # pragma: no cover
64     message = 'Module "%(module)s" cannnot be imported. Reason: "%(reason)s"'
65
66
67 class HeatTemplateError(YardstickException):
68     """Error in Heat during the stack deployment"""
69     message = ('Error in Heat during the creation of the OpenStack stack '
70                '"%(stack_name)s"')
71
72
73 class IPv6RangeError(YardstickException):
74     message = 'Start IP "%(start_ip)s" is greater than end IP "%(end_ip)s"'
75
76
77 class TrafficProfileNotImplemented(YardstickException):
78     message = 'No implementation for traffic profile %(profile_class)s.'
79
80
81 class DPDKSetupDriverError(YardstickException):
82     message = '"igb_uio" driver is not loaded'
83
84
85 class ScenarioConfigContextNameNotFound(YardstickException):
86     message = 'Context name "%(context_name)s" not found'
87
88
89 class StackCreationInterrupt(YardstickException):
90     message = 'Stack create interrupted.'
91
92
93 class TaskRenderArgumentError(YardstickException):
94     message = 'Error reading the task input arguments'
95
96
97 class TaskReadError(YardstickException):
98     message = 'Failed to read task %(task_file)s'
99
100
101 class TaskRenderError(YardstickException):
102     message = 'Failed to render template:\n%(input_task)s'
103
104
105 class ScenarioCreateNetworkError(YardstickException):
106     message = 'Create Neutron Network Scenario failed'
107
108
109 class ScenarioCreateSubnetError(YardstickException):
110     message = 'Create Neutron Subnet Scenario failed'
111
112
113 class ScenarioDeleteRouterError(YardstickException):
114     message = 'Delete Neutron Router Scenario failed'
115
116
117 class MissingPodInfoError(YardstickException):
118     message = 'Missing pod args, please check'
119
120
121 class UnsupportedPodFormatError(YardstickException):
122     message = 'Failed to load pod info, unsupported format'
123
124
125 class ScenarioCreateRouterError(YardstickException):
126     message = 'Create Neutron Router Scenario failed'