1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
|
# Copyright 2011 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""I totally stole most of this from melange, thx guys!!!"""
import re
from trove.openstack.common import log as logging
from trove.openstack.common import exception as openstack_exception
from trove.openstack.common import processutils
from trove.openstack.common.gettextutils import _
ClientConnectionError = openstack_exception.ClientConnectionError
ProcessExecutionError = processutils.ProcessExecutionError
DatabaseMigrationError = openstack_exception.DatabaseMigrationError
LOG = logging.getLogger(__name__)
wrap_exception = openstack_exception.wrap_exception
def safe_fmt_string(text):
return re.sub(r'%([0-9]+)', r'\1', text)
class TroveError(openstack_exception.OpenstackException):
"""Base exception that all custom trove app exceptions inherit from."""
internal_message = None
def __init__(self, message=None, **kwargs):
if message is not None:
self.message = message
if self.internal_message is not None:
try:
LOG.error(safe_fmt_string(self.internal_message) % kwargs)
except Exception:
LOG.error(self.internal_message)
self.message = safe_fmt_string(self.message)
super(TroveError, self).__init__(**kwargs)
class DBConstraintError(TroveError):
message = _("Failed to save %(model_name)s because: %(error)s")
class InvalidRPCConnectionReuse(TroveError):
message = _("Invalid RPC Connection Reuse")
class NotFound(TroveError):
message = _("Resource %(uuid)s cannot be found")
class FlavorNotFound(TroveError):
message = _("Resource %(uuid)s cannot be found")
class UserNotFound(NotFound):
message = _("User %(uuid)s cannot be found on the instance.")
class DatabaseNotFound(NotFound):
message = _("Database %(uuid)s cannot be found on the instance.")
class ComputeInstanceNotFound(NotFound):
internal_message = _("Cannot find compute instance %(server_id)s for "
"instance %(instance_id)s.")
message = _("Resource %(instance_id)s can not be retrieved.")
class DnsRecordNotFound(NotFound):
message = _("DnsRecord with name= %(name)s not found.")
class DatastoreNotFound(NotFound):
message = _("Datastore '%(datastore)s' cannot be found.")
class DatastoreVersionNotFound(NotFound):
message = _("Datastore version '%(version)s' cannot be found.")
class DatastoresNotFound(NotFound):
message = _("Datastores cannot be found.")
class DatastoreNoVersion(TroveError):
message = _("Datastore '%(datastore)s' has no version '%(version)s'.")
class DatastoreVersionInactive(TroveError):
message = _("Datastore version '%(version)s' is not active.")
class DatastoreDefaultDatastoreNotFound(TroveError):
message = _("Please specify datastore.")
class DatastoreDefaultVersionNotFound(TroveError):
message = _("Default version for datastore '%(datastore)s' not found.")
class DatastoreOperationNotSupported(TroveError):
message = _("The '%(operation)s' operation is not supported for "
"the '%(datastore)s' datastore.")
class NoUniqueMatch(TroveError):
message = _("Multiple matches found for '%(name)s', i"
"use an UUID to be more specific.")
class OverLimit(TroveError):
internal_message = _("The server rejected the request due to its size or "
"rate.")
class QuotaExceeded(TroveError):
message = _("Quota exceeded for resources: %(overs)s")
class VolumeQuotaExceeded(QuotaExceeded):
message = _("Instance volume quota exceeded.")
class GuestError(TroveError):
message = _("An error occurred communicating with the guest: "
"%(original_message)s.")
class GuestTimeout(TroveError):
message = _("Timeout trying to connect to the Guest Agent.")
class BadRequest(TroveError):
message = _("The server could not comply with the request since it is "
"either malformed or otherwise incorrect.")
class MissingKey(BadRequest):
message = _("Required element/key - %(key)s was not specified")
class DatabaseAlreadyExists(BadRequest):
message = _('A database with the name "%(name)s" already exists.')
class UserAlreadyExists(BadRequest):
message = _('A user with the name "%(name)s" already exists.')
class InstanceAssignedToConfiguration(BadRequest):
message = _('A configuration group cannot be deleted if it is '
'associated with one or more non-terminated instances. '
'Detach the configuration group from all non-terminated '
'instances and please try again.')
class UnprocessableEntity(TroveError):
message = _("Unable to process the contained request")
class CannotResizeToSameSize(TroveError):
message = _("When resizing, instances must change size!")
class VolumeAttachmentsNotFound(NotFound):
message = _("Cannot find the volumes attached to compute "
"instance %(server_id)")
class VolumeCreationFailure(TroveError):
message = _("Failed to create a volume in Nova.")
class VolumeSizeNotSpecified(BadRequest):
message = _("Volume size was not specified.")
class LocalStorageNotSpecified(BadRequest):
message = _("Local storage not specified in flavor ID: %(flavor)s.")
class LocalStorageNotSupported(TroveError):
message = _("Local storage support is not enabled.")
class VolumeNotSupported(TroveError):
message = _("Volume support is not enabled.")
class TaskManagerError(TroveError):
message = _("An error occurred communicating with the task manager: "
"%(original_message)s.")
class BadValue(TroveError):
message = _("Value could not be converted: %(msg)s")
class PollTimeOut(TroveError):
message = _("Polling request timed out.")
class Forbidden(TroveError):
message = _("User does not have admin privileges.")
class InvalidModelError(TroveError):
message = _("The following values are invalid: %(errors)s")
class ModelNotFoundError(NotFound):
message = _("Not Found")
class UpdateGuestError(TroveError):
message = _("Failed to update instances")
class ConfigNotFound(NotFound):
message = _("Config file not found")
class PasteAppNotFound(NotFound):
message = _("Paste app not found.")
class QuotaNotFound(NotFound):
message = _("Quota could not be found")
class TenantQuotaNotFound(QuotaNotFound):
message = _("Quota for tenant %(tenant_id)s could not be found.")
class QuotaResourceUnknown(QuotaNotFound):
message = _("Unknown quota resources %(unknown)s.")
class BackupUploadError(TroveError):
message = _("Unable to upload Backup onto swift")
class BackupDownloadError(TroveError):
message = _("Unable to download Backup from swift")
class BackupCreationError(TroveError):
message = _("Unable to create Backup")
class BackupUpdateError(TroveError):
message = _("Unable to update Backup table in db")
class SecurityGroupCreationError(TroveError):
message = _("Failed to create Security Group.")
class SecurityGroupDeletionError(TroveError):
message = _("Failed to delete Security Group.")
class SecurityGroupRuleCreationError(TroveError):
message = _("Failed to create Security Group Rule.")
class SecurityGroupRuleDeletionError(TroveError):
message = _("Failed to delete Security Group Rule.")
class MalformedSecurityGroupRuleError(TroveError):
message = _("Error creating security group rules."
" Malformed port(s). Port(s) is not integer."
" FromPort = %(from)s greater than ToPort = %(to)s")
class BackupNotCompleteError(TroveError):
message = _("Unable to create instance because backup %(backup_id)s is "
"not completed")
class BackupFileNotFound(NotFound):
message = _("Backup file in %(location)s was not found in the object "
"storage.")
class BackupDatastoreVersionMismatchError(TroveError):
message = _("The datastore-version from which the backup was"
" taken, %(version1)s, does not match the destination"
" datastore-version of %(version2)s")
class SwiftAuthError(TroveError):
message = _("Swift account not accessible for tenant %(tenant_id)s.")
class DatabaseForUserNotInDatabaseListError(TroveError):
message = _("The request indicates that user %(user)s should have access "
"to database %(database)s, but database %(database)s is not "
"included in the initial databases list.")
class DatabaseInitialDatabaseDuplicateError(TroveError):
message = _("Two or more databases share the same name in the initial "
"databases list. Please correct the names or remove the "
"duplicate entries.")
class DatabaseInitialUserDuplicateError(TroveError):
message = _("Two or more users share the same name and host in the "
"initial users list. Please correct the names or remove the "
"duplicate entries.")
class RestoreBackupIntegrityError(TroveError):
message = _("Current Swift object checksum does not match original "
"checksum for backup %(backup_id)s.")
class ConfigKeyNotFound(NotFound):
message = _("%(key)s is not a supported configuration parameter")
class NoConfigParserFound(NotFound):
message = _("No configuration parser found for datastore "
"%(datastore_manager)s")
class ConfigurationDatastoreNotMatchInstance(TroveError):
message = _("Datastore Version on Configuration "
"%(config_datastore_version)s does not "
"match the Datastore Version on the instance "
"%(instance_datastore_version)s.")
class ConfigurationParameterDeleted(object):
message = _("%(parameter_name)s parameter can no longer be "
" set as of %(parameter_deleted_at)s")
|