¡@

Home 

OpenStack Study: __init__.py

OpenStack Index

**** CubicPower OpenStack Study ****

def main():

    eventlet.monkey_patch()

    # the configuration will be read into the cfg.CONF global data structure

    config.parse(sys.argv[1:])

    if not cfg.CONF.config_file:

        sys.exit(_("ERROR: Unable to find configuration file via the default"

                   " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and"

                   " the '--config-file' option!"))

    try:

        pool = eventlet.GreenPool()

        neutron_api = service.serve_wsgi(service.NeutronApiService)

        api_thread = pool.spawn(neutron_api.wait)

        try:

            neutron_rpc = service.serve_rpc()

        except NotImplementedError:

            LOG.info(_("RPC was already started in parent process by plugin."))

        else:

            rpc_thread = pool.spawn(neutron_rpc.wait)

            # api and rpc should die together.  When one dies, kill the other.

            rpc_thread.link(lambda gt: api_thread.kill())

            api_thread.link(lambda gt: rpc_thread.kill())

        pool.waitall()

    except KeyboardInterrupt:

        pass

    except RuntimeError as e:

        sys.exit(_("ERROR: %s") % e)

if __name__ == "__main__":

    main()