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

« back to all changes in this revision

Viewing changes to bin/nova-api

  • 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=4
 
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 daemon for the main API endpoint.  
 
19
"""
 
20
 
 
21
import logging
 
22
 
 
23
from nova import vendor
 
24
from tornado import httpserver
 
25
from tornado import ioloop
 
26
 
 
27
from nova import flags
 
28
from nova import rpc
 
29
from nova import server
 
30
from nova import utils
 
31
from nova.auth import users
 
32
from nova.endpoint import admin
 
33
from nova.endpoint import api
 
34
from nova.endpoint import cloud
 
35
 
 
36
FLAGS = flags.FLAGS
 
37
 
 
38
 
 
39
def main(_argv):
 
40
    user_manager = users.UserManager()
 
41
    controllers = {
 
42
        'Cloud': cloud.CloudController(),
 
43
        'Admin': admin.AdminController(user_manager)
 
44
    }
 
45
    _app = api.APIServerApplication(user_manager, controllers)
 
46
 
 
47
    conn = rpc.Connection.instance()
 
48
    consumer = rpc.AdapterConsumer(connection=conn,
 
49
                                       topic=FLAGS.cloud_topic,
 
50
                                       proxy=controllers['Cloud'])
 
51
 
 
52
    io_inst = ioloop.IOLoop.instance()
 
53
    _injected = consumer.attach_to_tornado(io_inst)
 
54
 
 
55
    http_server = httpserver.HTTPServer(_app)
 
56
    http_server.listen(FLAGS.cc_port)
 
57
    logging.debug('Started HTTP server on %s', FLAGS.cc_port)
 
58
    io_inst.start()
 
59
 
 
60
 
 
61
if __name__ == '__main__':
 
62
    utils.default_flagfile()
 
63
    server.serve('nova-api', main)