diff options
| author | Todd Willey <todd@ansolabs.com> | 2010-08-03 12:58:58 -0400 |
|---|---|---|
| committer | Todd Willey <todd@ansolabs.com> | 2010-08-03 12:58:58 -0400 |
| commit | 3cb4226d7edba4889d7db7ac541a1949df35ea17 (patch) | |
| tree | 12acee30c05e0d559aa5915167d06188d174a011 /bin | |
| parent | 4044051266d97ffe05fbe75b642759d2e604da4d (diff) | |
| parent | 75c8ccaadedd59b8b7671c3802b8bcfd6368a998 (diff) | |
Merge from trunk.
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/nova-api | 4 | ||||
| -rwxr-xr-x | bin/nova-compute | 73 | ||||
| -rwxr-xr-x | bin/nova-dhcpbridge (renamed from bin/dhcpleasor.py) | 34 | ||||
| -rwxr-xr-x | bin/nova-import-canonical-imagestore | 2 | ||||
| -rwxr-xr-x | bin/nova-instancemonitor | 2 | ||||
| -rwxr-xr-x | bin/nova-manage | 13 | ||||
| -rwxr-xr-x | bin/nova-network | 32 | ||||
| -rwxr-xr-x | bin/nova-objectstore | 30 | ||||
| -rwxr-xr-x | bin/nova-rsapi | 14 | ||||
| -rwxr-xr-x | bin/nova-volume | 51 |
10 files changed, 85 insertions, 170 deletions
diff --git a/bin/nova-api b/bin/nova-api index 7bc9166b8..1f2009c30 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -22,8 +22,6 @@ Tornado daemon for the main API endpoint. """ import logging - -from nova import vendor from tornado import httpserver from tornado import ioloop @@ -31,7 +29,7 @@ from nova import flags from nova import rpc from nova import server from nova import utils -from nova.auth import users +from nova.auth import manager from nova.compute import model from nova.endpoint import admin from nova.endpoint import api diff --git a/bin/nova-compute b/bin/nova-compute index 803887039..e0c12354f 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -19,83 +19,14 @@ """ Twistd daemon for the nova compute nodes. - Receives messages via AMQP, manages pool of worker threads - for async tasks. """ -import logging -import os -import sys - -# NOTE(termie): kludge so that we can run this from the bin directory in the -# checkout without having to screw with paths -NOVA_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'nova') -if os.path.exists(NOVA_PATH): - sys.path.insert(0, os.path.dirname(NOVA_PATH)) - -from nova import vendor -from carrot import connection -from carrot import messaging -from twisted.internet import task -from twisted.application import service - -from nova import flags -from nova import rpc from nova import twistd -from nova.compute import node - - -FLAGS = flags.FLAGS -# NOTE(termie): This file will necessarily be re-imported under different -# context when the twistd.serve() call is made below so any -# flags we define here will have to be conditionally defined, -# flags defined by imported modules are safe. -if 'node_report_state_interval' not in FLAGS: - flags.DEFINE_integer('node_report_state_interval', 10, - 'seconds between nodes reporting state to cloud', - lower_bound=1) -logging.getLogger().setLevel(logging.DEBUG) - -def main(): - logging.warn('Starting compute node') - n = node.Node() - d = n.adopt_instances() - d.addCallback(lambda x: logging.info('Adopted %d instances', x)) - - conn = rpc.Connection.instance() - consumer_all = rpc.AdapterConsumer( - connection=conn, - topic='%s' % FLAGS.compute_topic, - proxy=n) - - consumer_node = rpc.AdapterConsumer( - connection=conn, - topic='%s.%s' % (FLAGS.compute_topic, FLAGS.node_name), - proxy=n) - - bin_name = os.path.basename(__file__) - pulse = task.LoopingCall(n.report_state, FLAGS.node_name, bin_name) - pulse.start(interval=FLAGS.node_report_state_interval, now=False) - - injected = consumer_all.attach_to_twisted() - injected = consumer_node.attach_to_twisted() - - # This is the parent service that twistd will be looking for when it - # parses this file, return it so that we can get it into globals below - application = service.Application(bin_name) - n.setServiceParent(application) - return application +from nova.compute import service -# NOTE(termie): When this script is executed from the commandline what it will -# actually do is tell the twistd application runner that it -# should run this file as a twistd application (see below). if __name__ == '__main__': twistd.serve(__file__) -# NOTE(termie): When this script is loaded by the twistd application runner -# this code path will be executed and twistd will expect a -# variable named 'application' to be available, it will then -# handle starting it and stopping it. if __name__ == '__builtin__': - application = main() + application = service.ComputeService.create() diff --git a/bin/dhcpleasor.py b/bin/nova-dhcpbridge index 31f4433fb..0db241b5e 100755 --- a/bin/dhcpleasor.py +++ b/bin/nova-dhcpbridge @@ -18,24 +18,27 @@ # under the License. """ -dhcpleasor.py +nova-dhcpbridge Handle lease database updates from DHCP servers. """ -import sys -import os import logging +import os +import sys + +#TODO(joshua): there is concern that the user dnsmasq runs under will not +# have nova in the path. This should be verified and if it is +# not true the ugly line below can be removed sys.path.append(os.path.abspath(os.path.join(__file__, "../../"))) -logging.debug(sys.path) -import getopt -from os import environ +from nova import flags +from nova import rpc +from nova import utils from nova.compute import linux_net from nova.compute import network -from nova import rpc -from nova import flags + FLAGS = flags.FLAGS @@ -64,17 +67,18 @@ def init_leases(interface): return res -def main(argv=None): - if argv is None: - argv = sys.argv - interface = environ.get('DNSMASQ_INTERFACE', 'br0') - if int(environ.get('TESTING', '0')): +def main(): + flagfile = os.environ.get('FLAGFILE', FLAGS.dhcpbridge_flagfile) + utils.default_flagfile(flagfile) + argv = FLAGS(sys.argv) + interface = os.environ.get('DNSMASQ_INTERFACE', 'br0') + if int(os.environ.get('TESTING', '0')): FLAGS.fake_rabbit = True FLAGS.redis_db = 8 FLAGS.network_size = 32 - FLAGS.fake_libvirt=True + FLAGS.connection_type = 'fake' FLAGS.fake_network=True - FLAGS.fake_users = True + FLAGS.auth_driver='nova.auth.ldapdriver.FakeLdapDriver' action = argv[1] if action in ['add','del','old']: mac = argv[2] diff --git a/bin/nova-import-canonical-imagestore b/bin/nova-import-canonical-imagestore index 82daf61ce..2e79f09b7 100755 --- a/bin/nova-import-canonical-imagestore +++ b/bin/nova-import-canonical-imagestore @@ -29,9 +29,9 @@ import subprocess import sys import urllib2 -from nova.objectstore import image from nova import flags from nova import utils +from nova.objectstore import image FLAGS = flags.FLAGS diff --git a/bin/nova-instancemonitor b/bin/nova-instancemonitor index d3f0ae221..b195089b7 100755 --- a/bin/nova-instancemonitor +++ b/bin/nova-instancemonitor @@ -22,8 +22,6 @@ """ import logging - -from nova import vendor from twisted.internet import task from twisted.application import service diff --git a/bin/nova-manage b/bin/nova-manage index 5693a40f6..b0f0029ed 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -23,15 +23,16 @@ """ import sys +import time from nova import flags from nova import utils -from nova.auth import users +from nova.auth import manager from nova.compute import model from nova.compute import network from nova.cloudpipe import pipelib from nova.endpoint import cloud -import time + FLAGS = flags.FLAGS @@ -41,7 +42,7 @@ class NetworkCommands(object): class VpnCommands(object): def __init__(self): - self.manager = users.UserManager.instance() + self.manager = manager.AuthManager() self.instdir = model.InstanceDirectory() self.pipe = pipelib.CloudPipe(cloud.CloudController()) @@ -89,7 +90,7 @@ class VpnCommands(object): class RoleCommands(object): def __init__(self): - self.manager = users.UserManager.instance() + self.manager = manager.AuthManager() def add(self, user, role, project=None): """adds role to user @@ -112,7 +113,7 @@ class RoleCommands(object): class UserCommands(object): def __init__(self): - self.manager = users.UserManager.instance() + self.manager = manager.AuthManager() def __print_export(self, user): print 'export EC2_ACCESS_KEY=%s' % user.access @@ -152,7 +153,7 @@ class UserCommands(object): class ProjectCommands(object): def __init__(self): - self.manager = users.UserManager.instance() + self.manager = manager.AuthManager() def add(self, project, user): """adds user to project diff --git a/bin/nova-network b/bin/nova-network new file mode 100755 index 000000000..52d6cb70a --- /dev/null +++ b/bin/nova-network @@ -0,0 +1,32 @@ +#!/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 network nodes. +""" + +from nova import twistd +from nova.network import service + + +if __name__ == '__main__': + twistd.serve(__file__) + +if __name__ == '__builtin__': + application = service.NetworkService.create() diff --git a/bin/nova-objectstore b/bin/nova-objectstore index 7876864c0..c0fa815c0 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -18,35 +18,27 @@ # under the License. """ - Tornado daemon for nova objectstore. Supports S3 API. + Twisted daemon for nova objectstore. Supports S3 API. """ -import logging - -from nova import vendor -from tornado import httpserver -from tornado import ioloop - from nova import flags -from nova import server from nova import utils -from nova.auth import users +from nova import twistd from nova.objectstore import handler FLAGS = flags.FLAGS -def main(argv): - # FIXME: if this log statement isn't here, no logging - # appears from other files and app won't start daemonized - logging.debug('Started HTTP server on %s' % (FLAGS.s3_internal_port)) - app = handler.Application(users.UserManager()) - server = httpserver.HTTPServer(app) - server.listen(FLAGS.s3_internal_port) - ioloop.IOLoop.instance().start() - +def main(): + app = handler.get_application() + print app + return app +# NOTE(soren): Stolen from nova-compute if __name__ == '__main__': + twistd.serve(__file__) + +if __name__ == '__builtin__': utils.default_flagfile() - server.serve('nova-objectstore', main) + application = main() diff --git a/bin/nova-rsapi b/bin/nova-rsapi index a529fc669..a17efccc0 100755 --- a/bin/nova-rsapi +++ b/bin/nova-rsapi @@ -4,33 +4,31 @@ # 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. """ - WSGI daemon for the main API endpoint. + WSGI daemon for the main API endpoint. """ import logging -from wsgiref import simple_server - -from nova import vendor from tornado import ioloop +from wsgiref import simple_server from nova import flags from nova import rpc from nova import server from nova import utils -from nova.auth import users +from nova.auth import manager from nova.endpoint import rackspace FLAGS = flags.FLAGS diff --git a/bin/nova-volume b/bin/nova-volume index 9b7787c96..f7a8fad37 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -18,54 +18,15 @@ # under the License. """ - Tornado Storage daemon manages AoE volumes via AMQP messaging. + Twistd daemon for the nova volume nodes. """ -import logging - -from nova import vendor -from tornado import ioloop - -from nova import flags -from nova import rpc -from nova import server -from nova import utils -from nova.volume import storage - - -FLAGS = flags.FLAGS -flags.DEFINE_integer('storage_report_state_interval', 10, - 'seconds between broadcasting state to cloud', - lower_bound=1) - - -def main(argv): - bs = storage.BlockStore() - - conn = rpc.Connection.instance() - consumer_all = rpc.AdapterConsumer( - connection=conn, - topic='%s' % FLAGS.storage_topic, - proxy=bs) - - consumer_node = rpc.AdapterConsumer( - connection=conn, - topic='%s.%s' % (FLAGS.storage_topic, FLAGS.node_name), - proxy=bs) - - io_inst = ioloop.IOLoop.instance() - scheduler = ioloop.PeriodicCallback( - lambda: bs.report_state(), - FLAGS.storage_report_state_interval * 1000, - io_loop=io_inst) - - injected = consumer_all.attachToTornado(io_inst) - injected = consumer_node.attachToTornado(io_inst) - scheduler.start() - io_inst.start() +from nova import twistd +from nova.volume import service if __name__ == '__main__': - utils.default_flagfile() - server.serve('nova-volume', main) + twistd.serve(__file__) +if __name__ == '__builtin__': + application = service.VolumeService.create() |
