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, flavor=objects.Flavor(root_gb=10, swap=1, ephemeral_gb=100, memory_mb=1024, vcpus=2))
def setUp(self): super(PlacementFixture, self).setUp() self.useFixture(ConfPatcher(group='api', auth_strategy='noauth2')) app = placement_deploy.loadapp(CONF) # in order to run these in tests we need to bind only to local # host, and dynamically allocate ports self.service = wsgi.Server('placement', app, host='127.0.0.1') self.service.start() self.addCleanup(self.service.stop) self._client = ks.Session(auth=None) # NOTE(sbauza): We need to mock the scheduler report client because # we need to fake Keystone by directly calling the endpoint instead # of looking up the service catalog, like we did for the OSAPIFixture. self.useFixture(fixtures.MonkeyPatch( 'nova.scheduler.client.report.SchedulerReportClient.get', self._fake_get)) self.useFixture(fixtures.MonkeyPatch( 'nova.scheduler.client.report.SchedulerReportClient.post', self._fake_post)) self.useFixture(fixtures.MonkeyPatch( 'nova.scheduler.client.report.SchedulerReportClient.put', self._fake_put)) self.useFixture(fixtures.MonkeyPatch( 'nova.scheduler.client.report.SchedulerReportClient.delete', self._fake_delete))
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))
def setUp(self): super(PlacementFixture, self).setUp() self.useFixture(ConfPatcher(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)
def init_application(): # initialize the config system conffile = _get_config_file() config.parse_args([], default_config_files=[conffile]) # initialize the logging system setup_logging(conf.CONF) # dump conf if we're at debug if conf.CONF.debug: conf.CONF.log_opt_values(logging.getLogger(__name__), logging.DEBUG) # build our paste app and return it for wsgi goodness return deploy.loadapp(conf.CONF)
def init_application(): # initialize the config system conffile = _get_config_file() config.parse_args([], default_config_files=[conffile]) # initialize the logging system setup_logging(conf.CONF) # dump conf if we're at debug if conf.CONF.debug: conf.CONF.log_opt_values(logging.getLogger(__name__), logging.DEBUG) LOG.info("Starting placement api") # build and return our WSGI app return deploy.loadapp(conf.CONF)
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)
def init_application(): # initialize the config system conffile = _get_config_file() config.parse_args([], default_config_files=[conffile]) # initialize the logging system setup_logging(conf.CONF) # dump conf if we're at debug if conf.CONF.debug: conf.CONF.log_opt_values( logging.getLogger(__name__), logging.DEBUG) # build and return our WSGI app return deploy.loadapp(conf.CONF)
def init_application(): # initialize the config system conffile = _get_config_file() config.parse_args([], default_config_files=[conffile]) # 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)
def init_application(): # initialize the config system conffile = _get_config_file() # NOTE(lyarwood): Call reset to ensure the ConfigOpts object doesn't # already contain registered options if the app is reloaded. conf.CONF.reset() _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)
def setUp(self): super(IronicResourceTrackerTest, self).setUp() self.flags(auth_strategy='noauth2', group='api') self.flags( reserved_host_memory_mb=0, cpu_allocation_ratio=1.0, ram_allocation_ratio=1.0, disk_allocation_ratio=1.0, ) self.ctx = context.RequestContext('user', 'project') self.app = lambda: deploy.loadapp(CONF) self.report_client = test_report_client.NoAuthReportClient() driver = mock.MagicMock(autospec='nova.virt.driver.ComputeDriver') driver.node_is_available.return_value = True self.driver_mock = driver self.rt = resource_tracker.ResourceTracker(COMPUTE_HOST, driver) self.rt.scheduler_client.reportclient = self.report_client self.url = 'http://localhost/placement' self.create_fixtures()
def init_application(): # initialize the config system conffile = _get_config_file() # NOTE(lyarwood): Call reset to ensure the ConfigOpts object doesn't # already contain registered options if the app is reloaded. conf.CONF.reset() _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)
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)
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)
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """WSGI script for Placement API WSGI handler for running Placement API under Apache2, nginx, gunicorn etc. """ from nova.api.openstack.placement import deploy from nova import conf from nova import config CONFIG_FILE = '/etc/nova/nova.conf' config.parse_args([], default_config_files=[CONFIG_FILE]) application = deploy.loadapp(conf.CONF)
def setup_app(): return deploy.loadapp(CONF)