Changes nova-volume to use twisted.
This commit is contained in:
@@ -33,9 +33,6 @@ NOVA_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'nova')
|
|||||||
if os.path.exists(NOVA_PATH):
|
if os.path.exists(NOVA_PATH):
|
||||||
sys.path.insert(0, os.path.dirname(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.internet import task
|
||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
|
|
||||||
@@ -50,8 +47,8 @@ FLAGS = flags.FLAGS
|
|||||||
# context when the twistd.serve() call is made below so any
|
# context when the twistd.serve() call is made below so any
|
||||||
# flags we define here will have to be conditionally defined,
|
# flags we define here will have to be conditionally defined,
|
||||||
# flags defined by imported modules are safe.
|
# flags defined by imported modules are safe.
|
||||||
if 'node_report_state_interval' not in FLAGS:
|
if 'compute_report_state_interval' not in FLAGS:
|
||||||
flags.DEFINE_integer('node_report_state_interval', 10,
|
flags.DEFINE_integer('compute_report_state_interval', 10,
|
||||||
'seconds between nodes reporting state to cloud',
|
'seconds between nodes reporting state to cloud',
|
||||||
lower_bound=1)
|
lower_bound=1)
|
||||||
logging.getLogger().setLevel(logging.DEBUG)
|
logging.getLogger().setLevel(logging.DEBUG)
|
||||||
@@ -75,10 +72,10 @@ def main():
|
|||||||
|
|
||||||
bin_name = os.path.basename(__file__)
|
bin_name = os.path.basename(__file__)
|
||||||
pulse = task.LoopingCall(n.report_state, FLAGS.node_name, bin_name)
|
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()
|
consumer_all.attach_to_twisted()
|
||||||
injected = consumer_node.attach_to_twisted()
|
consumer_node.attach_to_twisted()
|
||||||
|
|
||||||
# This is the parent service that twistd will be looking for when it
|
# 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
|
# parses this file, return it so that we can get it into globals below
|
||||||
|
|||||||
@@ -22,22 +22,37 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
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 flags
|
||||||
from nova import rpc
|
from nova import rpc
|
||||||
from nova import server
|
from nova import twistd
|
||||||
from nova import utils
|
|
||||||
from nova.volume import storage
|
from nova.volume import storage
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
flags.DEFINE_integer('storage_report_state_interval', 10,
|
# NOTE(termie): This file will necessarily be re-imported under different
|
||||||
'seconds between broadcasting state to cloud',
|
# context when the twistd.serve() call is made below so any
|
||||||
lower_bound=1)
|
# 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()
|
bs = storage.BlockStore()
|
||||||
|
|
||||||
conn = rpc.Connection.instance()
|
conn = rpc.Connection.instance()
|
||||||
@@ -51,19 +66,29 @@ def main(argv):
|
|||||||
topic='%s.%s' % (FLAGS.storage_topic, FLAGS.node_name),
|
topic='%s.%s' % (FLAGS.storage_topic, FLAGS.node_name),
|
||||||
proxy=bs)
|
proxy=bs)
|
||||||
|
|
||||||
io_inst = ioloop.IOLoop.instance()
|
bin_name = os.path.basename(__file__)
|
||||||
scheduler = ioloop.PeriodicCallback(
|
pulse = task.LoopingCall(bs.report_state, FLAGS.node_name, bin_name)
|
||||||
lambda: bs.report_state(),
|
pulse.start(interval=FLAGS.volume_report_state_interval, now=False)
|
||||||
FLAGS.storage_report_state_interval * 1000,
|
|
||||||
io_loop=io_inst)
|
|
||||||
|
|
||||||
injected = consumer_all.attachToTornado(io_inst)
|
consumer_all.attach_to_twisted()
|
||||||
injected = consumer_node.attachToTornado(io_inst)
|
consumer_node.attach_to_twisted()
|
||||||
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__':
|
if __name__ == '__main__':
|
||||||
utils.default_flagfile()
|
twistd.serve(__file__)
|
||||||
server.serve('nova-volume', main)
|
|
||||||
|
|
||||||
|
# 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()
|
||||||
|
|||||||
1
debian/nova-volume.conf
vendored
1
debian/nova-volume.conf
vendored
@@ -1,4 +1,3 @@
|
|||||||
--daemonize=1
|
|
||||||
--ca_path=/var/lib/nova/CA
|
--ca_path=/var/lib/nova/CA
|
||||||
--keys_path=/var/lib/nova/keys
|
--keys_path=/var/lib/nova/keys
|
||||||
--fake_users=1
|
--fake_users=1
|
||||||
|
|||||||
Reference in New Issue
Block a user