Skip to content

Commit

Permalink
Merge "conf: Move api options to a group"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Dec 2, 2016
2 parents 10d0326 + b7b282e commit 365fced
Show file tree
Hide file tree
Showing 39 changed files with 216 additions and 149 deletions.
4 changes: 2 additions & 2 deletions nova/api/auth.py
Expand Up @@ -55,7 +55,7 @@ def pipeline_factory(loader, global_conf, **local_conf):

def pipeline_factory_v21(loader, global_conf, **local_conf):
"""A paste pipeline replica that keys off of auth_strategy."""
return _load_pipeline(loader, local_conf[CONF.auth_strategy].split())
return _load_pipeline(loader, local_conf[CONF.api.auth_strategy].split())


class InjectContext(wsgi.Middleware):
Expand All @@ -82,7 +82,7 @@ def __call__(self, req):

# Build a context, including the auth_token...
remote_address = req.remote_addr
if CONF.use_forwarded_for:
if CONF.api.use_forwarded_for:
remote_address = req.headers.get('X-Forwarded-For', remote_address)

service_catalog = None
Expand Down
8 changes: 4 additions & 4 deletions nova/api/metadata/base.py
Expand Up @@ -483,8 +483,8 @@ def _vendor_data(self, version, path):
# specified an old style driver here, then use that. This second
# bit can be removed once old style vendordata is fully deprecated
# and removed.
if (CONF.vendordata_providers and
'StaticJSON' in CONF.vendordata_providers):
if (CONF.api.vendordata_providers and
'StaticJSON' in CONF.api.vendordata_providers):
return jsonutils.dump_as_bytes(
self.vendordata_providers['StaticJSON'].get())
else:
Expand All @@ -499,7 +499,7 @@ def _vendor_data2(self, version, path):
self.set_mimetype(MIME_TYPE_APPLICATION_JSON)

j = {}
for provider in CONF.vendordata_providers:
for provider in CONF.api.vendordata_providers:
if provider == 'StaticJSON':
j['static'] = self.vendordata_providers['StaticJSON'].get()
else:
Expand Down Expand Up @@ -576,7 +576,7 @@ def metadata_for_config_drive(self):
"""Yields (path, value) tuples for metadata elements."""
# EC2 style metadata
for version in VERSIONS + ["latest"]:
if version in CONF.config_drive_skip_versions.split(' '):
if version in CONF.api.config_drive_skip_versions.split(' '):
continue

data = self.get_ec2_metadata(version)
Expand Down
8 changes: 4 additions & 4 deletions nova/api/metadata/handler.py
Expand Up @@ -46,7 +46,7 @@ class MetadataRequestHandler(wsgi.Application):

def __init__(self):
self._cache = cache_utils.get_client(
expiration_time=CONF.metadata_cache_expiration)
expiration_time=CONF.api.metadata_cache_expiration)
if (CONF.neutron.service_metadata_proxy and
not CONF.neutron.metadata_proxy_shared_secret):
LOG.warning(_LW("metadata_proxy_shared_secret is not configured, "
Expand All @@ -68,7 +68,7 @@ def get_metadata_by_remote_address(self, address):
except exception.NotFound:
return None

if CONF.metadata_cache_expiration > 0:
if CONF.api.metadata_cache_expiration > 0:
self._cache.set(cache_key, data)

return data
Expand All @@ -85,7 +85,7 @@ def get_metadata_by_instance_id(self, instance_id, address):
except exception.NotFound:
return None

if CONF.metadata_cache_expiration > 0:
if CONF.api.metadata_cache_expiration > 0:
self._cache.set(cache_key, data)

return data
Expand Down Expand Up @@ -130,7 +130,7 @@ def __call__(self, req):

def _handle_remote_ip_request(self, req):
remote_address = req.remote_addr
if CONF.use_forwarded_for:
if CONF.api.use_forwarded_for:
remote_address = req.headers.get('X-Forwarded-For', remote_address)

try:
Expand Down
10 changes: 5 additions & 5 deletions nova/api/metadata/vendordata_dynamic.py
Expand Up @@ -65,11 +65,11 @@ def _do_request(self, service_name, url):
# SSL verification
verify = url.startswith('https://')

if verify and CONF.vendordata_dynamic_ssl_certfile:
verify = CONF.vendordata_dynamic_ssl_certfile
if verify and CONF.api.vendordata_dynamic_ssl_certfile:
verify = CONF.api.vendordata_dynamic_ssl_certfile

timeout = (CONF.vendordata_dynamic_connect_timeout,
CONF.vendordata_dynamic_read_timeout)
timeout = (CONF.api.vendordata_dynamic_connect_timeout,
CONF.api.vendordata_dynamic_read_timeout)

res = requests.request('POST', url, data=jsonutils.dumps(body),
headers=headers, verify=verify,
Expand All @@ -96,7 +96,7 @@ def _do_request(self, service_name, url):
def get(self):
j = {}

for target in CONF.vendordata_dynamic_targets:
for target in CONF.api.vendordata_dynamic_targets:
# NOTE(mikal): a target is composed of the following:
# name@url
# where name is the name to use in the metadata handed to
Expand Down
2 changes: 1 addition & 1 deletion nova/api/metadata/vendordata_json.py
Expand Up @@ -32,7 +32,7 @@ class JsonFileVendorData(vendordata.VendorDataDriver):
def __init__(self, *args, **kwargs):
super(JsonFileVendorData, self).__init__(*args, **kwargs)
data = {}
fpath = CONF.vendordata_jsonfile_path
fpath = CONF.api.vendordata_jsonfile_path
logprefix = "vendordata_jsonfile_path[%s]:" % fpath
if fpath:
try:
Expand Down
2 changes: 1 addition & 1 deletion nova/api/openstack/auth.py
Expand Up @@ -50,7 +50,7 @@ def base_call(self, req, project_id_in_path, always_admin=True):
user_id, _sep, project_id = token.partition(':')
project_id = project_id or user_id
remote_address = getattr(req, 'remote_address', '127.0.0.1')
if CONF.use_forwarded_for:
if CONF.api.use_forwarded_for:
remote_address = req.headers.get('X-Forwarded-For', remote_address)
is_admin = always_admin or (user_id == 'admin')
ctx = context.RequestContext(user_id,
Expand Down
22 changes: 10 additions & 12 deletions nova/api/openstack/common.py
Expand Up @@ -227,7 +227,7 @@ def limited(items, request):
"""
params = get_pagination_params(request)
offset = params.get('offset', 0)
limit = CONF.osapi_max_limit
limit = CONF.api.max_limit
limit = min(limit, params.get('limit') or limit)

return items[offset:(offset + limit)]
Expand All @@ -236,7 +236,7 @@ def limited(items, request):
def get_limit_and_marker(request):
"""Get limited parameter from request."""
params = get_pagination_params(request)
limit = CONF.osapi_max_limit
limit = CONF.api.max_limit
limit = min(limit, params.get('limit', limit))
marker = params.get('marker', None)

Expand Down Expand Up @@ -351,7 +351,7 @@ def raise_http_conflict_for_instance_invalid_state(exc, action, server_id):
def check_snapshots_enabled(f):
@functools.wraps(f)
def inner(*args, **kwargs):
if not CONF.allow_instance_snapshots:
if not CONF.api.allow_instance_snapshots:
LOG.warning(_LW('Rejecting snapshot request, snapshots currently'
' disabled'))
msg = _("Instance snapshots are not permitted at this time.")
Expand Down Expand Up @@ -433,15 +433,15 @@ def _get_collection_links(self,
id_key="uuid"):
"""Retrieve 'next' link, if applicable. This is included if:
1) 'limit' param is specified and equals the number of items.
2) 'limit' param is specified but it exceeds CONF.osapi_max_limit,
in this case the number of items is CONF.osapi_max_limit.
2) 'limit' param is specified but it exceeds CONF.api.max_limit,
in this case the number of items is CONF.api.max_limit.
3) 'limit' param is NOT specified but the number of items is
CONF.osapi_max_limit.
CONF.api.max_limit.
"""
links = []
max_items = min(
int(request.params.get("limit", CONF.osapi_max_limit)),
CONF.osapi_max_limit)
int(request.params.get("limit", CONF.api.max_limit)),
CONF.api.max_limit)
if max_items and max_items == len(items):
last_item = items[-1]
if id_key in last_item:
Expand All @@ -468,12 +468,10 @@ def _update_link_prefix(self, orig_url, prefix):
return urlparse.urlunsplit(url_parts).rstrip('/')

def _update_glance_link_prefix(self, orig_url):
return self._update_link_prefix(orig_url,
CONF.osapi_glance_link_prefix)
return self._update_link_prefix(orig_url, CONF.api.glance_link_prefix)

def _update_compute_link_prefix(self, orig_url):
return self._update_link_prefix(orig_url,
CONF.osapi_compute_link_prefix)
return self._update_link_prefix(orig_url, CONF.api.compute_link_prefix)


def get_instance(compute_api, context, instance_id, expected_attrs=None):
Expand Down
2 changes: 1 addition & 1 deletion nova/api/openstack/compute/evacuate.py
Expand Up @@ -128,7 +128,7 @@ def _evacuate(self, req, id, body):
raise exc.HTTPBadRequest(explanation=e.format_message())

if (not api_version_request.is_supported(req, min_version='2.14') and
CONF.enable_instance_password):
CONF.api.enable_instance_password):
return {'adminPass': password}
else:
return None
Expand Down
4 changes: 2 additions & 2 deletions nova/api/openstack/compute/fping.py
Expand Up @@ -43,13 +43,13 @@ def __init__(self, network_api=None):
self.last_call = {}

def check_fping(self):
if not os.access(CONF.fping_path, os.X_OK):
if not os.access(CONF.api.fping_path, os.X_OK):
raise exc.HTTPServiceUnavailable(
explanation=_("fping utility is not found."))

@staticmethod
def fping(ips):
fping_ret = utils.execute(CONF.fping_path, *ips,
fping_ret = utils.execute(CONF.api.fping_path, *ips,
check_exit_code=False)
if not fping_ret:
return set()
Expand Down
2 changes: 1 addition & 1 deletion nova/api/openstack/compute/hide_server_addresses.py
Expand Up @@ -30,7 +30,7 @@
class Controller(wsgi.Controller):
def __init__(self, *args, **kwargs):
super(Controller, self).__init__(*args, **kwargs)
hidden_states = CONF.osapi_hide_server_address_states
hidden_states = CONF.api.hide_server_address_states

# NOTE(jkoelker) _ is not considered uppercase ;)
valid_vm_states = [getattr(vm_states, state)
Expand Down
8 changes: 4 additions & 4 deletions nova/api/openstack/compute/quota_sets.py
Expand Up @@ -143,10 +143,10 @@ def _update(self, req, id, body, filtered_quotas):

quota_set = body['quota_set']

# NOTE(alex_xu): The CONF.enable_network_quota was deprecated due to
# it is only used by nova-network, and nova-network will be deprecated
# also. So when CONF.enable_newtork_quota is removed, the networks
# quota will disappeare also.
# NOTE(alex_xu): The CONF.enable_network_quota was deprecated
# due to it is only used by nova-network, and nova-network will be
# deprecated also. So when CONF.enable_newtork_quota is removed,
# the networks quota will disappeare also.
if not CONF.enable_network_quota and 'networks' in quota_set:
raise webob.exc.HTTPBadRequest(
explanation=_('The networks quota is disabled'))
Expand Down
2 changes: 1 addition & 1 deletion nova/api/openstack/compute/rescue.py
Expand Up @@ -77,7 +77,7 @@ def _rescue(self, req, id, body):
raise exc.HTTPBadRequest(
explanation=non_rescuable.format_message())

if CONF.enable_instance_password:
if CONF.api.enable_instance_password:
return {'adminPass': password}
else:
return {}
Expand Down
4 changes: 2 additions & 2 deletions nova/api/openstack/compute/servers.py
Expand Up @@ -708,7 +708,7 @@ def create(self, req, body):
req.cache_db_instances(instances)
server = self._view_builder.create(req, instances[0])

if CONF.enable_instance_password:
if CONF.api.enable_instance_password:
server['server']['adminPass'] = password

robj = wsgi.ResponseObject(server)
Expand Down Expand Up @@ -1032,7 +1032,7 @@ def _action_rebuild(self, req, id, body):

# Add on the admin_password attribute since the view doesn't do it
# unless instance passwords are disabled
if CONF.enable_instance_password:
if CONF.api.enable_instance_password:
view['server']['adminPass'] = password

robj = wsgi.ResponseObject(view)
Expand Down
4 changes: 2 additions & 2 deletions nova/api/openstack/compute/tenant_networks.py
Expand Up @@ -60,14 +60,14 @@ def __init__(self, network_api=None):

def _refresh_default_networks(self):
self._default_networks = []
if CONF.use_neutron_default_nets:
if CONF.api.use_neutron_default_nets:
try:
self._default_networks = self._get_default_networks()
except Exception:
LOG.exception(_LE("Failed to get default networks"))

def _get_default_networks(self):
project_id = CONF.neutron_default_tenant_id
project_id = CONF.api.neutron_default_tenant_id
ctx = nova_context.RequestContext(user_id=None,
project_id=project_id)
networks = {}
Expand Down
2 changes: 1 addition & 1 deletion nova/api/openstack/placement/deploy.py
Expand Up @@ -34,7 +34,7 @@

def deploy(conf, project_name):
"""Assemble the middleware pipeline leading to the placement app."""
if conf.auth_strategy == 'noauth2':
if conf.api.auth_strategy == 'noauth2':
auth_middleware = auth.NoAuthMiddleware
else:
# Do not provide global conf to middleware here.
Expand Down

0 comments on commit 365fced

Please sign in to comment.