~ubuntu-branches/ubuntu/vivid/sahara/vivid-proposed

« back to all changes in this revision

Viewing changes to sahara/cli/sahara_api.py

  • Committer: Package Import Robot
  • Author(s): Thomas Goirand
  • Date: 2014-09-24 16:34:46 UTC
  • Revision ID: package-import@ubuntu.com-20140924163446-8gu3zscu5e3n9lr2
Tags: upstream-2014.2~b3
ImportĀ upstreamĀ versionĀ 2014.2~b3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
# Copyright (c) 2013 Mirantis Inc.
 
4
#
 
5
# Licensed under the Apache License, Version 2.0 (the "License");
 
6
# you may not use this file except in compliance with the License.
 
7
# You may obtain a copy of the License at
 
8
#
 
9
#    http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
# Unless required by applicable law or agreed to in writing, software
 
12
# distributed under the License is distributed on an "AS IS" BASIS,
 
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
14
# implied.
 
15
# See the License for the specific language governing permissions and
 
16
# limitations under the License.
 
17
 
 
18
from sahara.utils import patches
 
19
patches.patch_all()
 
20
 
 
21
import os
 
22
import sys
 
23
 
 
24
import eventlet
 
25
from eventlet import wsgi
 
26
from oslo import i18n
 
27
 
 
28
 
 
29
# If ../sahara/__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,
 
35
                               'sahara',
 
36
                               '__init__.py')):
 
37
    sys.path.insert(0, possible_topdir)
 
38
 
 
39
 
 
40
# NOTE(slukjanov): i18n.enable_lazy() must be called before
 
41
#                  sahara.utils.i18n._() is called to ensure it has the desired
 
42
#                  lazy lookup behavior.
 
43
i18n.enable_lazy()
 
44
 
 
45
 
 
46
import sahara.main as server
 
47
from sahara.openstack.common import log as logging
 
48
 
 
49
 
 
50
LOG = logging.getLogger(__name__)
 
51
 
 
52
 
 
53
def main():
 
54
    server.setup_common(possible_topdir, 'API')
 
55
 
 
56
    app = server.make_app()
 
57
 
 
58
    server.setup_sahara_api('distributed')
 
59
 
 
60
    from oslo.config import cfg
 
61
    wsgi.server(eventlet.listen((cfg.CONF.host, cfg.CONF.port), backlog=500),
 
62
                app, log=logging.WritableLogger(LOG), debug=False)