~niedbalski/ubuntu/vivid/neutron/fixes-1447803

« back to all changes in this revision

Viewing changes to neutron/extensions/l3_ext_ha_mode.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-10-03 18:45:23 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20141003184523-4mt6dy1q3j8n30c9
Tags: 1:2014.2~rc1-0ubuntu1
* New upstream release candidate:
  - d/p/*: Refreshed.
  - d/control: Add python-requests-mock to BD's.
  - d/control: Align versioned requirements with upstream.
* Transition linuxbridge and openvswitch plugin users to modular
  layer 2 plugin (LP: #1323729):
  - d/control: Mark removed plugin packages as transitional, depend
    on neutron-plugin-ml2, mark oldlibs/extra.
  - d/neutron-plugin-{linuxbridge,openvswitch}.install: Drop.
  - d/control: Depend on neutron-plugin-ml2 for linuxbridge
    agent package.
  - d/neutron-plugin-linuxbridge-agent.upstart: Use ml2 plugin
    configuration files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
 
2
#
 
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
 
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, WITHOUT
 
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
12
# License for the specific language governing permissions and limitations
 
13
# under the License.
 
14
#
 
15
 
 
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
 
20
 
 
21
HA_INFO = 'ha'
 
22
EXTENDED_ATTRIBUTES_2_0 = {
 
23
    'routers': {
 
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}
 
28
    }
 
29
}
 
30
 
 
31
 
 
32
class DistributedHARouterNotSupported(NotImplementedError):
 
33
    message = _("Currenly distributed HA routers are "
 
34
                "not supported.")
 
35
 
 
36
 
 
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.")
 
40
 
 
41
 
 
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.")
 
46
 
 
47
 
 
48
class HANetworkCIDRNotValid(exceptions.NeutronException):
 
49
    message = _("The HA Network CIDR specified in the configuration file "
 
50
                "isn't valid; %(cidr)s.")
 
51
 
 
52
 
 
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.")
 
56
 
 
57
 
 
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)
 
62
 
 
63
 
 
64
class L3_ext_ha_mode(extensions.ExtensionDescriptor):
 
65
    """Extension class supporting virtual router in HA mode."""
 
66
 
 
67
    @classmethod
 
68
    def get_name(cls):
 
69
        return "HA Router extension"
 
70
 
 
71
    @classmethod
 
72
    def get_alias(cls):
 
73
        return constants.L3_HA_MODE_EXT_ALIAS
 
74
 
 
75
    @classmethod
 
76
    def get_description(cls):
 
77
        return "Add HA capability to routers."
 
78
 
 
79
    @classmethod
 
80
    def get_namespace(cls):
 
81
        return ""
 
82
 
 
83
    @classmethod
 
84
    def get_updated(cls):
 
85
        return "2014-04-26T00:00:00-00:00"
 
86
 
 
87
    def get_extended_resources(self, version):
 
88
        if version == "2.0":
 
89
            return EXTENDED_ATTRIBUTES_2_0
 
90
        else:
 
91
            return {}