author | Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com> |
Thu, 21 Jul 2016 09:32:01 -0700 | |
branch | s11u3-sru |
changeset 6444 | bf62eba2612a |
parent 6035 | c9748fcc32de |
permissions | -rw-r--r-- |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
1 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4 |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
2 |
|
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
3 |
# Copyright 2012 VMware, Inc. All rights reserved. |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
4 |
# |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
5 |
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
6 |
# |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
7 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
8 |
# not use this file except in compliance with the License. You may obtain |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
9 |
# a copy of the License at |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
10 |
# |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
11 |
# http://www.apache.org/licenses/LICENSE-2.0 |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
12 |
# |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
13 |
# Unless required by applicable law or agreed to in writing, software |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
14 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
15 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
16 |
# License for the specific language governing permissions and limitations |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
17 |
# under the License. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
18 |
# |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
19 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
20 |
""" |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
21 |
Based off generic l3_agent (neutron/agent/l3_agent) code |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
22 |
""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
23 |
|
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
24 |
import errno |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
25 |
import netaddr |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
26 |
|
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
27 |
from oslo.config import cfg |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
28 |
from oslo_log import log as logging |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
29 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
30 |
from neutron.agent.l3 import agent as l3_agent |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
31 |
from neutron.agent.l3 import router_info as router |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
32 |
from neutron.agent.linux import utils |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
33 |
from neutron.agent.solaris import interface |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
34 |
from neutron.agent.solaris import ipfilters_manager |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
35 |
from neutron.agent.solaris import net_lib |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
36 |
from neutron.agent.solaris import ra |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
37 |
from neutron.callbacks import events |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
38 |
from neutron.callbacks import registry |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
39 |
from neutron.callbacks import resources |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
40 |
from neutron.common import constants as l3_constants |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
41 |
from neutron.common import exceptions as n_exc |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
42 |
from neutron.common import utils as common_utils |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
43 |
from oslo_utils import importutils |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
44 |
from oslo_log import log as logging |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
45 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
46 |
import neutron_vpnaas.services.vpn.agent as neutron_vpnaas |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
47 |
from neutron_vpnaas.extensions import vpnaas |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
48 |
from neutron_vpnaas.services.vpn import vpn_service |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
49 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
50 |
LOG = logging.getLogger(__name__) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
51 |
INTERNAL_DEV_PREFIX = 'l3i' |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
52 |
EXTERNAL_DEV_PREFIX = 'l3e' |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
53 |
FLOATING_IP_CIDR_SUFFIX = '/32' |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
54 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
55 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
56 |
class SolarisRouterInfo(router.RouterInfo): |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
57 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
58 |
def __init__(self, router_id, router, agent_conf, interface_driver, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
59 |
use_ipv6=False): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
60 |
super(SolarisRouterInfo, self).__init__(router_id, router, agent_conf, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
61 |
interface_driver, use_ipv6) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
62 |
self.ipfilters_manager = ipfilters_manager.IPfiltersManager() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
63 |
self.iptables_manager = None |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
64 |
self.remove_route = False |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
65 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
66 |
def initialize(self, process_monitor): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
67 |
"""Initialize the router on the system. |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
68 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
69 |
This differs from __init__ in that this method actually affects the |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
70 |
system creating namespaces, starting processes, etc. The other merely |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
71 |
initializes the python object. This separates in-memory object |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
72 |
initialization from methods that actually go do stuff to the system. |
3200
16d08ab96b7f
18686478 kstat warning every minute in nova-compute log on SPARC
david.comay@oracle.com
parents:
3196
diff
changeset
|
73 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
74 |
:param process_monitor: The agent's process monitor instance. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
75 |
""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
76 |
self.process_monitor = process_monitor |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
77 |
self.radvd = ra.NDPD(self.router_id, self.get_internal_device_name) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
78 |
|
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
79 |
def get_internal_device_name(self, port_id): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
80 |
# Because of the way how dnsmasq works on Solaris, the length |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
81 |
# of datalink name cannot exceed 16 (includes terminating nul |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
82 |
# character). So, the linkname can only have 15 characters and |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
83 |
# the last two characters are set aside for '_0'. So, we only |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
84 |
# have 13 characters left. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
85 |
dname = (INTERNAL_DEV_PREFIX + port_id)[:13] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
86 |
dname += '_0' |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
87 |
return dname.replace('-', '_') |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
88 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
89 |
def get_external_device_name(self, port_id): |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
90 |
# please see the comment above |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
91 |
dname = (EXTERNAL_DEV_PREFIX + port_id)[:13] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
92 |
dname += '_0' |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
93 |
return dname.replace('-', '_') |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
94 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
95 |
def routes_updated(self): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
96 |
pass |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
97 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
98 |
def _get_existing_devices(self): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
99 |
return net_lib.Datalink.show_link() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
100 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
101 |
def internal_network_added(self, port): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
102 |
internal_dlname = self.get_internal_device_name(port['id']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
103 |
# driver just returns if datalink and IP interface already exists |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
104 |
self.driver.plug(port['tenant_id'], port['network_id'], port['id'], |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
105 |
internal_dlname) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
106 |
ip_cidrs = common_utils.fixed_ip_cidrs(port['fixed_ips']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
107 |
self.driver.init_l3(internal_dlname, ip_cidrs) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
108 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
109 |
# Since we support shared router model, we need to block the new |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
110 |
# internal port from reaching other tenant's ports |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
111 |
block_pname = self._get_ippool_name(port['mac_address']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
112 |
self.ipfilters_manager.add_ippool(block_pname, None) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
113 |
if self.agent_conf.allow_forwarding_between_networks: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
114 |
# If allow_forwarding_between_networks is set, then we need to |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
115 |
# allow forwarding of packets between same tenant's ports. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
116 |
allow_pname = self._get_ippool_name(port['mac_address'], '0') |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
117 |
self.ipfilters_manager.add_ippool(allow_pname, None) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
118 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
119 |
# walk through the other internal ports and retrieve their |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
120 |
# cidrs and at the same time add the new internal port's |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
121 |
# cidr to them |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
122 |
port_subnet = port['subnets'][0]['cidr'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
123 |
block_subnets = [] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
124 |
allow_subnets = [] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
125 |
for internal_port in self.internal_ports: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
126 |
if internal_port['mac_address'] == port['mac_address']: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
127 |
continue |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
128 |
if (self.agent_conf.allow_forwarding_between_networks and |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
129 |
internal_port['tenant_id'] == port['tenant_id']): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
130 |
allow_subnets.append(internal_port['subnets'][0]['cidr']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
131 |
# we need to add the port's subnet to this internal_port's |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
132 |
# allowed_subnet_pool |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
133 |
iport_allow_pname = \ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
134 |
self._get_ippool_name(internal_port['mac_address'], '0') |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
135 |
self.ipfilters_manager.add_ippool(iport_allow_pname, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
136 |
[port_subnet]) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
137 |
else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
138 |
block_subnets.append(internal_port['subnets'][0]['cidr']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
139 |
iport_block_pname = \ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
140 |
self._get_ippool_name(internal_port['mac_address']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
141 |
self.ipfilters_manager.add_ippool(iport_block_pname, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
142 |
[port_subnet]) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
143 |
# update the new port's pool with other ports' subnet |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
144 |
self.ipfilters_manager.add_ippool(block_pname, block_subnets) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
145 |
if self.agent_conf.allow_forwarding_between_networks: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
146 |
self.ipfilters_manager.add_ippool(allow_pname, allow_subnets) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
147 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
148 |
# now setup the IPF rules |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
149 |
rules = ['block in quick on %s from %s to pool/%d' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
150 |
(internal_dlname, port_subnet, block_pname)] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
151 |
# pass in packets between networks that belong to same tenant |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
152 |
if self.agent_conf.allow_forwarding_between_networks: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
153 |
rules.append('pass in quick on %s from %s to pool/%d' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
154 |
(internal_dlname, port_subnet, allow_pname)) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
155 |
# if the external gateway is already setup for the shared router, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
156 |
# then we need to add Policy Based Routing (PBR) for this internal |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
157 |
# network |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
158 |
ex_gw_port = self.ex_gw_port |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
159 |
ex_gw_ip = (ex_gw_port['subnets'][0]['gateway_ip'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
160 |
if ex_gw_port else None) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
161 |
if ex_gw_ip: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
162 |
external_dlname = self.get_external_device_name(ex_gw_port['id']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
163 |
rules.append('pass in on %s to %s:%s from any to !%s' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
164 |
(internal_dlname, external_dlname, ex_gw_ip, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
165 |
port_subnet)) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
166 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
167 |
ipversion = netaddr.IPNetwork(port_subnet).version |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
168 |
self.ipfilters_manager.add_ipf_rules(rules, ipversion) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
169 |
if self.agent_conf.enable_metadata_proxy and ipversion == 4: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
170 |
rdr_rule = ['rdr %s 169.254.169.254/32 port 80 -> %s port %d tcp' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
171 |
(internal_dlname, port['fixed_ips'][0]['ip_address'], |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
172 |
self.agent_conf.metadata_port)] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
173 |
self.ipfilters_manager.add_nat_rules(rdr_rule) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
174 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
175 |
def internal_network_removed(self, port): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
176 |
internal_dlname = self.get_internal_device_name(port['id']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
177 |
port_subnet = port['subnets'][0]['cidr'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
178 |
# remove all the IP filter rules that we added during |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
179 |
# internal network addition |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
180 |
block_pname = self._get_ippool_name(port['mac_address']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
181 |
rules = ['block in quick on %s from %s to pool/%d' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
182 |
(internal_dlname, port_subnet, block_pname)] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
183 |
if self.agent_conf.allow_forwarding_between_networks: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
184 |
allow_pname = self._get_ippool_name(port['mac_address'], '0') |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
185 |
rules.append('pass in quick on %s from %s to pool/%d' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
186 |
(internal_dlname, port_subnet, allow_pname)) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
187 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
188 |
# remove all the IP filter rules that we added during |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
189 |
# external network addition |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
190 |
ex_gw_port = self.ex_gw_port |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
191 |
ex_gw_ip = (ex_gw_port['subnets'][0]['gateway_ip'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
192 |
if ex_gw_port else None) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
193 |
if ex_gw_ip: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
194 |
external_dlname = self.get_external_device_name(ex_gw_port['id']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
195 |
rules.append('pass in on %s to %s:%s from any to !%s' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
196 |
(internal_dlname, external_dlname, ex_gw_ip, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
197 |
port_subnet)) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
198 |
ipversion = netaddr.IPNetwork(port['subnets'][0]['cidr']).version |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
199 |
self.ipfilters_manager.remove_ipf_rules(rules, ipversion) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
200 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
201 |
# remove the ippool |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
202 |
self.ipfilters_manager.remove_ippool(block_pname, None) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
203 |
if self.agent_conf.allow_forwarding_between_networks: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
204 |
self.ipfilters_manager.remove_ippool(allow_pname, None) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
205 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
206 |
for internal_port in self.internal_ports: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
207 |
if (self.agent_conf.allow_forwarding_between_networks and |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
208 |
internal_port['tenant_id'] == port['tenant_id']): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
209 |
iport_allow_pname = \ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
210 |
self._get_ippool_name(internal_port['mac_address'], '0') |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
211 |
self.ipfilters_manager.remove_ippool(iport_allow_pname, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
212 |
[port_subnet]) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
213 |
else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
214 |
iport_block_pname = \ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
215 |
self._get_ippool_name(internal_port['mac_address']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
216 |
self.ipfilters_manager.remove_ippool(iport_block_pname, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
217 |
[port_subnet]) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
218 |
if self.agent_conf.enable_metadata_proxy and ipversion == 4: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
219 |
rdr_rule = ['rdr %s 169.254.169.254/32 port 80 -> %s port %d tcp' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
220 |
(internal_dlname, port['fixed_ips'][0]['ip_address'], |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
221 |
self.agent_conf.metadata_port)] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
222 |
self.ipfilters_manager.remove_nat_rules(rdr_rule) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
223 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
224 |
if net_lib.Datalink.datalink_exists(internal_dlname): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
225 |
self.driver.fini_l3(internal_dlname) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
226 |
self.driver.unplug(internal_dlname) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
227 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
228 |
def _process_internal_ports(self): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
229 |
existing_port_ids = set([p['id'] for p in self.internal_ports]) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
230 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
231 |
internal_ports = self.router.get(l3_constants.INTERFACE_KEY, []) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
232 |
current_port_ids = set([p['id'] for p in internal_ports |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
233 |
if p['admin_state_up']]) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
234 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
235 |
new_port_ids = current_port_ids - existing_port_ids |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
236 |
new_ports = [p for p in internal_ports if p['id'] in new_port_ids] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
237 |
old_ports = [p for p in self.internal_ports if |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
238 |
p['id'] not in current_port_ids] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
239 |
# updated_ports = self._get_updated_ports(self.internal_ports, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
240 |
# internal_ports) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
241 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
242 |
enable_ra = False |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
243 |
for p in new_ports: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
244 |
self.internal_network_added(p) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
245 |
self.internal_ports.append(p) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
246 |
enable_ra = enable_ra or self._port_has_ipv6_subnet(p) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
247 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
248 |
for p in old_ports: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
249 |
self.internal_network_removed(p) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
250 |
self.internal_ports.remove(p) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
251 |
enable_ra = enable_ra or self._port_has_ipv6_subnet(p) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
252 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
253 |
# if updated_ports: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
254 |
# for index, p in enumerate(internal_ports): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
255 |
# if not updated_ports.get(p['id']): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
256 |
# continue |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
257 |
# self.internal_ports[index] = updated_ports[p['id']] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
258 |
# interface_name = self.get_internal_device_name(p['id']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
259 |
# ip_cidrs = common_utils.fixed_ip_cidrs(p['fixed_ips']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
260 |
# self.driver.init_l3(interface_name, ip_cidrs=ip_cidrs, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
261 |
# namespace=self.ns_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
262 |
# enable_ra = enable_ra or self._port_has_ipv6_subnet(p) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
263 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
264 |
# Enable RA |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
265 |
if enable_ra: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
266 |
self.radvd.enable(internal_ports) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
267 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
268 |
# remove any internal stale router interfaces (i.e., l3i.. VNICs) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
269 |
existing_devices = self._get_existing_devices() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
270 |
current_internal_devs = set(n for n in existing_devices |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
271 |
if n.startswith(INTERNAL_DEV_PREFIX)) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
272 |
current_port_devs = set(self.get_internal_device_name(port_id) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
273 |
for port_id in current_port_ids) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
274 |
stale_devs = current_internal_devs - current_port_devs |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
275 |
for stale_dev in stale_devs: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
276 |
LOG.debug(_('Deleting stale internal router device: %s'), |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
277 |
stale_dev) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
278 |
self.driver.fini_l3(stale_dev) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
279 |
self.driver.unplug(stale_dev) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
280 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
281 |
def _get_ippool_name(self, mac_address, suffix=None): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
282 |
# Generate a unique-name for ippool(1m) from that last 3 |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
283 |
# bytes of mac-address. It is called pool name, but it is |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
284 |
# actually a 32 bit integer |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
285 |
name = mac_address.split(':')[3:] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
286 |
if suffix: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
287 |
name.append(suffix) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
288 |
return int("".join(name), 16) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
289 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
290 |
def process_floating_ip_addresses(self, interface_name): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
291 |
"""Configure IP addresses on router's external gateway interface. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
292 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
293 |
Ensures addresses for existing floating IPs and cleans up |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
294 |
those that should not longer be configured. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
295 |
""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
296 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
297 |
fip_statuses = {} |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
298 |
if interface_name is None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
299 |
LOG.debug('No Interface for floating IPs router: %s', |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
300 |
self.router['id']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
301 |
return fip_statuses |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
302 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
303 |
ipintf = net_lib.IPInterface(interface_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
304 |
ipaddr_list = ipintf.ipaddr_list()['static'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
305 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
306 |
existing_cidrs = set(ipaddr_list) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
307 |
new_cidrs = set() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
308 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
309 |
existing_nat_rules = [nat_rule for nat_rule in |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
310 |
self.ipfilters_manager.ipv4['nat']] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
311 |
new_nat_rules = [] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
312 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
313 |
floating_ips = self.get_floating_ips() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
314 |
# Loop once to ensure that floating ips are configured. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
315 |
for fip in floating_ips: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
316 |
fip_ip = fip['floating_ip_address'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
317 |
fip_cidr = str(fip_ip) + FLOATING_IP_CIDR_SUFFIX |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
318 |
new_cidrs.add(fip_cidr) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
319 |
fixed_cidr = str(fip['fixed_ip_address']) + '/32' |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
320 |
nat_rule = 'bimap %s %s -> %s' % (interface_name, fixed_cidr, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
321 |
fip_cidr) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
322 |
if fip_cidr not in existing_cidrs: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
323 |
try: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
324 |
ipintf.create_address(fip_cidr) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
325 |
self.ipfilters_manager.add_nat_rules([nat_rule]) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
326 |
except Exception as err: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
327 |
# TODO(gmoodalb): If we fail in add_nat_rules(), then |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
328 |
# we need to remove the fip_cidr address |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
329 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
330 |
# any exception occurred here should cause the floating IP |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
331 |
# to be set in error state |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
332 |
fip_statuses[fip['id']] = ( |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
333 |
l3_constants.FLOATINGIP_STATUS_ERROR) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
334 |
LOG.warn(_("Unable to configure IP address for " |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
335 |
"floating IP: %s: %s") % (fip['id'], err)) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
336 |
continue |
6444
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
337 |
else: |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
338 |
# check if existing fip has been reassigned |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
339 |
fip_reassigned = False |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
340 |
for rule in existing_nat_rules: |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
341 |
if not rule.startswith('bimap'): |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
342 |
continue |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
343 |
if fip_ip not in rule: |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
344 |
continue |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
345 |
if fixed_cidr not in rule: |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
346 |
fip_reassigned = True |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
347 |
break |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
348 |
|
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
349 |
if fip_reassigned: |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
350 |
LOG.debug("Floating ip '%s' reassigned to '%s'", |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
351 |
fip_ip, fip['fixed_ip_address']) |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
352 |
# remove the old nat rule and |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
353 |
# add a new one for the new fixed_ip |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
354 |
try: |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
355 |
self.ipfilters_manager.remove_nat_rules([rule]) |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
356 |
existing_nat_rules.remove(rule) |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
357 |
self.ipfilters_manager.add_nat_rules([nat_rule]) |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
358 |
except Exception as err: |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
359 |
fip_statuses[fip['id']] = ( |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
360 |
l3_constants.FLOATINGIP_STATUS_ERROR) |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
361 |
LOG.warn(_("Unable to configure IP address for " |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
362 |
"floating IP: %s: %s") % (fip['id'], err)) |
bf62eba2612a
23506589 Need to modify args passed to dnsmasq in solaris/dhcp.py
Vardhnee Ramanujam Ravi <vardhnee.ramanujam.ravi@oracle.com>
parents:
6035
diff
changeset
|
363 |
continue |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
364 |
fip_statuses[fip['id']] = ( |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
365 |
l3_constants.FLOATINGIP_STATUS_ACTIVE) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
366 |
LOG.debug("Floating ip %(id)s added, status %(status)s", |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
367 |
{'id': fip['id'], |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
368 |
'status': fip_statuses.get(fip['id'])}) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
369 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
370 |
new_nat_rules.append(nat_rule) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
371 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
372 |
# remove all the old NAT rules |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
373 |
old_nat_rules = list(set(existing_nat_rules) - set(new_nat_rules)) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
374 |
# Filter out 'bimap' NAT rules as we don't want to remove NAT rules |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
375 |
# that were added for Metadata server |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
376 |
old_nat_rules = [rule for rule in old_nat_rules if "bimap" in rule] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
377 |
self.ipfilters_manager.remove_nat_rules(old_nat_rules) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
378 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
379 |
# Clean up addresses that no longer belong on the gateway interface. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
380 |
for ip_cidr in existing_cidrs - new_cidrs: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
381 |
if ip_cidr.endswith(FLOATING_IP_CIDR_SUFFIX): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
382 |
ipintf.delete_address(ip_cidr) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
383 |
return fip_statuses |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
384 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
385 |
# Todo(gmoodalb): need to do more work on ipv6 gateway |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
386 |
def external_gateway_added(self, ex_gw_port, external_dlname): |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
387 |
|
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
388 |
if not net_lib.Datalink.datalink_exists(external_dlname): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
389 |
dl = net_lib.Datalink(external_dlname) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
390 |
# determine the network type of the external network |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
391 |
evsname = ex_gw_port['network_id'] |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
392 |
cmd = ['/usr/sbin/evsadm', 'show-evs', '-co', 'l2type,vid', |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
393 |
'-f', 'evs=%s' % evsname] |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
394 |
try: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
395 |
stdout = utils.execute(cmd) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
396 |
except Exception as err: |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
397 |
LOG.error(_("Failed to retrieve the network type for " |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
398 |
"the external network, and it is required " |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
399 |
"to create an external gateway port: %s") % err) |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
400 |
return |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
401 |
output = stdout.splitlines()[0].strip() |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
402 |
l2type, vid = output.split(':') |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
403 |
if l2type != 'flat' and l2type != 'vlan': |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
404 |
LOG.error(_("External network should be either Flat or " |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
405 |
"VLAN based, and it is required to " |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
406 |
"create an external gateway port")) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
407 |
return |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
408 |
elif (l2type == 'vlan' and |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
409 |
self.agent_conf.get("external_network_datalink", None)): |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
410 |
LOG.warning(_("external_network_datalink is deprecated in " |
4430
5858809d8d01
21086485 neutron-l3-agent service should not report online if trace dump happened
saurabh.vyas@oracle.com
parents:
4072
diff
changeset
|
411 |
"Juno and will be removed in the next release " |
5858809d8d01
21086485 neutron-l3-agent service should not report online if trace dump happened
saurabh.vyas@oracle.com
parents:
4072
diff
changeset
|
412 |
"of Solaris OpenStack. Please use the evsadm " |
5858809d8d01
21086485 neutron-l3-agent service should not report online if trace dump happened
saurabh.vyas@oracle.com
parents:
4072
diff
changeset
|
413 |
"set-controlprop subcommand to setup the " |
5858809d8d01
21086485 neutron-l3-agent service should not report online if trace dump happened
saurabh.vyas@oracle.com
parents:
4072
diff
changeset
|
414 |
"uplink-port for an external network")) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
415 |
# proceed with the old-style of doing things |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
416 |
mac_address = ex_gw_port['mac_address'] |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
417 |
dl.create_vnic(self.agent_conf.external_network_datalink, |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
418 |
mac_address=mac_address, vid=vid) |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
419 |
else: |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
420 |
self.driver.plug(ex_gw_port['tenant_id'], |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
421 |
ex_gw_port['network_id'], |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
422 |
ex_gw_port['id'], external_dlname) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
423 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
424 |
ip_cidrs = common_utils.fixed_ip_cidrs(ex_gw_port['fixed_ips']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
425 |
self.driver.init_l3(external_dlname, ip_cidrs) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
426 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
427 |
gw_ip = ex_gw_port['subnets'][0]['gateway_ip'] |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
428 |
if gw_ip: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
429 |
cmd = ['/usr/bin/pfexec', '/usr/sbin/route', 'add', 'default', |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
430 |
gw_ip] |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
431 |
stdout = utils.execute(cmd, extra_ok_codes=[errno.EEXIST]) |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
432 |
if 'entry exists' not in stdout: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
433 |
self.remove_route = True |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
434 |
|
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
435 |
# for each of the internal ports, add Policy Based |
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
436 |
# Routing (PBR) rule |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
437 |
for port in self.internal_ports: |
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
438 |
internal_dlname = self.get_internal_device_name(port['id']) |
3435
25a421888935
19898528 PBR rule must not forward packets addressed to internal default gateway
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3323
diff
changeset
|
439 |
rules = ['pass in on %s to %s:%s from any to !%s' % |
25a421888935
19898528 PBR rule must not forward packets addressed to internal default gateway
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3323
diff
changeset
|
440 |
(internal_dlname, external_dlname, gw_ip, |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
441 |
port['subnets'][0]['cidr'])] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
442 |
ipversion = \ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
443 |
netaddr.IPNetwork(port['subnets'][0]['cidr']).version |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
444 |
self.ipfilters_manager.add_ipf_rules(rules, ipversion) |
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
445 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
446 |
def external_gateway_updated(self, ex_gw_port, external_dlname): |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
447 |
# There is nothing to do on Solaris |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
448 |
pass |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
449 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
450 |
def external_gateway_removed(self, ex_gw_port, external_dlname): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
451 |
gw_ip = ex_gw_port['subnets'][0]['gateway_ip'] |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3028
diff
changeset
|
452 |
if gw_ip: |
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
453 |
# remove PBR rules |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
454 |
for port in self.internal_ports: |
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
455 |
internal_dlname = self.get_internal_device_name(port['id']) |
3435
25a421888935
19898528 PBR rule must not forward packets addressed to internal default gateway
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3323
diff
changeset
|
456 |
rules = ['pass in on %s to %s:%s from any to !%s' % |
25a421888935
19898528 PBR rule must not forward packets addressed to internal default gateway
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3323
diff
changeset
|
457 |
(internal_dlname, external_dlname, gw_ip, |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
458 |
port['subnets'][0]['cidr'])] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
459 |
ipversion = \ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
460 |
netaddr.IPNetwork(port['subnets'][0]['cidr']).version |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
461 |
self.ipfilters_manager.remove_ipf_rules(rules, ipversion) |
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
462 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
463 |
if self.remove_route: |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
464 |
cmd = ['/usr/bin/pfexec', '/usr/sbin/route', 'delete', |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
465 |
'default', gw_ip] |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
466 |
utils.execute(cmd, check_exit_code=False) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
467 |
|
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
468 |
if net_lib.Datalink.datalink_exists(external_dlname): |
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
469 |
self.driver.fini_l3(external_dlname) |
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
470 |
self.driver.unplug(external_dlname) |
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
471 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
472 |
def _process_external_gateway(self, ex_gw_port): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
473 |
# TODO(Carl) Refactor to clarify roles of ex_gw_port vs self.ex_gw_port |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
474 |
ex_gw_port_id = (ex_gw_port and ex_gw_port['id'] or |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
475 |
self.ex_gw_port and self.ex_gw_port['id']) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
476 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
477 |
interface_name = None |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
478 |
if ex_gw_port_id: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
479 |
interface_name = self.get_external_device_name(ex_gw_port_id) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
480 |
if ex_gw_port: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
481 |
def _gateway_ports_equal(port1, port2): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
482 |
def _get_filtered_dict(d, ignore): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
483 |
return dict((k, v) for k, v in d.iteritems() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
484 |
if k not in ignore) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
485 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
486 |
keys_to_ignore = set(['binding:host_id']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
487 |
port1_filtered = _get_filtered_dict(port1, keys_to_ignore) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
488 |
port2_filtered = _get_filtered_dict(port2, keys_to_ignore) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
489 |
return port1_filtered == port2_filtered |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
490 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
491 |
if not self.ex_gw_port: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
492 |
self.external_gateway_added(ex_gw_port, interface_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
493 |
elif not _gateway_ports_equal(ex_gw_port, self.ex_gw_port): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
494 |
self.external_gateway_updated(ex_gw_port, interface_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
495 |
elif not ex_gw_port and self.ex_gw_port: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
496 |
self.external_gateway_removed(self.ex_gw_port, interface_name) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
497 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
498 |
# Remove any external stale router interfaces (i.e., l3e.. VNICs) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
499 |
existing_devices = self._get_existing_devices() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
500 |
stale_devs = [dev for dev in existing_devices |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
501 |
if dev.startswith(EXTERNAL_DEV_PREFIX) and |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
502 |
dev != interface_name] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
503 |
for stale_dev in stale_devs: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
504 |
LOG.debug(_('Deleting stale external router device: %s'), |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
505 |
stale_dev) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
506 |
self.driver.fini_l3(stale_dev) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
507 |
self.driver.unplug(stale_dev) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
508 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
509 |
# Process SNAT rules for external gateway |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
510 |
self.perform_snat_action(self._handle_router_snat_rules, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
511 |
interface_name) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
512 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
513 |
def external_gateway_snat_rules(self, ex_gw_ip, interface_name): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
514 |
rules = [] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
515 |
ip_cidrs = [] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
516 |
for port in self.internal_ports: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
517 |
if netaddr.IPNetwork(port['subnets'][0]['cidr']).version == 4: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
518 |
ip_cidrs.extend(common_utils.fixed_ip_cidrs(port['fixed_ips'])) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
519 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
520 |
for ip_cidr in ip_cidrs: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
521 |
rules.append('map %s %s -> %s/32' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
522 |
(interface_name, ip_cidr, ex_gw_ip)) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
523 |
return rules |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
524 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
525 |
def _handle_router_snat_rules(self, ex_gw_port, interface_name, action): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
526 |
# Remove all the old SNAT rules |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
527 |
# This is safe because if use_namespaces is set as False |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
528 |
# then the agent can only configure one router, otherwise |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
529 |
# each router's SNAT rules will be in their own namespace |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
530 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
531 |
# get only the SNAT rules |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
532 |
old_snat_rules = [rule for rule in self.ipfilters_manager.ipv4['nat'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
533 |
if rule.startswith('map')] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
534 |
self.ipfilters_manager.remove_nat_rules(old_snat_rules) |
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
535 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
536 |
# And add them back if the action is add_rules |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
537 |
if action == 'add_rules' and ex_gw_port: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
538 |
# NAT rules are added only if ex_gw_port has an IPv4 address |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
539 |
for ip_addr in ex_gw_port['fixed_ips']: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
540 |
ex_gw_ip = ip_addr['ip_address'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
541 |
if netaddr.IPAddress(ex_gw_ip).version == 4: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
542 |
rules = self.external_gateway_snat_rules(ex_gw_ip, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
543 |
interface_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
544 |
self.ipfilters_manager.add_nat_rules(rules) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
545 |
break |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3435
diff
changeset
|
546 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
547 |
def process_external(self, agent): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
548 |
existing_floating_ips = self.floating_ips |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
549 |
try: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
550 |
ex_gw_port = self.get_ex_gw_port() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
551 |
self._process_external_gateway(ex_gw_port) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
552 |
# TODO(Carl) Return after setting existing_floating_ips and |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
553 |
# still call update_fip_statuses? |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
554 |
if not ex_gw_port: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
555 |
return |
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
556 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
557 |
# Once NAT rules for floating IPs are safely in place |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
558 |
# configure their addresses on the external gateway port |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
559 |
interface_name = self.get_external_device_name(ex_gw_port['id']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
560 |
fip_statuses = self.configure_fip_addresses(interface_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
561 |
except (n_exc.FloatingIpSetupException, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
562 |
n_exc.IpTablesApplyException) as e: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
563 |
# All floating IPs must be put in error state |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
564 |
LOG.exception(e) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
565 |
fip_statuses = self.put_fips_in_error_state() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
566 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
567 |
agent.update_fip_statuses(self, existing_floating_ips, fip_statuses) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
568 |
|
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
569 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
570 |
class EVSL3NATAgent(l3_agent.L3NATAgentWithStateReport): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
571 |
OPTS = [ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
572 |
cfg.StrOpt('external_network_datalink', default='net0', |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
573 |
help=_("Name of the datalink that connects to " |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
574 |
"an external network.")), |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
575 |
cfg.BoolOpt('allow_forwarding_between_networks', default=False, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
576 |
help=_("Allow forwarding of packets between tenant's " |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
577 |
"networks")), |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
578 |
] |
3323
b4b74d363c31
19571319 datalink protection kicks in if L3 agent and DHCP agent are on the same m/c
Girish Moodalbail <Girish.Moodalbail@oracle.COM>
parents:
3200
diff
changeset
|
579 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
580 |
def __init__(self, host, conf=None): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
581 |
cfg.CONF.register_opts(self.OPTS) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
582 |
cfg.CONF.register_opts(interface.OPTS) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
583 |
super(EVSL3NATAgent, self).__init__(host=host, conf=conf) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
584 |
cfg.CONF.register_opts(neutron_vpnaas.vpn_agent_opts, 'vpnagent') |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
585 |
self.service = vpn_service.VPNService(self) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
586 |
self.device_drivers = self.service.load_device_drivers(host) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
587 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
588 |
def _router_added(self, router_id, router): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
589 |
args = [] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
590 |
kwargs = { |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
591 |
'router_id': router_id, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
592 |
'router': router, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
593 |
'use_ipv6': self.use_ipv6, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
594 |
'agent_conf': self.conf, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
595 |
'interface_driver': self.driver, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
596 |
} |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
597 |
ri = SolarisRouterInfo(*args, **kwargs) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
598 |
registry.notify(resources.ROUTER, events.BEFORE_CREATE, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
599 |
self, router=ri) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
600 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
601 |
self.router_info[router_id] = ri |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
602 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4647
diff
changeset
|
603 |
ri.initialize(self.process_monitor) |