From c8fdce011092f23efd55385b45db8e6f3886beb1 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Thu, 15 Jul 2010 11:07:40 -0500 Subject: remove import of vendor since we have PPA now --- bin/nova-api | 2 +- bin/nova-compute | 2 +- bin/nova-instancemonitor | 2 +- bin/nova-objectstore | 2 +- bin/nova-rsapi | 2 +- bin/nova-volume | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index 7bc9166b8..ae274abf6 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -23,7 +23,7 @@ Tornado daemon for the main API endpoint. import logging -from nova import vendor + from tornado import httpserver from tornado import ioloop diff --git a/bin/nova-compute b/bin/nova-compute index 803887039..5635efbaf 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -33,7 +33,7 @@ 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 diff --git a/bin/nova-instancemonitor b/bin/nova-instancemonitor index d3f0ae221..d2ed82c9f 100755 --- a/bin/nova-instancemonitor +++ b/bin/nova-instancemonitor @@ -23,7 +23,7 @@ import logging -from nova import vendor + from twisted.internet import task from twisted.application import service diff --git a/bin/nova-objectstore b/bin/nova-objectstore index 7876864c0..8ae80707e 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -23,7 +23,7 @@ import logging -from nova import vendor + from tornado import httpserver from tornado import ioloop diff --git a/bin/nova-rsapi b/bin/nova-rsapi index c2f2c9d70..cca5b3048 100755 --- a/bin/nova-rsapi +++ b/bin/nova-rsapi @@ -23,7 +23,7 @@ import logging from wsgiref import simple_server -from nova import vendor + from tornado import ioloop from nova import flags diff --git a/bin/nova-volume b/bin/nova-volume index 9b7787c96..8296eb1d8 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -23,7 +23,7 @@ import logging -from nova import vendor + from tornado import ioloop from nova import flags -- cgit From 0b396e1315a76112ab978a677e96d7b3a371faa9 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 15 Jul 2010 23:11:33 +0000 Subject: Fixes to dhcp lease code to use a flagfile --- bin/dhcpleasor.py | 90 -------------------------------------------------- bin/nova-dhcpbridge | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 90 deletions(-) delete mode 100755 bin/dhcpleasor.py create mode 100755 bin/nova-dhcpbridge (limited to 'bin') diff --git a/bin/dhcpleasor.py b/bin/dhcpleasor.py deleted file mode 100755 index 31f4433fb..000000000 --- a/bin/dhcpleasor.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/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. - -""" -dhcpleasor.py - -Handle lease database updates from DHCP servers. -""" - -import sys -import os -import logging -sys.path.append(os.path.abspath(os.path.join(__file__, "../../"))) - -logging.debug(sys.path) -import getopt -from os import environ -from nova.compute import linux_net -from nova.compute import network -from nova import rpc - -from nova import flags -FLAGS = flags.FLAGS - - -def add_lease(mac, ip, hostname, interface): - if FLAGS.fake_rabbit: - network.lease_ip(ip) - else: - rpc.cast(FLAGS.cloud_topic, {"method": "lease_ip", - "args" : {"address": ip}}) - -def old_lease(mac, ip, hostname, interface): - logging.debug("Adopted old lease or got a change of mac/hostname") - -def del_lease(mac, ip, hostname, interface): - if FLAGS.fake_rabbit: - network.release_ip(ip) - else: - rpc.cast(FLAGS.cloud_topic, {"method": "release_ip", - "args" : {"address": ip}}) - -def init_leases(interface): - net = network.get_network_by_interface(interface) - res = "" - for host_name in net.hosts: - res += "%s\n" % linux_net.hostDHCP(net, host_name, net.hosts[host_name]) - 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')): - FLAGS.fake_rabbit = True - FLAGS.redis_db = 8 - FLAGS.network_size = 32 - FLAGS.fake_libvirt=True - FLAGS.fake_network=True - FLAGS.fake_users = True - action = argv[1] - if action in ['add','del','old']: - mac = argv[2] - ip = argv[3] - hostname = argv[4] - logging.debug("Called %s for mac %s with ip %s and hostname %s on interface %s" % (action, mac, ip, hostname, interface)) - globals()[action+'_lease'](mac, ip, hostname, interface) - else: - print init_leases(interface) - exit(0) - -if __name__ == "__main__": - sys.exit(main()) diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge new file mode 100755 index 000000000..cd0eab2a8 --- /dev/null +++ b/bin/nova-dhcpbridge @@ -0,0 +1,94 @@ +#!/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. + +""" +nova-dhcpbridge + +Handle lease database updates from DHCP servers. +""" + +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__, "../../"))) + +from nova import rpc +from nova import utils + +from nova.compute import linux_net +from nova.compute import network + +from nova import flags +FLAGS = flags.FLAGS + + +def add_lease(mac, ip, hostname, interface): + if FLAGS.fake_rabbit: + network.lease_ip(ip) + else: + rpc.cast(FLAGS.cloud_topic, {"method": "lease_ip", + "args" : {"address": ip}}) + +def old_lease(mac, ip, hostname, interface): + logging.debug("Adopted old lease or got a change of mac/hostname") + +def del_lease(mac, ip, hostname, interface): + if FLAGS.fake_rabbit: + network.release_ip(ip) + else: + rpc.cast(FLAGS.cloud_topic, {"method": "release_ip", + "args" : {"address": ip}}) + +def init_leases(interface): + net = network.get_network_by_interface(interface) + res = "" + for host_name in net.hosts: + res += "%s\n" % linux_net.hostDHCP(net, host_name, net.hosts[host_name]) + return res + + +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.fake_network=True + FLAGS.fake_users = True + action = argv[1] + if action in ['add','del','old']: + mac = argv[2] + ip = argv[3] + hostname = argv[4] + logging.debug("Called %s for mac %s with ip %s and hostname %s on interface %s" % (action, mac, ip, hostname, interface)) + globals()[action+'_lease'](mac, ip, hostname, interface) + else: + print init_leases(interface) + exit(0) + +if __name__ == "__main__": + sys.exit(main()) -- cgit From 3ce6ec1a83731da868c5a77c4684808a54ffd8fd Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Thu, 15 Jul 2010 18:13:48 -0500 Subject: reorder imports spacing --- bin/dhcpleasor.py | 5 ++--- bin/nova-api | 2 -- bin/nova-import-canonical-imagestore | 2 +- bin/nova-instancemonitor | 2 -- bin/nova-manage | 3 ++- bin/nova-objectstore | 2 -- bin/nova-rsapi | 4 +--- bin/nova-volume | 2 -- 8 files changed, 6 insertions(+), 16 deletions(-) (limited to 'bin') diff --git a/bin/dhcpleasor.py b/bin/dhcpleasor.py index 31f4433fb..07ff325f1 100755 --- a/bin/dhcpleasor.py +++ b/bin/dhcpleasor.py @@ -31,11 +31,10 @@ sys.path.append(os.path.abspath(os.path.join(__file__, "../../"))) logging.debug(sys.path) import getopt from os import environ -from nova.compute import linux_net -from nova.compute import network from nova import rpc - from nova import flags +from nova.compute import linux_net +from nova.compute import network FLAGS = flags.FLAGS diff --git a/bin/nova-api b/bin/nova-api index ae274abf6..26f5dbc87 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -22,8 +22,6 @@ Tornado daemon for the main API endpoint. """ import logging - - from tornado import httpserver from tornado import ioloop 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 d2ed82c9f..b195089b7 100755 --- a/bin/nova-instancemonitor +++ b/bin/nova-instancemonitor @@ -22,8 +22,6 @@ """ import logging - - from twisted.internet import task from twisted.application import service diff --git a/bin/nova-manage b/bin/nova-manage index 5693a40f6..56f89ce30 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -23,6 +23,7 @@ """ import sys +import time from nova import flags from nova import utils @@ -31,7 +32,7 @@ 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 diff --git a/bin/nova-objectstore b/bin/nova-objectstore index 8ae80707e..521f3d5d1 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -22,8 +22,6 @@ """ import logging - - from tornado import httpserver from tornado import ioloop diff --git a/bin/nova-rsapi b/bin/nova-rsapi index cca5b3048..5cbe2d8c1 100755 --- a/bin/nova-rsapi +++ b/bin/nova-rsapi @@ -21,10 +21,8 @@ """ import logging -from wsgiref import simple_server - - from tornado import ioloop +from wsgiref import simple_server from nova import flags from nova import rpc diff --git a/bin/nova-volume b/bin/nova-volume index 8296eb1d8..df9fb5c7a 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -22,8 +22,6 @@ """ import logging - - from tornado import ioloop from nova import flags -- cgit From 73af1a84eb682423bf40323387d739778765e138 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 16 Jul 2010 21:52:10 +0000 Subject: make nova-volume start with twisteds daemonize stuff --- bin/nova-compute | 9 +++------ bin/nova-volume | 61 +++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 46 insertions(+), 24 deletions(-) (limited to 'bin') diff --git a/bin/nova-compute b/bin/nova-compute index 5635efbaf..4b559beb4 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -33,9 +33,6 @@ 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 carrot import connection -from carrot import messaging from twisted.internet import task from twisted.application import service @@ -50,8 +47,8 @@ FLAGS = flags.FLAGS # 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, +if 'compute_report_state_interval' not in FLAGS: + flags.DEFINE_integer('compute_report_state_interval', 10, 'seconds between nodes reporting state to cloud', lower_bound=1) logging.getLogger().setLevel(logging.DEBUG) @@ -75,7 +72,7 @@ def main(): 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) + pulse.start(interval=FLAGS.compute_report_state_interval, now=False) injected = consumer_all.attach_to_twisted() injected = consumer_node.attach_to_twisted() diff --git a/bin/nova-volume b/bin/nova-volume index df9fb5c7a..64b726627 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -22,22 +22,37 @@ """ import logging -from tornado import ioloop +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 twisted.internet import task +from twisted.application import service from nova import flags from nova import rpc -from nova import server -from nova import utils +from nova import twistd 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) +# 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 'volume_report_state_interval' not in FLAGS: + flags.DEFINE_integer('volume_report_state_interval', 10, + 'seconds between nodes reporting state to cloud', + lower_bound=1) -def main(argv): +def main(): + logging.warn('Starting volume node') bs = storage.BlockStore() conn = rpc.Connection.instance() @@ -51,19 +66,29 @@ def main(argv): 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) + bin_name = os.path.basename(__file__) + pulse = task.LoopingCall(bs.report_state, FLAGS.node_name, bin_name) + pulse.start(interval=FLAGS.volume_report_state_interval, now=False) + + injected = consumer_all.attach_to_twisted() + injected = consumer_node.attach_to_twisted() - injected = consumer_all.attachToTornado(io_inst) - injected = consumer_node.attachToTornado(io_inst) - scheduler.start() - io_inst.start() + # 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) + bs.setServiceParent(application) + return application +# 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__': - utils.default_flagfile() - server.serve('nova-volume', 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() -- cgit From 9e023095e303f096ac0d2914ed427d2a37d1444d Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Sat, 17 Jul 2010 23:00:53 -0700 Subject: Replace nova-objectstore with a twistd style wrapper. Add a get_application method to objectstore handler. --- bin/nova-objectstore | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'bin') diff --git a/bin/nova-objectstore b/bin/nova-objectstore index 7876864c0..5ac911f09 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -18,35 +18,32 @@ # 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): +def main(): # 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() - + 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() -- cgit From 2d5124c3f2c6e4e78dc09eb8f38cb125641b9b1c Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Sat, 17 Jul 2010 23:04:46 -0700 Subject: Remove s3_internal_port setting. Objectstore should be able to handle the beatings now. As such, nginx is no longer needed, so it's removed from the dependencies and the configuration files are removed. --- bin/nova-objectstore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-objectstore b/bin/nova-objectstore index 5ac911f09..9385fd299 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -35,7 +35,7 @@ FLAGS = flags.FLAGS def main(): # 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)) + logging.debug('Started HTTP server on %s' % (FLAGS.s3_port)) app = handler.get_application() print app return app -- cgit From f39d6549d4e57941b14f328fa5a52a3a5f925d42 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Sun, 18 Jul 2010 18:15:12 +0100 Subject: In preparation for XenAPI support, refactor the interface between nova.compute and the hypervisor (i.e. libvirt). compute.node is no longer coupled tightly with libvirt. Instead, hypervisor connections are handled through a simple abstract interface. This has the additional advantage that there is no need to riddle the code with FLAGS.fake_libvirt checks, as we now have an interface behind which we can mock. The libvirt-specific code, and the fakevirt code used for unit tests, have moved into nova.virt. The fake_libvirt flag has been replaced with a connection_type flag, that will allow us to specify different connection types. The disk image handling (S3 or local disk image fetch) has moved into nova.virt.images, where it will be easier to share between connection types. The power_state values (Instance.RUNNING etc) and the INSTANCE_TYPES dictionary have moved into their own files (nova.compute.instance_types and nova.compute.power_state) so that we can share them without mutual dependencies between nova.compute.node and nova.virt.libvirt_conn. --- bin/dhcpleasor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/dhcpleasor.py b/bin/dhcpleasor.py index 07ff325f1..4a3f374d5 100755 --- a/bin/dhcpleasor.py +++ b/bin/dhcpleasor.py @@ -71,7 +71,7 @@ def main(argv=None): 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 action = argv[1] -- cgit From a3ca587654095ffd4b97103302fb0744e505e332 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 19 Jul 2010 13:19:26 -0500 Subject: Massive refactor of users.py Split users.py into manager.py and ldpadriver.py Added tons of docstrings Cleaned up public methods Simplified manager singleton handling --- bin/nova-api | 2 +- bin/nova-manage | 10 +++++----- bin/nova-objectstore | 6 +++--- bin/nova-rsapi | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index 26f5dbc87..1f2009c30 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -29,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-manage b/bin/nova-manage index 56f89ce30..b0f0029ed 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -27,7 +27,7 @@ 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 @@ -42,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()) @@ -90,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 @@ -113,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 @@ -153,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-objectstore b/bin/nova-objectstore index 521f3d5d1..837eb2e0c 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -18,7 +18,7 @@ # under the License. """ - Tornado daemon for nova objectstore. Supports S3 API. + Tornado daemon for nova objectstore. Supports S3 API. """ import logging @@ -28,7 +28,7 @@ from tornado import ioloop from nova import flags from nova import server from nova import utils -from nova.auth import users +from nova.auth import manager from nova.objectstore import handler @@ -39,7 +39,7 @@ 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()) + app = handler.Application(manager.AuthManager()) server = httpserver.HTTPServer(app) server.listen(FLAGS.s3_internal_port) ioloop.IOLoop.instance().start() diff --git a/bin/nova-rsapi b/bin/nova-rsapi index 5cbe2d8c1..306a1fc60 100755 --- a/bin/nova-rsapi +++ b/bin/nova-rsapi @@ -4,20 +4,20 @@ # 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 @@ -28,14 +28,14 @@ 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 flags.DEFINE_integer('cc_port', 8773, 'cloud controller port') def main(_argv): - user_manager = users.UserManager() + user_manager = manager.AuthManager() api_instance = rackspace.Api(user_manager) conn = rpc.Connection.instance() rpc_consumer = rpc.AdapterConsumer(connection=conn, -- cgit From 2d49a870fe89b3266f908a5711a5d412fa6d7a19 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 21 Jul 2010 08:46:53 -0500 Subject: remove all of the unused saved return values from attach_to_twisted --- bin/nova-compute | 4 ++-- bin/nova-volume | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-compute b/bin/nova-compute index 4b559beb4..49710e1b3 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -74,8 +74,8 @@ def main(): pulse = task.LoopingCall(n.report_state, FLAGS.node_name, bin_name) pulse.start(interval=FLAGS.compute_report_state_interval, now=False) - injected = consumer_all.attach_to_twisted() - injected = consumer_node.attach_to_twisted() + consumer_all.attach_to_twisted() + 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 diff --git a/bin/nova-volume b/bin/nova-volume index 64b726627..7d4b65205 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -70,8 +70,8 @@ def main(): pulse = task.LoopingCall(bs.report_state, FLAGS.node_name, bin_name) pulse.start(interval=FLAGS.volume_report_state_interval, now=False) - injected = consumer_all.attach_to_twisted() - injected = consumer_node.attach_to_twisted() + consumer_all.attach_to_twisted() + 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 -- cgit From 3b982f62bb7cb92cbe9e96a1bde4410b3d06f997 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 21 Jul 2010 14:42:22 -0500 Subject: refactor daemons to use common base class in preparation for network refactor --- bin/nova-compute | 68 +------------------------------------------------------- bin/nova-network | 32 ++++++++++++++++++++++++++ bin/nova-volume | 68 +++----------------------------------------------------- 3 files changed, 36 insertions(+), 132 deletions(-) create mode 100644 bin/nova-network (limited to 'bin') diff --git a/bin/nova-compute b/bin/nova-compute index 49710e1b3..67c93fcb8 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -19,80 +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 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 'compute_report_state_interval' not in FLAGS: - flags.DEFINE_integer('compute_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.compute_report_state_interval, now=False) - - consumer_all.attach_to_twisted() - 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 - - -# 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 = node.ComputeNode.create() diff --git a/bin/nova-network b/bin/nova-network new file mode 100644 index 000000000..c69690081 --- /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 node + + +if __name__ == '__main__': + twistd.serve(__file__) + +if __name__ == '__builtin__': + application = node.NetworkNode.create() diff --git a/bin/nova-volume b/bin/nova-volume index 7d4b65205..cdf2782bc 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -18,77 +18,15 @@ # under the License. """ - Tornado Storage daemon manages AoE volumes via AMQP messaging. + Twistd daemon for the nova volume nodes. """ -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 twisted.internet import task -from twisted.application import service - -from nova import flags -from nova import rpc from nova import twistd -from nova.volume import storage - - -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 'volume_report_state_interval' not in FLAGS: - flags.DEFINE_integer('volume_report_state_interval', 10, - 'seconds between nodes reporting state to cloud', - lower_bound=1) - - -def main(): - logging.warn('Starting volume node') - 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) - - bin_name = os.path.basename(__file__) - pulse = task.LoopingCall(bs.report_state, FLAGS.node_name, bin_name) - pulse.start(interval=FLAGS.volume_report_state_interval, now=False) - - consumer_all.attach_to_twisted() - 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) - bs.setServiceParent(application) - return application +from nova.volume import node -# 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 = node.VolumeNode.create() -- cgit From 80d03bbeb1f1acb82c495747dcf5cc9390df025a Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 21 Jul 2010 14:55:16 -0500 Subject: make nova-network executable --- bin/nova-network | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/nova-network (limited to 'bin') diff --git a/bin/nova-network b/bin/nova-network old mode 100644 new mode 100755 -- cgit From b03f05a0eb321350297e2f86a05ec4593bfc4049 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 22 Jul 2010 07:51:03 -0500 Subject: typo fixes and extra print statements removed --- bin/nova-compute | 4 ++-- bin/nova-network | 4 ++-- bin/nova-volume | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/nova-compute b/bin/nova-compute index 67c93fcb8..1d5fa709d 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -22,11 +22,11 @@ """ from nova import twistd -from nova.compute import node +from nova.compute import computenode if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = node.ComputeNode.create() + application = computenode.ComputeNode.create() diff --git a/bin/nova-network b/bin/nova-network index c69690081..db9d4b970 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -22,11 +22,11 @@ """ from nova import twistd -from nova.network import node +from nova.network import networknode if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = node.NetworkNode.create() + application = networknode.NetworkNode.create() diff --git a/bin/nova-volume b/bin/nova-volume index cdf2782bc..2e9b530a7 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -22,11 +22,11 @@ """ from nova import twistd -from nova.volume import node +from nova.volume import volumenode if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = node.VolumeNode.create() + application = volumenode.VolumeNode.create() -- cgit From 35fda702abf91792d3c4753a1bbccdb119eaf6eb Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 23 Jul 2010 15:27:18 -0700 Subject: renamed xxxnode to xxservice --- bin/nova-compute | 4 ++-- bin/nova-network | 4 ++-- bin/nova-volume | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/nova-compute b/bin/nova-compute index 1d5fa709d..7ef5d074a 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -22,11 +22,11 @@ """ from nova import twistd -from nova.compute import computenode +from nova.compute import computeservice if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = computenode.ComputeNode.create() + application = computeservice.ComputeService.create() diff --git a/bin/nova-network b/bin/nova-network index db9d4b970..0d3aa0002 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -22,11 +22,11 @@ """ from nova import twistd -from nova.network import networknode +from nova.network import networkservice if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = networknode.NetworkNode.create() + application = networkservice.NetworkService.create() diff --git a/bin/nova-volume b/bin/nova-volume index 2e9b530a7..c1c0163cf 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -22,11 +22,11 @@ """ from nova import twistd -from nova.volume import volumenode +from nova.volume import volumeservice if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = volumenode.VolumeNode.create() + application = volumeservice.VolumeService.create() -- cgit From 480d1b6d5dd12490298b2b4d3e62f40917390bde Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Sun, 25 Jul 2010 15:32:10 +0100 Subject: Add an import so that nova-compute sees the images_path flag, so that it can be used on the command line. --- bin/nova-compute | 1 + 1 file changed, 1 insertion(+) (limited to 'bin') diff --git a/bin/nova-compute b/bin/nova-compute index 5635efbaf..63d57a765 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -43,6 +43,7 @@ from nova import flags from nova import rpc from nova import twistd from nova.compute import node +from nova.objectstore import image # For the images_path flag FLAGS = flags.FLAGS -- cgit From f7962c73aa9835c76857005ab56f512fbc9eebfd Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sun, 25 Jul 2010 11:20:09 -0700 Subject: More Cleanup of code Moved code in AuthManager init to new so it isn't called multiple times Changed AuthManager flag to specify class name as well as module name Added exception for missing auth_driver Changed import to use "recommended" style for nested imports http://docs.python.org/dev/library/functions.html#__import__ --- bin/nova-dhcpbridge | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index ece7ffc8c..c519c6ccb 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -78,7 +78,7 @@ def main(): FLAGS.network_size = 32 FLAGS.fake_libvirt=True FLAGS.fake_network=True - FLAGS.auth_driver='nova.auth.fakeldapdriver' + FLAGS.auth_driver='nova.auth.ldapdriver.FakeLdapDriver' action = argv[1] if action in ['add','del','old']: mac = argv[2] -- cgit From 754db8ef1ceb84fa9a1f44bfc6c5c6bbd99cd7e1 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 26 Jul 2010 17:14:28 -0700 Subject: renamed xxxservice to service --- bin/nova-compute | 4 ++-- bin/nova-network | 4 ++-- bin/nova-volume | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/nova-compute b/bin/nova-compute index 7ef5d074a..e0c12354f 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -22,11 +22,11 @@ """ from nova import twistd -from nova.compute import computeservice +from nova.compute import service if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = computeservice.ComputeService.create() + application = service.ComputeService.create() diff --git a/bin/nova-network b/bin/nova-network index 0d3aa0002..52d6cb70a 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -22,11 +22,11 @@ """ from nova import twistd -from nova.network import networkservice +from nova.network import service if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = networkservice.NetworkService.create() + application = service.NetworkService.create() diff --git a/bin/nova-volume b/bin/nova-volume index c1c0163cf..f7a8fad37 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -22,11 +22,11 @@ """ from nova import twistd -from nova.volume import volumeservice +from nova.volume import service if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = volumeservice.VolumeService.create() + application = service.VolumeService.create() -- cgit From 912a6bd28adb2a17c4d0508ee44b1d19ae2624f0 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 30 Jul 2010 11:29:13 -0700 Subject: Make nodaemon twistd processes log to stdout --- bin/nova-objectstore | 5 ----- 1 file changed, 5 deletions(-) (limited to 'bin') diff --git a/bin/nova-objectstore b/bin/nova-objectstore index 9385fd299..c0fa815c0 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -21,8 +21,6 @@ Twisted daemon for nova objectstore. Supports S3 API. """ -import logging - from nova import flags from nova import utils from nova import twistd @@ -33,9 +31,6 @@ FLAGS = flags.FLAGS def main(): - # 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_port)) app = handler.get_application() print app return app -- cgit