From 2337fab0979b72bbc7e7730e94518a0e835a2751 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Mon, 25 Oct 2010 03:45:19 +0900 Subject: part way through porting the codebase off of twisted this provides a very basic eventlet-based service replacement for the twistd-based services, a replacement for task.LoopingCall also adds nova-combined with the goal of running a single service when doing local testing and dev --- bin/nova-combined | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 bin/nova-combined (limited to 'bin/nova-combined') diff --git a/bin/nova-combined b/bin/nova-combined new file mode 100755 index 000000000..65865acd9 --- /dev/null +++ b/bin/nova-combined @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" + Twistd daemon for the nova compute nodes. +""" + +import eventlet +eventlet.monkey_patch() + +import os +import sys + +from eventlet import greenthread + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + +from nova import api +from nova import flags +from nova import service_eventlet +from nova import wsgi + + +FLAGS = flags.FLAGS +flags.DEFINE_integer('api_port', 8773, 'API port') + + +if __name__ == '__main__': + FLAGS(sys.argv) + + compute = service_eventlet.Service.create(binary='nova-compute') + network = service_eventlet.Service.create(binary='nova-network') + volume = service_eventlet.Service.create(binary='nova-volume') + scheduler = service_eventlet.Service.create(binary='nova-scheduler') + #objectstore = service_eventlet.Service.create(binary='nova-objectstore') + + service_eventlet.serve(compute, network, volume, scheduler) + wsgi.run_server(api.API(), FLAGS.api_port) + -- cgit From 00f329d479564ad8349ed32a27990da2ed3a396e Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Thu, 9 Dec 2010 14:36:23 -0800 Subject: make nova binaries use eventlet --- bin/nova-combined | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'bin/nova-combined') diff --git a/bin/nova-combined b/bin/nova-combined index 65865acd9..c86584328 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -27,8 +27,6 @@ eventlet.monkey_patch() import os import sys -from eventlet import greenthread - # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -46,6 +44,12 @@ from nova import wsgi FLAGS = flags.FLAGS flags.DEFINE_integer('api_port', 8773, 'API port') +FLAGS = flags.FLAGS +flags.DEFINE_integer('osapi_port', 8774, 'OpenStack API port') +flags.DEFINE_string('osapi_host', '0.0.0.0', 'OpenStack API host') +flags.DEFINE_integer('ec2api_port', 8773, 'EC2 API port') +flags.DEFINE_string('ec2api_host', '0.0.0.0', 'EC2 API host') + if __name__ == '__main__': FLAGS(sys.argv) @@ -57,5 +61,9 @@ if __name__ == '__main__': #objectstore = service_eventlet.Service.create(binary='nova-objectstore') service_eventlet.serve(compute, network, volume, scheduler) - wsgi.run_server(api.API(), FLAGS.api_port) + + server = wsgi.Server() + server.start(api.API('os'), FLAGS.osapi_port, host=FLAGS.osapi_host) + server.start(api.API('ec2'), FLAGS.ec2api_port, host=FLAGS.ec2api_host) + server.wait() -- cgit From b3f5aba0c465b263c1d0a15c7d249dafb3a98e6c Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Thu, 9 Dec 2010 15:25:14 -0800 Subject: remove service and rename service_eventlet to service --- bin/nova-combined | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'bin/nova-combined') diff --git a/bin/nova-combined b/bin/nova-combined index c86584328..c70d1d9ef 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -37,7 +37,7 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import api from nova import flags -from nova import service_eventlet +from nova import service from nova import wsgi @@ -54,13 +54,13 @@ flags.DEFINE_string('ec2api_host', '0.0.0.0', 'EC2 API host') if __name__ == '__main__': FLAGS(sys.argv) - compute = service_eventlet.Service.create(binary='nova-compute') - network = service_eventlet.Service.create(binary='nova-network') - volume = service_eventlet.Service.create(binary='nova-volume') - scheduler = service_eventlet.Service.create(binary='nova-scheduler') - #objectstore = service_eventlet.Service.create(binary='nova-objectstore') + compute = service.Service.create(binary='nova-compute') + network = service.Service.create(binary='nova-network') + volume = service.Service.create(binary='nova-volume') + scheduler = service.Service.create(binary='nova-scheduler') + #objectstore = service.Service.create(binary='nova-objectstore') - service_eventlet.serve(compute, network, volume, scheduler) + service.serve(compute, network, volume, scheduler) server = wsgi.Server() server.start(api.API('os'), FLAGS.osapi_port, host=FLAGS.osapi_host) -- cgit From a1640f352806ee12f6b485a8d69a65bd42b51411 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Thu, 9 Dec 2010 16:05:13 -0800 Subject: formatting and naming cleanup --- bin/nova-combined | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'bin/nova-combined') diff --git a/bin/nova-combined b/bin/nova-combined index c70d1d9ef..964ffd438 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -17,9 +17,7 @@ # License for the specific language governing permissions and limitations # under the License. -""" - Twistd daemon for the nova compute nodes. -""" +"""Combined starter script for Nova services.""" import eventlet eventlet.monkey_patch() -- cgit From 4d06429290a373ae3a42b1f9b58d7253d269e048 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Thu, 9 Dec 2010 16:45:51 -0800 Subject: add back utils.default_flagflie --- bin/nova-combined | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin/nova-combined') diff --git a/bin/nova-combined b/bin/nova-combined index 964ffd438..e82b9c9b6 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -36,6 +36,7 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import api from nova import flags from nova import service +from nova import utils from nova import wsgi @@ -50,6 +51,7 @@ flags.DEFINE_string('ec2api_host', '0.0.0.0', 'EC2 API host') if __name__ == '__main__': + utils.default_flagfile() FLAGS(sys.argv) compute = service.Service.create(binary='nova-compute') -- cgit From a2a8406b5d793545c8ecb359e18b80bba618c509 Mon Sep 17 00:00:00 2001 From: termie Date: Tue, 14 Dec 2010 16:05:39 -0800 Subject: updates per review --- bin/nova-combined | 3 --- 1 file changed, 3 deletions(-) (limited to 'bin/nova-combined') diff --git a/bin/nova-combined b/bin/nova-combined index e82b9c9b6..5f635b3a3 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -40,9 +40,6 @@ from nova import utils from nova import wsgi -FLAGS = flags.FLAGS -flags.DEFINE_integer('api_port', 8773, 'API port') - FLAGS = flags.FLAGS flags.DEFINE_integer('osapi_port', 8774, 'OpenStack API port') flags.DEFINE_string('osapi_host', '0.0.0.0', 'OpenStack API host') -- cgit From e306d236e3cf91c00a36940e277ad2d105b055a1 Mon Sep 17 00:00:00 2001 From: termie Date: Thu, 16 Dec 2010 12:45:06 -0800 Subject: pep8 fixes for bin --- bin/nova-combined | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin/nova-combined') diff --git a/bin/nova-combined b/bin/nova-combined index 5f635b3a3..c6a04f7e9 100755 --- a/bin/nova-combined +++ b/bin/nova-combined @@ -50,7 +50,7 @@ flags.DEFINE_string('ec2api_host', '0.0.0.0', 'EC2 API host') if __name__ == '__main__': utils.default_flagfile() FLAGS(sys.argv) - + compute = service.Service.create(binary='nova-compute') network = service.Service.create(binary='nova-network') volume = service.Service.create(binary='nova-volume') @@ -63,4 +63,3 @@ if __name__ == '__main__': server.start(api.API('os'), FLAGS.osapi_port, host=FLAGS.osapi_host) server.start(api.API('ec2'), FLAGS.ec2api_port, host=FLAGS.ec2api_host) server.wait() - -- cgit