| 1 |
# Copyright 2011 VMware, Inc, 2015 A10 Networks, Inc |
| 2 |
# All Rights Reserved. |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 |
# not use this file except in compliance with the License. You may obtain |
| 6 |
# a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations |
| 14 |
# under the License. |
| 15 |
|
| 16 |
""" |
| 17 |
Neutron base exception handling. |
| 18 |
""" |
| 19 |
|
| 20 |
from oslo_utils import excutils |
| 21 |
|
| 22 |
from neutron_lib._i18n import _ |
| 23 |
|
| 24 |
|
| 25 |
class NeutronException(Exception): |
| 26 |
"""Base Neutron Exception. |
| 27 |
|
| 28 |
To correctly use this class, inherit from it and define |
| 29 |
a 'message' property. That message will get printf'd |
| 30 |
with the keyword arguments provided to the constructor. |
| 31 |
""" |
| 32 |
message = _("An unknown exception occurred.") |
| 33 |
|
| 34 |
def __init__(self, **kwargs): |
| 35 |
try: |
| 36 |
super().__init__(self.message % kwargs) |
| 37 |
self.msg = self.message % kwargs |
| 38 |
except Exception: |
| 39 |
with excutils.save_and_reraise_exception() as ctxt: |
| 40 |
if not self.use_fatal_exceptions(): |
| 41 |
ctxt.reraise = False |
| 42 |
# at least get the core message out if something happened |
| 43 |
super().__init__(self.message) |
| 44 |
|
| 45 |
def __str__(self): |
| 46 |
return self.msg |
| 47 |
|
| 48 |
def use_fatal_exceptions(self): |
| 49 |
"""Is the instance using fatal exceptions. |
| 50 |
|
| 51 |
:returns: Always returns False. |
| 52 |
""" |
| 53 |
return False |
| 54 |
|
| 55 |
|
| 56 |
class BadRequest(NeutronException): |
| 57 |
"""An exception indicating a generic bad request for a said resource. |
| 58 |
|
| 59 |
A generic exception indicating a bad request for a specified resource. |
| 60 |
|
| 61 |
:param resource: The resource requested. |
| 62 |
:param msg: A message indicating why the request is bad. |
| 63 |
""" |
| 64 |
message = _('Bad %(resource)s request: %(msg)s.') |
| 65 |
|
| 66 |
|
| 67 |
class NotFound(NeutronException): |
| 68 |
"""A generic not found exception.""" |
| 69 |
pass |
| 70 |
|
| 71 |
|
| 72 |
class Conflict(NeutronException): |
| 73 |
"""A generic conflict exception.""" |
| 74 |
pass |
| 75 |
|
| 76 |
|
| 77 |
class NotAuthorized(NeutronException): |
| 78 |
"""A generic not authorized exception.""" |
| 79 |
message = _("Not authorized.") |
| 80 |
|
| 81 |
|
| 82 |
class ServiceUnavailable(NeutronException): |
| 83 |
"""A generic service unavailable exception.""" |
| 84 |
message = _("The service is unavailable.") |
| 85 |
|
| 86 |
|
| 87 |
class AdminRequired(NotAuthorized): |
| 88 |
"""A not authorized exception indicating an admin is required. |
| 89 |
|
| 90 |
A specialization of the NotAuthorized exception that indicates and admin |
| 91 |
is required to carry out the operation or access a resource. |
| 92 |
|
| 93 |
:param reason: A message indicating additional details on why admin is |
| 94 |
required for the operation access. |
| 95 |
""" |
| 96 |
message = _("User does not have admin privileges: %(reason)s.") |
| 97 |
|
| 98 |
|
| 99 |
class ObjectNotFound(NotFound): |
| 100 |
"""A not found exception indicating an identifiable object isn't found. |
| 101 |
|
| 102 |
A specialization of the NotFound exception indicating an object with a said |
| 103 |
ID doesn't exist. |
| 104 |
|
| 105 |
:param id: The ID of the (not found) object. |
| 106 |
""" |
| 107 |
message = _("Object %(id)s not found.") |
| 108 |
|
| 109 |
|
| 110 |
class NetworkNotFound(NotFound): |
| 111 |
"""An exception indicating a network was not found. |
| 112 |
|
| 113 |
A specialization of the NotFound exception indicating a requested network |
| 114 |
could not be found. |
| 115 |
|
| 116 |
:param net_id: The UUID of the (not found) network requested. |
| 117 |
""" |
| 118 |
message = _("Network %(net_id)s could not be found.") |
| 119 |
|
| 120 |
|
| 121 |
class SubnetNotFound(NotFound): |
| 122 |
"""An exception for a requested subnet that's not found. |
| 123 |
|
| 124 |
A specialization of the NotFound exception indicating a requested subnet |
| 125 |
could not be found. |
| 126 |
|
| 127 |
:param subnet_id: The UUID of the (not found) subnet that was requested. |
| 128 |
""" |
| 129 |
message = _("Subnet %(subnet_id)s could not be found.") |
| 130 |
|
| 131 |
|
| 132 |
class PortNotFound(NotFound): |
| 133 |
"""An exception for a requested port that's not found. |
| 134 |
|
| 135 |
A specialization of the NotFound exception indicating a requested port |
| 136 |
could not be found. |
| 137 |
|
| 138 |
:param port_id: The UUID of the (not found) port that was requested. |
| 139 |
""" |
| 140 |
message = _("Port %(port_id)s could not be found.") |
| 141 |
|
| 142 |
|
| 143 |
class PortNotFoundOnNetwork(NotFound): |
| 144 |
"""An exception for a requested port on a network that's not found. |
| 145 |
|
| 146 |
A specialization of the NotFound exception that indicates a specified |
| 147 |
port on a specified network doesn't exist. |
| 148 |
|
| 149 |
:param port_id: The UUID of the (not found) port that was requested. |
| 150 |
:param net_id: The UUID of the network that was requested for the port. |
| 151 |
""" |
| 152 |
message = _("Port %(port_id)s could not be found " |
| 153 |
"on network %(net_id)s.") |
| 154 |
|
| 155 |
|
| 156 |
class DeviceNotFoundError(NotFound): |
| 157 |
"""An exception for a requested device that's not found. |
| 158 |
|
| 159 |
A specialization of the NotFound exception indicating a requested device |
| 160 |
could not be found. |
| 161 |
|
| 162 |
:param device_name: The name of the (not found) device that was requested. |
| 163 |
""" |
| 164 |
message = _("Device '%(device_name)s' does not exist.") |
| 165 |
|
| 166 |
|
| 167 |
class InUse(NeutronException): |
| 168 |
"""A generic exception indicating a resource is already in use.""" |
| 169 |
message = _("The resource is in use.") |
| 170 |
|
| 171 |
|
| 172 |
class NetworkInUse(InUse): |
| 173 |
"""An operational error indicating the network still has ports in use. |
| 174 |
|
| 175 |
A specialization of the InUse exception indicating a network operation was |
| 176 |
requested, but failed because there are still ports in use on the said |
| 177 |
network. |
| 178 |
|
| 179 |
:param net_id: The UUID of the network requested. |
| 180 |
:param reason: Details on why the operation failed. If None, a default |
| 181 |
reason is used indicating one or more ports still in use |
| 182 |
on the network. |
| 183 |
""" |
| 184 |
message = _("Unable to complete operation on network %(net_id)s. " |
| 185 |
"%(reason)s.") |
| 186 |
|
| 187 |
def __init__(self, **kwargs): |
| 188 |
if 'reason' not in kwargs: |
| 189 |
kwargs['reason'] = _("There are one or more ports still in use " |
| 190 |
"on the network") |
| 191 |
super().__init__(**kwargs) |
| 192 |
|
| 193 |
|
| 194 |
class SubnetInUse(InUse): |
| 195 |
"""An operational error indicating a subnet is still in use. |
| 196 |
|
| 197 |
A specialization of the InUse exception indicating an operation failed |
| 198 |
on a subnet because the subnet is still in use. |
| 199 |
|
| 200 |
:param subnet_id: The UUID of the subnet requested. |
| 201 |
:param reason: Details on why the operation failed. If None, a default |
| 202 |
reason is used indicating one or more ports still have IP allocations |
| 203 |
on the subnet. |
| 204 |
""" |
| 205 |
message = _("Unable to complete operation on subnet %(subnet_id)s: " |
| 206 |
"%(reason)s.") |
| 207 |
|
| 208 |
def __init__(self, **kwargs): |
| 209 |
if 'reason' not in kwargs: |
| 210 |
kwargs['reason'] = _("One or more ports have an IP allocation " |
| 211 |
"from this subnet") |
| 212 |
super().__init__(**kwargs) |
| 213 |
|
| 214 |
|
| 215 |
class SubnetPoolInUse(InUse): |
| 216 |
"""An operational error indicating a subnet pool is still in use. |
| 217 |
|
| 218 |
A specialization of the InUse exception indicating an operation failed |
| 219 |
on a subnet pool because it's still in use. |
| 220 |
|
| 221 |
:param subnet_pool_id: The UUID of the subnet pool requested. |
| 222 |
:param reason: Details on why the operation failed. If None a default |
| 223 |
reason is used indicating two or more concurrent subnets are allocated. |
| 224 |
""" |
| 225 |
message = _("Unable to complete operation on subnet pool " |
| 226 |
"%(subnet_pool_id)s. %(reason)s.") |
| 227 |
|
| 228 |
def __init__(self, **kwargs): |
| 229 |
if 'reason' not in kwargs: |
| 230 |
kwargs['reason'] = _("Two or more concurrent subnets allocated") |
| 231 |
super().__init__(**kwargs) |
| 232 |
|
| 233 |
|
| 234 |
class PortInUse(InUse): |
| 235 |
"""An operational error indicating a requested port is already attached. |
| 236 |
|
| 237 |
A specialization of the InUse exception indicating an operation failed on |
| 238 |
a port because it already has an attached device. |
| 239 |
|
| 240 |
:param port_id: The UUID of the port requested. |
| 241 |
:param net_id: The UUID of the requested port's network. |
| 242 |
:param device_id: The UUID of the device already attached to the port. |
| 243 |
""" |
| 244 |
message = _("Unable to complete operation on port %(port_id)s " |
| 245 |
"for network %(net_id)s. Port already has an attached " |
| 246 |
"device %(device_id)s.") |
| 247 |
|
| 248 |
|
| 249 |
class ServicePortInUse(InUse): |
| 250 |
"""An error indicating a service port can't be deleted. |
| 251 |
|
| 252 |
A specialization of the InUse exception indicating a requested service |
| 253 |
port can't be deleted via the APIs. |
| 254 |
|
| 255 |
:param port_id: The UUID of the port requested. |
| 256 |
:param reason: Details on why the operation failed. |
| 257 |
""" |
| 258 |
message = _("Port %(port_id)s cannot be deleted directly via the " |
| 259 |
"port API: %(reason)s.") |
| 260 |
|
| 261 |
|
| 262 |
class PortBound(InUse): |
| 263 |
"""An operational error indicating a port is already bound. |
| 264 |
|
| 265 |
A specialization of the InUse exception indicating an operation can't |
| 266 |
complete because the port is already bound. |
| 267 |
|
| 268 |
:param port_id: The UUID of the port requested. |
| 269 |
:param vif_type: The VIF type associated with the bound port. |
| 270 |
:param old_mac: The old MAC address of the port. |
| 271 |
:param net_mac: The new MAC address of the port. |
| 272 |
""" |
| 273 |
message = _("Unable to complete operation on port %(port_id)s, " |
| 274 |
"port is already bound, port type: %(vif_type)s, " |
| 275 |
"old_mac %(old_mac)s, new_mac %(new_mac)s.") |
| 276 |
|
| 277 |
|
| 278 |
class PortBoundNUMAAffinityPolicy(InUse): |
| 279 |
"""An operational error indicating a port is already bound. |
| 280 |
|
| 281 |
NUMA affinity policy cannot be modified when the port is bound. |
| 282 |
|
| 283 |
:param port_id: The UUID of the port requested. |
| 284 |
:param host_id: The host ID where the port is bound. |
| 285 |
:param numa_affinity_policy: value passed to be updated. |
| 286 |
""" |
| 287 |
message = _("Unable to complete operation on port %(port_id)s, " |
| 288 |
"port is already bound to host %(host_id)s, " |
| 289 |
"numa_affinity_policy value given %(numa_affinity_policy)s.") |
| 290 |
|
| 291 |
|
| 292 |
class MacAddressInUse(InUse): |
| 293 |
"""An network operational error indicating a MAC address is already in use. |
| 294 |
|
| 295 |
A specialization of the InUse exception indicating an operation failed |
| 296 |
on a network because a specified MAC address is already in use on that |
| 297 |
network. |
| 298 |
|
| 299 |
:param net_id: The UUID of the network. |
| 300 |
:param mac: The requested MAC address that's already in use. |
| 301 |
""" |
| 302 |
message = _("Unable to complete operation for network %(net_id)s. " |
| 303 |
"The mac address %(mac)s is in use.") |
| 304 |
|
| 305 |
|
| 306 |
class InvalidIpForNetwork(BadRequest): |
| 307 |
"""An exception indicating an invalid IP was specified for a network. |
| 308 |
|
| 309 |
A specialization of the BadRequest exception indicating a specified IP |
| 310 |
address is invalid for a network. |
| 311 |
|
| 312 |
:param ip_address: The IP address that's invalid on the network. |
| 313 |
""" |
| 314 |
message = _("IP address %(ip_address)s is not a valid IP " |
| 315 |
"for any of the subnets on the specified network.") |
| 316 |
|
| 317 |
|
| 318 |
class InvalidIpForSubnet(BadRequest): |
| 319 |
"""An exception indicating an invalid IP was specified for a subnet. |
| 320 |
|
| 321 |
A specialization of the BadRequest exception indicating a specified IP |
| 322 |
address is invalid for a subnet. |
| 323 |
|
| 324 |
:param ip_address: The IP address that's invalid on the subnet. |
| 325 |
""" |
| 326 |
message = _("IP address %(ip_address)s is not a valid IP " |
| 327 |
"for the specified subnet.") |
| 328 |
|
| 329 |
|
| 330 |
class IpAddressInUse(InUse): |
| 331 |
"""An network operational error indicating an IP address is already in use. |
| 332 |
|
| 333 |
A specialization of the InUse exception indicating an operation can't |
| 334 |
complete because an IP address is in use. |
| 335 |
|
| 336 |
:param net_id: The UUID of the network. |
| 337 |
:param ip_address: The IP address that's already in use on the network. |
| 338 |
""" |
| 339 |
message = _("Unable to complete operation for network %(net_id)s. " |
| 340 |
"The IP address %(ip_address)s is in use.") |
| 341 |
|
| 342 |
|
| 343 |
class VlanIdInUse(InUse): |
| 344 |
"""A network operational error indicating a VLAN ID is already in use. |
| 345 |
|
| 346 |
A specialization of the InUse exception indicating network creation failed |
| 347 |
because a specified VLAN is already in use on the physical network. |
| 348 |
|
| 349 |
:param vlan_id: The VLAN ID. |
| 350 |
:param physical_network: The physical network. |
| 351 |
""" |
| 352 |
message = _("Unable to create the network. " |
| 353 |
"The VLAN %(vlan_id)s on physical network " |
| 354 |
"%(physical_network)s is in use.") |
| 355 |
|
| 356 |
|
| 357 |
class TunnelIdInUse(InUse): |
| 358 |
"""A network creation failure due to tunnel ID already in use. |
| 359 |
|
| 360 |
A specialization of the InUse exception indicating network creation failed |
| 361 |
because a said tunnel ID is already in use. |
| 362 |
|
| 363 |
:param tunnel_id: The ID of the tunnel that's already in use. |
| 364 |
""" |
| 365 |
message = _("Unable to create the network. " |
| 366 |
"The tunnel ID %(tunnel_id)s is in use.") |
| 367 |
|
| 368 |
|
| 369 |
class ResourceExhausted(ServiceUnavailable): |
| 370 |
"""A service unavailable error indicating a resource is exhausted.""" |
| 371 |
pass |
| 372 |
|
| 373 |
|
| 374 |
class NoNetworkAvailable(ResourceExhausted): |
| 375 |
"""A failure to create a network due to no tenant networks for allocation. |
| 376 |
|
| 377 |
A specialization of the ResourceExhausted exception indicating network |
| 378 |
creation failed because no project network are available for allocation. |
| 379 |
""" |
| 380 |
message = _("Unable to create the network. " |
| 381 |
"No project network is available for allocation.") |
| 382 |
|
| 383 |
|
| 384 |
class SubnetMismatchForPort(BadRequest): |
| 385 |
"""A bad request error indicating a specified subnet isn't on a port. |
| 386 |
|
| 387 |
A specialization of the BadRequest exception indicating a subnet on a port |
| 388 |
doesn't match a specified subnet. |
| 389 |
|
| 390 |
:param port_id: The UUID of the port. |
| 391 |
:param subnet_id: The UUID of the requested subnet. |
| 392 |
""" |
| 393 |
message = _("Subnet on port %(port_id)s does not match " |
| 394 |
"the requested subnet %(subnet_id)s.") |
| 395 |
|
| 396 |
|
| 397 |
class Invalid(NeutronException): |
| 398 |
"""A generic base class for invalid errors.""" |
| 399 |
|
| 400 |
def __init__(self, message=None): |
| 401 |
self.message = message |
| 402 |
super().__init__() |
| 403 |
|
| 404 |
|
| 405 |
class InvalidInput(BadRequest): |
| 406 |
"""A bad request due to invalid input. |
| 407 |
|
| 408 |
A specialization of the BadRequest error indicating bad input was |
| 409 |
specified. |
| 410 |
|
| 411 |
:param error_message: Details on the operation that failed due to bad |
| 412 |
input. |
| 413 |
""" |
| 414 |
message = _("Invalid input for operation: %(error_message)s.") |
| 415 |
|
| 416 |
|
| 417 |
class IpAddressGenerationFailure(Conflict): |
| 418 |
"""A conflict error due to no more IP addresses on a said network. |
| 419 |
|
| 420 |
:param net_id: The UUID of the network that has no more IP addresses. |
| 421 |
""" |
| 422 |
message = _("No more IP addresses available on network %(net_id)s.") |
| 423 |
|
| 424 |
|
| 425 |
class PreexistingDeviceFailure(NeutronException): |
| 426 |
"""A creation error due to an already existing device. |
| 427 |
|
| 428 |
An exception indication creation failed due to an already existing |
| 429 |
device. |
| 430 |
|
| 431 |
:param dev_name: The device name that already exists. |
| 432 |
""" |
| 433 |
message = _("Creation failed. %(dev_name)s already exists.") |
| 434 |
|
| 435 |
|
| 436 |
class OverQuota(Conflict): |
| 437 |
"""A error due to exceeding quota limits. |
| 438 |
|
| 439 |
A specialization of the Conflict exception indicating quota has been |
| 440 |
exceeded. |
| 441 |
|
| 442 |
:param overs: The resources that have exceeded quota. |
| 443 |
""" |
| 444 |
message = _("Quota exceeded for resources: %(overs)s.") |
| 445 |
|
| 446 |
|
| 447 |
class InvalidContentType(NeutronException): |
| 448 |
"""An error due to invalid content type. |
| 449 |
|
| 450 |
:param content_type: The invalid content type. |
| 451 |
""" |
| 452 |
message = _("Invalid content type %(content_type)s.") |
| 453 |
|
| 454 |
|
| 455 |
class ExternalIpAddressExhausted(BadRequest): |
| 456 |
"""An error due to not finding IP addresses on an external network. |
| 457 |
|
| 458 |
A specialization of the BadRequest exception indicating no IP addresses |
| 459 |
can be found on a network. |
| 460 |
|
| 461 |
:param net_id: The UUID of the network. |
| 462 |
""" |
| 463 |
message = _("Unable to find any IP address on external " |
| 464 |
"network %(net_id)s.") |
| 465 |
|
| 466 |
|
| 467 |
class InvalidConfigurationOption(NeutronException): |
| 468 |
"""An error due to an invalid configuration option value. |
| 469 |
|
| 470 |
:param opt_name: The name of the configuration option that has an invalid |
| 471 |
value. |
| 472 |
:param opt_value: The value that's invalid for the configuration option. |
| 473 |
""" |
| 474 |
message = _("An invalid value was provided for %(opt_name)s: " |
| 475 |
"%(opt_value)s.") |
| 476 |
|
| 477 |
|
| 478 |
class NetworkTunnelRangeError(NeutronException): |
| 479 |
"""An error due to an invalid network tunnel range. |
| 480 |
|
| 481 |
An exception indicating an invalid network tunnel range was specified. |
| 482 |
|
| 483 |
:param tunnel_range: The invalid tunnel range. If specified in the |
| 484 |
start:end' format, they will be converted automatically. |
| 485 |
:param error: Additional details on why the range is invalid. |
| 486 |
""" |
| 487 |
message = _("Invalid network tunnel range: " |
| 488 |
"'%(tunnel_range)s' - %(error)s.") |
| 489 |
|
| 490 |
def __init__(self, **kwargs): |
| 491 |
# Convert tunnel_range tuple to 'start:end' format for display |
| 492 |
if isinstance(kwargs['tunnel_range'], tuple): |
| 493 |
kwargs['tunnel_range'] = "%d:%d" % kwargs['tunnel_range'] |
| 494 |
super().__init__(**kwargs) |
| 495 |
|
| 496 |
|
| 497 |
class PolicyInitError(NeutronException): |
| 498 |
"""An error due to policy initialization failure. |
| 499 |
|
| 500 |
:param policy: The policy that failed to initialize. |
| 501 |
:param reason: Details on why the policy failed to initialize. |
| 502 |
""" |
| 503 |
message = _("Failed to initialize policy %(policy)s because %(reason)s.") |
| 504 |
|
| 505 |
|
| 506 |
class PolicyCheckError(NeutronException): |
| 507 |
"""An error due to a policy check failure. |
| 508 |
|
| 509 |
:param policy: The policy that failed to check. |
| 510 |
:param reason: Additional details on the failure. |
| 511 |
""" |
| 512 |
message = _("Failed to check policy %(policy)s because %(reason)s.") |
| 513 |
|
| 514 |
|
| 515 |
class MultipleExceptions(Exception): |
| 516 |
"""Container for multiple exceptions encountered. |
| 517 |
|
| 518 |
The API layer of Neutron will automatically unpack, translate, |
| 519 |
filter, and combine the inner exceptions in any exception derived |
| 520 |
from this class. |
| 521 |
""" |
| 522 |
|
| 523 |
def __init__(self, exceptions, *args, **kwargs): |
| 524 |
"""Create a new instance wrapping the exceptions. |
| 525 |
|
| 526 |
:param exceptions: The inner exceptions this instance is composed of. |
| 527 |
:param args: Passed onto parent constructor. |
| 528 |
:param kwargs: Passed onto parent constructor. |
| 529 |
""" |
| 530 |
super().__init__(*args, **kwargs) |
| 531 |
self.inner_exceptions = exceptions |
| 532 |
|
| 533 |
|
| 534 |
class HostMacAddressGenerationFailure(ServiceUnavailable): |
| 535 |
"""MAC address generation failure for a host. |
| 536 |
|
| 537 |
:param host: The host MAC address generation failed for. |
| 538 |
""" |
| 539 |
message = _("Unable to generate unique mac for host %(host)s.") |
| 540 |
|
| 541 |
|
| 542 |
class NetworkMacAddressGenerationFailure(ServiceUnavailable): |
| 543 |
"""An error related to MAC address generation on a network. |
| 544 |
|
| 545 |
:param net_id: The ID of the network MAC address generation failed on. |
| 546 |
""" |
| 547 |
message = _("Unable to generate unique mac on network %(net_id)s.") |
| 548 |
|
| 549 |
|
| 550 |
class InvalidServiceType(InvalidInput): |
| 551 |
"""An error due to an invalid service type. |
| 552 |
|
| 553 |
:param service_type: The service type that's invalid. |
| 554 |
""" |
| 555 |
message = _("Invalid service type: %(service_type)s.") |
| 556 |
|
| 557 |
|
| 558 |
class NetworkVlanRangeError(NeutronException): |
| 559 |
message = _("Invalid network VLAN range: '%(vlan_range)s' - '%(error)s'.") |
| 560 |
|
| 561 |
def __init__(self, **kwargs): |
| 562 |
# Convert vlan_range tuple to 'start:end' format for display |
| 563 |
if isinstance(kwargs['vlan_range'], tuple): |
| 564 |
kwargs['vlan_range'] = "%d:%d" % kwargs['vlan_range'] |
| 565 |
super().__init__(**kwargs) |
| 566 |
|
| 567 |
|
| 568 |
class PhysicalNetworkNameError(NeutronException): |
| 569 |
message = _("Empty physical network name.") |
| 570 |
|
| 571 |
|
| 572 |
class TenantIdProjectIdFilterConflict(BadRequest): |
| 573 |
message = _("Both tenant_id and project_id passed as filters.") |
| 574 |
|
| 575 |
|
| 576 |
class SubnetPoolNotFound(NotFound): |
| 577 |
message = _("Subnet pool %(subnetpool_id)s could not be found.") |
| 578 |
|
| 579 |
|
| 580 |
class StateInvalid(BadRequest): |
| 581 |
message = _("Unsupported port state: %(port_state)s.") |
| 582 |
|
| 583 |
|
| 584 |
class DhcpPortInUse(InUse): |
| 585 |
message = _("Port %(port_id)s is already acquired by another DHCP agent") |
| 586 |
|
| 587 |
|
| 588 |
class HostRoutesExhausted(BadRequest): |
| 589 |
# NOTE(xchenum): probably make sense to use quota exceeded exception? |
| 590 |
message = _("Unable to complete operation for %(subnet_id)s. " |
| 591 |
"The number of host routes exceeds the limit %(quota)s.") |
| 592 |
|
| 593 |
|
| 594 |
class DNSNameServersExhausted(BadRequest): |
| 595 |
# NOTE(xchenum): probably make sense to use quota exceeded exception? |
| 596 |
message = _("Unable to complete operation for %(subnet_id)s. " |
| 597 |
"The number of DNS nameservers exceeds the limit %(quota)s.") |
| 598 |
|
| 599 |
|
| 600 |
class FlatNetworkInUse(InUse): |
| 601 |
message = _("Unable to create the flat network. " |
| 602 |
"Physical network %(physical_network)s is in use.") |
| 603 |
|
| 604 |
|
| 605 |
class NoNetworkFoundInMaximumAllowedAttempts(ServiceUnavailable): |
| 606 |
message = _("Unable to create the network. " |
| 607 |
"No available network found in maximum allowed attempts.") |
| 608 |
|
| 609 |
|
| 610 |
class MalformedRequestBody(BadRequest): |
| 611 |
message = _("Malformed request body: %(reason)s.") |
| 612 |
|
| 613 |
|
| 614 |
class InvalidAllocationPool(BadRequest): |
| 615 |
message = _("The allocation pool %(pool)s is not valid.") |
| 616 |
|
| 617 |
|
| 618 |
class UnsupportedPortDeviceOwner(Conflict): |
| 619 |
message = _("Operation %(op)s is not supported for device_owner " |
| 620 |
"%(device_owner)s on port %(port_id)s.") |
| 621 |
|
| 622 |
|
| 623 |
class OverlappingAllocationPools(Conflict): |
| 624 |
message = _("Found overlapping allocation pools: " |
| 625 |
"%(pool_1)s %(pool_2)s for subnet %(subnet_cidr)s.") |
| 626 |
|
| 627 |
|
| 628 |
class OutOfBoundsAllocationPool(BadRequest): |
| 629 |
message = _("The allocation pool %(pool)s spans " |
| 630 |
"beyond the subnet cidr %(subnet_cidr)s.") |
| 631 |
|
| 632 |
|
| 633 |
class BridgeDoesNotExist(NeutronException): |
| 634 |
message = _("Bridge %(bridge)s does not exist.") |
| 635 |
|
| 636 |
|
| 637 |
class QuotaResourceUnknown(NotFound): |
| 638 |
message = _("Unknown quota resources %(unknown)s.") |
| 639 |
|
| 640 |
|
| 641 |
class QuotaMissingTenant(BadRequest): |
| 642 |
message = _("Tenant-id was missing from quota request.") |
| 643 |
|
| 644 |
|
| 645 |
class InvalidQuotaValue(Conflict): |
| 646 |
message = _("Change would make usage less than 0 for the following " |
| 647 |
"resources: %(unders)s.") |
| 648 |
|
| 649 |
|
| 650 |
class InvalidSharedSetting(Conflict): |
| 651 |
message = _("Unable to reconfigure sharing settings for network " |
| 652 |
"%(network)s. Multiple projects are using it.") |
| 653 |
|
| 654 |
|
| 655 |
class ExtensionsNotFound(NotFound): |
| 656 |
message = _("Extensions not found: %(extensions)s.") |
| 657 |
|
| 658 |
|
| 659 |
class GatewayConflictWithAllocationPools(InUse): |
| 660 |
message = _("Gateway ip %(ip_address)s conflicts with " |
| 661 |
"allocation pool %(pool)s.") |
| 662 |
|
| 663 |
|
| 664 |
class GatewayIpInUse(InUse): |
| 665 |
message = _("Current gateway ip %(ip_address)s already in use " |
| 666 |
"by port %(port_id)s. Unable to update.") |
| 667 |
|
| 668 |
|
| 669 |
class NetworkVxlanPortRangeError(NeutronException): |
| 670 |
message = _("Invalid network VXLAN port range: '%(vxlan_range)s'.") |
| 671 |
|
| 672 |
|
| 673 |
class VxlanNetworkUnsupported(NeutronException): |
| 674 |
message = _("VXLAN network unsupported.") |
| 675 |
|
| 676 |
|
| 677 |
class DuplicatedExtension(NeutronException): |
| 678 |
message = _("Found duplicate extension: %(alias)s.") |
| 679 |
|
| 680 |
|
| 681 |
class DriverCallError(MultipleExceptions): |
| 682 |
def __init__(self, exc_list=None): |
| 683 |
super().__init__(exc_list or []) |
| 684 |
|
| 685 |
|
| 686 |
class DeviceIDNotOwnedByTenant(Conflict): |
| 687 |
message = _("The following device_id %(device_id)s is not owned by your " |
| 688 |
"project or matches another project router.") |
| 689 |
|
| 690 |
|
| 691 |
class InvalidCIDR(BadRequest): |
| 692 |
message = _("Invalid CIDR %(input)s given as IP prefix.") |
| 693 |
|
| 694 |
|
| 695 |
class FailToDropPrivilegesExit(SystemExit): |
| 696 |
"""Exit exception raised when a drop privileges action fails.""" |
| 697 |
code = 99 |
| 698 |
|
| 699 |
|
| 700 |
class NetworkIdOrRouterIdRequiredError(NeutronException): |
| 701 |
message = _('Both network_id and router_id are None. ' |
| 702 |
'One must be provided.') |
| 703 |
|
| 704 |
|
| 705 |
class EmptySubnetPoolPrefixList(BadRequest): |
| 706 |
message = _("Empty subnet pool prefix list.") |
| 707 |
|
| 708 |
|
| 709 |
class PrefixVersionMismatch(BadRequest): |
| 710 |
message = _("Cannot mix IPv4 and IPv6 prefixes in a subnet pool.") |
| 711 |
|
| 712 |
|
| 713 |
class UnsupportedMinSubnetPoolPrefix(BadRequest): |
| 714 |
message = _("Prefix '%(prefix)s' not supported in IPv%(version)s pool.") |
| 715 |
|
| 716 |
|
| 717 |
class IllegalSubnetPoolPrefixBounds(BadRequest): |
| 718 |
message = _("Illegal prefix bounds: %(prefix_type)s=%(prefixlen)s, " |
| 719 |
"%(base_prefix_type)s=%(base_prefixlen)s.") |
| 720 |
|
| 721 |
|
| 722 |
class IllegalSubnetPoolPrefixUpdate(BadRequest): |
| 723 |
message = _("Illegal update to prefixes: %(msg)s.") |
| 724 |
|
| 725 |
|
| 726 |
class SubnetAllocationError(NeutronException): |
| 727 |
message = _("Failed to allocate subnet: %(reason)s.") |
| 728 |
|
| 729 |
|
| 730 |
class AddressScopePrefixConflict(Conflict): |
| 731 |
message = _("Failed to associate address scope: subnetpools " |
| 732 |
"within an address scope must have unique prefixes.") |
| 733 |
|
| 734 |
|
| 735 |
class IllegalSubnetPoolAssociationToAddressScope(BadRequest): |
| 736 |
message = _("Illegal subnetpool association: subnetpool %(subnetpool_id)s " |
| 737 |
"cannot be associated with address scope " |
| 738 |
"%(address_scope_id)s.") |
| 739 |
|
| 740 |
|
| 741 |
class IllegalSubnetPoolIpVersionAssociationToAddressScope(BadRequest): |
| 742 |
message = _("Illegal subnetpool association: subnetpool %(subnetpool_id)s " |
| 743 |
"cannot associate with address scope %(address_scope_id)s " |
| 744 |
"because subnetpool ip_version is not %(ip_version)s.") |
| 745 |
|
| 746 |
|
| 747 |
class IllegalSubnetPoolUpdate(BadRequest): |
| 748 |
message = _("Illegal subnetpool update : %(reason)s.") |
| 749 |
|
| 750 |
|
| 751 |
class MinPrefixSubnetAllocationError(BadRequest): |
| 752 |
message = _("Unable to allocate subnet with prefix length %(prefixlen)s, " |
| 753 |
"minimum allowed prefix is %(min_prefixlen)s.") |
| 754 |
|
| 755 |
|
| 756 |
class MaxPrefixSubnetAllocationError(BadRequest): |
| 757 |
message = _("Unable to allocate subnet with prefix length %(prefixlen)s, " |
| 758 |
"maximum allowed prefix is %(max_prefixlen)s.") |
| 759 |
|
| 760 |
|
| 761 |
class SubnetPoolDeleteError(BadRequest): |
| 762 |
message = _("Unable to delete subnet pool: %(reason)s.") |
| 763 |
|
| 764 |
|
| 765 |
class SubnetPoolQuotaExceeded(OverQuota): |
| 766 |
message = _("Per-project subnet pool prefix quota exceeded.") |
| 767 |
|
| 768 |
|
| 769 |
class NetworkSubnetPoolAffinityError(BadRequest): |
| 770 |
message = _("Subnets hosted on the same network must be allocated from " |
| 771 |
"the same subnet pool.") |
| 772 |
|
| 773 |
|
| 774 |
class ObjectActionError(NeutronException): |
| 775 |
message = _('Object action %(action)s failed because: %(reason)s.') |
| 776 |
|
| 777 |
|
| 778 |
class CTZoneExhaustedError(NeutronException): |
| 779 |
message = _("IPtables conntrack zones exhausted, iptables rules cannot " |
| 780 |
"be applied.") |
| 781 |
|
| 782 |
|
| 783 |
class TenantQuotaNotFound(NotFound): |
| 784 |
message = _("Quota for project %(tenant_id)s could not be found.") |
| 785 |
|
| 786 |
|
| 787 |
class MultipleFilterIDForIPFound(Conflict): |
| 788 |
message = _("Multiple filter IDs for IP %(ip)s found.") |
| 789 |
|
| 790 |
|
| 791 |
class FilterIDForIPNotFound(NotFound): |
| 792 |
message = _("Filter ID for IP %(ip)s could not be found.") |
| 793 |
|
| 794 |
|
| 795 |
class FailedToAddQdiscToDevice(NeutronException): |
| 796 |
message = _("Failed to add %(direction)s qdisc " |
| 797 |
"to device %(device)s.") |
| 798 |
|
| 799 |
|
| 800 |
class PortBindingNotFound(NotFound): |
| 801 |
message = _("Binding for port %(port_id)s for host %(host)s could not be " |
| 802 |
"found.") |
| 803 |
|
| 804 |
|
| 805 |
class PortBindingAlreadyActive(Conflict): |
| 806 |
message = _("Binding for port %(port_id)s on host %(host)s is already " |
| 807 |
"active.") |
| 808 |
|
| 809 |
|
| 810 |
class PortBindingAlreadyExists(Conflict): |
| 811 |
message = _("Binding for port %(port_id)s on host %(host)s already " |
| 812 |
"exists.") |
| 813 |
|
| 814 |
|
| 815 |
class PortBindingError(NeutronException): |
| 816 |
message = _("Binding for port %(port_id)s on host %(host)s could not be " |
| 817 |
"created or updated.") |
| 818 |
|
| 819 |
|
| 820 |
class ProcessExecutionError(RuntimeError): |
| 821 |
def __init__(self, message, returncode): |
| 822 |
super().__init__(message) |
| 823 |
self.returncode = returncode |
| 824 |
|
| 825 |
|
| 826 |
class InvalidSubnetServiceType(InvalidInput): |
| 827 |
message = _("Subnet service type %(service_type)s does not correspond " |
| 828 |
"to a valid device owner.") |
| 829 |
|
| 830 |
|
| 831 |
class InvalidInputSubnetServiceType(InvalidInput): |
| 832 |
message = _("Subnet service type %(service_type)s is not a string.") |
| 833 |
|
| 834 |
|
| 835 |
class NetworkMTUSubnetConflict(Conflict): |
| 836 |
"""A conflict error due to MTU being invalid on said network. |
| 837 |
|
| 838 |
:param net_id: The UUID of the network |
| 839 |
:param mtu: The minimum MTU required by a subnet for the network |
| 840 |
""" |
| 841 |
message = _("MTU of %(net_id)s is not valid, subnet requires a " |
| 842 |
"minimum of %(mtu)s") |