~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/exception.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandelman
  • Date: 2013-02-22 09:27:29 UTC
  • mfrom: (1.1.68)
  • Revision ID: package-import@ubuntu.com-20130222092729-nn3gt8rf97uvts77
Tags: 2013.1.g3-0ubuntu1
[ Chuck Short ]
* New usptream release. 
* debian/patches/debian/patches/fix-ubuntu-tests.patch: Refreshed.
* debian/nova-baremetal.logrotate: Fix logfile path.
* debian/control, debian/nova-spiceproxy.{install, logrotate, upstart}:
  Add spice html5 proxy support.
* debian/nova-novncproxy.upstart: Start on runlevel [2345]
* debian/rules: Call testr directly since run_tests.sh -N gives weird return
  value when tests pass.
* debian/pyddist-overrides: Add websockify.
* debian/nova-common.postinst: Removed config file conversion, since
  the option is no longer available. (LP: #1110567)
* debian/control: Add python-pyasn1 as a dependency.
* debian/control: Add python-oslo-config as a dependency.
* debian/control: Suggest sysfsutils, sg3-utils, multipath-tools for fibre
  channel support.

[ Adam Gandelman ]
* debian/control: Fix typo (websocikfy -> websockify).

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
"""
26
26
 
27
27
import functools
28
 
import itertools
29
28
 
 
29
from oslo.config import cfg
30
30
import webob.exc
31
31
 
32
 
from nova.openstack.common import cfg
33
32
from nova.openstack.common import excutils
34
33
from nova.openstack.common import log as logging
35
34
 
82
81
    # to pass it in as a parameter. Otherwise we get a cyclic import of
83
82
    # nova.notifier.api -> nova.utils -> nova.exception :(
84
83
    def inner(f):
85
 
        def wrapped(*args, **kw):
 
84
        def wrapped(self, context, *args, **kw):
 
85
            # Don't store self or context in the payload, it now seems to
 
86
            # contain confidential information.
86
87
            try:
87
 
                return f(*args, **kw)
 
88
                return f(self, context, *args, **kw)
88
89
            except Exception, e:
89
90
                with excutils.save_and_reraise_exception():
90
91
                    if notifier:
104
105
                            # propagated.
105
106
                            temp_type = f.__name__
106
107
 
107
 
                        context = get_context_from_function_and_args(f,
108
 
                                                                     args,
109
 
                                                                     kw)
110
 
 
111
108
                        notifier.notify(context, publisher_id, temp_type,
112
109
                                        temp_level, payload)
113
110
 
167
164
        super(EC2APIError, self).__init__(outstr)
168
165
 
169
166
 
170
 
class DBError(NovaException):
171
 
    """Wraps an implementation specific exception."""
172
 
    def __init__(self, inner_exception=None):
173
 
        self.inner_exception = inner_exception
174
 
        super(DBError, self).__init__(str(inner_exception))
175
 
 
176
 
 
177
 
class DBDuplicateEntry(DBError):
178
 
    """Wraps an implementation specific exception."""
179
 
    def __init__(self, columns=[], inner_exception=None):
180
 
        self.columns = columns
181
 
        super(DBDuplicateEntry, self).__init__(inner_exception)
 
167
class EncryptionFailure(NovaException):
 
168
    message = _("Failed to encrypt text: %(reason)s")
182
169
 
183
170
 
184
171
class DecryptionFailure(NovaException):
185
 
    message = _("Failed to decrypt text")
 
172
    message = _("Failed to decrypt text: %(reason)s")
186
173
 
187
174
 
188
175
class VirtualInterfaceCreateException(NovaException):
329
316
 
330
317
 
331
318
class InstanceResumeFailure(Invalid):
332
 
    message = _("Failed to resume server") + ": %(reason)s."
 
319
    message = _("Failed to resume instance: %(reason)s.")
 
320
 
 
321
 
 
322
class InstancePowerOnFailure(Invalid):
 
323
    message = _("Failed to power on instance: %(reason)s.")
 
324
 
 
325
 
 
326
class InstancePowerOffFailure(Invalid):
 
327
    message = _("Failed to power off instance: %(reason)s.")
333
328
 
334
329
 
335
330
class InstanceRebootFailure(Invalid):
340
335
    message = _("Failed to terminate instance") + ": %(reason)s"
341
336
 
342
337
 
 
338
class InstanceDeployFailure(Invalid):
 
339
    message = _("Failed to deploy instance") + ": %(reason)s"
 
340
 
 
341
 
343
342
class ServiceUnavailable(Invalid):
344
343
    message = _("Service is unavailable at this time.")
345
344
 
349
348
 
350
349
 
351
350
class ComputeServiceUnavailable(ServiceUnavailable):
352
 
    message = _("Compute service is unavailable at this time.")
 
351
    message = _("Compute service of %(host)s is unavailable at this time.")
353
352
 
354
353
 
355
354
class UnableToMigrateToSelf(Invalid):
501
500
    message = _("Network %(network_id)s could not be found.")
502
501
 
503
502
 
 
503
class PortNotFound(NotFound):
 
504
    message = _("Port id %(port_id)s could not be found.")
 
505
 
 
506
 
504
507
class NetworkNotFoundForBridge(NetworkNotFound):
505
508
    message = _("Network could not be found for bridge %(bridge)s")
506
509
 
534
537
    message = _("Port %(port_id)s is still in use.")
535
538
 
536
539
 
537
 
class PortNotFound(NotFound):
538
 
    message = _("Port %(port_id)s could not be found.")
 
540
class PortNotUsable(NovaException):
 
541
    message = _("Port %(port_id)s not usable for instance %(instance)s.")
 
542
 
 
543
 
 
544
class PortNotFree(NovaException):
 
545
    message = _("No free port available for instance %(instance)s.")
539
546
 
540
547
 
541
548
class FixedIpNotFound(NotFound):
729
736
                " the instance %(instance_id)s")
730
737
 
731
738
 
 
739
class SecurityGroupDefaultRuleNotFound(Invalid):
 
740
    message = _("Security group default rule (%rule_id)s not found.")
 
741
 
 
742
 
 
743
class SecurityGroupCannotBeApplied(Invalid):
 
744
    message = _("Network requires port_security_enabled and subnet associated"
 
745
                " in order to apply security groups.")
 
746
 
 
747
 
 
748
class NoUniqueMatch(NovaException):
 
749
    message = _("No Unique Match Found.")
 
750
    code = 409
 
751
 
 
752
 
732
753
class MigrationNotFound(NotFound):
733
754
    message = _("Migration %(migration_id)s could not be found.")
734
755
 
784
805
 
785
806
 
786
807
class CellNotFound(NotFound):
787
 
    message = _("Cell %(cell_id)s could not be found.")
 
808
    message = _("Cell %(cell_name)s doesn't exist.")
788
809
 
789
810
 
790
811
class CellRoutingInconsistency(NovaException):
1039
1060
    message = _("Instance %(instance_id)s could not be found.")
1040
1061
 
1041
1062
 
 
1063
class NodeNotFound(NotFound):
 
1064
    message = _("Node %(node_id)s could not be found.")
 
1065
 
 
1066
 
 
1067
class NodeNotFoundByUUID(NotFound):
 
1068
    message = _("Node with UUID %(node_uuid)s could not be found.")
 
1069
 
 
1070
 
1042
1071
class MarkerNotFound(NotFound):
1043
1072
    message = _("Marker %(marker)s could not be found.")
1044
1073
 
1073
1102
                "iso9660 or vfat.")
1074
1103
 
1075
1104
 
 
1105
class InterfaceAttachFailed(Invalid):
 
1106
    message = _("Failed to attach network adapter device to %(instance)s")
 
1107
 
 
1108
 
 
1109
class InterfaceDetachFailed(Invalid):
 
1110
    message = _("Failed to detach network adapter device from  %(instance)s")
 
1111
 
 
1112
 
1076
1113
class InstanceUserDataTooLarge(NovaException):
1077
1114
    message = _("User data too large. User data must be no larger than "
1078
1115
                "%(maxsize)s bytes once base64 encoded. Your data is "
1088
1125
                "the actual state is %(actual)s")
1089
1126
 
1090
1127
 
 
1128
class InstanceActionNotFound(NovaException):
 
1129
    message = _("Action for request_id %(request_id)s on instance"
 
1130
                " %(instance_uuid)s not found")
 
1131
 
 
1132
 
 
1133
class InstanceActionEventNotFound(NovaException):
 
1134
    message = _("Event %(event)s not found for action id %(action_id)s")
 
1135
 
 
1136
 
1091
1137
class CryptoCAFileNotFound(FileNotFound):
1092
1138
    message = _("The CA file for %(project)s could not be found")
1093
1139
 
1096
1142
    message = _("The CRL file for %(project)s could not be found")
1097
1143
 
1098
1144
 
1099
 
def get_context_from_function_and_args(function, args, kwargs):
1100
 
    """Find an arg of type RequestContext and return it.
1101
 
 
1102
 
       This is useful in a couple of decorators where we don't
1103
 
       know much about the function we're wrapping.
1104
 
    """
1105
 
 
1106
 
    # import here to avoid circularity:
1107
 
    from nova import context
1108
 
 
1109
 
    for arg in itertools.chain(kwargs.values(), args):
1110
 
        if isinstance(arg, context.RequestContext):
1111
 
            return arg
1112
 
 
1113
 
    return None
 
1145
class InstanceRecreateNotSupported(Invalid):
 
1146
    message = _('Instance recreate is not implemented by this virt driver.')
 
1147
 
 
1148
 
 
1149
class ServiceGroupUnavailable(NovaException):
 
1150
    message = _("The service from servicegroup driver %(driver) is "
 
1151
                "temporarily unavailable.")
 
1152
 
 
1153
 
 
1154
class DBNotAllowed(NovaException):
 
1155
    message = _('%(binary)s attempted direct database access which is '
 
1156
                'not allowed by policy')
 
1157
 
 
1158
 
 
1159
class UnsupportedVirtType(Invalid):
 
1160
    message = _("Virtualization type '%(virt)s' is not supported by "
 
1161
                "this compute driver")
 
1162
 
 
1163
 
 
1164
class UnsupportedHardware(Invalid):
 
1165
    message = _("Requested hardware '%(model)s' is not supported by "
 
1166
                "the '%(virt)s' virt driver")