summaryrefslogtreecommitdiff
path: root/neutron/db/l3_dvr_ha_scheduler_db.py
blob: dcdb7a09ff191cf0623de3fd6328a68246a4f5bc (plain)
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
# Copyright (c) 2016 Hewlett Packard Enterprise Development Company, L.P.
# 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.

import neutron.db.l3_dvrscheduler_db as l3agent_dvr_sch_db
import neutron.db.l3_hascheduler_db as l3_ha_sch_db


class L3_DVR_HA_scheduler_db_mixin(l3agent_dvr_sch_db.L3_DVRsch_db_mixin,
                                   l3_ha_sch_db.L3_HA_scheduler_db_mixin):

    def get_dvr_routers_to_remove(self, context, port_id):
        """Returns info about which routers should be removed

        In case dvr serviceable port was deleted we need to check
        if any dvr routers should be removed from l3 agent on port's host
        """
        remove_router_info = super(L3_DVR_HA_scheduler_db_mixin,
                                   self).get_dvr_routers_to_remove(context,
                                                                   port_id)
        # Process the router information which was returned to make
        # sure we don't delete routers which have dvrhs snat bindings.
        processed_remove_router_info = []
        for router_info in remove_router_info:
            router_id = router_info['router_id']
            agent_id = router_info['agent_id']
            if not self._check_router_agent_ha_binding(
                    context, router_id, agent_id):
                processed_remove_router_info.append(router_info)

        return processed_remove_router_info