Replace FLAGS with cfg.CONF in api
Replace all the FLAGS with cfg.CONF in cinder/api Large commit was split into several parts Change-Id: I2114d5fc45f5299c3b2011270034a3370e0ec388 Fixes: bug #1182037
This commit is contained in:
		@@ -16,17 +16,17 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from oslo.config import cfg
 | 
				
			||||||
import paste.urlmap
 | 
					import paste.urlmap
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CONF = cfg.CONF
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def root_app_factory(loader, global_conf, **local_conf):
 | 
					def root_app_factory(loader, global_conf, **local_conf):
 | 
				
			||||||
    if not FLAGS.enable_v1_api:
 | 
					    if not CONF.enable_v1_api:
 | 
				
			||||||
        del local_conf['/v1']
 | 
					        del local_conf['/v1']
 | 
				
			||||||
    if not FLAGS.enable_v2_api:
 | 
					    if not CONF.enable_v2_api:
 | 
				
			||||||
        del local_conf['/v2']
 | 
					        del local_conf['/v2']
 | 
				
			||||||
    return paste.urlmap.urlmap_factory(loader, global_conf, **local_conf)
 | 
					    return paste.urlmap.urlmap_factory(loader, global_conf, **local_conf)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,21 +15,22 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
import urlparse
 | 
					import urlparse
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from oslo.config import cfg
 | 
				
			||||||
import webob
 | 
					import webob
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from cinder.api.openstack import wsgi
 | 
					from cinder.api.openstack import wsgi
 | 
				
			||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
from cinder import utils
 | 
					from cinder import utils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CONF = cfg.CONF
 | 
				
			||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
XML_NS_V1 = 'http://docs.openstack.org/volume/api/v1'
 | 
					XML_NS_V1 = 'http://docs.openstack.org/volume/api/v1'
 | 
				
			||||||
@@ -73,7 +74,7 @@ def _get_marker_param(request):
 | 
				
			|||||||
    return request.GET['marker']
 | 
					    return request.GET['marker']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def limited(items, request, max_limit=FLAGS.osapi_max_limit):
 | 
					def limited(items, request, max_limit=CONF.osapi_max_limit):
 | 
				
			||||||
    """Return a slice of items according to requested offset and limit.
 | 
					    """Return a slice of items according to requested offset and limit.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    :param items: A sliceable entity
 | 
					    :param items: A sliceable entity
 | 
				
			||||||
@@ -110,7 +111,7 @@ def limited(items, request, max_limit=FLAGS.osapi_max_limit):
 | 
				
			|||||||
    return items[offset:range_end]
 | 
					    return items[offset:range_end]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def limited_by_marker(items, request, max_limit=FLAGS.osapi_max_limit):
 | 
					def limited_by_marker(items, request, max_limit=CONF.osapi_max_limit):
 | 
				
			||||||
    """Return a slice of items according to the requested marker and limit."""
 | 
					    """Return a slice of items according to the requested marker and limit."""
 | 
				
			||||||
    params = get_pagination_params(request)
 | 
					    params = get_pagination_params(request)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -192,7 +193,7 @@ class ViewBuilder(object):
 | 
				
			|||||||
        params = request.params.copy()
 | 
					        params = request.params.copy()
 | 
				
			||||||
        params["marker"] = identifier
 | 
					        params["marker"] = identifier
 | 
				
			||||||
        prefix = self._update_link_prefix(request.application_url,
 | 
					        prefix = self._update_link_prefix(request.application_url,
 | 
				
			||||||
                                          FLAGS.osapi_volume_base_URL)
 | 
					                                          CONF.osapi_volume_base_URL)
 | 
				
			||||||
        url = os.path.join(prefix,
 | 
					        url = os.path.join(prefix,
 | 
				
			||||||
                           request.environ["cinder.context"].project_id,
 | 
					                           request.environ["cinder.context"].project_id,
 | 
				
			||||||
                           self._collection_name)
 | 
					                           self._collection_name)
 | 
				
			||||||
@@ -201,7 +202,7 @@ class ViewBuilder(object):
 | 
				
			|||||||
    def _get_href_link(self, request, identifier):
 | 
					    def _get_href_link(self, request, identifier):
 | 
				
			||||||
        """Return an href string pointing to this object."""
 | 
					        """Return an href string pointing to this object."""
 | 
				
			||||||
        prefix = self._update_link_prefix(request.application_url,
 | 
					        prefix = self._update_link_prefix(request.application_url,
 | 
				
			||||||
                                          FLAGS.osapi_volume_base_URL)
 | 
					                                          CONF.osapi_volume_base_URL)
 | 
				
			||||||
        return os.path.join(prefix,
 | 
					        return os.path.join(prefix,
 | 
				
			||||||
                            request.environ["cinder.context"].project_id,
 | 
					                            request.environ["cinder.context"].project_id,
 | 
				
			||||||
                            self._collection_name,
 | 
					                            self._collection_name,
 | 
				
			||||||
@@ -211,7 +212,7 @@ class ViewBuilder(object):
 | 
				
			|||||||
        """Create a URL that refers to a specific resource."""
 | 
					        """Create a URL that refers to a specific resource."""
 | 
				
			||||||
        base_url = remove_version_from_href(request.application_url)
 | 
					        base_url = remove_version_from_href(request.application_url)
 | 
				
			||||||
        base_url = self._update_link_prefix(base_url,
 | 
					        base_url = self._update_link_prefix(base_url,
 | 
				
			||||||
                                            FLAGS.osapi_volume_base_URL)
 | 
					                                            CONF.osapi_volume_base_URL)
 | 
				
			||||||
        return os.path.join(base_url,
 | 
					        return os.path.join(base_url,
 | 
				
			||||||
                            request.environ["cinder.context"].project_id,
 | 
					                            request.environ["cinder.context"].project_id,
 | 
				
			||||||
                            self._collection_name,
 | 
					                            self._collection_name,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,12 +21,13 @@ It can't be called 'extensions' because that causes namespacing problems.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from oslo.config import cfg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from cinder.api import extensions
 | 
					from cinder.api import extensions
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					CONF = cfg.CONF
 | 
				
			||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -36,4 +37,4 @@ def standard_extensions(ext_mgr):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def select_extensions(ext_mgr):
 | 
					def select_extensions(ext_mgr):
 | 
				
			||||||
    extensions.load_standard_extensions(ext_mgr, LOG, __path__, __package__,
 | 
					    extensions.load_standard_extensions(ext_mgr, LOG, __path__, __package__,
 | 
				
			||||||
                                        FLAGS.osapi_volume_ext_list)
 | 
					                                        CONF.osapi_volume_ext_list)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
"""The backups api."""
 | 
					"""The backups api."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import webob
 | 
					import webob
 | 
				
			||||||
from webob import exc
 | 
					from webob import exc
 | 
				
			||||||
from xml.dom import minidom
 | 
					from xml.dom import minidom
 | 
				
			||||||
@@ -26,10 +27,9 @@ from cinder.api.views import backups as backup_views
 | 
				
			|||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import backup as backupAPI
 | 
					from cinder import backup as backupAPI
 | 
				
			||||||
from cinder import exception
 | 
					from cinder import exception
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					
 | 
				
			||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,18 +14,17 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
"""The Extended Snapshot Attributes API extension."""
 | 
					"""The Extended Snapshot Attributes API extension."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from webob import exc
 | 
					from webob import exc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from cinder.api import extensions
 | 
					from cinder.api import extensions
 | 
				
			||||||
from cinder.api.openstack import wsgi
 | 
					from cinder.api.openstack import wsgi
 | 
				
			||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import exception
 | 
					from cinder import exception
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
from cinder import volume
 | 
					from cinder import volume
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					 | 
				
			||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
authorize = extensions.soft_extension_authorizer(
 | 
					authorize = extensions.soft_extension_authorizer(
 | 
				
			||||||
    'volume',
 | 
					    'volume',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
"""The hosts admin extension."""
 | 
					"""The hosts admin extension."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from oslo.config import cfg
 | 
				
			||||||
import webob.exc
 | 
					import webob.exc
 | 
				
			||||||
from xml.parsers import expat
 | 
					from xml.parsers import expat
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,13 +25,14 @@ from cinder.api.openstack import wsgi
 | 
				
			|||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import db
 | 
					from cinder import db
 | 
				
			||||||
from cinder import exception
 | 
					from cinder import exception
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
from cinder.openstack.common import timeutils
 | 
					from cinder.openstack.common import timeutils
 | 
				
			||||||
from cinder import utils
 | 
					from cinder import utils
 | 
				
			||||||
from cinder.volume import api as volume_api
 | 
					from cinder.volume import api as volume_api
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					
 | 
				
			||||||
 | 
					CONF = cfg.CONF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
authorize = extensions.extension_authorizer('volume', 'hosts')
 | 
					authorize = extensions.extension_authorizer('volume', 'hosts')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -103,7 +106,7 @@ def _list_hosts(req, service=None):
 | 
				
			|||||||
    hosts = []
 | 
					    hosts = []
 | 
				
			||||||
    for host in services:
 | 
					    for host in services:
 | 
				
			||||||
        delta = curr_time - (host['updated_at'] or host['created_at'])
 | 
					        delta = curr_time - (host['updated_at'] or host['created_at'])
 | 
				
			||||||
        alive = abs(utils.total_seconds(delta)) <= FLAGS.service_down_time
 | 
					        alive = abs(utils.total_seconds(delta)) <= CONF.service_down_time
 | 
				
			||||||
        status = (alive and "available") or "unavailable"
 | 
					        status = (alive and "available") or "unavailable"
 | 
				
			||||||
        active = 'enabled'
 | 
					        active = 'enabled'
 | 
				
			||||||
        if host['disabled']:
 | 
					        if host['disabled']:
 | 
				
			||||||
@@ -205,7 +208,7 @@ class HostController(object):
 | 
				
			|||||||
        try:
 | 
					        try:
 | 
				
			||||||
            host_ref = db.service_get_by_host_and_topic(context,
 | 
					            host_ref = db.service_get_by_host_and_topic(context,
 | 
				
			||||||
                                                        host,
 | 
					                                                        host,
 | 
				
			||||||
                                                        FLAGS.volume_topic)
 | 
					                                                        CONF.volume_topic)
 | 
				
			||||||
        except exception.ServiceNotFound:
 | 
					        except exception.ServiceNotFound:
 | 
				
			||||||
            raise webob.exc.HTTPNotFound(explanation=_("Host not found"))
 | 
					            raise webob.exc.HTTPNotFound(explanation=_("Host not found"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,14 +18,12 @@ from cinder.api import extensions
 | 
				
			|||||||
from cinder.api.openstack import wsgi
 | 
					from cinder.api.openstack import wsgi
 | 
				
			||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import exception
 | 
					from cinder import exception
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
from cinder.openstack.common.rpc import common as rpc_common
 | 
					from cinder.openstack.common.rpc import common as rpc_common
 | 
				
			||||||
from cinder import utils
 | 
					from cinder import utils
 | 
				
			||||||
from cinder import volume
 | 
					from cinder import volume
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					 | 
				
			||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,6 +18,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from oslo.config import cfg
 | 
				
			||||||
import webob.dec
 | 
					import webob.dec
 | 
				
			||||||
import webob.exc
 | 
					import webob.exc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -25,15 +26,15 @@ import cinder.api.openstack
 | 
				
			|||||||
from cinder.api.openstack import wsgi
 | 
					from cinder.api.openstack import wsgi
 | 
				
			||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import exception
 | 
					from cinder import exception
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import exception as common_exception
 | 
					from cinder.openstack.common import exception as common_exception
 | 
				
			||||||
from cinder.openstack.common import importutils
 | 
					from cinder.openstack.common import importutils
 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
import cinder.policy
 | 
					import cinder.policy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CONF = cfg.CONF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ExtensionDescriptor(object):
 | 
					class ExtensionDescriptor(object):
 | 
				
			||||||
@@ -183,7 +184,7 @@ class ExtensionManager(object):
 | 
				
			|||||||
    def __init__(self):
 | 
					    def __init__(self):
 | 
				
			||||||
        LOG.audit(_('Initializing extension manager.'))
 | 
					        LOG.audit(_('Initializing extension manager.'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.cls_list = FLAGS.osapi_volume_extension
 | 
					        self.cls_list = CONF.osapi_volume_extension
 | 
				
			||||||
        self.extensions = {}
 | 
					        self.extensions = {}
 | 
				
			||||||
        self._load_extensions()
 | 
					        self._load_extensions()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,6 +18,8 @@
 | 
				
			|||||||
Common Auth Middleware.
 | 
					Common Auth Middleware.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from oslo.config import cfg
 | 
					from oslo.config import cfg
 | 
				
			||||||
@@ -26,26 +28,27 @@ import webob.exc
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from cinder.api.openstack import wsgi
 | 
					from cinder.api.openstack import wsgi
 | 
				
			||||||
from cinder import context
 | 
					from cinder import context
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
from cinder import wsgi as base_wsgi
 | 
					from cinder import wsgi as base_wsgi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use_forwarded_for_opt = cfg.BoolOpt(
 | 
					use_forwarded_for_opt = cfg.BoolOpt(
 | 
				
			||||||
    'use_forwarded_for',
 | 
					    'use_forwarded_for',
 | 
				
			||||||
    default=False,
 | 
					    default=False,
 | 
				
			||||||
    help='Treat X-Forwarded-For as the canonical remote address. '
 | 
					    help='Treat X-Forwarded-For as the canonical remote address. '
 | 
				
			||||||
         'Only enable this if you have a sanitizing proxy.')
 | 
					         'Only enable this if you have a sanitizing proxy.')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					CONF = cfg.CONF
 | 
				
			||||||
FLAGS.register_opt(use_forwarded_for_opt)
 | 
					CONF.register_opt(use_forwarded_for_opt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def pipeline_factory(loader, global_conf, **local_conf):
 | 
					def pipeline_factory(loader, global_conf, **local_conf):
 | 
				
			||||||
    """A paste pipeline replica that keys off of auth_strategy."""
 | 
					    """A paste pipeline replica that keys off of auth_strategy."""
 | 
				
			||||||
    pipeline = local_conf[FLAGS.auth_strategy]
 | 
					    pipeline = local_conf[CONF.auth_strategy]
 | 
				
			||||||
    if not FLAGS.api_rate_limit:
 | 
					    if not CONF.api_rate_limit:
 | 
				
			||||||
        limit_name = FLAGS.auth_strategy + '_nolimit'
 | 
					        limit_name = CONF.auth_strategy + '_nolimit'
 | 
				
			||||||
        pipeline = local_conf.get(limit_name, pipeline)
 | 
					        pipeline = local_conf.get(limit_name, pipeline)
 | 
				
			||||||
    pipeline = pipeline.split()
 | 
					    pipeline = pipeline.split()
 | 
				
			||||||
    filters = [loader.get_filter(n) for n in pipeline[:-1]]
 | 
					    filters = [loader.get_filter(n) for n in pipeline[:-1]]
 | 
				
			||||||
@@ -94,7 +97,7 @@ class CinderKeystoneContext(base_wsgi.Middleware):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # Build a context, including the auth_token...
 | 
					        # Build a context, including the auth_token...
 | 
				
			||||||
        remote_address = req.remote_addr
 | 
					        remote_address = req.remote_addr
 | 
				
			||||||
        if FLAGS.use_forwarded_for:
 | 
					        if CONF.use_forwarded_for:
 | 
				
			||||||
            remote_address = req.headers.get('X-Forwarded-For', remote_address)
 | 
					            remote_address = req.headers.get('X-Forwarded-For', remote_address)
 | 
				
			||||||
        ctx = context.RequestContext(user_id,
 | 
					        ctx = context.RequestContext(user_id,
 | 
				
			||||||
                                     project_id,
 | 
					                                     project_id,
 | 
				
			||||||
@@ -129,7 +132,7 @@ class NoAuthMiddleware(base_wsgi.Middleware):
 | 
				
			|||||||
        user_id, _sep, project_id = token.partition(':')
 | 
					        user_id, _sep, project_id = token.partition(':')
 | 
				
			||||||
        project_id = project_id or user_id
 | 
					        project_id = project_id or user_id
 | 
				
			||||||
        remote_address = getattr(req, 'remote_address', '127.0.0.1')
 | 
					        remote_address = getattr(req, 'remote_address', '127.0.0.1')
 | 
				
			||||||
        if FLAGS.use_forwarded_for:
 | 
					        if CONF.use_forwarded_for:
 | 
				
			||||||
            remote_address = req.headers.get('X-Forwarded-For', remote_address)
 | 
					            remote_address = req.headers.get('X-Forwarded-For', remote_address)
 | 
				
			||||||
        ctx = context.RequestContext(user_id,
 | 
					        ctx = context.RequestContext(user_id,
 | 
				
			||||||
                                     project_id,
 | 
					                                     project_id,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,21 +18,23 @@ Request Body limiting middleware.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from oslo.config import cfg
 | 
					from oslo.config import cfg
 | 
				
			||||||
import webob.dec
 | 
					import webob.dec
 | 
				
			||||||
import webob.exc
 | 
					import webob.exc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
from cinder import wsgi
 | 
					from cinder import wsgi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#default request size is 112k
 | 
					#default request size is 112k
 | 
				
			||||||
max_request_body_size_opt = cfg.IntOpt('osapi_max_request_body_size',
 | 
					max_request_body_size_opt = cfg.IntOpt('osapi_max_request_body_size',
 | 
				
			||||||
                                       default=114688,
 | 
					                                       default=114688,
 | 
				
			||||||
                                       help='Max size for body of a request')
 | 
					                                       help='Max size for body of a request')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					CONF = cfg.CONF
 | 
				
			||||||
FLAGS.register_opt(max_request_body_size_opt)
 | 
					CONF.register_opt(max_request_body_size_opt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -73,11 +75,11 @@ class RequestBodySizeLimiter(wsgi.Middleware):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @webob.dec.wsgify(RequestClass=wsgi.Request)
 | 
					    @webob.dec.wsgify(RequestClass=wsgi.Request)
 | 
				
			||||||
    def __call__(self, req):
 | 
					    def __call__(self, req):
 | 
				
			||||||
        if req.content_length > FLAGS.osapi_max_request_body_size:
 | 
					        if req.content_length > CONF.osapi_max_request_body_size:
 | 
				
			||||||
            msg = _("Request is too large.")
 | 
					            msg = _("Request is too large.")
 | 
				
			||||||
            raise webob.exc.HTTPRequestEntityTooLarge(explanation=msg)
 | 
					            raise webob.exc.HTTPRequestEntityTooLarge(explanation=msg)
 | 
				
			||||||
        if req.content_length is None and req.is_body_readable:
 | 
					        if req.content_length is None and req.is_body_readable:
 | 
				
			||||||
            limiter = LimitingReader(req.body_file,
 | 
					            limiter = LimitingReader(req.body_file,
 | 
				
			||||||
                                     FLAGS.osapi_max_request_body_size)
 | 
					                                     CONF.osapi_max_request_body_size)
 | 
				
			||||||
            req.body_file = limiter
 | 
					            req.body_file = limiter
 | 
				
			||||||
        return self.application
 | 
					        return self.application
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,6 @@ from cinder.api.openstack import wsgi
 | 
				
			|||||||
from cinder.api.v1 import volumes
 | 
					from cinder.api.v1 import volumes
 | 
				
			||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import exception
 | 
					from cinder import exception
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
from cinder.openstack.common import strutils
 | 
					from cinder.openstack.common import strutils
 | 
				
			||||||
from cinder import utils
 | 
					from cinder import utils
 | 
				
			||||||
@@ -33,9 +32,6 @@ from cinder import volume
 | 
				
			|||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def _translate_snapshot_detail_view(context, snapshot):
 | 
					def _translate_snapshot_detail_view(context, snapshot):
 | 
				
			||||||
    """Maps keys for snapshots details view."""
 | 
					    """Maps keys for snapshots details view."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,7 +22,6 @@ from cinder.api import common
 | 
				
			|||||||
from cinder.api.openstack import wsgi
 | 
					from cinder.api.openstack import wsgi
 | 
				
			||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import exception
 | 
					from cinder import exception
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
from cinder.openstack.common import uuidutils
 | 
					from cinder.openstack.common import uuidutils
 | 
				
			||||||
from cinder import utils
 | 
					from cinder import utils
 | 
				
			||||||
@@ -33,9 +32,6 @@ from cinder.volume import volume_types
 | 
				
			|||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def _translate_attachment_detail_view(_context, vol):
 | 
					def _translate_attachment_detail_view(_context, vol):
 | 
				
			||||||
    """Maps keys for attachment details view."""
 | 
					    """Maps keys for attachment details view."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,6 @@ from cinder.api.openstack import wsgi
 | 
				
			|||||||
from cinder.api.v2 import volumes
 | 
					from cinder.api.v2 import volumes
 | 
				
			||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import exception
 | 
					from cinder import exception
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
from cinder.openstack.common import strutils
 | 
					from cinder.openstack.common import strutils
 | 
				
			||||||
from cinder import utils
 | 
					from cinder import utils
 | 
				
			||||||
@@ -33,9 +32,6 @@ from cinder import volume
 | 
				
			|||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def _translate_snapshot_detail_view(context, snapshot):
 | 
					def _translate_snapshot_detail_view(context, snapshot):
 | 
				
			||||||
    """Maps keys for snapshots details view."""
 | 
					    """Maps keys for snapshots details view."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
"""The volumes api."""
 | 
					"""The volumes api."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import webob
 | 
					import webob
 | 
				
			||||||
from webob import exc
 | 
					from webob import exc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,7 +24,6 @@ from cinder.api.openstack import wsgi
 | 
				
			|||||||
from cinder.api.v2.views import volumes as volume_views
 | 
					from cinder.api.v2.views import volumes as volume_views
 | 
				
			||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import exception
 | 
					from cinder import exception
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
from cinder.openstack.common import log as logging
 | 
					from cinder.openstack.common import log as logging
 | 
				
			||||||
from cinder.openstack.common import uuidutils
 | 
					from cinder.openstack.common import uuidutils
 | 
				
			||||||
from cinder import utils
 | 
					from cinder import utils
 | 
				
			||||||
@@ -34,7 +34,6 @@ from cinder.volume import volume_types
 | 
				
			|||||||
LOG = logging.getLogger(__name__)
 | 
					LOG = logging.getLogger(__name__)
 | 
				
			||||||
SCHEDULER_HINTS_NAMESPACE =\
 | 
					SCHEDULER_HINTS_NAMESPACE =\
 | 
				
			||||||
    "http://docs.openstack.org/block-service/ext/scheduler-hints/api/v2"
 | 
					    "http://docs.openstack.org/block-service/ext/scheduler-hints/api/v2"
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def make_attachment(elem):
 | 
					def make_attachment(elem):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,15 +15,18 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import datetime
 | 
					import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from lxml import etree
 | 
					from lxml import etree
 | 
				
			||||||
 | 
					from oslo.config import cfg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from cinder.api.openstack import wsgi
 | 
					from cinder.api.openstack import wsgi
 | 
				
			||||||
from cinder.api.views import versions as views_versions
 | 
					from cinder.api.views import versions as views_versions
 | 
				
			||||||
from cinder.api import xmlutil
 | 
					from cinder.api import xmlutil
 | 
				
			||||||
from cinder import flags
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
FLAGS = flags.FLAGS
 | 
					
 | 
				
			||||||
 | 
					CONF = cfg.CONF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
_KNOWN_VERSIONS = {
 | 
					_KNOWN_VERSIONS = {
 | 
				
			||||||
@@ -87,16 +90,15 @@ _KNOWN_VERSIONS = {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        ],
 | 
					        ],
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_supported_versions():
 | 
					def get_supported_versions():
 | 
				
			||||||
    versions = {}
 | 
					    versions = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if FLAGS.enable_v1_api:
 | 
					    if CONF.enable_v1_api:
 | 
				
			||||||
        versions['v1.0'] = _KNOWN_VERSIONS['v1.0']
 | 
					        versions['v1.0'] = _KNOWN_VERSIONS['v1.0']
 | 
				
			||||||
    if FLAGS.enable_v2_api:
 | 
					    if CONF.enable_v2_api:
 | 
				
			||||||
        versions['v2.0'] = _KNOWN_VERSIONS['v2.0']
 | 
					        versions['v2.0'] = _KNOWN_VERSIONS['v2.0']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return versions
 | 
					    return versions
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user