From 7eb5abdf4e3455ff094ba270e1d141a6595a2e9c Mon Sep 17 00:00:00 2001 From: Li Ma Date: Sat, 12 Dec 2015 20:31:39 +0800 Subject: [PATCH] Remove explicit eventlet.monkey_patch() Change-Id: Idacf87355d6efabcd0d2714f05b4285ac39ad08b Closes-Bug: #1522784 Related-Bug: #1568220 --- devstack/plugin.sh | 14 ++++++++------ devstack/settings | 5 +++-- dragonflow/cmd/eventlet/df_local_controller.py | 17 +++++++++++++++++ dragonflow/cmd/eventlet/df_publisher_service.py | 17 +++++++++++++++++ dragonflow/common/utils.py | 2 -- dragonflow/controller/df_local_controller.py | 7 ------- dragonflow/controller/df_publisher_service.py | 6 +----- dragonflow/db/api_nb.py | 2 -- dragonflow/db/neutron/lockedobjects_db.py | 3 --- .../db/pubsub_drivers/redis_db_pubsub_driver.py | 3 +-- dragonflow/tests/__init__.py | 15 +++++++++++++++ setup.cfg | 2 ++ 12 files changed, 64 insertions(+), 29 deletions(-) create mode 100644 dragonflow/cmd/eventlet/df_local_controller.py create mode 100644 dragonflow/cmd/eventlet/df_publisher_service.py diff --git a/devstack/plugin.sh b/devstack/plugin.sh index dd8ece95b..a0c049196 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -290,7 +290,7 @@ function start_df { if is_service_enabled df-controller ; then sudo ovs-vsctl --no-wait set-controller br-int tcp:$HOST_IP:6633 - run_process df-controller "python $DF_LOCAL_CONTROLLER --config-file $NEUTRON_CONF" + run_process df-controller "$DF_LOCAL_CONTROLLER_BINARY --config-file $NEUTRON_CONF" run_process df-ext-services "bash $DEST/dragonflow/devstack/df-ext-services.sh" fi } @@ -331,14 +331,16 @@ function verify_ryu_version { } function start_pubsub_service { - PUBLISHER_SERVICE=$DRAGONFLOW_DIR/dragonflow/controller/df_publisher_service.py - set python $PUBLISHER_SERVICE - set "$@" --config-file $NEUTRON_CONF - run_process df-publisher-service "$*" + echo "Starting Dragonflow publisher service" + if is_service_enabled df-publisher-service ; then + run_process df-publisher-service "$DF_PUBLISHER_SERVICE_BINARY --config-file $NEUTRON_CONF" + fi } function stop_pubsub_service { - stop_process df-publisher-service + if is_service_enabled df-publisher-service ; then + stop_process df-publisher-service + fi } # main loop diff --git a/devstack/settings b/devstack/settings index afe818f54..c5f6cc0ae 100644 --- a/devstack/settings +++ b/devstack/settings @@ -8,8 +8,9 @@ DRAGONFLOW_BRANCH=${DRAGONFLOW_BRANCH:-master} DF_L3_SERVICE_PLUGIN="dragonflow.neutron.services.l3.l3_controller_plugin.ControllerL3ServicePlugin" -DF_LOCAL_CONTROLLER=$DRAGONFLOW_DIR/dragonflow/controller/df_local_controller.py -DF_L3_BINARY=${DF_L3_BINARY:-"$NEUTRON_BIN_DIR/df-l3-agent"} +DF_L3_BINARY=$NEUTRON_BIN_DIR/df-l3-agent +DF_LOCAL_CONTROLLER_BINARY=$NEUTRON_BIN_DIR/df-local-controller +DF_PUBLISHER_SERVICE_BINARY=$NEUTRON_BIN_DIR/df-publisher-service DF_L2_RESPONDER=${DF_L2_RESPONDER:-'True'} diff --git a/dragonflow/cmd/eventlet/df_local_controller.py b/dragonflow/cmd/eventlet/df_local_controller.py new file mode 100644 index 000000000..384c398d7 --- /dev/null +++ b/dragonflow/cmd/eventlet/df_local_controller.py @@ -0,0 +1,17 @@ +# 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.controller import df_local_controller + + +def main(): + df_local_controller.main() diff --git a/dragonflow/cmd/eventlet/df_publisher_service.py b/dragonflow/cmd/eventlet/df_publisher_service.py new file mode 100644 index 000000000..25ab8698d --- /dev/null +++ b/dragonflow/cmd/eventlet/df_publisher_service.py @@ -0,0 +1,17 @@ +# 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.controller import df_publisher_service + + +def main(): + df_publisher_service.main() diff --git a/dragonflow/common/utils.py b/dragonflow/common/utils.py index e13e721fb..c1d4a8962 100644 --- a/dragonflow/common/utils.py +++ b/dragonflow/common/utils.py @@ -29,8 +29,6 @@ import six DF_PUBSUB_DRIVER_NAMESPACE = 'dragonflow.pubsub_driver' LOG = logging.getLogger(__name__) -eventlet.monkey_patch() - def load_driver(driver_cfg, namespace): try: diff --git a/dragonflow/controller/df_local_controller.py b/dragonflow/controller/df_local_controller.py index 7b2df26bc..58345adf1 100644 --- a/dragonflow/controller/df_local_controller.py +++ b/dragonflow/controller/df_local_controller.py @@ -17,8 +17,6 @@ import socket import sys import time -import eventlet - from oslo_config import cfg from oslo_log import log from oslo_utils import importutils @@ -40,8 +38,6 @@ from ryu.base.app_manager import AppManager config.setup_logging() LOG = log.getLogger("dragonflow.controller.df_local_controller") -eventlet.monkey_patch() - cfg.CONF.register_opts(common_params.df_opts, 'df') @@ -538,6 +534,3 @@ def main(): common_config.init(sys.argv[1:]) controller = DfLocalController(chassis_name) controller.run() - -if __name__ == "__main__": - main() diff --git a/dragonflow/controller/df_publisher_service.py b/dragonflow/controller/df_publisher_service.py index 04c1d655e..c10fd1b47 100644 --- a/dragonflow/controller/df_publisher_service.py +++ b/dragonflow/controller/df_publisher_service.py @@ -11,7 +11,7 @@ # under the License. import eventlet -from Queue import Queue +from eventlet.queue import Queue import sys import time import traceback @@ -31,7 +31,6 @@ from dragonflow.common import utils as df_utils from dragonflow.db import db_common from dragonflow.db import pub_sub_api -eventlet.monkey_patch() LOG = logging.getLogger(__name__) @@ -156,6 +155,3 @@ def main(): service = PublisherService() service.initialize() service.run() - -if __name__ == "__main__": - main() diff --git a/dragonflow/db/api_nb.py b/dragonflow/db/api_nb.py index 556175237..99c82eb63 100644 --- a/dragonflow/db/api_nb.py +++ b/dragonflow/db/api_nb.py @@ -30,8 +30,6 @@ from dragonflow.db.db_common import DbUpdate, SEND_ALL_TOPIC, \ DB_SYNC_MINIMUM_INTERVAL from dragonflow.db import pub_sub_api -eventlet.monkey_patch() - LOG = log.getLogger(__name__) diff --git a/dragonflow/db/neutron/lockedobjects_db.py b/dragonflow/db/neutron/lockedobjects_db.py index f0067c7c7..3970c6b80 100644 --- a/dragonflow/db/neutron/lockedobjects_db.py +++ b/dragonflow/db/neutron/lockedobjects_db.py @@ -13,9 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import eventlet -eventlet.monkey_patch() - import inspect import random diff --git a/dragonflow/db/pubsub_drivers/redis_db_pubsub_driver.py b/dragonflow/db/pubsub_drivers/redis_db_pubsub_driver.py index a7fed790c..37c40d182 100644 --- a/dragonflow/db/pubsub_drivers/redis_db_pubsub_driver.py +++ b/dragonflow/db/pubsub_drivers/redis_db_pubsub_driver.py @@ -21,9 +21,8 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils import redis -LOG = logging.getLogger(__name__) -eventlet.monkey_patch() +LOG = logging.getLogger(__name__) cfg.CONF.register_opts(common_params.df_opts, 'df') diff --git a/dragonflow/tests/__init__.py b/dragonflow/tests/__init__.py index e69de29bb..01f9f6933 100644 --- a/dragonflow/tests/__init__.py +++ b/dragonflow/tests/__init__.py @@ -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() diff --git a/setup.cfg b/setup.cfg index 770178630..9f22d50d4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -50,6 +50,8 @@ neutron.db.alembic_migrations = dragonflow = dragonflow.db.neutron.migration:alembic_migrations console_scripts = df-db = dragonflow.cli.df_db:main + df-local-controller = dragonflow.cmd.eventlet.df_local_controller:main + df-publisher-service = dragonflow.cmd.eventlet.df_publisher_service: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