~ubuntu-branches/ubuntu/precise/keystone/precise-security

« back to all changes in this revision

Viewing changes to bin/keystone-admin

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-08-23 10:18:22 UTC
  • Revision ID: james.westby@ubuntu.com-20110823101822-enve6zceb3lqhuvj
Tags: upstream-1.0~d4~20110823.1078
ImportĀ upstreamĀ versionĀ 1.0~d4~20110823.1078

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 United States Government as represented by the
 
5
# Administrator of the National Aeronautics and Space Administration.
 
6
# Copyright 2011 OpenStack LLC.
 
7
# All Rights Reserved.
 
8
#
 
9
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
10
#    not use this file except in compliance with the License. You may obtain
 
11
#    a copy of the License at
 
12
#
 
13
#         http://www.apache.org/licenses/LICENSE-2.0
 
14
#
 
15
#    Unless required by applicable law or agreed to in writing, software
 
16
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
17
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
18
#    License for the specific language governing permissions and limitations
 
19
#    under the License.
 
20
 
 
21
"""
 
22
Keystone Identity Server - Admin API
 
23
"""
 
24
 
 
25
import optparse
 
26
import os
 
27
import sys
 
28
 
 
29
# If ../../keystone/__init__.py exists, add ../ to Python search path, so that
 
30
# it will override what happens to be installed in /usr/(local/)lib/python...
 
31
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
 
32
                                   os.pardir,
 
33
                                   os.pardir))
 
34
if os.path.exists(os.path.join(possible_topdir, 'keystone', '__init__.py')):
 
35
    sys.path.insert(0, possible_topdir)
 
36
 
 
37
import tools.tracer  # @UnusedImport # module runs on import
 
38
import keystone
 
39
from keystone.common import config, wsgi
 
40
 
 
41
 
 
42
if __name__ == '__main__':
 
43
    # Initialize a parser for our configuration paramaters
 
44
    parser = optparse.OptionParser(version='%%prog %s' % keystone.version)
 
45
    common_group = config.add_common_options(parser)
 
46
    config.add_log_options(parser)
 
47
 
 
48
    # Parse arguments and load config
 
49
    (options, args) = config.parse_options(parser)
 
50
    config_file = config.find_config_file(options, args)
 
51
 
 
52
    # Start services
 
53
    try:
 
54
        # Load Admin API server
 
55
        conf, app = config.load_paste_app('admin', options, args)
 
56
 
 
57
        debug = options.get('debug') or conf.get('debug', False)
 
58
        debug = debug in [True, "True", "1"]
 
59
        verbose = options.get('verbose') or conf.get('verbose', False)
 
60
        verbose = verbose in [True, "True", "1"]
 
61
        if debug or verbose:
 
62
            print "Using config file:", config_file
 
63
 
 
64
        server = wsgi.Server()
 
65
        server.start(app, int(conf['admin_port']), conf['admin_host'])
 
66
 
 
67
        print "Admin API listening on %s:%s" % (
 
68
            conf['admin_host'], conf['admin_port'])
 
69
 
 
70
        server.wait()
 
71
    except RuntimeError, e:
 
72
        sys.exit("ERROR: %s" % e)