"Fossies" - the Fresh Open Source Software Archive

Member "openstack-heat-13.0.0/heat/cmd/all.py" (16 Oct 2019, 2622 Bytes) of package /linux/misc/openstack/openstack-heat-13.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "all.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 12.0.0_vs_13.0.0.

    1 #
    2 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    3 #    not use this file except in compliance with the License. You may obtain
    4 #    a copy of the License at
    5 #
    6 #         http://www.apache.org/licenses/LICENSE-2.0
    7 #
    8 #    Unless required by applicable law or agreed to in writing, software
    9 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   10 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   11 #    License for the specific language governing permissions and limitations
   12 #    under the License.
   13 
   14 """Heat All Server.
   15 
   16 An OpenStack Heat server that can run all services.
   17 """
   18 import eventlet
   19 eventlet.monkey_patch(os=False)
   20 
   21 import sys
   22 
   23 from oslo_config import cfg
   24 import oslo_i18n as i18n
   25 from oslo_log import log as logging
   26 from oslo_service import systemd
   27 import six
   28 
   29 from heat.cmd import api
   30 from heat.cmd import api_cfn
   31 from heat.cmd import engine
   32 from heat.common import config
   33 from heat.common import messaging
   34 from heat import version
   35 
   36 
   37 i18n.enable_lazy()
   38 
   39 LOG = logging.getLogger('heat.all')
   40 
   41 API_LAUNCH_OPTS = {'setup_logging': False}
   42 
   43 LAUNCH_SERVICES = {
   44     'engine': [engine.launch_engine, {'setup_logging': False}],
   45     'api': [api.launch_api, API_LAUNCH_OPTS],
   46     'api_cfn': [api_cfn.launch_cfn_api, API_LAUNCH_OPTS],
   47 }
   48 
   49 services_opt = cfg.ListOpt(
   50     'enabled_services',
   51     default=['engine', 'api', 'api_cfn'],
   52     help='Specifies the heat services that are enabled when running heat-all. '
   53          'Valid options are all or any combination of '
   54          'api, engine or api_cfn.'
   55 )
   56 
   57 cfg.CONF.register_opt(services_opt, group='heat_all')
   58 
   59 
   60 def _start_service_threads(services):
   61     threads = []
   62     for option in services:
   63         launch_func = LAUNCH_SERVICES[option][0]
   64         kwargs = LAUNCH_SERVICES[option][1]
   65         threads.append(eventlet.spawn(launch_func, **kwargs))
   66     return threads
   67 
   68 
   69 def launch_all(setup_logging=True):
   70         if setup_logging:
   71             logging.register_options(cfg.CONF)
   72         cfg.CONF(project='heat', prog='heat-all',
   73                  version=version.version_info.version_string())
   74         if setup_logging:
   75             logging.setup(cfg.CONF, 'heat-all')
   76         config.set_config_defaults()
   77         messaging.setup()
   78         return _start_service_threads(set(cfg.CONF.heat_all.enabled_services))
   79 
   80 
   81 def main():
   82     try:
   83         threads = launch_all()
   84         services = [thread.wait() for thread in threads]
   85         systemd.notify_once()
   86         [service.wait() for service in services]
   87     except RuntimeError as e:
   88         msg = six.text_type(e)
   89         sys.exit("ERROR: %s" % msg)