Removing deprecated using of flags module from project
Moving file flags.py to manila/common/config.py, replacing FLAGS by CONF. Rename modules fake_flags to conf_fixture, test_flags to test_conf, declare_flags to declare_conf, runtime_flags to runtime_conf like it was done in cinder, nova, glance etc. Implement bp: use-oslo-conf Change-Id: I38d869123e5e706d3b06f1844b97ead05e22668f
This commit is contained in:
parent
a2b6193e0b
commit
3f24fee218
@ -33,7 +33,7 @@ eventlet.monkey_patch()
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
|
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
|
||||||
sys.argv[0]), os.pardir, os.pardir))
|
sys.argv[0]), os.pardir, os.pardir))
|
||||||
if os.path.exists(os.path.join(possible_topdir, "manila", "__init__.py")):
|
if os.path.exists(os.path.join(possible_topdir, "manila", "__init__.py")):
|
||||||
@ -42,14 +42,17 @@ if os.path.exists(os.path.join(possible_topdir, "manila", "__init__.py")):
|
|||||||
from manila.openstack.common import gettextutils
|
from manila.openstack.common import gettextutils
|
||||||
gettextutils.install('manila')
|
gettextutils.install('manila')
|
||||||
|
|
||||||
from manila import flags
|
from manila.common import config # Need to register global_opts
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import service
|
from manila import service
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
from manila import version
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
flags.parse_args(sys.argv)
|
CONF(sys.argv[1:], project='manila',
|
||||||
|
version=version.version_string())
|
||||||
logging.setup("manila")
|
logging.setup("manila")
|
||||||
LOG = logging.getLogger('manila.all')
|
LOG = logging.getLogger('manila.all')
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ eventlet.monkey_patch()
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
|
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
|
||||||
sys.argv[0]), os.pardir, os.pardir))
|
sys.argv[0]), os.pardir, os.pardir))
|
||||||
@ -38,13 +39,17 @@ if os.path.exists(os.path.join(possible_topdir, "manila", "__init__.py")):
|
|||||||
from manila.openstack.common import gettextutils
|
from manila.openstack.common import gettextutils
|
||||||
gettextutils.install('manila')
|
gettextutils.install('manila')
|
||||||
|
|
||||||
from manila import flags
|
from manila.common import config # Need to register global_opts
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import service
|
from manila import service
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
from manila import version
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
flags.parse_args(sys.argv)
|
CONF(sys.argv[1:], project='manila',
|
||||||
|
version=version.version_string())
|
||||||
logging.setup("manila")
|
logging.setup("manila")
|
||||||
utils.monkey_patch()
|
utils.monkey_patch()
|
||||||
server = service.WSGIService('osapi_share')
|
server = service.WSGIService('osapi_share')
|
||||||
|
@ -28,6 +28,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
# If ../manila/__init__.py exists, add ../ to Python search path, so that
|
# If ../manila/__init__.py exists, add ../ to Python search path, so that
|
||||||
# it will override what happens to be installed in /usr/(local/)lib/python...
|
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||||
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||||
@ -39,21 +40,20 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'manila', '__init__.py')):
|
|||||||
from manila.openstack.common import gettextutils
|
from manila.openstack.common import gettextutils
|
||||||
gettextutils.install('manila')
|
gettextutils.install('manila')
|
||||||
|
|
||||||
from oslo.config import cfg
|
from manila.common import config # Need to register global_opts
|
||||||
|
|
||||||
from manila import context
|
from manila import context
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common import rpc
|
from manila.openstack.common import rpc
|
||||||
|
from manila import version
|
||||||
|
|
||||||
delete_exchange_opt = \
|
delete_exchange_opt = \
|
||||||
cfg.BoolOpt('delete_exchange',
|
cfg.BoolOpt('delete_exchange',
|
||||||
default=False,
|
default=False,
|
||||||
help='delete manila exchange too.')
|
help='delete manila exchange too.')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_cli_opt(delete_exchange_opt)
|
CONF.register_cli_opt(delete_exchange_opt)
|
||||||
|
|
||||||
|
|
||||||
def delete_exchange(exch):
|
def delete_exchange(exch):
|
||||||
@ -69,8 +69,9 @@ def delete_queues(queues):
|
|||||||
x.queue_delete(q)
|
x.queue_delete(q)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
args = flags.parse_args(sys.argv)
|
args = CONF(sys.argv[1:], project='manila',
|
||||||
|
version=version.version_string())
|
||||||
logging.setup("manila")
|
logging.setup("manila")
|
||||||
delete_queues(args[1:])
|
delete_queues(args[1:])
|
||||||
if FLAGS.delete_exchange:
|
if CONF.delete_exchange:
|
||||||
delete_exchange(FLAGS.control_exchange)
|
delete_exchange(CONF.control_exchange)
|
||||||
|
@ -76,18 +76,18 @@ gettextutils.install('manila')
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
from manila.common import config # Need to register global_opts
|
||||||
from manila import context
|
from manila import context
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila.db import migration
|
from manila.db import migration
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common import rpc
|
from manila.openstack.common import rpc
|
||||||
from manila.openstack.common import uuidutils
|
from manila.openstack.common import uuidutils
|
||||||
from manila import utils
|
from manila import utils
|
||||||
from manila import version
|
from manila import version
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
# Decorators for actions
|
# Decorators for actions
|
||||||
@ -243,7 +243,7 @@ class ConfigCommands(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
for key, value in FLAGS.iteritems():
|
for key, value in CONF.iteritems():
|
||||||
if value is not None:
|
if value is not None:
|
||||||
print '%s = %s' % (key, value)
|
print '%s = %s' % (key, value)
|
||||||
|
|
||||||
@ -254,10 +254,10 @@ class GetLogCommands(object):
|
|||||||
def errors(self):
|
def errors(self):
|
||||||
"""Get all of the errors from the log files."""
|
"""Get all of the errors from the log files."""
|
||||||
error_found = 0
|
error_found = 0
|
||||||
if FLAGS.log_dir:
|
if CONF.log_dir:
|
||||||
logs = [x for x in os.listdir(FLAGS.log_dir) if x.endswith('.log')]
|
logs = [x for x in os.listdir(CONF.log_dir) if x.endswith('.log')]
|
||||||
for file in logs:
|
for file in logs:
|
||||||
log_file = os.path.join(FLAGS.log_dir, file)
|
log_file = os.path.join(CONF.log_dir, file)
|
||||||
lines = [line.strip() for line in open(log_file, "r")]
|
lines = [line.strip() for line in open(log_file, "r")]
|
||||||
lines.reverse()
|
lines.reverse()
|
||||||
print_name = 0
|
print_name = 0
|
||||||
@ -373,7 +373,7 @@ category_opt = cfg.SubCommandOpt('category',
|
|||||||
def get_arg_string(args):
|
def get_arg_string(args):
|
||||||
arg = None
|
arg = None
|
||||||
if args[0] == '-':
|
if args[0] == '-':
|
||||||
# (Note)zhiteng: args starts with FLAGS.oparser.prefix_chars
|
# (Note)zhiteng: args starts with CONF.oparser.prefix_chars
|
||||||
# is optional args. Notice that cfg module takes care of
|
# is optional args. Notice that cfg module takes care of
|
||||||
# actual ArgParser so prefix_chars is always '-'.
|
# actual ArgParser so prefix_chars is always '-'.
|
||||||
if args[1] == '-':
|
if args[1] == '-':
|
||||||
@ -391,14 +391,14 @@ def fetch_func_args(func):
|
|||||||
fn_args = []
|
fn_args = []
|
||||||
for args, kwargs in getattr(func, 'args', []):
|
for args, kwargs in getattr(func, 'args', []):
|
||||||
arg = get_arg_string(args[0])
|
arg = get_arg_string(args[0])
|
||||||
fn_args.append(getattr(FLAGS.category, arg))
|
fn_args.append(getattr(CONF.category, arg))
|
||||||
|
|
||||||
return fn_args
|
return fn_args
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Parse options and call the appropriate class/method."""
|
"""Parse options and call the appropriate class/method."""
|
||||||
FLAGS.register_cli_opt(category_opt)
|
CONF.register_cli_opt(category_opt)
|
||||||
script_name = sys.argv[0]
|
script_name = sys.argv[0]
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print(_("\nOpenStack manila version: %(version)s\n") %
|
print(_("\nOpenStack manila version: %(version)s\n") %
|
||||||
@ -410,10 +410,11 @@ def main():
|
|||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
flags.parse_args(sys.argv)
|
CONF(sys.argv[1:], project='manila',
|
||||||
|
version=version.version_string())
|
||||||
logging.setup("manila")
|
logging.setup("manila")
|
||||||
except cfg.ConfigFilesNotFoundError:
|
except cfg.ConfigFilesNotFoundError:
|
||||||
cfgfile = FLAGS.config_file[-1] if FLAGS.config_file else None
|
cfgfile = CONF.config_file[-1] if CONF.config_file else None
|
||||||
if cfgfile and not os.access(cfgfile, os.R_OK):
|
if cfgfile and not os.access(cfgfile, os.R_OK):
|
||||||
st = os.stat(cfgfile)
|
st = os.stat(cfgfile)
|
||||||
print _("Could not read %s. Re-running with sudo") % cfgfile
|
print _("Could not read %s. Re-running with sudo") % cfgfile
|
||||||
@ -425,7 +426,7 @@ def main():
|
|||||||
print _('Please re-run manila-manage as root.')
|
print _('Please re-run manila-manage as root.')
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
fn = FLAGS.category.action_fn
|
fn = CONF.category.action_fn
|
||||||
|
|
||||||
fn_args = fetch_func_args(fn)
|
fn_args = fetch_func_args(fn)
|
||||||
fn(*fn_args)
|
fn(*fn_args)
|
||||||
|
@ -25,6 +25,8 @@ eventlet.monkey_patch()
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
# If ../manila/__init__.py exists, add ../ to Python search path, so that
|
# If ../manila/__init__.py exists, add ../ to Python search path, so that
|
||||||
# it will override what happens to be installed in /usr/(local/)lib/python...
|
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||||
@ -36,13 +38,17 @@ if os.path.exists(os.path.join(possible_topdir, 'manila', '__init__.py')):
|
|||||||
from manila.openstack.common import gettextutils
|
from manila.openstack.common import gettextutils
|
||||||
gettextutils.install('manila')
|
gettextutils.install('manila')
|
||||||
|
|
||||||
from manila import flags
|
from manila.common import config # Need to register global_opts
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import service
|
from manila import service
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
from manila import version
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
flags.parse_args(sys.argv)
|
CONF(sys.argv[1:], project='manila',
|
||||||
|
version=version.version_string())
|
||||||
logging.setup("manila")
|
logging.setup("manila")
|
||||||
utils.monkey_patch()
|
utils.monkey_patch()
|
||||||
server = service.Service.create(binary='manila-scheduler')
|
server = service.Service.create(binary='manila-scheduler')
|
||||||
|
@ -24,6 +24,8 @@ eventlet.monkey_patch()
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
# If ../manila/__init__.py exists, add ../ to Python search path, so that
|
# If ../manila/__init__.py exists, add ../ to Python search path, so that
|
||||||
# it will override what happens to be installed in /usr/(local/)lib/python...
|
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||||
@ -35,21 +37,23 @@ if os.path.exists(os.path.join(possible_topdir, 'manila', '__init__.py')):
|
|||||||
from manila.openstack.common import gettextutils
|
from manila.openstack.common import gettextutils
|
||||||
gettextutils.install('manila')
|
gettextutils.install('manila')
|
||||||
|
|
||||||
from manila import flags
|
from manila.common import config # Need to register global_opts
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import service
|
from manila import service
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
from manila import version
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
flags.parse_args(sys.argv)
|
args = CONF(sys.argv[1:], project='manila',
|
||||||
|
version=version.version_string())
|
||||||
logging.setup("manila")
|
logging.setup("manila")
|
||||||
utils.monkey_patch()
|
utils.monkey_patch()
|
||||||
launcher = service.ProcessLauncher()
|
launcher = service.ProcessLauncher()
|
||||||
if FLAGS.enabled_share_backends:
|
if CONF.enabled_share_backends:
|
||||||
for backend in FLAGS.enabled_share_backends:
|
for backend in CONF.enabled_share_backends:
|
||||||
host = "%s@%s" % (FLAGS.host, backend)
|
host = "%s@%s" % (CONF.host, backend)
|
||||||
server = service.Service.create(
|
server = service.Service.create(
|
||||||
host=host,
|
host=host,
|
||||||
service_name=backend)
|
service_name=backend)
|
||||||
|
@ -135,20 +135,20 @@ The :mod:`manila.wsgi` Module
|
|||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
The :mod:`declare_flags` Module
|
The :mod:`declare_conf` Module
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. automodule:: manila.tests.declare_flags
|
.. automodule:: manila.tests.declare_conf
|
||||||
:noindex:
|
:noindex:
|
||||||
:members:
|
:members:
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
|
|
||||||
The :mod:`fake_flags` Module
|
The :mod:`conf_fixture` Module
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. automodule:: manila.tests.fake_flags
|
.. automodule:: manila.tests.conf_fixture
|
||||||
:noindex:
|
:noindex:
|
||||||
:members:
|
:members:
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
@ -195,10 +195,10 @@ The :mod:`rpc_unittest` Module
|
|||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
|
|
||||||
The :mod:`runtime_flags` Module
|
The :mod:`runtime_conf` Module
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. automodule:: manila.tests.runtime_flags
|
.. automodule:: manila.tests.runtime_conf
|
||||||
:noindex:
|
:noindex:
|
||||||
:members:
|
:members:
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
|
@ -139,7 +139,7 @@ Gotchas
|
|||||||
If you are running the unit tests from a shared folder, you may see tests start
|
If you are running the unit tests from a shared folder, you may see tests start
|
||||||
to fail or stop completely as a result of Python lockfile issues [#f4]_. You
|
to fail or stop completely as a result of Python lockfile issues [#f4]_. You
|
||||||
can get around this by manually setting or updating the following line in
|
can get around this by manually setting or updating the following line in
|
||||||
``manila/tests/fake_flags.py``::
|
``manila/tests/conf_fixture.py``::
|
||||||
|
|
||||||
FLAGS['lock_path'].SetDefault('/tmp')
|
FLAGS['lock_path'].SetDefault('/tmp')
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Options defined in manila.flags
|
# Options defined in manila.common.config
|
||||||
#
|
#
|
||||||
|
|
||||||
# Virtualization api connection type : libvirt, xenapi, or
|
# Virtualization api connection type : libvirt, xenapi, or
|
||||||
|
@ -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 manila 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)
|
||||||
|
@ -23,13 +23,13 @@ import webob
|
|||||||
|
|
||||||
from manila.api.openstack import wsgi
|
from manila.api.openstack import wsgi
|
||||||
from manila.api import xmlutil
|
from manila.api import xmlutil
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
XML_NS_V1 = 'http://docs.openstack.org/volume/api/v1'
|
XML_NS_V1 = 'http://docs.openstack.org/volume/api/v1'
|
||||||
@ -73,7 +73,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 +110,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 +192,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_share_base_URL)
|
CONF.osapi_share_base_URL)
|
||||||
url = os.path.join(prefix,
|
url = os.path.join(prefix,
|
||||||
request.environ["manila.context"].project_id,
|
request.environ["manila.context"].project_id,
|
||||||
self._collection_name)
|
self._collection_name)
|
||||||
@ -201,7 +201,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_share_base_URL)
|
CONF.osapi_share_base_URL)
|
||||||
return os.path.join(prefix,
|
return os.path.join(prefix,
|
||||||
request.environ["manila.context"].project_id,
|
request.environ["manila.context"].project_id,
|
||||||
self._collection_name,
|
self._collection_name,
|
||||||
@ -211,7 +211,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_share_base_URL)
|
CONF.osapi_share_base_URL)
|
||||||
return os.path.join(base_url,
|
return os.path.join(base_url,
|
||||||
request.environ["manila.context"].project_id,
|
request.environ["manila.context"].project_id,
|
||||||
self._collection_name,
|
self._collection_name,
|
||||||
|
@ -22,11 +22,12 @@ It can't be called 'extensions' because that causes namespacing problems.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from manila.api import extensions
|
from manila.api import extensions
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
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_share_ext_list)
|
CONF.osapi_share_ext_list)
|
||||||
|
@ -25,15 +25,16 @@ import manila.api.openstack
|
|||||||
from manila.api.openstack import wsgi
|
from manila.api.openstack import wsgi
|
||||||
from manila.api import xmlutil
|
from manila.api import xmlutil
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import exception as common_exception
|
from manila.openstack.common import exception as common_exception
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
import manila.policy
|
import manila.policy
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
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_share_extension
|
self.cls_list = CONF.osapi_share_extension
|
||||||
|
|
||||||
self.extensions = {}
|
self.extensions = {}
|
||||||
self._load_extensions()
|
self._load_extensions()
|
||||||
|
@ -26,7 +26,7 @@ import webob.exc
|
|||||||
|
|
||||||
from manila.api.openstack import wsgi
|
from manila.api.openstack import wsgi
|
||||||
from manila import context
|
from manila import context
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import wsgi as base_wsgi
|
from manila import wsgi as base_wsgi
|
||||||
|
|
||||||
@ -36,16 +36,16 @@ use_forwarded_for_opt = cfg.BoolOpt(
|
|||||||
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 +94,7 @@ class ManilaKeystoneContext(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 +129,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,
|
||||||
|
@ -22,7 +22,7 @@ from oslo.config import cfg
|
|||||||
import webob.dec
|
import webob.dec
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import wsgi
|
from manila import wsgi
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ 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 +73,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
|
||||||
|
@ -21,9 +21,10 @@ from lxml import etree
|
|||||||
from manila.api.openstack import wsgi
|
from manila.api.openstack import wsgi
|
||||||
from manila.api.views import versions as views_versions
|
from manila.api.views import versions as views_versions
|
||||||
from manila.api import xmlutil
|
from manila.api import xmlutil
|
||||||
from manila import flags
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
_KNOWN_VERSIONS = {
|
_KNOWN_VERSIONS = {
|
||||||
@ -94,9 +95,9 @@ _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
|
||||||
|
@ -28,30 +28,11 @@ stepping stone.
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import sys
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import version
|
|
||||||
|
|
||||||
FLAGS = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
def parse_args(argv, default_config_files=None):
|
|
||||||
FLAGS(argv[1:], project='manila',
|
|
||||||
version=version.version_string(),
|
|
||||||
default_config_files=default_config_files)
|
|
||||||
|
|
||||||
|
|
||||||
class UnrecognizedFlag(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def DECLARE(name, module_string, flag_values=FLAGS):
|
|
||||||
if module_string not in sys.modules:
|
|
||||||
__import__(module_string, globals(), locals())
|
|
||||||
if name not in flag_values:
|
|
||||||
raise UnrecognizedFlag('%s not defined by %s' % (name, module_string))
|
|
||||||
|
|
||||||
|
|
||||||
def _get_my_ip():
|
def _get_my_ip():
|
||||||
@ -92,7 +73,8 @@ core_opts = [
|
|||||||
help='File name for the paste.deploy config for manila-api'),
|
help='File name for the paste.deploy config for manila-api'),
|
||||||
cfg.StrOpt('pybasedir',
|
cfg.StrOpt('pybasedir',
|
||||||
default=os.path.abspath(os.path.join(os.path.dirname(__file__),
|
default=os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||||
'../')),
|
'..',
|
||||||
|
'..')),
|
||||||
help='Directory where the manila python module is installed'),
|
help='Directory where the manila python module is installed'),
|
||||||
cfg.StrOpt('bindir',
|
cfg.StrOpt('bindir',
|
||||||
default='$pybasedir/bin',
|
default='$pybasedir/bin',
|
||||||
@ -104,8 +86,8 @@ core_opts = [
|
|||||||
debug_opts = [
|
debug_opts = [
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS.register_cli_opts(core_opts)
|
CONF.register_cli_opts(core_opts)
|
||||||
FLAGS.register_cli_opts(debug_opts)
|
CONF.register_cli_opts(debug_opts)
|
||||||
|
|
||||||
global_opts = [
|
global_opts = [
|
||||||
cfg.StrOpt('my_ip',
|
cfg.StrOpt('my_ip',
|
||||||
@ -237,4 +219,4 @@ global_opts = [
|
|||||||
default=False,
|
default=False,
|
||||||
help='Whether snapshots count against GigaByte quota'), ]
|
help='Whether snapshots count against GigaByte quota'), ]
|
||||||
|
|
||||||
FLAGS.register_opts(global_opts)
|
CONF.register_opts(global_opts)
|
@ -46,7 +46,7 @@ these objects be simple dictionaries.
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
|
||||||
db_opts = [
|
db_opts = [
|
||||||
@ -65,8 +65,8 @@ db_opts = [
|
|||||||
'names'),
|
'names'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(db_opts)
|
CONF.register_opts(db_opts)
|
||||||
|
|
||||||
IMPL = utils.LazyPluggable('db_backend',
|
IMPL = utils.LazyPluggable('db_backend',
|
||||||
sqlalchemy='manila.db.sqlalchemy.api')
|
sqlalchemy='manila.db.sqlalchemy.api')
|
||||||
|
@ -20,15 +20,15 @@
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
|
|
||||||
db_driver_opt = cfg.StrOpt('db_driver',
|
db_driver_opt = cfg.StrOpt('db_driver',
|
||||||
default='manila.db',
|
default='manila.db',
|
||||||
help='driver to use for database access')
|
help='driver to use for database access')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opt(db_driver_opt)
|
CONF.register_opt(db_driver_opt)
|
||||||
|
|
||||||
|
|
||||||
class Base(object):
|
class Base(object):
|
||||||
@ -36,5 +36,5 @@ class Base(object):
|
|||||||
|
|
||||||
def __init__(self, db_driver=None):
|
def __init__(self, db_driver=None):
|
||||||
if not db_driver:
|
if not db_driver:
|
||||||
db_driver = FLAGS.db_driver
|
db_driver = CONF.db_driver
|
||||||
self.db = importutils.import_module(db_driver) # pylint: disable=C0103
|
self.db = importutils.import_module(db_driver) # pylint: disable=C0103
|
||||||
|
@ -23,6 +23,7 @@ import datetime
|
|||||||
import uuid
|
import uuid
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
from sqlalchemy.exc import IntegrityError
|
from sqlalchemy.exc import IntegrityError
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
from sqlalchemy.orm import joinedload
|
from sqlalchemy.orm import joinedload
|
||||||
@ -34,12 +35,11 @@ from manila import db
|
|||||||
from manila.db.sqlalchemy import models
|
from manila.db.sqlalchemy import models
|
||||||
from manila.db.sqlalchemy.session import get_session
|
from manila.db.sqlalchemy.session import get_session
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ def _service_get_all_topic_subquery(context, session, topic, subq, label):
|
|||||||
def service_get_all_share_sorted(context):
|
def service_get_all_share_sorted(context):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
topic = FLAGS.share_topic
|
topic = CONF.share_topic
|
||||||
label = 'share_gigabytes'
|
label = 'share_gigabytes'
|
||||||
subq = model_query(context, models.Share.host,
|
subq = model_query(context, models.Share.host,
|
||||||
func.sum(models.Share.size).label(label),
|
func.sum(models.Share.size).label(label),
|
||||||
@ -309,7 +309,7 @@ def service_get_by_args(context, host, binary):
|
|||||||
def service_create(context, values):
|
def service_create(context, values):
|
||||||
service_ref = models.Service()
|
service_ref = models.Service()
|
||||||
service_ref.update(values)
|
service_ref.update(values)
|
||||||
if not FLAGS.enable_new_services:
|
if not CONF.enable_new_services:
|
||||||
service_ref.disabled = True
|
service_ref.disabled = True
|
||||||
service_ref.save()
|
service_ref.save()
|
||||||
return service_ref
|
return service_ref
|
||||||
|
@ -14,13 +14,14 @@
|
|||||||
# 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
|
||||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey
|
from sqlalchemy import Boolean, Column, DateTime, ForeignKey
|
||||||
from sqlalchemy import Integer, MetaData, String, Table
|
from sqlalchemy import Integer, MetaData, String, Table
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -19,10 +19,12 @@
|
|||||||
import distutils.version as dist_version
|
import distutils.version as dist_version
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila.db import migration
|
from manila.db import migration
|
||||||
from manila.db.sqlalchemy.session import get_engine
|
from manila.db.sqlalchemy.session import get_engine
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ from migrate import exceptions as versioning_exceptions
|
|||||||
from migrate.versioning import api as versioning_api
|
from migrate.versioning import api as versioning_api
|
||||||
from migrate.versioning.repository import Repository
|
from migrate.versioning.repository import Repository
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
_REPOSITORY = None
|
_REPOSITORY = None
|
||||||
|
|
||||||
|
@ -30,11 +30,12 @@ from sqlalchemy.orm import relationship, backref, object_mapper
|
|||||||
from manila.db.sqlalchemy.session import get_session
|
from manila.db.sqlalchemy.session import get_session
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
BASE = declarative_base()
|
BASE = declarative_base()
|
||||||
|
|
||||||
|
|
||||||
@ -216,7 +217,7 @@ class Share(BASE, ManilaBase):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return FLAGS.share_name_template % self.id
|
return CONF.share_name_template % self.id
|
||||||
|
|
||||||
id = Column(String(36), primary_key=True)
|
id = Column(String(36), primary_key=True)
|
||||||
user_id = Column(String(255))
|
user_id = Column(String(255))
|
||||||
@ -259,11 +260,11 @@ class ShareSnapshot(BASE, ManilaBase):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return FLAGS.share_snapshot_name_template % self.id
|
return CONF.share_snapshot_name_template % self.id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def share_name(self):
|
def share_name(self):
|
||||||
return FLAGS.share_name_template % self.share_id
|
return CONF.share_name_template % self.share_id
|
||||||
|
|
||||||
id = Column(String(36), primary_key=True)
|
id = Column(String(36), primary_key=True)
|
||||||
user_id = Column(String(255))
|
user_id = Column(String(255))
|
||||||
@ -298,6 +299,6 @@ def register_models():
|
|||||||
ShareAccessMapping,
|
ShareAccessMapping,
|
||||||
ShareSnapshot
|
ShareSnapshot
|
||||||
)
|
)
|
||||||
engine = create_engine(FLAGS.sql_connection, echo=False)
|
engine = create_engine(CONF.sql_connection, echo=False)
|
||||||
for model in models:
|
for model in models:
|
||||||
model.metadata.create_all(engine)
|
model.metadata.create_all(engine)
|
||||||
|
@ -20,17 +20,17 @@
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
from sqlalchemy.exc import DisconnectionError, OperationalError
|
from sqlalchemy.exc import DisconnectionError, OperationalError
|
||||||
import sqlalchemy.interfaces
|
import sqlalchemy.interfaces
|
||||||
import sqlalchemy.orm
|
import sqlalchemy.orm
|
||||||
from sqlalchemy.pool import NullPool, StaticPool
|
from sqlalchemy.pool import NullPool, StaticPool
|
||||||
|
|
||||||
import manila.exception
|
import manila.exception
|
||||||
import manila.flags as flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
_ENGINE = None
|
_ENGINE = None
|
||||||
@ -89,33 +89,33 @@ def get_engine():
|
|||||||
"""Return a SQLAlchemy engine."""
|
"""Return a SQLAlchemy engine."""
|
||||||
global _ENGINE
|
global _ENGINE
|
||||||
if _ENGINE is None:
|
if _ENGINE is None:
|
||||||
connection_dict = sqlalchemy.engine.url.make_url(FLAGS.sql_connection)
|
connection_dict = sqlalchemy.engine.url.make_url(CONF.sql_connection)
|
||||||
|
|
||||||
engine_args = {
|
engine_args = {
|
||||||
"pool_recycle": FLAGS.sql_idle_timeout,
|
"pool_recycle": CONF.sql_idle_timeout,
|
||||||
"echo": False,
|
"echo": False,
|
||||||
'convert_unicode': True,
|
'convert_unicode': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Map our SQL debug level to SQLAlchemy's options
|
# Map our SQL debug level to SQLAlchemy's options
|
||||||
if FLAGS.sql_connection_debug >= 100:
|
if CONF.sql_connection_debug >= 100:
|
||||||
engine_args['echo'] = 'debug'
|
engine_args['echo'] = 'debug'
|
||||||
elif FLAGS.sql_connection_debug >= 50:
|
elif CONF.sql_connection_debug >= 50:
|
||||||
engine_args['echo'] = True
|
engine_args['echo'] = True
|
||||||
|
|
||||||
if "sqlite" in connection_dict.drivername:
|
if "sqlite" in connection_dict.drivername:
|
||||||
engine_args["poolclass"] = NullPool
|
engine_args["poolclass"] = NullPool
|
||||||
|
|
||||||
if FLAGS.sql_connection == "sqlite://":
|
if CONF.sql_connection == "sqlite://":
|
||||||
engine_args["poolclass"] = StaticPool
|
engine_args["poolclass"] = StaticPool
|
||||||
engine_args["connect_args"] = {'check_same_thread': False}
|
engine_args["connect_args"] = {'check_same_thread': False}
|
||||||
|
|
||||||
_ENGINE = sqlalchemy.create_engine(FLAGS.sql_connection, **engine_args)
|
_ENGINE = sqlalchemy.create_engine(CONF.sql_connection, **engine_args)
|
||||||
|
|
||||||
if 'mysql' in connection_dict.drivername:
|
if 'mysql' in connection_dict.drivername:
|
||||||
sqlalchemy.event.listen(_ENGINE, 'checkout', ping_listener)
|
sqlalchemy.event.listen(_ENGINE, 'checkout', ping_listener)
|
||||||
elif "sqlite" in connection_dict.drivername:
|
elif "sqlite" in connection_dict.drivername:
|
||||||
if not FLAGS.sqlite_synchronous:
|
if not CONF.sqlite_synchronous:
|
||||||
sqlalchemy.event.listen(_ENGINE, 'connect',
|
sqlalchemy.event.listen(_ENGINE, 'connect',
|
||||||
synchronous_switch_listener)
|
synchronous_switch_listener)
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ def get_engine():
|
|||||||
if not is_db_connection_error(e.args[0]):
|
if not is_db_connection_error(e.args[0]):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
remaining = FLAGS.sql_max_retries
|
remaining = CONF.sql_max_retries
|
||||||
if remaining == -1:
|
if remaining == -1:
|
||||||
remaining = 'infinite'
|
remaining = 'infinite'
|
||||||
while True:
|
while True:
|
||||||
@ -133,7 +133,7 @@ def get_engine():
|
|||||||
LOG.warn(msg % remaining)
|
LOG.warn(msg % remaining)
|
||||||
if remaining != 'infinite':
|
if remaining != 'infinite':
|
||||||
remaining -= 1
|
remaining -= 1
|
||||||
time.sleep(FLAGS.sql_retry_interval)
|
time.sleep(CONF.sql_retry_interval)
|
||||||
try:
|
try:
|
||||||
_ENGINE.connect()
|
_ENGINE.connect()
|
||||||
break
|
break
|
||||||
|
@ -27,7 +27,7 @@ SHOULD include dedicated exception logging.
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -38,8 +38,8 @@ exc_log_opts = [
|
|||||||
help='make exception message format errors fatal'),
|
help='make exception message format errors fatal'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(exc_log_opts)
|
CONF.register_opts(exc_log_opts)
|
||||||
|
|
||||||
|
|
||||||
class ConvertedException(webob.exc.WSGIHTTPException):
|
class ConvertedException(webob.exc.WSGIHTTPException):
|
||||||
@ -125,7 +125,7 @@ class ManilaException(Exception):
|
|||||||
LOG.exception(_('Exception in string format operation'))
|
LOG.exception(_('Exception in string format operation'))
|
||||||
for name, value in kwargs.iteritems():
|
for name, value in kwargs.iteritems():
|
||||||
LOG.error("%s: %s" % (name, value))
|
LOG.error("%s: %s" % (name, value))
|
||||||
if FLAGS.fatal_exception_format_errors:
|
if CONF.fatal_exception_format_errors:
|
||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
# at least get the core message out if something happened
|
# at least get the core message out if something happened
|
||||||
|
@ -30,14 +30,15 @@ import glanceclient
|
|||||||
import glanceclient.exc
|
import glanceclient.exc
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import jsonutils
|
from manila.openstack.common import jsonutils
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
def _parse_image_ref(image_href):
|
def _parse_image_ref(image_href):
|
||||||
@ -57,17 +58,17 @@ def _parse_image_ref(image_href):
|
|||||||
|
|
||||||
|
|
||||||
def _create_glance_client(context, host, port, use_ssl,
|
def _create_glance_client(context, host, port, use_ssl,
|
||||||
version=FLAGS.glance_api_version):
|
version=CONF.glance_api_version):
|
||||||
"""Instantiate a new glanceclient.Client object"""
|
"""Instantiate a new glanceclient.Client object"""
|
||||||
if version is None:
|
if version is None:
|
||||||
version = FLAGS.glance_api_version
|
version = CONF.glance_api_version
|
||||||
if use_ssl:
|
if use_ssl:
|
||||||
scheme = 'https'
|
scheme = 'https'
|
||||||
else:
|
else:
|
||||||
scheme = 'http'
|
scheme = 'http'
|
||||||
params = {}
|
params = {}
|
||||||
params['insecure'] = FLAGS.glance_api_insecure
|
params['insecure'] = CONF.glance_api_insecure
|
||||||
if FLAGS.auth_strategy == 'keystone':
|
if CONF.auth_strategy == 'keystone':
|
||||||
params['token'] = context.auth_token
|
params['token'] = context.auth_token
|
||||||
endpoint = '%s://%s:%s' % (scheme, host, port)
|
endpoint = '%s://%s:%s' % (scheme, host, port)
|
||||||
return glanceclient.Client(str(version), endpoint, **params)
|
return glanceclient.Client(str(version), endpoint, **params)
|
||||||
@ -75,12 +76,12 @@ def _create_glance_client(context, host, port, use_ssl,
|
|||||||
|
|
||||||
def get_api_servers():
|
def get_api_servers():
|
||||||
"""
|
"""
|
||||||
Shuffle a list of FLAGS.glance_api_servers and return an iterator
|
Shuffle a list of CONF.glance_api_servers and return an iterator
|
||||||
that will cycle through the list, looping around to the beginning
|
that will cycle through the list, looping around to the beginning
|
||||||
if necessary.
|
if necessary.
|
||||||
"""
|
"""
|
||||||
api_servers = []
|
api_servers = []
|
||||||
for api_server in FLAGS.glance_api_servers:
|
for api_server in CONF.glance_api_servers:
|
||||||
if '//' not in api_server:
|
if '//' not in api_server:
|
||||||
api_server = 'http://' + api_server
|
api_server = 'http://' + api_server
|
||||||
url = urlparse.urlparse(api_server)
|
url = urlparse.urlparse(api_server)
|
||||||
@ -128,7 +129,7 @@ class GlanceClientWrapper(object):
|
|||||||
def call(self, context, method, *args, **kwargs):
|
def call(self, context, method, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Call a glance client method. If we get a connection error,
|
Call a glance client method. If we get a connection error,
|
||||||
retry the request according to FLAGS.glance_num_retries.
|
retry the request according to CONF.glance_num_retries.
|
||||||
"""
|
"""
|
||||||
version = self.version
|
version = self.version
|
||||||
if version in kwargs:
|
if version in kwargs:
|
||||||
@ -137,7 +138,7 @@ class GlanceClientWrapper(object):
|
|||||||
retry_excs = (glanceclient.exc.ServiceUnavailable,
|
retry_excs = (glanceclient.exc.ServiceUnavailable,
|
||||||
glanceclient.exc.InvalidEndpoint,
|
glanceclient.exc.InvalidEndpoint,
|
||||||
glanceclient.exc.CommunicationError)
|
glanceclient.exc.CommunicationError)
|
||||||
num_attempts = 1 + FLAGS.glance_num_retries
|
num_attempts = 1 + CONF.glance_num_retries
|
||||||
|
|
||||||
for attempt in xrange(1, num_attempts + 1):
|
for attempt in xrange(1, num_attempts + 1):
|
||||||
client = self.client or self._create_onetime_client(context,
|
client = self.client or self._create_onetime_client(context,
|
||||||
|
@ -32,7 +32,7 @@ import tempfile
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
|
||||||
@ -42,8 +42,8 @@ image_helper_opt = [cfg.StrOpt('image_conversion_dir',
|
|||||||
default='/tmp',
|
default='/tmp',
|
||||||
help='parent dir for tempdir used for image conversion'), ]
|
help='parent dir for tempdir used for image conversion'), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(image_helper_opt)
|
CONF.register_opts(image_helper_opt)
|
||||||
|
|
||||||
|
|
||||||
class QemuImgInfo(object):
|
class QemuImgInfo(object):
|
||||||
@ -204,15 +204,15 @@ def fetch(context, image_service, image_id, path, _user_id, _project_id):
|
|||||||
def fetch_to_raw(context, image_service,
|
def fetch_to_raw(context, image_service,
|
||||||
image_id, dest,
|
image_id, dest,
|
||||||
user_id=None, project_id=None):
|
user_id=None, project_id=None):
|
||||||
if (FLAGS.image_conversion_dir and not
|
if (CONF.image_conversion_dir and not
|
||||||
os.path.exists(FLAGS.image_conversion_dir)):
|
os.path.exists(CONF.image_conversion_dir)):
|
||||||
os.makedirs(FLAGS.image_conversion_dir)
|
os.makedirs(CONF.image_conversion_dir)
|
||||||
|
|
||||||
# NOTE(avishay): I'm not crazy about creating temp files which may be
|
# NOTE(avishay): I'm not crazy about creating temp files which may be
|
||||||
# large and cause disk full errors which would confuse users.
|
# large and cause disk full errors which would confuse users.
|
||||||
# Unfortunately it seems that you can't pipe to 'qemu-img convert' because
|
# Unfortunately it seems that you can't pipe to 'qemu-img convert' because
|
||||||
# it seeks. Maybe we can think of something for a future version.
|
# it seeks. Maybe we can think of something for a future version.
|
||||||
fd, tmp = tempfile.mkstemp(dir=FLAGS.image_conversion_dir)
|
fd, tmp = tempfile.mkstemp(dir=CONF.image_conversion_dir)
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
with utils.remove_path_on_error(tmp):
|
with utils.remove_path_on_error(tmp):
|
||||||
fetch(context, image_service, image_id, tmp, user_id, project_id)
|
fetch(context, image_service, image_id, tmp, user_id, project_id)
|
||||||
|
@ -53,15 +53,16 @@ This module provides Manager, a base class for managers.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila.db import base
|
from manila.db import base
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common.rpc import dispatcher as rpc_dispatcher
|
from manila.openstack.common.rpc import dispatcher as rpc_dispatcher
|
||||||
from manila.scheduler import rpcapi as scheduler_rpcapi
|
from manila.scheduler import rpcapi as scheduler_rpcapi
|
||||||
from manila import version
|
from manila import version
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -136,7 +137,7 @@ class Manager(base.Base):
|
|||||||
|
|
||||||
def __init__(self, host=None, db_driver=None):
|
def __init__(self, host=None, db_driver=None):
|
||||||
if not host:
|
if not host:
|
||||||
host = FLAGS.host
|
host = CONF.host
|
||||||
self.host = host
|
self.host = host
|
||||||
super(Manager, self).__init__(db_driver)
|
super(Manager, self).__init__(db_driver)
|
||||||
|
|
||||||
@ -184,8 +185,8 @@ class Manager(base.Base):
|
|||||||
|
|
||||||
def service_config(self, context):
|
def service_config(self, context):
|
||||||
config = {}
|
config = {}
|
||||||
for key in FLAGS:
|
for key in CONF:
|
||||||
config[key] = FLAGS.get(key, None)
|
config[key] = CONF.get(key, None)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import policy
|
from manila.openstack.common import policy
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
|
||||||
@ -32,8 +32,8 @@ policy_opts = [
|
|||||||
default='default',
|
default='default',
|
||||||
help=_('Rule checked when requested rule is not found')), ]
|
help=_('Rule checked when requested rule is not found')), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(policy_opts)
|
CONF.register_opts(policy_opts)
|
||||||
|
|
||||||
_POLICY_PATH = None
|
_POLICY_PATH = None
|
||||||
_POLICY_CACHE = {}
|
_POLICY_CACHE = {}
|
||||||
@ -51,13 +51,13 @@ def init():
|
|||||||
global _POLICY_PATH
|
global _POLICY_PATH
|
||||||
global _POLICY_CACHE
|
global _POLICY_CACHE
|
||||||
if not _POLICY_PATH:
|
if not _POLICY_PATH:
|
||||||
_POLICY_PATH = utils.find_config(FLAGS.policy_file)
|
_POLICY_PATH = utils.find_config(CONF.policy_file)
|
||||||
utils.read_cached_file(_POLICY_PATH, _POLICY_CACHE,
|
utils.read_cached_file(_POLICY_PATH, _POLICY_CACHE,
|
||||||
reload_func=_set_brain)
|
reload_func=_set_brain)
|
||||||
|
|
||||||
|
|
||||||
def _set_brain(data):
|
def _set_brain(data):
|
||||||
default_rule = FLAGS.policy_default_rule
|
default_rule = CONF.policy_default_rule
|
||||||
policy.set_brain(policy.HttpBrain.load_json(data, default_rule))
|
policy.set_brain(policy.HttpBrain.load_json(data, default_rule))
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ from oslo.config import cfg
|
|||||||
|
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
@ -55,8 +54,8 @@ quota_opts = [
|
|||||||
default='manila.quota.DbQuotaDriver',
|
default='manila.quota.DbQuotaDriver',
|
||||||
help='default driver to use for quota checks'), ]
|
help='default driver to use for quota checks'), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(quota_opts)
|
CONF.register_opts(quota_opts)
|
||||||
|
|
||||||
|
|
||||||
class DbQuotaDriver(object):
|
class DbQuotaDriver(object):
|
||||||
@ -296,7 +295,7 @@ class DbQuotaDriver(object):
|
|||||||
|
|
||||||
# Set up the reservation expiration
|
# Set up the reservation expiration
|
||||||
if expire is None:
|
if expire is None:
|
||||||
expire = FLAGS.reservation_expire
|
expire = CONF.reservation_expire
|
||||||
if isinstance(expire, (int, long)):
|
if isinstance(expire, (int, long)):
|
||||||
expire = datetime.timedelta(seconds=expire)
|
expire = datetime.timedelta(seconds=expire)
|
||||||
if isinstance(expire, datetime.timedelta):
|
if isinstance(expire, datetime.timedelta):
|
||||||
@ -321,7 +320,7 @@ class DbQuotaDriver(object):
|
|||||||
# session isn't available outside the DBAPI, we
|
# session isn't available outside the DBAPI, we
|
||||||
# have to do the work there.
|
# have to do the work there.
|
||||||
return db.quota_reserve(context, resources, quotas, deltas, expire,
|
return db.quota_reserve(context, resources, quotas, deltas, expire,
|
||||||
FLAGS.until_refresh, FLAGS.max_age,
|
CONF.until_refresh, CONF.max_age,
|
||||||
project_id=project_id)
|
project_id=project_id)
|
||||||
|
|
||||||
def commit(self, context, reservations, project_id=None):
|
def commit(self, context, reservations, project_id=None):
|
||||||
@ -446,7 +445,7 @@ class BaseResource(object):
|
|||||||
def default(self):
|
def default(self):
|
||||||
"""Return the default value of the quota."""
|
"""Return the default value of the quota."""
|
||||||
|
|
||||||
return FLAGS[self.flag] if self.flag else -1
|
return CONF[self.flag] if self.flag else -1
|
||||||
|
|
||||||
|
|
||||||
class ReservableResource(BaseResource):
|
class ReservableResource(BaseResource):
|
||||||
@ -538,7 +537,7 @@ class QuotaEngine(object):
|
|||||||
"""Initialize a Quota object."""
|
"""Initialize a Quota object."""
|
||||||
|
|
||||||
if not quota_driver_class:
|
if not quota_driver_class:
|
||||||
quota_driver_class = FLAGS.quota_driver
|
quota_driver_class = CONF.quota_driver
|
||||||
|
|
||||||
if isinstance(quota_driver_class, basestring):
|
if isinstance(quota_driver_class, basestring):
|
||||||
quota_driver_class = importutils.import_object(quota_driver_class)
|
quota_driver_class = importutils.import_object(quota_driver_class)
|
||||||
@ -792,7 +791,7 @@ def _sync_gigabytes(context, project_id, session):
|
|||||||
(_junk, share_gigs) = db.share_data_get_for_project(context,
|
(_junk, share_gigs) = db.share_data_get_for_project(context,
|
||||||
project_id,
|
project_id,
|
||||||
session=session)
|
session=session)
|
||||||
if FLAGS.no_snapshot_gb_quota:
|
if CONF.no_snapshot_gb_quota:
|
||||||
return {'gigabytes': share_gigs}
|
return {'gigabytes': share_gigs}
|
||||||
|
|
||||||
(_junk, snap_gigs) = db.snapshot_data_get_for_project(context,
|
(_junk, snap_gigs) = db.snapshot_data_get_for_project(context,
|
||||||
|
@ -24,11 +24,12 @@ Chance (Random) Scheduler implementation
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.scheduler import driver
|
from manila.scheduler import driver
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class ChanceScheduler(driver.Scheduler):
|
class ChanceScheduler(driver.Scheduler):
|
||||||
@ -60,7 +61,7 @@ class ChanceScheduler(driver.Scheduler):
|
|||||||
|
|
||||||
def schedule_create_share(self, context, request_spec, filter_properties):
|
def schedule_create_share(self, context, request_spec, filter_properties):
|
||||||
"""Picks a host that is up at random."""
|
"""Picks a host that is up at random."""
|
||||||
topic = FLAGS.share_topic
|
topic = CONF.share_topic
|
||||||
host = self._schedule(context, topic, request_spec,
|
host = self._schedule(context, topic, request_spec,
|
||||||
filter_properties=filter_properties)
|
filter_properties=filter_properties)
|
||||||
share_id = request_spec['share_id']
|
share_id = request_spec['share_id']
|
||||||
|
@ -24,7 +24,7 @@ Scheduler base class that all Schedulers should inherit from
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
from manila.share import rpcapi as share_rpcapi
|
from manila.share import rpcapi as share_rpcapi
|
||||||
@ -39,8 +39,8 @@ scheduler_driver_opts = [
|
|||||||
help='Maximum number of attempts to schedule a share'),
|
help='Maximum number of attempts to schedule a share'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(scheduler_driver_opts)
|
CONF.register_opts(scheduler_driver_opts)
|
||||||
|
|
||||||
|
|
||||||
def share_update_db(context, share_id, host):
|
def share_update_db(context, share_id, host):
|
||||||
@ -58,7 +58,7 @@ class Scheduler(object):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.host_manager = importutils.import_object(
|
self.host_manager = importutils.import_object(
|
||||||
FLAGS.scheduler_host_manager)
|
CONF.scheduler_host_manager)
|
||||||
self.share_rpcapi = share_rpcapi.ShareAPI()
|
self.share_rpcapi = share_rpcapi.ShareAPI()
|
||||||
|
|
||||||
def get_host_list(self):
|
def get_host_list(self):
|
||||||
|
@ -23,14 +23,15 @@ Weighing Functions.
|
|||||||
import operator
|
import operator
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.scheduler import driver
|
from manila.scheduler import driver
|
||||||
from manila.scheduler import scheduler_options
|
from manila.scheduler import scheduler_options
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ class FilterScheduler(driver.Scheduler):
|
|||||||
hosts.append(host)
|
hosts.append(host)
|
||||||
|
|
||||||
def _max_attempts(self):
|
def _max_attempts(self):
|
||||||
max_attempts = FLAGS.scheduler_max_attempts
|
max_attempts = CONF.scheduler_max_attempts
|
||||||
if max_attempts < 1:
|
if max_attempts < 1:
|
||||||
msg = _("Invalid value for 'scheduler_max_attempts', "
|
msg = _("Invalid value for 'scheduler_max_attempts', "
|
||||||
"must be >=1")
|
"must be >=1")
|
||||||
|
@ -23,7 +23,7 @@ from oslo.config import cfg
|
|||||||
|
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common.scheduler import filters
|
from manila.openstack.common.scheduler import filters
|
||||||
from manila.openstack.common.scheduler import weights
|
from manila.openstack.common.scheduler import weights
|
||||||
@ -46,8 +46,8 @@ host_manager_opts = [
|
|||||||
help='Which weigher class names to use for weighing hosts.')
|
help='Which weigher class names to use for weighing hosts.')
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(host_manager_opts)
|
CONF.register_opts(host_manager_opts)
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ class HostManager(object):
|
|||||||
of acceptable filters.
|
of acceptable filters.
|
||||||
"""
|
"""
|
||||||
if filter_cls_names is None:
|
if filter_cls_names is None:
|
||||||
filter_cls_names = FLAGS.scheduler_default_filters
|
filter_cls_names = CONF.scheduler_default_filters
|
||||||
if not isinstance(filter_cls_names, (list, tuple)):
|
if not isinstance(filter_cls_names, (list, tuple)):
|
||||||
filter_cls_names = [filter_cls_names]
|
filter_cls_names = [filter_cls_names]
|
||||||
good_filters = []
|
good_filters = []
|
||||||
@ -181,7 +181,7 @@ class HostManager(object):
|
|||||||
of acceptable weighers.
|
of acceptable weighers.
|
||||||
"""
|
"""
|
||||||
if weight_cls_names is None:
|
if weight_cls_names is None:
|
||||||
weight_cls_names = FLAGS.scheduler_default_weighers
|
weight_cls_names = CONF.scheduler_default_weighers
|
||||||
if not isinstance(weight_cls_names, (list, tuple)):
|
if not isinstance(weight_cls_names, (list, tuple)):
|
||||||
weight_cls_names = [weight_cls_names]
|
weight_cls_names = [weight_cls_names]
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ class HostManager(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Get resource usage across the available share nodes:
|
# Get resource usage across the available share nodes:
|
||||||
topic = FLAGS.share_topic
|
topic = CONF.share_topic
|
||||||
share_services = db.service_get_all_by_topic(context, topic)
|
share_services = db.service_get_all_by_topic(context, topic)
|
||||||
for service in share_services:
|
for service in share_services:
|
||||||
if not utils.service_is_up(service) or service['disabled']:
|
if not utils.service_is_up(service) or service['disabled']:
|
||||||
|
@ -26,7 +26,7 @@ from oslo.config import cfg
|
|||||||
from manila import context
|
from manila import context
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila import manager
|
from manila import manager
|
||||||
from manila.openstack.common import excutils
|
from manila.openstack.common import excutils
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
@ -41,8 +41,8 @@ scheduler_driver_opt = cfg.StrOpt('scheduler_driver',
|
|||||||
'FilterScheduler',
|
'FilterScheduler',
|
||||||
help='Default scheduler driver to use')
|
help='Default scheduler driver to use')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opt(scheduler_driver_opt)
|
CONF.register_opt(scheduler_driver_opt)
|
||||||
|
|
||||||
|
|
||||||
class SchedulerManager(manager.Manager):
|
class SchedulerManager(manager.Manager):
|
||||||
@ -53,7 +53,7 @@ class SchedulerManager(manager.Manager):
|
|||||||
def __init__(self, scheduler_driver=None, service_name=None,
|
def __init__(self, scheduler_driver=None, service_name=None,
|
||||||
*args, **kwargs):
|
*args, **kwargs):
|
||||||
if not scheduler_driver:
|
if not scheduler_driver:
|
||||||
scheduler_driver = FLAGS.scheduler_driver
|
scheduler_driver = CONF.scheduler_driver
|
||||||
self.driver = importutils.import_object(scheduler_driver)
|
self.driver = importutils.import_object(scheduler_driver)
|
||||||
super(SchedulerManager, self).__init__(*args, **kwargs)
|
super(SchedulerManager, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
@ -18,12 +18,13 @@
|
|||||||
Client side of the scheduler manager RPC API.
|
Client side of the scheduler manager RPC API.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import jsonutils
|
from manila.openstack.common import jsonutils
|
||||||
import manila.openstack.common.rpc.proxy
|
import manila.openstack.common.rpc.proxy
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class SchedulerAPI(manila.openstack.common.rpc.proxy.RpcProxy):
|
class SchedulerAPI(manila.openstack.common.rpc.proxy.RpcProxy):
|
||||||
@ -42,7 +43,7 @@ class SchedulerAPI(manila.openstack.common.rpc.proxy.RpcProxy):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(SchedulerAPI, self).__init__(
|
super(SchedulerAPI, self).__init__(
|
||||||
topic=FLAGS.scheduler_topic,
|
topic=CONF.scheduler_topic,
|
||||||
default_version=self.RPC_API_VERSION)
|
default_version=self.RPC_API_VERSION)
|
||||||
|
|
||||||
def create_share(self, ctxt, topic, share_id, snapshot_id=None,
|
def create_share(self, ctxt, topic, share_id, snapshot_id=None,
|
||||||
|
@ -28,7 +28,7 @@ import os
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
|
|
||||||
@ -37,8 +37,8 @@ scheduler_json_config_location_opt = cfg.StrOpt(
|
|||||||
default='',
|
default='',
|
||||||
help='Absolute path to scheduler configuration JSON file.')
|
help='Absolute path to scheduler configuration JSON file.')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opt(scheduler_json_config_location_opt)
|
CONF.register_opt(scheduler_json_config_location_opt)
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class SchedulerOptions(object):
|
|||||||
def get_configuration(self, filename=None):
|
def get_configuration(self, filename=None):
|
||||||
"""Check the json file for changes and load it if needed."""
|
"""Check the json file for changes and load it if needed."""
|
||||||
if not filename:
|
if not filename:
|
||||||
filename = FLAGS.scheduler_json_config_location
|
filename = CONF.scheduler_json_config_location
|
||||||
if not filename:
|
if not filename:
|
||||||
return self.data
|
return self.data
|
||||||
if self.last_checked:
|
if self.last_checked:
|
||||||
|
@ -25,7 +25,7 @@ from oslo.config import cfg
|
|||||||
|
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.scheduler import chance
|
from manila.scheduler import chance
|
||||||
from manila.scheduler import driver
|
from manila.scheduler import driver
|
||||||
from manila import utils
|
from manila import utils
|
||||||
@ -35,8 +35,8 @@ simple_scheduler_opts = [
|
|||||||
default=10000,
|
default=10000,
|
||||||
help="maximum number of volume gigabytes to allow per host"), ]
|
help="maximum number of volume gigabytes to allow per host"), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(simple_scheduler_opts)
|
CONF.register_opts(simple_scheduler_opts)
|
||||||
|
|
||||||
|
|
||||||
class SimpleScheduler(chance.ChanceScheduler):
|
class SimpleScheduler(chance.ChanceScheduler):
|
||||||
@ -57,7 +57,7 @@ class SimpleScheduler(chance.ChanceScheduler):
|
|||||||
if availability_zone:
|
if availability_zone:
|
||||||
zone, _x, host = availability_zone.partition(':')
|
zone, _x, host = availability_zone.partition(':')
|
||||||
if host and context.is_admin:
|
if host and context.is_admin:
|
||||||
service = db.service_get_by_args(elevated, host, FLAGS.share_topic)
|
service = db.service_get_by_args(elevated, host, CONF.share_topic)
|
||||||
if not utils.service_is_up(service):
|
if not utils.service_is_up(service):
|
||||||
raise exception.WillNotSchedule(host=host)
|
raise exception.WillNotSchedule(host=host)
|
||||||
updated_share = driver.share_update_db(context, share_id, host)
|
updated_share = driver.share_update_db(context, share_id, host)
|
||||||
@ -76,7 +76,7 @@ class SimpleScheduler(chance.ChanceScheduler):
|
|||||||
if service['availability_zone'] == zone]
|
if service['availability_zone'] == zone]
|
||||||
for result in results:
|
for result in results:
|
||||||
(service, share_gigabytes) = result
|
(service, share_gigabytes) = result
|
||||||
if share_gigabytes + share_size > FLAGS.max_gigabytes:
|
if share_gigabytes + share_size > CONF.max_gigabytes:
|
||||||
msg = _("Not enough allocatable share gigabytes remaining")
|
msg = _("Not enough allocatable share gigabytes remaining")
|
||||||
raise exception.NoValidHost(reason=msg)
|
raise exception.NoValidHost(reason=msg)
|
||||||
if utils.service_is_up(service) and not service['disabled']:
|
if utils.service_is_up(service) and not service['disabled']:
|
||||||
|
@ -24,7 +24,7 @@ import math
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common.scheduler import weights
|
from manila.openstack.common.scheduler import weights
|
||||||
|
|
||||||
capacity_weight_opts = [
|
capacity_weight_opts = [
|
||||||
@ -34,14 +34,14 @@ capacity_weight_opts = [
|
|||||||
'Negative numbers mean to stack vs spread.'),
|
'Negative numbers mean to stack vs spread.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(capacity_weight_opts)
|
CONF.register_opts(capacity_weight_opts)
|
||||||
|
|
||||||
|
|
||||||
class CapacityWeigher(weights.BaseHostWeigher):
|
class CapacityWeigher(weights.BaseHostWeigher):
|
||||||
def _weight_multiplier(self):
|
def _weight_multiplier(self):
|
||||||
"""Override the weight multiplier."""
|
"""Override the weight multiplier."""
|
||||||
return FLAGS.capacity_weight_multiplier
|
return CONF.capacity_weight_multiplier
|
||||||
|
|
||||||
def _weigh_object(self, host_state, weight_properties):
|
def _weigh_object(self, host_state, weight_properties):
|
||||||
"""Higher weights win. We want spreading to be the default."""
|
"""Higher weights win. We want spreading to be the default."""
|
||||||
|
@ -34,7 +34,7 @@ from oslo.config import cfg
|
|||||||
from manila import context
|
from manila import context
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common import rpc
|
from manila.openstack.common import rpc
|
||||||
@ -63,8 +63,8 @@ service_opts = [
|
|||||||
default=8786,
|
default=8786,
|
||||||
help='port for os share api to listen'), ]
|
help='port for os share api to listen'), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(service_opts)
|
CONF.register_opts(service_opts)
|
||||||
|
|
||||||
|
|
||||||
class SignalExit(SystemExit):
|
class SignalExit(SystemExit):
|
||||||
@ -398,7 +398,7 @@ class Service(object):
|
|||||||
self.timers.append(periodic)
|
self.timers.append(periodic)
|
||||||
|
|
||||||
def _create_service_ref(self, context):
|
def _create_service_ref(self, context):
|
||||||
zone = FLAGS.storage_availability_zone
|
zone = CONF.storage_availability_zone
|
||||||
service_ref = db.service_create(context,
|
service_ref = db.service_create(context,
|
||||||
{'host': self.host,
|
{'host': self.host,
|
||||||
'binary': self.binary,
|
'binary': self.binary,
|
||||||
@ -417,30 +417,30 @@ class Service(object):
|
|||||||
periodic_fuzzy_delay=None, service_name=None):
|
periodic_fuzzy_delay=None, service_name=None):
|
||||||
"""Instantiates class and passes back application object.
|
"""Instantiates class and passes back application object.
|
||||||
|
|
||||||
:param host: defaults to FLAGS.host
|
:param host: defaults to CONF.host
|
||||||
:param binary: defaults to basename of executable
|
:param binary: defaults to basename of executable
|
||||||
:param topic: defaults to bin_name - 'manila-' part
|
:param topic: defaults to bin_name - 'manila-' part
|
||||||
:param manager: defaults to FLAGS.<topic>_manager
|
:param manager: defaults to CONF.<topic>_manager
|
||||||
:param report_interval: defaults to FLAGS.report_interval
|
:param report_interval: defaults to CONF.report_interval
|
||||||
:param periodic_interval: defaults to FLAGS.periodic_interval
|
:param periodic_interval: defaults to CONF.periodic_interval
|
||||||
:param periodic_fuzzy_delay: defaults to FLAGS.periodic_fuzzy_delay
|
:param periodic_fuzzy_delay: defaults to CONF.periodic_fuzzy_delay
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not host:
|
if not host:
|
||||||
host = FLAGS.host
|
host = CONF.host
|
||||||
if not binary:
|
if not binary:
|
||||||
binary = os.path.basename(inspect.stack()[-1][1])
|
binary = os.path.basename(inspect.stack()[-1][1])
|
||||||
if not topic:
|
if not topic:
|
||||||
topic = binary
|
topic = binary
|
||||||
if not manager:
|
if not manager:
|
||||||
subtopic = topic.rpartition('manila-')[2]
|
subtopic = topic.rpartition('manila-')[2]
|
||||||
manager = FLAGS.get('%s_manager' % subtopic, None)
|
manager = CONF.get('%s_manager' % subtopic, None)
|
||||||
if report_interval is None:
|
if report_interval is None:
|
||||||
report_interval = FLAGS.report_interval
|
report_interval = CONF.report_interval
|
||||||
if periodic_interval is None:
|
if periodic_interval is None:
|
||||||
periodic_interval = FLAGS.periodic_interval
|
periodic_interval = CONF.periodic_interval
|
||||||
if periodic_fuzzy_delay is None:
|
if periodic_fuzzy_delay is None:
|
||||||
periodic_fuzzy_delay = FLAGS.periodic_fuzzy_delay
|
periodic_fuzzy_delay = CONF.periodic_fuzzy_delay
|
||||||
service_obj = cls(host, binary, topic, manager,
|
service_obj = cls(host, binary, topic, manager,
|
||||||
report_interval=report_interval,
|
report_interval=report_interval,
|
||||||
periodic_interval=periodic_interval,
|
periodic_interval=periodic_interval,
|
||||||
@ -486,7 +486,7 @@ class Service(object):
|
|||||||
def report_state(self):
|
def report_state(self):
|
||||||
"""Update the state of this service in the datastore."""
|
"""Update the state of this service in the datastore."""
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
zone = FLAGS.storage_availability_zone
|
zone = CONF.storage_availability_zone
|
||||||
state_catalog = {}
|
state_catalog = {}
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
@ -531,8 +531,8 @@ class WSGIService(object):
|
|||||||
self.manager = self._get_manager()
|
self.manager = self._get_manager()
|
||||||
self.loader = loader or wsgi.Loader()
|
self.loader = loader or wsgi.Loader()
|
||||||
self.app = self.loader.load_app(name)
|
self.app = self.loader.load_app(name)
|
||||||
self.host = getattr(FLAGS, '%s_listen' % name, "0.0.0.0")
|
self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0")
|
||||||
self.port = getattr(FLAGS, '%s_listen_port' % name, 0)
|
self.port = getattr(CONF, '%s_listen_port' % name, 0)
|
||||||
self.server = wsgi.Server(name,
|
self.server = wsgi.Server(name,
|
||||||
self.app,
|
self.app,
|
||||||
host=self.host,
|
host=self.host,
|
||||||
@ -549,10 +549,10 @@ class WSGIService(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
fl = '%s_manager' % self.name
|
fl = '%s_manager' % self.name
|
||||||
if fl not in FLAGS:
|
if fl not in CONF:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
manager_class_name = FLAGS.get(fl, None)
|
manager_class_name = CONF.get(fl, None)
|
||||||
if not manager_class_name:
|
if not manager_class_name:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -605,9 +605,9 @@ def serve(*servers):
|
|||||||
|
|
||||||
|
|
||||||
def wait():
|
def wait():
|
||||||
LOG.debug(_('Full set of FLAGS:'))
|
LOG.debug(_('Full set of CONF:'))
|
||||||
for flag in FLAGS:
|
for flag in CONF:
|
||||||
flag_get = FLAGS.get(flag, None)
|
flag_get = CONF.get(flag, None)
|
||||||
# hide flag contents from log if contains a password
|
# hide flag contents from log if contains a password
|
||||||
# should use secret flag when switch over to openstack-common
|
# should use secret flag when switch over to openstack-common
|
||||||
if ("_password" in flag or "_key" in flag or
|
if ("_password" in flag or "_key" in flag or
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
# Importing full names to not pollute the namespace and cause possible
|
# Importing full names to not pollute the namespace and cause possible
|
||||||
# collisions with use of 'from manila.share import <foo>' elsewhere.
|
# collisions with use of 'from manila.share import <foo>' elsewhere.
|
||||||
import manila.flags
|
from manila.common import config
|
||||||
import manila.openstack.common.importutils
|
import manila.openstack.common.importutils as import_utils
|
||||||
|
|
||||||
API = manila.openstack.common.importutils.import_class(
|
CONF = config.CONF
|
||||||
manila.flags.FLAGS.share_api_class)
|
|
||||||
|
API = import_utils.import_class(CONF.share_api_class)
|
||||||
|
@ -24,7 +24,6 @@ import functools
|
|||||||
|
|
||||||
from manila.db import base
|
from manila.db import base
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.image import glance
|
from manila.image import glance
|
||||||
from manila.openstack.common import excutils
|
from manila.openstack.common import excutils
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
@ -38,7 +37,7 @@ from manila.share import rpcapi as share_rpcapi
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
GB = 1048576 * 1024
|
GB = 1048576 * 1024
|
||||||
@ -145,7 +144,7 @@ class API(base.Base):
|
|||||||
raise exception.ShareLimitExceeded(allowed=quotas['shares'])
|
raise exception.ShareLimitExceeded(allowed=quotas['shares'])
|
||||||
|
|
||||||
if availability_zone is None:
|
if availability_zone is None:
|
||||||
availability_zone = FLAGS.storage_availability_zone
|
availability_zone = CONF.storage_availability_zone
|
||||||
|
|
||||||
options = {'size': size,
|
options = {'size': size,
|
||||||
'user_id': context.user_id,
|
'user_id': context.user_id,
|
||||||
@ -179,7 +178,7 @@ class API(base.Base):
|
|||||||
|
|
||||||
self.scheduler_rpcapi.create_share(
|
self.scheduler_rpcapi.create_share(
|
||||||
context,
|
context,
|
||||||
FLAGS.share_topic,
|
CONF.share_topic,
|
||||||
share['id'],
|
share['id'],
|
||||||
snapshot_id,
|
snapshot_id,
|
||||||
request_spec=request_spec,
|
request_spec=request_spec,
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
Configuration support for all drivers.
|
Configuration support for all drivers.
|
||||||
|
|
||||||
This module allows support for setting configurations either from default
|
This module allows support for setting configurations either from default
|
||||||
or from a particular FLAGS group, to be able to set multiple configurations
|
or from a particular CONF group, to be able to set multiple configurations
|
||||||
for a given set of values.
|
for a given set of values.
|
||||||
|
|
||||||
For instance, two lvm configurations can be set by naming them in groups as
|
For instance, two lvm configurations can be set by naming them in groups as
|
||||||
@ -45,11 +45,10 @@ and registered in the group in which they are used.
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -63,12 +62,12 @@ class Configuration(object):
|
|||||||
# set the local conf so that __call__'s know what to use
|
# set the local conf so that __call__'s know what to use
|
||||||
if self.config_group:
|
if self.config_group:
|
||||||
self._ensure_config_values(share_opts)
|
self._ensure_config_values(share_opts)
|
||||||
self.local_conf = FLAGS._get(self.config_group)
|
self.local_conf = CONF._get(self.config_group)
|
||||||
else:
|
else:
|
||||||
self.local_conf = FLAGS
|
self.local_conf = CONF
|
||||||
|
|
||||||
def _ensure_config_values(self, share_opts):
|
def _ensure_config_values(self, share_opts):
|
||||||
FLAGS.register_opts(share_opts,
|
CONF.register_opts(share_opts,
|
||||||
group=self.config_group)
|
group=self.config_group)
|
||||||
|
|
||||||
def append_config_values(self, share_opts):
|
def append_config_values(self, share_opts):
|
||||||
|
@ -25,7 +25,6 @@ import re
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.share.configuration import Configuration
|
from manila.share.configuration import Configuration
|
||||||
from manila import utils
|
from manila import utils
|
||||||
@ -48,8 +47,8 @@ share_opts = [
|
|||||||
help='The backend name for a given driver implementation'),
|
help='The backend name for a given driver implementation'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(share_opts)
|
CONF.register_opts(share_opts)
|
||||||
|
|
||||||
|
|
||||||
#TODO(rushiagr): keep the configuration option in only one class and not two
|
#TODO(rushiagr): keep the configuration option in only one class and not two
|
||||||
|
@ -25,7 +25,6 @@ import os
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.share import driver
|
from manila.share import driver
|
||||||
@ -61,8 +60,8 @@ share_opts = [
|
|||||||
help='Specify list of share export helpers.'),
|
help='Specify list of share export helpers.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(share_opts)
|
CONF.register_opts(share_opts)
|
||||||
|
|
||||||
|
|
||||||
class LVMShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
class LVMShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
||||||
|
@ -23,7 +23,6 @@ import suds
|
|||||||
from suds.sax import text
|
from suds.sax import text
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log
|
from manila.openstack.common import log
|
||||||
from manila.share import driver
|
from manila.share import driver
|
||||||
|
|
||||||
@ -53,8 +52,8 @@ NETAPP_NAS_OPTS = [
|
|||||||
help='Use secure connection to server.'),
|
help='Use secure connection to server.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(NETAPP_NAS_OPTS)
|
CONF.register_opts(NETAPP_NAS_OPTS)
|
||||||
|
|
||||||
|
|
||||||
class NetAppShareDriver(driver.ShareDriver):
|
class NetAppShareDriver(driver.ShareDriver):
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
from manila import context
|
from manila import context
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila import manager
|
from manila import manager
|
||||||
from manila.openstack.common import excutils
|
from manila.openstack.common import excutils
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
@ -43,8 +42,8 @@ share_manager_opts = [
|
|||||||
help='Driver to use for share creation'),
|
help='Driver to use for share creation'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(share_manager_opts)
|
CONF.register_opts(share_manager_opts)
|
||||||
|
|
||||||
QUOTAS = quota.QUOTAS
|
QUOTAS = quota.QUOTAS
|
||||||
|
|
||||||
|
@ -19,12 +19,12 @@ Client side of the share RPC API.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import rpc
|
from manila.openstack.common import rpc
|
||||||
import manila.openstack.common.rpc.proxy
|
import manila.openstack.common.rpc.proxy
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class ShareAPI(manila.openstack.common.rpc.proxy.RpcProxy):
|
class ShareAPI(manila.openstack.common.rpc.proxy.RpcProxy):
|
||||||
@ -41,7 +41,7 @@ class ShareAPI(manila.openstack.common.rpc.proxy.RpcProxy):
|
|||||||
|
|
||||||
def __init__(self, topic=None):
|
def __init__(self, topic=None):
|
||||||
super(ShareAPI, self).__init__(
|
super(ShareAPI, self).__init__(
|
||||||
topic=topic or FLAGS.share_topic,
|
topic=topic or CONF.share_topic,
|
||||||
default_version=self.BASE_RPC_API_VERSION)
|
default_version=self.BASE_RPC_API_VERSION)
|
||||||
|
|
||||||
def create_share(self, ctxt, share, host,
|
def create_share(self, ctxt, share, host,
|
||||||
|
@ -32,13 +32,13 @@ import nose.plugins.skip
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import stubout
|
import stubout
|
||||||
|
|
||||||
from manila import flags
|
from manila.common import config
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
from manila import service
|
from manila import service
|
||||||
from manila import tests
|
from manila import tests
|
||||||
from manila.tests import fake_flags
|
from manila.tests import conf_fixture
|
||||||
|
|
||||||
test_opts = [
|
test_opts = [
|
||||||
cfg.StrOpt('sqlite_clean_db',
|
cfg.StrOpt('sqlite_clean_db',
|
||||||
@ -48,8 +48,8 @@ test_opts = [
|
|||||||
default=True,
|
default=True,
|
||||||
help='should we use everything for testing'), ]
|
help='should we use everything for testing'), ]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opts(test_opts)
|
CONF.register_opts(test_opts)
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ def skip_if_fake(func):
|
|||||||
"""Decorator that skips a test if running in fake mode."""
|
"""Decorator that skips a test if running in fake mode."""
|
||||||
def _skipper(*args, **kw):
|
def _skipper(*args, **kw):
|
||||||
"""Wrapped skipper function."""
|
"""Wrapped skipper function."""
|
||||||
if FLAGS.fake_tests:
|
if CONF.fake_tests:
|
||||||
raise unittest.SkipTest('Test cannot be run in fake mode')
|
raise unittest.SkipTest('Test cannot be run in fake mode')
|
||||||
else:
|
else:
|
||||||
return func(*args, **kw)
|
return func(*args, **kw)
|
||||||
@ -122,8 +122,8 @@ class TestCase(unittest.TestCase):
|
|||||||
"""Run before each test method to initialize test environment."""
|
"""Run before each test method to initialize test environment."""
|
||||||
super(TestCase, self).setUp()
|
super(TestCase, self).setUp()
|
||||||
|
|
||||||
fake_flags.set_defaults(FLAGS)
|
conf_fixture.set_defaults(CONF)
|
||||||
flags.parse_args([], default_config_files=[])
|
CONF([], default_config_files=[])
|
||||||
|
|
||||||
# NOTE(vish): We need a better method for creating fixtures for tests
|
# NOTE(vish): We need a better method for creating fixtures for tests
|
||||||
# now that we have some required db setup for the system
|
# now that we have some required db setup for the system
|
||||||
@ -137,7 +137,7 @@ class TestCase(unittest.TestCase):
|
|||||||
self.stubs = stubout.StubOutForTesting()
|
self.stubs = stubout.StubOutForTesting()
|
||||||
self.injected = []
|
self.injected = []
|
||||||
self._services = []
|
self._services = []
|
||||||
FLAGS.set_override('fatal_exception_format_errors', True)
|
CONF.set_override('fatal_exception_format_errors', True)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""Runs after each test method to tear down test environment."""
|
"""Runs after each test method to tear down test environment."""
|
||||||
@ -149,7 +149,7 @@ class TestCase(unittest.TestCase):
|
|||||||
super(TestCase, self).tearDown()
|
super(TestCase, self).tearDown()
|
||||||
finally:
|
finally:
|
||||||
# Reset any overridden flags
|
# Reset any overridden flags
|
||||||
FLAGS.reset()
|
CONF.reset()
|
||||||
|
|
||||||
# Stop any timers
|
# Stop any timers
|
||||||
for x in self.injected:
|
for x in self.injected:
|
||||||
@ -174,7 +174,7 @@ class TestCase(unittest.TestCase):
|
|||||||
def flags(self, **kw):
|
def flags(self, **kw):
|
||||||
"""Override flag variables for a test."""
|
"""Override flag variables for a test."""
|
||||||
for k, v in kw.iteritems():
|
for k, v in kw.iteritems():
|
||||||
FLAGS.set_override(k, v)
|
CONF.set_override(k, v)
|
||||||
|
|
||||||
def start_service(self, name, host=None, **kwargs):
|
def start_service(self, name, host=None, **kwargs):
|
||||||
host = host and host or uuid.uuid4().hex
|
host = host and host or uuid.uuid4().hex
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
import eventlet
|
import eventlet
|
||||||
eventlet.monkey_patch()
|
eventlet.monkey_patch()
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
||||||
# The code below enables nosetests to work with i18n _() blocks
|
# The code below enables nosetests to work with i18n _() blocks
|
||||||
import __builtin__
|
import __builtin__
|
||||||
@ -41,45 +43,46 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from manila.db.sqlalchemy.session import get_engine
|
from manila.db.sqlalchemy.session import get_engine
|
||||||
from manila import flags
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
_DB = None
|
_DB = None
|
||||||
|
|
||||||
|
|
||||||
def reset_db():
|
def reset_db():
|
||||||
if FLAGS.sql_connection == "sqlite://":
|
if CONF.sql_connection == "sqlite://":
|
||||||
engine = get_engine()
|
engine = get_engine()
|
||||||
engine.dispose()
|
engine.dispose()
|
||||||
conn = engine.connect()
|
conn = engine.connect()
|
||||||
conn.connection.executescript(_DB)
|
conn.connection.executescript(_DB)
|
||||||
else:
|
else:
|
||||||
shutil.copyfile(os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db),
|
shutil.copyfile(os.path.join(CONF.state_path, CONF.sqlite_clean_db),
|
||||||
os.path.join(FLAGS.state_path, FLAGS.sqlite_db))
|
os.path.join(CONF.state_path, CONF.sqlite_db))
|
||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
import mox # Fail fast if you don't have mox. Workaround for bug 810424
|
import mox # Fail fast if you don't have mox. Workaround for bug 810424
|
||||||
|
|
||||||
from manila.db import migration
|
from manila.db import migration
|
||||||
from manila.tests import fake_flags
|
from manila.tests import conf_fixture
|
||||||
fake_flags.set_defaults(FLAGS)
|
|
||||||
|
|
||||||
if FLAGS.sql_connection == "sqlite://":
|
conf_fixture.set_defaults(CONF)
|
||||||
|
|
||||||
|
if CONF.sql_connection == "sqlite://":
|
||||||
if migration.db_version() > 1:
|
if migration.db_version() > 1:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
testdb = os.path.join(FLAGS.state_path, FLAGS.sqlite_db)
|
testdb = os.path.join(CONF.state_path, CONF.sqlite_db)
|
||||||
if os.path.exists(testdb):
|
if os.path.exists(testdb):
|
||||||
return
|
return
|
||||||
migration.db_sync()
|
migration.db_sync()
|
||||||
|
|
||||||
if FLAGS.sql_connection == "sqlite://":
|
if CONF.sql_connection == "sqlite://":
|
||||||
global _DB
|
global _DB
|
||||||
engine = get_engine()
|
engine = get_engine()
|
||||||
conn = engine.connect()
|
conn = engine.connect()
|
||||||
_DB = "".join(line for line in conn.connection.iterdump())
|
_DB = "".join(line for line in conn.connection.iterdump())
|
||||||
else:
|
else:
|
||||||
cleandb = os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db)
|
cleandb = os.path.join(CONF.state_path, CONF.sqlite_clean_db)
|
||||||
shutil.copyfile(testdb, cleandb)
|
shutil.copyfile(testdb, cleandb)
|
||||||
|
@ -20,7 +20,7 @@ import webob
|
|||||||
|
|
||||||
from manila.api.contrib import share_actions
|
from manila.api.contrib import share_actions
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import jsonutils
|
from manila.openstack.common import jsonutils
|
||||||
from manila.openstack.common.rpc import common as rpc_common
|
from manila.openstack.common.rpc import common as rpc_common
|
||||||
from manila import share
|
from manila import share
|
||||||
@ -28,9 +28,10 @@ from manila.share import api as share_api
|
|||||||
from manila import test
|
from manila import test
|
||||||
from manila.tests.api.contrib import stubs
|
from manila.tests.api.contrib import stubs
|
||||||
from manila.tests.api import fakes
|
from manila.tests.api import fakes
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
def _fake_access_get(self, ctxt, access_id):
|
def _fake_access_get(self, ctxt, access_id):
|
||||||
|
@ -16,11 +16,13 @@ import StringIO
|
|||||||
import webob
|
import webob
|
||||||
|
|
||||||
from manila.api.middleware import sizelimit
|
from manila.api.middleware import sizelimit
|
||||||
from manila import flags
|
|
||||||
from manila import test
|
from manila import test
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
from oslo.config import cfg
|
||||||
MAX_REQUEST_BODY_SIZE = FLAGS.osapi_max_request_body_size
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
MAX_REQUEST_BODY_SIZE = CONF.osapi_max_request_body_size
|
||||||
|
|
||||||
|
|
||||||
class TestLimitingReader(test.TestCase):
|
class TestLimitingReader(test.TestCase):
|
||||||
|
@ -22,18 +22,19 @@ import webob
|
|||||||
|
|
||||||
from manila.api.v1 import router
|
from manila.api.v1 import router
|
||||||
from manila.api import xmlutil
|
from manila.api import xmlutil
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import jsonutils
|
from manila.openstack.common import jsonutils
|
||||||
from manila import test
|
from manila import test
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
NS = "{http://docs.openstack.org/common/api/v1.0}"
|
NS = "{http://docs.openstack.org/common/api/v1.0}"
|
||||||
|
|
||||||
|
|
||||||
class ExtensionTestCase(test.TestCase):
|
class ExtensionTestCase(test.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ExtensionTestCase, self).setUp()
|
super(ExtensionTestCase, self).setUp()
|
||||||
ext_list = FLAGS.osapi_share_extension[:]
|
ext_list = CONF.osapi_share_extension[:]
|
||||||
fox = ('manila.tests.api.extensions.foxinsocks.Foxinsocks')
|
fox = ('manila.tests.api.extensions.foxinsocks.Foxinsocks')
|
||||||
if fox not in ext_list:
|
if fox not in ext_list:
|
||||||
ext_list.append(fox)
|
ext_list.append(fox)
|
||||||
|
@ -17,12 +17,13 @@
|
|||||||
from manila.api.openstack import wsgi
|
from manila.api.openstack import wsgi
|
||||||
from manila.api.v1 import router
|
from manila.api.v1 import router
|
||||||
from manila.api import versions
|
from manila.api import versions
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import test
|
from manila import test
|
||||||
from manila.tests.api import fakes
|
from manila.tests.api import fakes
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
# 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 manila import flags
|
from oslo.config import cfg
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
flags.DECLARE('policy_file', 'manila.policy')
|
CONF.import_opt('policy_file', 'manila.policy')
|
||||||
|
|
||||||
def_vol_type = 'fake_vol_type'
|
def_vol_type = 'fake_vol_type'
|
||||||
|
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opt(cfg.IntOpt('answer', default=42, help='test flag'))
|
CONF.register_opt(cfg.IntOpt('answer', default=42, help='test conf'))
|
@ -19,7 +19,6 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from eventlet import greenthread
|
from eventlet import greenthread
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
@ -23,15 +23,16 @@ import datetime
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
import manila.image.glance
|
import manila.image.glance
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class _FakeImageService(object):
|
class _FakeImageService(object):
|
||||||
|
@ -25,13 +25,14 @@ from glanceclient.v2.client import Client as glanceclient_v2
|
|||||||
|
|
||||||
from manila import context
|
from manila import context
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.image import glance
|
from manila.image import glance
|
||||||
from manila import test
|
from manila import test
|
||||||
from manila.tests.glance import stubs as glance_stubs
|
from manila.tests.glance import stubs as glance_stubs
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class NullWriter(object):
|
class NullWriter(object):
|
||||||
@ -566,7 +567,7 @@ class TestGlanceClientVersion(test.TestCase):
|
|||||||
9292)
|
9292)
|
||||||
self.assertEquals(client_wrapper_v2.client.__module__,
|
self.assertEquals(client_wrapper_v2.client.__module__,
|
||||||
'glanceclient.v2.client')
|
'glanceclient.v2.client')
|
||||||
FLAGS.reset()
|
CONF.reset()
|
||||||
|
|
||||||
def test_glance_version_by_arg(self):
|
def test_glance_version_by_arg(self):
|
||||||
"""Test glance version set by arg to GlanceClientWrapper"""
|
"""Test glance version set by arg to GlanceClientWrapper"""
|
||||||
|
@ -23,13 +23,15 @@ import random
|
|||||||
import string
|
import string
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import service
|
from manila import service
|
||||||
from manila import test # For the flags
|
from manila import test # For the flags
|
||||||
from manila.tests.integrated.api import client
|
from manila.tests.integrated.api import client
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,19 +15,20 @@
|
|||||||
# 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 manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.tests.integrated import integrated_helpers
|
from manila.tests.integrated import integrated_helpers
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ExtensionsTest(integrated_helpers._IntegratedTestBase):
|
class ExtensionsTest(integrated_helpers._IntegratedTestBase):
|
||||||
def _get_flags(self):
|
def _get_flags(self):
|
||||||
f = super(ExtensionsTest, self)._get_flags()
|
f = super(ExtensionsTest, self)._get_flags()
|
||||||
f['osapi_share_extension'] = FLAGS.osapi_share_extension[:]
|
f['osapi_share_extension'] = CONF.osapi_share_extension[:]
|
||||||
f['osapi_share_extension'].append(
|
f['osapi_share_extension'].append(
|
||||||
'manila.tests.api.extensions.foxinsocks.Foxinsocks')
|
'manila.tests.api.extensions.foxinsocks.Foxinsocks')
|
||||||
return f
|
return f
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
FLAGS.register_opt(cfg.IntOpt('runtime_answer', default=54, help='test flag'))
|
CONF.register_opt(cfg.IntOpt('runtime_answer', default=54, help='test flag'))
|
@ -19,15 +19,16 @@ Tests For HostManager
|
|||||||
|
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common.scheduler import filters
|
from manila.openstack.common.scheduler import filters
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
from manila.scheduler import host_manager
|
from manila.scheduler import host_manager
|
||||||
from manila import test
|
from manila import test
|
||||||
from manila.tests.scheduler import fakes
|
from manila.tests.scheduler import fakes
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class FakeFilterClass1(filters.BaseHostFilter):
|
class FakeFilterClass1(filters.BaseHostFilter):
|
||||||
@ -137,7 +138,7 @@ class HostManagerTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_get_all_host_states_share(self):
|
def test_get_all_host_states_share(self):
|
||||||
context = 'fake_context'
|
context = 'fake_context'
|
||||||
topic = FLAGS.share_topic
|
topic = CONF.share_topic
|
||||||
|
|
||||||
self.mox.StubOutWithMock(db, 'service_get_all_by_topic')
|
self.mox.StubOutWithMock(db, 'service_get_all_by_topic')
|
||||||
self.mox.StubOutWithMock(host_manager.LOG, 'warn')
|
self.mox.StubOutWithMock(host_manager.LOG, 'warn')
|
||||||
|
@ -19,13 +19,14 @@ Unit Tests for manila.scheduler.rpcapi
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from manila import context
|
from manila import context
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import rpc
|
from manila.openstack.common import rpc
|
||||||
from manila.scheduler import rpcapi as scheduler_rpcapi
|
from manila.scheduler import rpcapi as scheduler_rpcapi
|
||||||
from manila import test
|
from manila import test
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class SchedulerRpcAPITestCase(test.TestCase):
|
class SchedulerRpcAPITestCase(test.TestCase):
|
||||||
@ -58,7 +59,7 @@ class SchedulerRpcAPITestCase(test.TestCase):
|
|||||||
retval = getattr(rpcapi, method)(ctxt, **kwargs)
|
retval = getattr(rpcapi, method)(ctxt, **kwargs)
|
||||||
|
|
||||||
self.assertEqual(retval, expected_retval)
|
self.assertEqual(retval, expected_retval)
|
||||||
expected_args = [ctxt, FLAGS.scheduler_topic, expected_msg]
|
expected_args = [ctxt, CONF.scheduler_topic, expected_msg]
|
||||||
for arg, expected_arg in zip(self.fake_args, expected_args):
|
for arg, expected_arg in zip(self.fake_args, expected_args):
|
||||||
self.assertEqual(arg, expected_arg)
|
self.assertEqual(arg, expected_arg)
|
||||||
|
|
||||||
|
@ -24,16 +24,17 @@ from mox import IsA
|
|||||||
from manila import context
|
from manila import context
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
from manila.scheduler import driver
|
from manila.scheduler import driver
|
||||||
from manila.scheduler import manager
|
from manila.scheduler import manager
|
||||||
from manila.scheduler import simple
|
from manila.scheduler import simple
|
||||||
from manila import test
|
from manila import test
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class SchedulerManagerTestCase(test.TestCase):
|
class SchedulerManagerTestCase(test.TestCase):
|
||||||
|
83
manila/tests/test_conf.py
Normal file
83
manila/tests/test_conf.py
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# Copyright 2010 United States Government as represented by the
|
||||||
|
# Administrator of the National Aeronautics and Space Administration.
|
||||||
|
# All Rights Reserved.
|
||||||
|
# Copyright 2011 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
|
from manila import test
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
CONF.register_opt(cfg.StrOpt('conf_unittest',
|
||||||
|
default='foo',
|
||||||
|
help='for testing purposes only'))
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigTestCase(test.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(ConfigTestCase, self).setUp()
|
||||||
|
|
||||||
|
def test_declare(self):
|
||||||
|
self.assertNotIn('answer', CONF)
|
||||||
|
CONF.import_opt('answer', 'manila.tests.declare_conf')
|
||||||
|
self.assertIn('answer', CONF)
|
||||||
|
self.assertEqual(CONF.answer, 42)
|
||||||
|
|
||||||
|
# Make sure we don't overwrite anything
|
||||||
|
CONF.set_override('answer', 256)
|
||||||
|
self.assertEqual(CONF.answer, 256)
|
||||||
|
CONF.import_opt('answer', 'manila.tests.declare_conf')
|
||||||
|
self.assertEqual(CONF.answer, 256)
|
||||||
|
|
||||||
|
def test_runtime_and_unknown_flags(self):
|
||||||
|
self.assertNotIn('runtime_answer', CONF)
|
||||||
|
import manila.tests.runtime_conf
|
||||||
|
self.assertIn('runtime_answer', CONF)
|
||||||
|
self.assertEqual(CONF.runtime_answer, 54)
|
||||||
|
|
||||||
|
def test_long_vs_short_flags(self):
|
||||||
|
CONF.clear()
|
||||||
|
CONF.register_cli_opt(cfg.StrOpt('duplicate_answer_long',
|
||||||
|
default='val',
|
||||||
|
help='desc'))
|
||||||
|
CONF.register_cli_opt(cfg.IntOpt('duplicate_answer',
|
||||||
|
default=50,
|
||||||
|
help='desc'))
|
||||||
|
|
||||||
|
argv = ['--duplicate_answer=60']
|
||||||
|
CONF(argv, default_config_files=[])
|
||||||
|
self.assertEqual(CONF.duplicate_answer, 60)
|
||||||
|
self.assertEqual(CONF.duplicate_answer_long, 'val')
|
||||||
|
|
||||||
|
def test_flag_leak_left(self):
|
||||||
|
self.assertEqual(CONF.conf_unittest, 'foo')
|
||||||
|
self.flags(conf_unittest='bar')
|
||||||
|
self.assertEqual(CONF.conf_unittest, 'bar')
|
||||||
|
|
||||||
|
def test_flag_leak_right(self):
|
||||||
|
self.assertEqual(CONF.conf_unittest, 'foo')
|
||||||
|
self.flags(conf_unittest='bar')
|
||||||
|
self.assertEqual(CONF.conf_unittest, 'bar')
|
||||||
|
|
||||||
|
def test_flag_overrides(self):
|
||||||
|
self.assertEqual(CONF.conf_unittest, 'foo')
|
||||||
|
self.flags(conf_unittest='bar')
|
||||||
|
self.assertEqual(CONF.conf_unittest, 'bar')
|
||||||
|
CONF.reset()
|
||||||
|
self.assertEqual(CONF.conf_unittest, 'foo')
|
@ -1,83 +0,0 @@
|
|||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
|
|
||||||
# Copyright 2010 United States Government as represented by the
|
|
||||||
# Administrator of the National Aeronautics and Space Administration.
|
|
||||||
# All Rights Reserved.
|
|
||||||
# Copyright 2011 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
from manila import test
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
|
||||||
FLAGS.register_opt(cfg.StrOpt('flags_unittest',
|
|
||||||
default='foo',
|
|
||||||
help='for testing purposes only'))
|
|
||||||
|
|
||||||
|
|
||||||
class FlagsTestCase(test.TestCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(FlagsTestCase, self).setUp()
|
|
||||||
|
|
||||||
def test_declare(self):
|
|
||||||
self.assert_('answer' not in FLAGS)
|
|
||||||
flags.DECLARE('answer', 'manila.tests.declare_flags')
|
|
||||||
self.assert_('answer' in FLAGS)
|
|
||||||
self.assertEqual(FLAGS.answer, 42)
|
|
||||||
|
|
||||||
# Make sure we don't overwrite anything
|
|
||||||
FLAGS.set_override('answer', 256)
|
|
||||||
self.assertEqual(FLAGS.answer, 256)
|
|
||||||
flags.DECLARE('answer', 'manila.tests.declare_flags')
|
|
||||||
self.assertEqual(FLAGS.answer, 256)
|
|
||||||
|
|
||||||
def test_runtime_and_unknown_flags(self):
|
|
||||||
self.assert_('runtime_answer' not in FLAGS)
|
|
||||||
import manila.tests.runtime_flags
|
|
||||||
self.assert_('runtime_answer' in FLAGS)
|
|
||||||
self.assertEqual(FLAGS.runtime_answer, 54)
|
|
||||||
|
|
||||||
def test_long_vs_short_flags(self):
|
|
||||||
FLAGS.clear()
|
|
||||||
FLAGS.register_cli_opt(cfg.StrOpt('duplicate_answer_long',
|
|
||||||
default='val',
|
|
||||||
help='desc'))
|
|
||||||
FLAGS.register_cli_opt(cfg.IntOpt('duplicate_answer',
|
|
||||||
default=50,
|
|
||||||
help='desc'))
|
|
||||||
|
|
||||||
argv = ['flags_test', '--duplicate_answer=60']
|
|
||||||
flags.parse_args(argv, default_config_files=[])
|
|
||||||
self.assertEqual(FLAGS.duplicate_answer, 60)
|
|
||||||
self.assertEqual(FLAGS.duplicate_answer_long, 'val')
|
|
||||||
|
|
||||||
def test_flag_leak_left(self):
|
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
|
||||||
self.flags(flags_unittest='bar')
|
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'bar')
|
|
||||||
|
|
||||||
def test_flag_leak_right(self):
|
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
|
||||||
self.flags(flags_unittest='bar')
|
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'bar')
|
|
||||||
|
|
||||||
def test_flag_overrides(self):
|
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
|
||||||
self.flags(flags_unittest='bar')
|
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'bar')
|
|
||||||
FLAGS.reset()
|
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
|
@ -23,14 +23,15 @@ import urllib2
|
|||||||
|
|
||||||
from manila import context
|
from manila import context
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
import manila.openstack.common.policy
|
import manila.openstack.common.policy
|
||||||
from manila.openstack.common import policy as common_policy
|
from manila.openstack.common import policy as common_policy
|
||||||
from manila import policy
|
from manila import policy
|
||||||
from manila import test
|
from manila import test
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class PolicyFileTestCase(test.TestCase):
|
class PolicyFileTestCase(test.TestCase):
|
||||||
@ -209,7 +210,7 @@ class ContextIsAdminPolicyTestCase(test.TestCase):
|
|||||||
rules = {
|
rules = {
|
||||||
'context_is_admin': [["role:administrator"], ["role:johnny-admin"]]
|
'context_is_admin': [["role:administrator"], ["role:johnny-admin"]]
|
||||||
}
|
}
|
||||||
brain = common_policy.Brain(rules, FLAGS.policy_default_rule)
|
brain = common_policy.Brain(rules, CONF.policy_default_rule)
|
||||||
common_policy.set_brain(brain)
|
common_policy.set_brain(brain)
|
||||||
ctx = context.RequestContext('fake', 'fake', roles=['johnny-admin'])
|
ctx = context.RequestContext('fake', 'fake', roles=['johnny-admin'])
|
||||||
self.assert_(ctx.is_admin)
|
self.assert_(ctx.is_admin)
|
||||||
@ -224,7 +225,7 @@ class ContextIsAdminPolicyTestCase(test.TestCase):
|
|||||||
"admin_or_owner": [["role:admin"], ["project_id:%(project_id)s"]],
|
"admin_or_owner": [["role:admin"], ["project_id:%(project_id)s"]],
|
||||||
"default": [["rule:admin_or_owner"]],
|
"default": [["rule:admin_or_owner"]],
|
||||||
}
|
}
|
||||||
brain = common_policy.Brain(rules, FLAGS.policy_default_rule)
|
brain = common_policy.Brain(rules, CONF.policy_default_rule)
|
||||||
common_policy.set_brain(brain)
|
common_policy.set_brain(brain)
|
||||||
ctx = context.RequestContext('fake', 'fake')
|
ctx = context.RequestContext('fake', 'fake')
|
||||||
self.assertFalse(ctx.is_admin)
|
self.assertFalse(ctx.is_admin)
|
||||||
|
@ -23,16 +23,17 @@ from manila import db
|
|||||||
from manila.db.sqlalchemy import api as sqa_api
|
from manila.db.sqlalchemy import api as sqa_api
|
||||||
from manila.db.sqlalchemy import models as sqa_models
|
from manila.db.sqlalchemy import models as sqa_models
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import rpc
|
from manila.openstack.common import rpc
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
from manila import quota
|
from manila import quota
|
||||||
from manila import share
|
from manila import share
|
||||||
from manila import test
|
from manila import test
|
||||||
import manila.tests.image.fake
|
import manila.tests.image.fake
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class QuotaIntegrationTestCase(test.TestCase):
|
class QuotaIntegrationTestCase(test.TestCase):
|
||||||
@ -79,7 +80,7 @@ class QuotaIntegrationTestCase(test.TestCase):
|
|||||||
@test.skip_test("SQLAlchemy sqlite insert bug")
|
@test.skip_test("SQLAlchemy sqlite insert bug")
|
||||||
def test_too_many_shares(self):
|
def test_too_many_shares(self):
|
||||||
share_ids = []
|
share_ids = []
|
||||||
for i in range(FLAGS.quota_shares):
|
for i in range(CONF.quota_shares):
|
||||||
share_ref = self._create_share()
|
share_ref = self._create_share()
|
||||||
share_ids.append(share_ref['id'])
|
share_ids.append(share_ref['id'])
|
||||||
self.assertRaises(exception.QuotaError,
|
self.assertRaises(exception.QuotaError,
|
||||||
|
@ -26,7 +26,7 @@ from oslo.config import cfg
|
|||||||
from manila import context
|
from manila import context
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila import manager
|
from manila import manager
|
||||||
from manila import service
|
from manila import service
|
||||||
from manila import test
|
from manila import test
|
||||||
@ -43,7 +43,8 @@ test_service_opts = [
|
|||||||
default=0,
|
default=0,
|
||||||
help="Port number to bind test service to"), ]
|
help="Port number to bind test service to"), ]
|
||||||
|
|
||||||
flags.FLAGS.register_opts(test_service_opts)
|
CONF = cfg.CONF
|
||||||
|
CONF.register_opts(test_service_opts)
|
||||||
|
|
||||||
|
|
||||||
class FakeManager(manager.Manager):
|
class FakeManager(manager.Manager):
|
||||||
|
@ -29,7 +29,7 @@ import tempfile
|
|||||||
from manila import context
|
from manila import context
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.image import image_utils
|
from manila.image import image_utils
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common.notifier import api as notifier_api
|
from manila.openstack.common.notifier import api as notifier_api
|
||||||
@ -38,9 +38,10 @@ from manila.openstack.common import rpc
|
|||||||
import manila.policy
|
import manila.policy
|
||||||
from manila.share import manager
|
from manila.share import manager
|
||||||
from manila import test
|
from manila import test
|
||||||
from manila.tests import fake_flags
|
from manila.tests import conf_fixture
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class FakeShareDriver(object):
|
class FakeShareDriver(object):
|
||||||
@ -100,7 +101,7 @@ class ShareTestCase(test.TestCase):
|
|||||||
super(ShareTestCase, self).setUp()
|
super(ShareTestCase, self).setUp()
|
||||||
self.flags(connection_type='fake',
|
self.flags(connection_type='fake',
|
||||||
share_driver='manila.tests.test_share.FakeShareDriver')
|
share_driver='manila.tests.test_share.FakeShareDriver')
|
||||||
self.share = importutils.import_object(FLAGS.share_manager)
|
self.share = importutils.import_object(CONF.share_manager)
|
||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -112,9 +113,9 @@ class ShareTestCase(test.TestCase):
|
|||||||
share['snapshot_id'] = snapshot_id
|
share['snapshot_id'] = snapshot_id
|
||||||
share['user_id'] = 'fake'
|
share['user_id'] = 'fake'
|
||||||
share['project_id'] = 'fake'
|
share['project_id'] = 'fake'
|
||||||
share['availability_zone'] = FLAGS.storage_availability_zone
|
share['availability_zone'] = CONF.storage_availability_zone
|
||||||
share['status'] = status
|
share['status'] = status
|
||||||
share['host'] = FLAGS.host
|
share['host'] = CONF.host
|
||||||
return db.share_create(context.get_admin_context(), share)
|
return db.share_create(context.get_admin_context(), share)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -21,7 +21,7 @@ import os
|
|||||||
from manila import context
|
from manila import context
|
||||||
from manila.db.sqlalchemy import models
|
from manila.db.sqlalchemy import models
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila.share.configuration import Configuration
|
from manila.share.configuration import Configuration
|
||||||
@ -29,9 +29,10 @@ from manila.share.drivers import lvm
|
|||||||
from manila import test
|
from manila import test
|
||||||
from manila.tests.db import fakes as db_fakes
|
from manila.tests.db import fakes as db_fakes
|
||||||
from manila.tests import fake_utils
|
from manila.tests import fake_utils
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
def fake_share(**kwargs):
|
def fake_share(**kwargs):
|
||||||
@ -80,8 +81,8 @@ class LVMShareDriverTestCase(test.TestCase):
|
|||||||
self._execute = fake_utils.fake_execute
|
self._execute = fake_utils.fake_execute
|
||||||
self._context = context.get_admin_context()
|
self._context = context.get_admin_context()
|
||||||
|
|
||||||
FLAGS.set_default('share_volume_group', 'fakevg')
|
CONF.set_default('share_volume_group', 'fakevg')
|
||||||
FLAGS.set_default('share_export_ip', '10.0.0.1')
|
CONF.set_default('share_export_ip', '10.0.0.1')
|
||||||
|
|
||||||
self._helper_cifs = self.mox.CreateMock(lvm.CIFSNetConfHelper)
|
self._helper_cifs = self.mox.CreateMock(lvm.CIFSNetConfHelper)
|
||||||
self._helper_nfs = self.mox.CreateMock(lvm.NFSHelper)
|
self._helper_nfs = self.mox.CreateMock(lvm.NFSHelper)
|
||||||
@ -152,27 +153,27 @@ class LVMShareDriverTestCase(test.TestCase):
|
|||||||
|
|
||||||
fake_utils.fake_execute_set_repliers([('vgs --noheadings -o name',
|
fake_utils.fake_execute_set_repliers([('vgs --noheadings -o name',
|
||||||
exec_runner)])
|
exec_runner)])
|
||||||
FLAGS.set_default('share_export_ip', None)
|
CONF.set_default('share_export_ip', None)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
self.assertRaises(exception.InvalidParameterValue,
|
self.assertRaises(exception.InvalidParameterValue,
|
||||||
self._driver.check_for_setup_error)
|
self._driver.check_for_setup_error)
|
||||||
|
|
||||||
def test_local_path_normal(self):
|
def test_local_path_normal(self):
|
||||||
share = fake_share(name='fake_sharename')
|
share = fake_share(name='fake_sharename')
|
||||||
FLAGS.set_default('share_volume_group', 'fake_vg')
|
CONF.set_default('share_volume_group', 'fake_vg')
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
ret = self._driver._local_path(share)
|
ret = self._driver._local_path(share)
|
||||||
self.assertEqual(ret, '/dev/mapper/fake_vg-fake_sharename')
|
self.assertEqual(ret, '/dev/mapper/fake_vg-fake_sharename')
|
||||||
|
|
||||||
def test_local_path_escapes(self):
|
def test_local_path_escapes(self):
|
||||||
share = fake_share(name='fake-sharename')
|
share = fake_share(name='fake-sharename')
|
||||||
FLAGS.set_default('share_volume_group', 'fake-vg')
|
CONF.set_default('share_volume_group', 'fake-vg')
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
ret = self._driver._local_path(share)
|
ret = self._driver._local_path(share)
|
||||||
self.assertEqual(ret, '/dev/mapper/fake--vg-fake--sharename')
|
self.assertEqual(ret, '/dev/mapper/fake--vg-fake--sharename')
|
||||||
|
|
||||||
def test_allocate_container_normal(self):
|
def test_allocate_container_normal(self):
|
||||||
FLAGS.set_default('share_lvm_mirrors', 0)
|
CONF.set_default('share_lvm_mirrors', 0)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
ret = self._driver.allocate_container(self._context, self.share)
|
ret = self._driver.allocate_container(self._context, self.share)
|
||||||
expected_exec = [
|
expected_exec = [
|
||||||
@ -182,7 +183,7 @@ class LVMShareDriverTestCase(test.TestCase):
|
|||||||
self.assertEqual(fake_utils.fake_execute_get_log(), expected_exec)
|
self.assertEqual(fake_utils.fake_execute_get_log(), expected_exec)
|
||||||
|
|
||||||
def test_allocate_container_from_snapshot(self):
|
def test_allocate_container_from_snapshot(self):
|
||||||
FLAGS.set_default('share_lvm_mirrors', 0)
|
CONF.set_default('share_lvm_mirrors', 0)
|
||||||
mount_share = '/dev/mapper/fakevg-fakename'
|
mount_share = '/dev/mapper/fakevg-fakename'
|
||||||
mount_snapshot = '/dev/mapper/fakevg-fakesnapshotname'
|
mount_snapshot = '/dev/mapper/fakevg-fakesnapshotname'
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
@ -202,7 +203,7 @@ class LVMShareDriverTestCase(test.TestCase):
|
|||||||
def exec_runner(*ignore_args, **ignore_kwargs):
|
def exec_runner(*ignore_args, **ignore_kwargs):
|
||||||
raise exception.ProcessExecutionError()
|
raise exception.ProcessExecutionError()
|
||||||
|
|
||||||
FLAGS.set_default('share_lvm_mirrors', 0)
|
CONF.set_default('share_lvm_mirrors', 0)
|
||||||
mount_share = '/dev/mapper/fakevg-fakename'
|
mount_share = '/dev/mapper/fakevg-fakename'
|
||||||
mount_snapshot = '/dev/mapper/fakevg-fakesnapshotname'
|
mount_snapshot = '/dev/mapper/fakevg-fakesnapshotname'
|
||||||
expected_exec = [
|
expected_exec = [
|
||||||
@ -220,7 +221,7 @@ class LVMShareDriverTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_allocate_container_mirrors(self):
|
def test_allocate_container_mirrors(self):
|
||||||
share = fake_share(size='2048')
|
share = fake_share(size='2048')
|
||||||
FLAGS.set_default('share_lvm_mirrors', 2)
|
CONF.set_default('share_lvm_mirrors', 2)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
ret = self._driver.allocate_container(self._context, share)
|
ret = self._driver.allocate_container(self._context, share)
|
||||||
expected_exec = [
|
expected_exec = [
|
||||||
@ -243,7 +244,7 @@ class LVMShareDriverTestCase(test.TestCase):
|
|||||||
'vgs --noheadings --nosuffix --unit=G -o name,size,free fakevg',
|
'vgs --noheadings --nosuffix --unit=G -o name,size,free fakevg',
|
||||||
]
|
]
|
||||||
fake_utils.fake_execute_set_repliers([(expected_exec[0], exec_runner)])
|
fake_utils.fake_execute_set_repliers([(expected_exec[0], exec_runner)])
|
||||||
FLAGS.set_default('reserved_share_percentage', 1)
|
CONF.set_default('reserved_share_percentage', 1)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
ret = self._driver.get_share_stats(refresh=True)
|
ret = self._driver.get_share_stats(refresh=True)
|
||||||
expected_ret = {
|
expected_ret = {
|
||||||
@ -267,7 +268,7 @@ class LVMShareDriverTestCase(test.TestCase):
|
|||||||
'vgs --noheadings --nosuffix --unit=G -o name,size,free fakevg',
|
'vgs --noheadings --nosuffix --unit=G -o name,size,free fakevg',
|
||||||
]
|
]
|
||||||
fake_utils.fake_execute_set_repliers([(expected_exec[0], exec_runner)])
|
fake_utils.fake_execute_set_repliers([(expected_exec[0], exec_runner)])
|
||||||
FLAGS.set_default('reserved_share_percentage', 1)
|
CONF.set_default('reserved_share_percentage', 1)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
ret = self._driver.get_share_stats(refresh=True)
|
ret = self._driver.get_share_stats(refresh=True)
|
||||||
expected_ret = {
|
expected_ret = {
|
||||||
@ -354,7 +355,7 @@ class LVMShareDriverTestCase(test.TestCase):
|
|||||||
self._driver.create_snapshot(self._context, self.snapshot)
|
self._driver.create_snapshot(self._context, self.snapshot)
|
||||||
expected_exec = [
|
expected_exec = [
|
||||||
("lvcreate -L 1G --name fakesnapshotname --snapshot %s/fakename" %
|
("lvcreate -L 1G --name fakesnapshotname --snapshot %s/fakename" %
|
||||||
(FLAGS.share_volume_group,)),
|
(CONF.share_volume_group,)),
|
||||||
]
|
]
|
||||||
self.assertEqual(fake_utils.fake_execute_get_log(), expected_exec)
|
self.assertEqual(fake_utils.fake_execute_get_log(), expected_exec)
|
||||||
|
|
||||||
@ -466,7 +467,7 @@ class LVMShareDriverTestCase(test.TestCase):
|
|||||||
fake_share(share_proto='FAKE'))
|
fake_share(share_proto='FAKE'))
|
||||||
|
|
||||||
def _get_mount_path(self, share):
|
def _get_mount_path(self, share):
|
||||||
return os.path.join(FLAGS.share_export_root, share['name'])
|
return os.path.join(CONF.share_export_root, share['name'])
|
||||||
|
|
||||||
|
|
||||||
class NFSHelperTestCase(test.TestCase):
|
class NFSHelperTestCase(test.TestCase):
|
||||||
@ -475,7 +476,7 @@ class NFSHelperTestCase(test.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(NFSHelperTestCase, self).setUp()
|
super(NFSHelperTestCase, self).setUp()
|
||||||
fake_utils.stub_out_utils_execute(self.stubs)
|
fake_utils.stub_out_utils_execute(self.stubs)
|
||||||
FLAGS.set_default('share_export_ip', '127.0.0.1')
|
CONF.set_default('share_export_ip', '127.0.0.1')
|
||||||
self._execute = fake_utils.fake_execute
|
self._execute = fake_utils.fake_execute
|
||||||
self.fake_conf = Configuration(None)
|
self.fake_conf = Configuration(None)
|
||||||
self._helper = lvm.NFSHelper(self._execute, self.fake_conf)
|
self._helper = lvm.NFSHelper(self._execute, self.fake_conf)
|
||||||
@ -497,7 +498,7 @@ class NFSHelperTestCase(test.TestCase):
|
|||||||
def test_create_export(self):
|
def test_create_export(self):
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
ret = self._helper.create_export('/opt/nfs', 'volume-00001')
|
ret = self._helper.create_export('/opt/nfs', 'volume-00001')
|
||||||
expected_location = '%s:/opt/nfs' % FLAGS.share_export_ip
|
expected_location = '%s:/opt/nfs' % CONF.share_export_ip
|
||||||
self.assertEqual(ret, expected_location)
|
self.assertEqual(ret, expected_location)
|
||||||
|
|
||||||
def test_remove_export(self):
|
def test_remove_export(self):
|
||||||
@ -545,7 +546,7 @@ class CIFSNetConfHelperTestCase(test.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CIFSNetConfHelperTestCase, self).setUp()
|
super(CIFSNetConfHelperTestCase, self).setUp()
|
||||||
fake_utils.stub_out_utils_execute(self.stubs)
|
fake_utils.stub_out_utils_execute(self.stubs)
|
||||||
FLAGS.set_default('share_export_ip', '127.0.0.1')
|
CONF.set_default('share_export_ip', '127.0.0.1')
|
||||||
self.share = fake_share()
|
self.share = fake_share()
|
||||||
self._execute = fake_utils.fake_execute
|
self._execute = fake_utils.fake_execute
|
||||||
self.fake_conf = Configuration(None)
|
self.fake_conf = Configuration(None)
|
||||||
|
@ -680,11 +680,11 @@ class NetAppApiClientTestCase(test.TestCase):
|
|||||||
def test_successfull_setup(self):
|
def test_successfull_setup(self):
|
||||||
drv = self._driver
|
drv = self._driver
|
||||||
for flag in drv.REQUIRED_FLAGS:
|
for flag in drv.REQUIRED_FLAGS:
|
||||||
setattr(netapp.FLAGS, flag, 'val')
|
setattr(netapp.CONF, flag, 'val')
|
||||||
conf_obj = Configuration(netapp.FLAGS)
|
conf_obj = Configuration(netapp.CONF)
|
||||||
drv.check_configuration(conf_obj)
|
drv.check_configuration(conf_obj)
|
||||||
|
|
||||||
def test_failing_setup(self):
|
def test_failing_setup(self):
|
||||||
drv = self._driver
|
drv = self._driver
|
||||||
self.assertRaises(exception.Error, drv.check_configuration,
|
self.assertRaises(exception.Error, drv.check_configuration,
|
||||||
Configuration(netapp.FLAGS))
|
Configuration(netapp.CONF))
|
||||||
|
@ -21,14 +21,15 @@ Unit Tests for manila.volume.rpcapi.
|
|||||||
|
|
||||||
from manila import context
|
from manila import context
|
||||||
from manila import db
|
from manila import db
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import jsonutils
|
from manila.openstack.common import jsonutils
|
||||||
from manila.openstack.common import rpc
|
from manila.openstack.common import rpc
|
||||||
from manila.share import rpcapi as share_rpcapi
|
from manila.share import rpcapi as share_rpcapi
|
||||||
from manila import test
|
from manila import test
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class ShareRpcAPITestCase(test.TestCase):
|
class ShareRpcAPITestCase(test.TestCase):
|
||||||
@ -37,7 +38,7 @@ class ShareRpcAPITestCase(test.TestCase):
|
|||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
shr = {}
|
shr = {}
|
||||||
shr['host'] = 'fake_host'
|
shr['host'] = 'fake_host'
|
||||||
shr['availability_zone'] = FLAGS.storage_availability_zone
|
shr['availability_zone'] = CONF.storage_availability_zone
|
||||||
shr['status'] = "available"
|
shr['status'] = "available"
|
||||||
share = db.share_create(self.context, shr)
|
share = db.share_create(self.context, shr)
|
||||||
acs = {}
|
acs = {}
|
||||||
@ -91,7 +92,7 @@ class ShareRpcAPITestCase(test.TestCase):
|
|||||||
host = kwargs['host']
|
host = kwargs['host']
|
||||||
else:
|
else:
|
||||||
host = kwargs['share']['host']
|
host = kwargs['share']['host']
|
||||||
expected_topic = '%s.%s' % (FLAGS.share_topic, host)
|
expected_topic = '%s.%s' % (CONF.share_topic, host)
|
||||||
|
|
||||||
self.fake_args = None
|
self.fake_args = None
|
||||||
self.fake_kwargs = None
|
self.fake_kwargs = None
|
||||||
|
@ -28,14 +28,15 @@ import mox
|
|||||||
|
|
||||||
import manila
|
import manila
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import strutils
|
from manila.openstack.common import strutils
|
||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
from manila import test
|
from manila import test
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class ExecuteTestCase(test.TestCase):
|
class ExecuteTestCase(test.TestCase):
|
||||||
@ -302,7 +303,7 @@ class GenericUtilsTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_generate_glance_url(self):
|
def test_generate_glance_url(self):
|
||||||
generated_url = utils.generate_glance_url()
|
generated_url = utils.generate_glance_url()
|
||||||
actual_url = "http://%s:%d" % (FLAGS.glance_host, FLAGS.glance_port)
|
actual_url = "http://%s:%d" % (CONF.glance_host, CONF.glance_port)
|
||||||
self.assertEqual(generated_url, actual_url)
|
self.assertEqual(generated_url, actual_url)
|
||||||
|
|
||||||
def test_read_cached_file(self):
|
def test_read_cached_file(self):
|
||||||
|
@ -19,8 +19,6 @@ import os
|
|||||||
|
|
||||||
import manila.context
|
import manila.context
|
||||||
|
|
||||||
FLAGS = manila.flags.FLAGS
|
|
||||||
|
|
||||||
|
|
||||||
def get_test_admin_context():
|
def get_test_admin_context():
|
||||||
return manila.context.get_admin_context()
|
return manila.context.get_admin_context()
|
||||||
|
@ -21,13 +21,12 @@ Windows storage classes to be used in testing.
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from manila import flags
|
|
||||||
|
|
||||||
# Check needed for unit testing on Unix
|
# Check needed for unit testing on Unix
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
import wmi
|
import wmi
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class WindowsUtils(object):
|
class WindowsUtils(object):
|
||||||
@ -89,7 +88,7 @@ class WindowsUtils(object):
|
|||||||
def _get_vhd_path(self, volume_name):
|
def _get_vhd_path(self, volume_name):
|
||||||
'''Gets the path disk of the volume.'''
|
'''Gets the path disk of the volume.'''
|
||||||
|
|
||||||
base_vhd_folder = FLAGS.windows_iscsi_lun_path
|
base_vhd_folder = CONF.windows_iscsi_lun_path
|
||||||
return os.path.join(base_vhd_folder, volume_name + ".vhd")
|
return os.path.join(base_vhd_folder, volume_name + ".vhd")
|
||||||
|
|
||||||
def delete_snapshot(self, name):
|
def delete_snapshot(self, name):
|
||||||
|
@ -51,9 +51,10 @@ from eventlet import event
|
|||||||
from eventlet.green import subprocess
|
from eventlet.green import subprocess
|
||||||
from eventlet import greenthread
|
from eventlet import greenthread
|
||||||
from eventlet import pools
|
from eventlet import pools
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import excutils
|
from manila.openstack.common import excutils
|
||||||
from manila.openstack.common import importutils
|
from manila.openstack.common import importutils
|
||||||
from manila.openstack.common import lockutils
|
from manila.openstack.common import lockutils
|
||||||
@ -61,10 +62,10 @@ from manila.openstack.common import log as logging
|
|||||||
from manila.openstack.common import timeutils
|
from manila.openstack.common import timeutils
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
|
ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
|
||||||
PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
|
PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
|
||||||
FLAGS = flags.FLAGS
|
|
||||||
|
|
||||||
synchronized = lockutils.synchronized_with_prefix('manila-')
|
synchronized = lockutils.synchronized_with_prefix('manila-')
|
||||||
|
|
||||||
@ -79,9 +80,9 @@ def find_config(config_path):
|
|||||||
"""
|
"""
|
||||||
possible_locations = [
|
possible_locations = [
|
||||||
config_path,
|
config_path,
|
||||||
os.path.join(FLAGS.state_path, "etc", "manila", config_path),
|
os.path.join(CONF.state_path, "etc", "manila", config_path),
|
||||||
os.path.join(FLAGS.state_path, "etc", config_path),
|
os.path.join(CONF.state_path, "etc", config_path),
|
||||||
os.path.join(FLAGS.state_path, config_path),
|
os.path.join(CONF.state_path, config_path),
|
||||||
"/etc/manila/%s" % config_path,
|
"/etc/manila/%s" % config_path,
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -149,18 +150,18 @@ def execute(*cmd, **kwargs):
|
|||||||
|
|
||||||
if run_as_root:
|
if run_as_root:
|
||||||
|
|
||||||
if FLAGS.rootwrap_config is None or FLAGS.root_helper != 'sudo':
|
if CONF.rootwrap_config is None or CONF.root_helper != 'sudo':
|
||||||
LOG.deprecated(_('The root_helper option (which lets you specify '
|
LOG.deprecated(_('The root_helper option (which lets you specify '
|
||||||
'a root wrapper different from manila-rootwrap, '
|
'a root wrapper different from manila-rootwrap, '
|
||||||
'and defaults to using sudo) is now deprecated. '
|
'and defaults to using sudo) is now deprecated. '
|
||||||
'You should use the rootwrap_config option '
|
'You should use the rootwrap_config option '
|
||||||
'instead.'))
|
'instead.'))
|
||||||
|
|
||||||
if (FLAGS.rootwrap_config is not None):
|
if (CONF.rootwrap_config is not None):
|
||||||
cmd = ['sudo', 'manila-rootwrap',
|
cmd = ['sudo', 'manila-rootwrap',
|
||||||
FLAGS.rootwrap_config] + list(cmd)
|
CONF.rootwrap_config] + list(cmd)
|
||||||
else:
|
else:
|
||||||
cmd = shlex.split(FLAGS.root_helper) + list(cmd)
|
cmd = shlex.split(CONF.root_helper) + list(cmd)
|
||||||
cmd = map(str, cmd)
|
cmd = map(str, cmd)
|
||||||
|
|
||||||
while attempts > 0:
|
while attempts > 0:
|
||||||
@ -410,7 +411,7 @@ def last_completed_audit_period(unit=None):
|
|||||||
The begin timestamp of this audit period is the same as the
|
The begin timestamp of this audit period is the same as the
|
||||||
end of the previous."""
|
end of the previous."""
|
||||||
if not unit:
|
if not unit:
|
||||||
unit = FLAGS.volume_usage_audit_period
|
unit = CONF.volume_usage_audit_period
|
||||||
|
|
||||||
offset = 0
|
offset = 0
|
||||||
if '@' in unit:
|
if '@' in unit:
|
||||||
@ -564,7 +565,7 @@ class LazyPluggable(object):
|
|||||||
|
|
||||||
def __get_backend(self):
|
def __get_backend(self):
|
||||||
if not self.__backend:
|
if not self.__backend:
|
||||||
backend_name = FLAGS[self.__pivot]
|
backend_name = CONF[self.__pivot]
|
||||||
if backend_name not in self.__backends:
|
if backend_name not in self.__backends:
|
||||||
raise exception.Error(_('Invalid backend: %s') % backend_name)
|
raise exception.Error(_('Invalid backend: %s') % backend_name)
|
||||||
|
|
||||||
@ -845,7 +846,7 @@ def monkey_patch():
|
|||||||
this function patches a decorator
|
this function patches a decorator
|
||||||
for all functions in specified modules.
|
for all functions in specified modules.
|
||||||
You can set decorators for each modules
|
You can set decorators for each modules
|
||||||
using FLAGS.monkey_patch_modules.
|
using CONF.monkey_patch_modules.
|
||||||
The format is "Module path:Decorator function".
|
The format is "Module path:Decorator function".
|
||||||
Example: 'manila.api.ec2.cloud:' \
|
Example: 'manila.api.ec2.cloud:' \
|
||||||
manila.openstack.common.notifier.api.notify_decorator'
|
manila.openstack.common.notifier.api.notify_decorator'
|
||||||
@ -856,11 +857,11 @@ def monkey_patch():
|
|||||||
name - name of the function
|
name - name of the function
|
||||||
function - object of the function
|
function - object of the function
|
||||||
"""
|
"""
|
||||||
# If FLAGS.monkey_patch is not True, this function do nothing.
|
# If CONF.monkey_patch is not True, this function do nothing.
|
||||||
if not FLAGS.monkey_patch:
|
if not CONF.monkey_patch:
|
||||||
return
|
return
|
||||||
# Get list of modules and decorators
|
# Get list of modules and decorators
|
||||||
for module_and_decorator in FLAGS.monkey_patch_modules:
|
for module_and_decorator in CONF.monkey_patch_modules:
|
||||||
module, decorator_name = module_and_decorator.split(':')
|
module, decorator_name = module_and_decorator.split(':')
|
||||||
# import decorator function
|
# import decorator function
|
||||||
decorator = importutils.import_class(decorator_name)
|
decorator = importutils.import_class(decorator_name)
|
||||||
@ -909,7 +910,7 @@ def generate_glance_url():
|
|||||||
"""Generate the URL to glance."""
|
"""Generate the URL to glance."""
|
||||||
# TODO(jk0): This will eventually need to take SSL into consideration
|
# TODO(jk0): This will eventually need to take SSL into consideration
|
||||||
# when supported in glance.
|
# when supported in glance.
|
||||||
return "http://%s:%d" % (FLAGS.glance_host, FLAGS.glance_port)
|
return "http://%s:%d" % (CONF.glance_host, CONF.glance_port)
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
@ -1046,7 +1047,7 @@ def service_is_up(service):
|
|||||||
last_heartbeat = service['updated_at'] or service['created_at']
|
last_heartbeat = service['updated_at'] or service['created_at']
|
||||||
# Timestamps in DB are UTC.
|
# Timestamps in DB are UTC.
|
||||||
elapsed = total_seconds(timeutils.utcnow() - last_heartbeat)
|
elapsed = total_seconds(timeutils.utcnow() - last_heartbeat)
|
||||||
return abs(elapsed) <= FLAGS.service_down_time
|
return abs(elapsed) <= CONF.service_down_time
|
||||||
|
|
||||||
|
|
||||||
def generate_mac_address():
|
def generate_mac_address():
|
||||||
|
@ -36,7 +36,7 @@ import webob.dec
|
|||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila import flags
|
|
||||||
from manila.openstack.common import log as logging
|
from manila.openstack.common import log as logging
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ socket_opts = [
|
|||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
CONF.register_opts(socket_opts)
|
CONF.register_opts(socket_opts)
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ class Loader(object):
|
|||||||
:returns: None
|
:returns: None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
config_path = config_path or FLAGS.api_paste_config
|
config_path = config_path or CONF.api_paste_config
|
||||||
self.config_path = utils.find_config(config_path)
|
self.config_path = utils.find_config(config_path)
|
||||||
|
|
||||||
def load_app(self, name):
|
def load_app(self, name):
|
||||||
|
Loading…
Reference in New Issue
Block a user