~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to bin/nova-volume

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# vim: tabstop=4 shiftwidth=4 softtabstop
 
3
 
 
4
# Copyright [2010] [Anso Labs, LLC]
 
5
 
6
#    Licensed under the Apache License, Version 2.0 (the "License");
 
7
#    you may not use this file except in compliance with the License.
 
8
#    You may obtain a copy of the License at
 
9
 
10
#        http://www.apache.org/licenses/LICENSE-2.0
 
11
 
12
#    Unless required by applicable law or agreed to in writing, software
 
13
#    distributed under the License is distributed on an "AS IS" BASIS,
 
14
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
15
#    See the License for the specific language governing permissions and
 
16
#    limitations under the License.
 
17
"""
 
18
    Tornado Storage daemon manages AoE volumes via AMQP messaging.
 
19
"""
 
20
 
 
21
import logging
 
22
 
 
23
from nova import vendor
 
24
from tornado import ioloop
 
25
 
 
26
from nova import flags
 
27
from nova import rpc
 
28
from nova import server
 
29
from nova import utils
 
30
from nova.volume import storage
 
31
 
 
32
 
 
33
FLAGS = flags.FLAGS
 
34
flags.DEFINE_integer('storage_report_state_interval', 10,
 
35
                     'seconds between broadcasting state to cloud',
 
36
                     lower_bound=1)
 
37
 
 
38
 
 
39
def main(argv):
 
40
    bs = storage.BlockStore()
 
41
 
 
42
    conn = rpc.Connection.instance()
 
43
    consumer_all = rpc.AdapterConsumer(
 
44
            connection=conn,
 
45
            topic='%s' % FLAGS.storage_topic,
 
46
            proxy=bs)
 
47
 
 
48
    consumer_node = rpc.AdapterConsumer(
 
49
            connection=conn,
 
50
            topic='%s.%s' % (FLAGS.storage_topic, FLAGS.node_name),
 
51
            proxy=bs)
 
52
 
 
53
    io_inst = ioloop.IOLoop.instance()
 
54
    scheduler = ioloop.PeriodicCallback(
 
55
            lambda: bs.report_state(),
 
56
            FLAGS.storage_report_state_interval * 1000,
 
57
            io_loop=io_inst)
 
58
 
 
59
    injected = consumer_all.attachToTornado(io_inst)
 
60
    injected = consumer_node.attachToTornado(io_inst)
 
61
    scheduler.start()
 
62
    io_inst.start()
 
63
 
 
64
 
 
65
if __name__ == '__main__':
 
66
    utils.default_flagfile()
 
67
    server.serve('nova-volume', main)
 
68