Example #1
0
def initialize_app(conf=None, name='main'):
    try:
        config.parse_args()
        config.setup_logging()
    except Exception as e:
        pass
    conf = config.find_paste_config()
    app = deploy.loadapp('config:%s' % conf, name=name)
    return app
Example #2
0
def initialize_app(conf=None, name='main'):
    """ initializing app for paste to deploy it """

    # register and parse arguments
    config.parse_args(args=sys.argv[1:])
    # register logging opts
    config.setup_logging()
    # locate and load paste file
    conf = config.find_paste_config()
    app = deploy.loadapp('config:%s' % conf, name=name)
    return app
Example #3
0
    def setUp(self):
        super(FreezerBaseTestCase, self).setUp()

        self._config_fixture = self.useFixture(cfg_fixture.Config())
        config.parse_args(args=[])
        self.addCleanup(CONF.reset)
        self.test_dir = self.useFixture(fixtures.TempDir()).path
        self.conf_dir = os.path.join(self.test_dir, 'etc')
        os.makedirs(self.conf_dir)
        policy.ENFORCER = None
        policy.setup_policy(CONF)
Example #4
0
def initialize_app(conf=None, name='main'):
    """ initializing app for paste to deploy it """

    # register and parse arguments
    config.parse_args(args=sys.argv[1:])
    # register logging opts
    config.setup_logging()
    # locate and load paste file
    conf = config.find_paste_config()
    app = deploy.loadapp('config:%s' % conf, name=name)
    return app
Example #5
0
    def setUp(self):
        try:
            super(FreezerBaseTestCase, self).setUp()
        except Exception:
            super().setUp()

        self._config_fixture = self.useFixture(cfg_fixture.Config())
        config.parse_args(args=[])
        self.addCleanup(CONF.reset)
        self.test_dir = self.useFixture(fixtures.TempDir()).path
        self.conf_dir = os.path.join(self.test_dir, 'etc')
        os.makedirs(self.conf_dir)
        self.configure_policy()
        policy.ENFORCER = FakePolicyEnforcer()
Example #6
0
    def setUp(self):
        try:
            super(FreezerBaseTestCase, self).setUp()
        except Exception:
            super().setUp()

        self._config_fixture = self.useFixture(cfg_fixture.Config())
        config.parse_args(args=[])
        self.addCleanup(CONF.reset)
        self.test_dir = self.useFixture(fixtures.TempDir()).path
        self.conf_dir = os.path.join(self.test_dir, 'etc')
        os.makedirs(self.conf_dir)
        self.configure_policy()
        policy.ENFORCER = FakePolicyEnforcer()
Example #7
0
def main():
    # setup opts
    config.parse_args()
    config.setup_logging()
    paste_conf = config.find_paste_config()

    # quick simple server for testing purposes or simple scenarios
    ip = CONF.get('bind_host', '0.0.0.0')
    port = CONF.get('bind_port', 9090)
    try:
        httpserver.serve(
            application=deploy.loadapp('config:%s' % paste_conf, name='main'),
            host=ip,
            port=port)
        message = _i18n._('Server listening on %(ip)s:%(port)s' %
                          {'ip': ip, 'port': port})
        _LOG.info(message)
        print(message)
    except KeyboardInterrupt:
        print(_i18n._("Thank You ! \nBye."))
        sys.exit(0)
Example #8
0
def main():
    # setup opts
    config.parse_args(args=sys.argv[1:])
    config.setup_logging()
    paste_conf = config.find_paste_config()

    # quick simple server for testing purposes or simple scenarios
    ip = CONF.get('bind_host', '0.0.0.0')
    port = CONF.get('bind_port', 9090)
    try:
        httpserver.serve(application=deploy.loadapp('config:%s' % paste_conf,
                                                    name='main'),
                         host=ip,
                         port=port)
        message = (_i18n._('Server listening on %(ip)s:%(port)s') % {
            'ip': ip,
            'port': port
        })
        _LOG.info(message)
        print(message)
    except KeyboardInterrupt:
        print(_i18n._("Thank You ! \nBye."))
        sys.exit(0)
Example #9
0
    # pylint: disable=no-value-for-parameter
    app = middleware.json_translator(app)

    if 'keystone_authtoken' in config.CONF:
        app = auth_token.AuthProtocol(app, {})
    else:
        logging.warning(_i18n._LW("keystone authentication disabled"))

    app = middleware.HealthApp(app=app, path='/v1/health')

    return app

config_file = '/etc/freezer-api.conf'
config_files_list = [config_file] if os.path.isfile(config_file) else []
config.parse_args(args=[], default_config_files=config_files_list)
log.setup()
logging.info(_i18n._LI("Freezer API starting"))
logging.info(_i18n._LI("Freezer config file(s) used: %s")
             % ', '.join(cfg.CONF.config_file))
try:
    db = driver.get_db()
    application = get_application(db)
except Exception as err:
    message = _i18n._('Unable to start server: %s ') % err
    print(message)
    logging.fatal(message)
    sys.exit(1)


def main():
Example #10
0
    endpoint_catalog = [('/v1', v1.public_endpoints(db)),
                        ('/', [('', versions.Resource())])]
    for version_path, endpoints in endpoint_catalog:
        for route, resource in endpoints:
            app.add_route(version_path + route, resource)

    if 'keystone_authtoken' in config.CONF:
        app = auth_token.AuthProtocol(app, {})
    else:
        logging.warning("keystone authentication disabled")
    return app


config_file = '/etc/freezer-api.conf'
config_files_list = [config_file] if os.path.isfile(config_file) else []
config.parse_args(args=[], default_config_files=config_files_list)
log.setup()
logging.info("Freezer API starting")
logging.info("Freezer config file(s) used: {0}".format(', '.join(
    cfg.CONF.config_file)))
try:
    db = driver.get_db()
    application = get_application(db)
except Exception as err:
    message = 'Unable to start server: {0}'.format(err)
    print message
    logging.fatal(message)
    sys.exit(1)


def main():