summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2010-07-26 11:02:28 -0700
committerVishvananda Ishaya <vishvananda@gmail.com>2010-07-26 11:02:28 -0700
commitb1bc1e2edc9fdafabfc27b5ea313dbb934c374eb (patch)
treec51a31f5c90eba7935458c0052539799dc67937d /bin
parent3233f7a964564fba9ec88c277d566eebed50d12a (diff)
parent340f9fc8d63ec931485aba1dcfeccdc1cb3849fa (diff)
merged trunk
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nova-compute14
-rwxr-xr-xbin/nova-volume61
2 files changed, 49 insertions, 26 deletions
diff --git a/bin/nova-compute b/bin/nova-compute
index 5635efbaf..4738abd4b 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
@@ -43,6 +40,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
@@ -50,8 +48,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,10 +73,10 @@ 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()
+ 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 df9fb5c7a..7d4b65205 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)
+
+ consumer_all.attach_to_twisted()
+ 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()