Dragonflow L3 Agent for distributed DNAT

Current Dragonflow will support only distributed DNAT, both the SNAT and the
centralized fip will be implmented with the centralized Dragonflow L3 agent
on network node.

The distributed fip of dvr will be implemented by local Dragonflow controller.

Change-Id: I18e16e4b96a4600acc4854b73f45f917393306df
This commit is contained in:
Fei Rao 2016-03-17 22:42:47 -04:00
parent 8e9d0f5f07
commit 9b55f16106
11 changed files with 158 additions and 3 deletions

View File

@ -112,6 +112,9 @@ function configure_df_plugin {
iniset $NEUTRON_CONF df enable_df_pub_sub "$DF_PUB_SUB"
iniset $NEUTRON_CONF df pub_sub_use_multiproc "$DF_PUB_SUB_USE_MULTIPROC"
iniset $NEUTRON_CONF df publishers_ips "$PUBLISHERS_HOSTS"
iniset $NEUTRON_CONF df_dnat_app external_network_bridge "br-ex"
iniset $NEUTRON_CONF df_dnat_app int_peer_patch_port "patch-ex"
iniset $NEUTRON_CONF df_dnat_app ex_peer_patch_port "patch-int"
iniset $NEUTRON_CONF DEFAULT advertise_mtu "True"
iniset $NEUTRON_CONF DEFAULT core_plugin "$Q_PLUGIN_CLASS"
iniset $NEUTRON_CONF DEFAULT service_plugins ""
@ -154,6 +157,9 @@ function configure_df_plugin {
iniset $NEUTRON_CONF df_l2_app l2_responder "$DF_L2_RESPONDER"
iniset $NEUTRON_CONF df enable_df_pub_sub "$DF_PUB_SUB"
iniset $NEUTRON_CONF df publishers_ips "$PUBLISHERS_HOSTS"
iniset $NEUTRON_CONF df_dnat_app external_network_bridge "br-ex"
iniset $NEUTRON_CONF df_dnat_app int_peer_patch_port "patch-ex"
iniset $NEUTRON_CONF df_dnat_app ex_peer_patch_port "patch-int"
fi
}
@ -398,6 +404,23 @@ function stop_pubsub_service {
stop_process df-publisher-service
}
# start_df_l3_agent() - Start running processes, including screen
function start_df_l3_agent {
echo "Starting Dragonflow l3 agent"
if is_service_enabled df-l3-agent ; then
_configure_neutron_l3_agent
run_process df-l3-agent "python $DF_L3_BINARY --config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE"
fi
}
# stop_df_l3_agent() - Stop running processes (non-screen)
function stop_df_l3_agent {
if is_service_enabled df-l3-agent ; then
stop_process df-l3-agent
fi
}
# main loop
if [[ "$Q_ENABLE_DRAGONFLOW_LOCAL_CONTROLLER" == "True" ]]; then
if [[ "$1" == "stack" && "$2" == "install" ]]; then
@ -431,6 +454,8 @@ if [[ "$Q_ENABLE_DRAGONFLOW_LOCAL_CONTROLLER" == "True" ]]; then
if is_service_enabled df-publisher-service; then
start_pubsub_service
fi
start_df_l3_agent
start_df
fi
@ -441,5 +466,7 @@ if [[ "$Q_ENABLE_DRAGONFLOW_LOCAL_CONTROLLER" == "True" ]]; then
if [[ "$DF_PUB_SUB" == "True" ]]; then
stop_pubsub_service
fi
stop_df_l3_agent
fi
fi

View File

@ -4,9 +4,8 @@ DRAGONFLOW_BRANCH=${DRAGONFLOW_BRANCH:-master}
DF_L3_SERVICE_PLUGIN="dragonflow.neutron.services.l3.l3_controller_plugin.ControllerL3ServicePlugin"
DF_L2_AGENT=$DRAGONFLOW_DIR/dragonflow/neutron/agent/l2/ovs_dragonflow_neutron_agent.py
DF_L3_AGENT=$DRAGONFLOW_DIR/dragonflow/neutron/agent/l3_sdn_agent.py
DF_LOCAL_CONTROLLER=$DRAGONFLOW_DIR/dragonflow/controller/df_local_controller.py
DF_L3_BINARY=${DF_L3_BINARY:-"$NEUTRON_BIN_DIR/df-l3-agent"}
DF_L2_RESPONDER=${DF_L2_RESPONDER:-'True'}

View File

@ -1,3 +1,15 @@
#
# Sample DevStack local.conf.
#
# Network node is a logic node of Neutron, it can be deployed on the same host node
# with a controller node or compute node. Of course it can be deployed on an
# independent host node too.
# Wherever the network is deployed, you need to enable the df-l3-agent insteading
# of neutron-l3-agent.
# This sample file is intended to be used when df-l3-agent is deployed on the
# controller node.
[[local|localrc]]
Q_ENABLE_DRAGONFLOW_LOCAL_CONTROLLER=True
@ -17,7 +29,7 @@ enable_service df-zmq-publisher-service
disable_service n-net
enable_service q-svc
enable_service q-l3
enable_service df-l3-agent
disable_service heat
disable_service tempest
@ -29,3 +41,7 @@ disable_service q-agt
# We have to disable the neutron dhcp agent. DF does not use the dhcp agent.
disable_service q-dhcp
[[post-config|$NEUTRON_CONF]]
[DEFAULT]
router_distributed=True

View File

View File

@ -0,0 +1,15 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from neutron.common import eventlet_utils
eventlet_utils.monkey_patch()

View File

@ -0,0 +1,18 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from dragonflow.neutron.agent import df_l3_agent
def main():
df_l3_agent.main()

View File

View File

@ -0,0 +1,21 @@
# Copyright (c) 2015 OpenStack Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from neutron.agent import l3_agent
def main(manager='dragonflow.neutron.agent.l3.df_router.'
'DfL3NATAgentWithStateReport'):
l3_agent.main(manager)

View File

View File

@ -0,0 +1,58 @@
# Copyright (c) 2015 OpenStack Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from neutron.agent.l3 import agent
from neutron.agent.l3 import legacy_router
class DfDvrRouter(legacy_router.LegacyRouter):
def add_floating_ip(self, fip, interface_name, device):
if is_distributed_router(self.router):
return
return super(DfDvrRouter, self).add_floating_ip(
fip, interface_name, device)
def remove_floating_ip(self, device, ip_cidr):
if is_distributed_router(self.router):
return
super(DfDvrRouter, self).remove_floating_ip(
device, ip_cidr)
def process_snat_dnat_for_fip(self):
if is_distributed_router(self.router):
return
super(DfDvrRouter, self).process_snat_dnat_for_fip()
class DfL3NATAgentWithStateReport(agent.L3NATAgentWithStateReport):
def _create_router(self, router_id, router):
args = []
kwargs = {
'router_id': router_id,
'router': router,
'use_ipv6': self.use_ipv6,
'agent_conf': self.conf,
'interface_driver': self.driver,
}
if is_distributed_router(router):
return DfDvrRouter(*args, **kwargs)
return super(DfL3NATAgentWithStateReport, self)._create_router(
router_id, router)
def is_distributed_router(router):
return router.get('distributed', False)

View File

@ -50,6 +50,7 @@ neutron.db.alembic_migrations =
dragonflow = dragonflow.db.neutron.migration:alembic_migrations
console_scripts =
df-db = dragonflow.cli.df_db:main
df-l3-agent = dragonflow.cmd.eventlet.df_l3_agent:main
dragonflow.pubsub_driver =
zmq_pubsub_driver = dragonflow.db.pubsub_drivers.zmq_pubsub_driver:ZMQPubSub
zmq_pubsub_multiproc_driver = dragonflow.db.pubsub_drivers.zmq_pubsub_driver:ZMQPubSubMultiproc