1
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
# not use this file except in compliance with the License. You may obtain
5
# 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, WITHOUT
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
# License for the specific language governing permissions and limitations
16
from neutron.api import extensions
17
from neutron.api.v2 import attributes
18
from neutron.common import constants
19
from neutron.common import exceptions
22
EXTENDED_ATTRIBUTES_2_0 = {
24
HA_INFO: {'allow_post': True, 'allow_put': True,
25
'default': attributes.ATTR_NOT_SPECIFIED, 'is_visible': True,
26
'enforce_policy': True,
27
'convert_to': attributes.convert_to_boolean_if_not_none}
32
class DistributedHARouterNotSupported(NotImplementedError):
33
message = _("Currenly distributed HA routers are "
37
class MaxVRIDAllocationTriesReached(exceptions.NeutronException):
38
message = _("Failed to allocate a VRID in the network %(network_id)s "
39
"for the router %(router_id)s after %(max_tries)s tries.")
42
class NoVRIDAvailable(exceptions.Conflict):
43
message = _("No more Virtual Router Identifier (VRID) available when "
44
"creating router %(router_id)s. The limit of number "
45
"of HA Routers per tenant is 254.")
48
class HANetworkCIDRNotValid(exceptions.NeutronException):
49
message = _("The HA Network CIDR specified in the configuration file "
50
"isn't valid; %(cidr)s.")
53
class HANotEnoughAvailableAgents(exceptions.NeutronException):
54
message = _("Not enough l3 agents available to ensure HA. Minimum "
55
"required %(min_agents)s, available %(num_agents)s.")
58
class HAMinimumAgentsNumberNotValid(exceptions.NeutronException):
59
message = (_("min_l3_agents_per_router config parameter is not valid. "
60
"It has to be equal to or more than %s for HA.") %
61
constants.MINIMUM_AGENTS_FOR_HA)
64
class L3_ext_ha_mode(extensions.ExtensionDescriptor):
65
"""Extension class supporting virtual router in HA mode."""
69
return "HA Router extension"
73
return constants.L3_HA_MODE_EXT_ALIAS
76
def get_description(cls):
77
return "Add HA capability to routers."
80
def get_namespace(cls):
85
return "2014-04-26T00:00:00-00:00"
87
def get_extended_resources(self, version):
89
return EXTENDED_ATTRIBUTES_2_0