Exemplo n.º 1
0
def init_application():
    # initialize the config system
    conffiles = _get_config_files()

    config = cfg.ConfigOpts()
    conf.register_opts(config)

    # This will raise cfg.RequiredOptError when a required option is not set
    # (notably the database connection string). We want this to be a hard fail
    # that prevents the application from starting. The error will show up in
    # the wsgi server's logs.
    _parse_args(config, [], default_config_files=conffiles)
    # initialize the logging system
    setup_logging(config)

    # configure database
    db_api.configure(config)

    # dump conf at debug if log_options
    if config.log_options:
        config.log_opt_values(logging.getLogger(__name__), logging.DEBUG)

    setup_profiler(config)

    # build and return our WSGI app
    return deploy.loadapp(config)
Exemplo n.º 2
0
    def setUp(self):
        super(SchedulerReportClientTests, self).setUp()
        self.flags(auth_strategy='noauth2', group='api')

        self.app = lambda: deploy.loadapp(CONF)
        self.client = NoAuthReportClient()
        # TODO(cdent): Port required here to deal with a bug
        # in wsgi-intercept:
        # https://github.com/cdent/wsgi-intercept/issues/41
        self.url = 'http://localhost:80/placement'
        self.compute_uuid = uuids.compute_node
        self.compute_name = 'computehost'
        self.compute_node = objects.ComputeNode(
            uuid=self.compute_uuid,
            hypervisor_hostname=self.compute_name,
            vcpus=2,
            cpu_allocation_ratio=16.0,
            memory_mb=2048,
            ram_allocation_ratio=1.5,
            local_gb=1024,
            disk_allocation_ratio=1.0)

        self.instance_uuid = uuids.inst
        self.instance = objects.Instance(
            uuid=self.instance_uuid,
            project_id = uuids.project,
            user_id = uuids.user,
            flavor=objects.Flavor(root_gb=10,
                                  swap=1,
                                  ephemeral_gb=100,
                                  memory_mb=1024,
                                  vcpus=2,
                                  extra_specs={}))
        self.context = context.get_admin_context()
Exemplo n.º 3
0
    def setUp(self):
        super(PlacementFixture, self).setUp()
        if not self.conf_fixture:
            config = cfg.ConfigOpts()
            self.conf_fixture = self.useFixture(config_fixture.Config(config))
        if self.register_opts:
            conf.register_opts(self.conf_fixture.conf)

        if self.db:
            self.useFixture(
                db_fixture.Database(self.conf_fixture, set_config=True))
        policy_opts.set_defaults(self.conf_fixture.conf)
        self.conf_fixture.config(group='api', auth_strategy='noauth2')

        self.conf_fixture.conf([], default_config_files=[])

        self.useFixture(policy_fixture.PolicyFixture(self.conf_fixture))

        if self.use_intercept:
            loader = deploy.loadapp(self.conf_fixture.conf)

            def app():
                return loader

            self.endpoint = 'http://%s/placement' % uuidutils.generate_uuid()
            intercept = interceptor.RequestsInterceptor(app, url=self.endpoint)
            intercept.install_intercept()
            self.addCleanup(intercept.uninstall_intercept)
Exemplo n.º 4
0
    def setUp(self):
        super(PlacementFixture, self).setUp()

        conf_fixture = config_fixture.Config(CONF)
        conf_fixture.config(group='api', auth_strategy='noauth2')
        loader = deploy.loadapp(CONF)
        app = lambda: loader
        self.endpoint = 'http://%s/placement' % uuidutils.generate_uuid()
        intercept = interceptor.RequestsInterceptor(app, url=self.endpoint)
        intercept.install_intercept()
        self.addCleanup(intercept.uninstall_intercept)
Exemplo n.º 5
0
def init_application():
    # initialize the config system
    conffile = _get_config_file()
    _parse_args([], default_config_files=[conffile])
    db_api.configure(conf.CONF)

    # initialize the logging system
    setup_logging(conf.CONF)

    # dump conf at debug if log_options
    if conf.CONF.log_options:
        conf.CONF.log_opt_values(logging.getLogger(__name__), logging.DEBUG)

    # build and return our WSGI app
    return deploy.loadapp(conf.CONF)
Exemplo n.º 6
0
def init_application():
    # initialize the config system
    conffile = _get_config_file()
    _parse_args([], default_config_files=[conffile])
    db_api.configure(conf.CONF)

    # initialize the logging system
    setup_logging(conf.CONF)

    # dump conf at debug (log_options option comes from oslo.service)
    # FIXME(mriedem): This is gross but we don't have a public hook into
    # oslo.service to register these options, so we are doing it manually for
    # now; remove this when we have a hook method into oslo.service.
    conf.CONF.register_opts(service_opts.service_opts)
    if conf.CONF.log_options:
        conf.CONF.log_opt_values(
            logging.getLogger(__name__),
            logging.DEBUG)

    # build and return our WSGI app
    return deploy.loadapp(conf.CONF)
Exemplo n.º 7
0
 def __init__(self, conf, latest_microversion=False):
     conf.set_override('auth_strategy', 'noauth2', group='api')
     app = lambda: deploy.loadapp(conf)
     self.url = 'http://%s/placement' % str(uuidutils.generate_uuid())
     # Supply our own session so the wsgi-intercept can intercept
     # the right thing.
     request_session = requests.Session()
     headers = {
         'x-auth-token': 'admin',
     }
     # TODO(efried): See below
     if latest_microversion:
         headers['OpenStack-API-Version'] = 'placement latest'
     self.adapter = adapter.Adapter(
         session.Session(auth=None, session=request_session,
                         additional_headers=headers),
         service_type='placement', raise_exc=False)
     # TODO(efried): Figure out why this isn't working:
     #   default_microversion='latest' if latest_microversion else None)
     self._mocked_endpoint = mock.patch(
         'keystoneauth1.session.Session.get_endpoint',
         new=mock.Mock(return_value=self.url))
     super(PlacementDirect, self).__init__(app, url=self.url)
Exemplo n.º 8
0
def setup_app():
    global CONF
    return deploy.loadapp(CONF)
Exemplo n.º 9
0
def setup_app():
    return deploy.loadapp(CONF)
Exemplo n.º 10
0
 def app():
     return deploy.loadapp(conf)