Use pbr entry_points to setup the cinder scripts
The following patch changes how cinder scripts are installed and unit tested. This patch moves all the cinder scripts from bin into cinder/cmd and creates entry_points for those scripts in setup.cfg. When cinder is installed, these scripts will be installed under /usr/local/bin by pbr. DocImpact: 'host' config option for multiple-storage backends in cinder.conf is renamed to 'backend_host' in order to avoid a naming conflict with the 'host' to locate redis Change-Id: If82cf0c58d765bf79dbf721ca95c10a468940cab Implements: blueprint unit-test-cases-for-cinder-scripts
This commit is contained in:
parent
83bc931790
commit
5fb266a0da
0
cinder/cmd/__init__.py
Normal file
0
cinder/cmd/__init__.py
Normal file
@ -25,12 +25,9 @@ continue attempting to launch the rest of the services.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
|
|
||||||
eventlet.monkey_patch()
|
eventlet.monkey_patch()
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@ -38,12 +35,6 @@ warnings.simplefilter('once', DeprecationWarning)
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
|
||||||
os.pardir,
|
|
||||||
os.pardir))
|
|
||||||
if os.path.exists(os.path.join(possible_topdir, "cinder", "__init__.py")):
|
|
||||||
sys.path.insert(0, possible_topdir)
|
|
||||||
|
|
||||||
from cinder import i18n
|
from cinder import i18n
|
||||||
i18n.enable_lazy()
|
i18n.enable_lazy()
|
||||||
|
|
||||||
@ -59,7 +50,7 @@ from cinder import version
|
|||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
CONF(sys.argv[1:], project='cinder',
|
CONF(sys.argv[1:], project='cinder',
|
||||||
version=version.version_string())
|
version=version.version_string())
|
||||||
logging.setup("cinder")
|
logging.setup("cinder")
|
@ -20,7 +20,6 @@
|
|||||||
import eventlet
|
import eventlet
|
||||||
eventlet.monkey_patch()
|
eventlet.monkey_patch()
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@ -28,12 +27,6 @@ warnings.simplefilter('once', DeprecationWarning)
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
|
||||||
os.pardir,
|
|
||||||
os.pardir))
|
|
||||||
if os.path.exists(os.path.join(possible_topdir, "cinder", "__init__.py")):
|
|
||||||
sys.path.insert(0, possible_topdir)
|
|
||||||
|
|
||||||
from cinder import i18n
|
from cinder import i18n
|
||||||
i18n.enable_lazy()
|
i18n.enable_lazy()
|
||||||
|
|
||||||
@ -49,7 +42,7 @@ from cinder import version
|
|||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
CONF(sys.argv[1:], project='cinder',
|
CONF(sys.argv[1:], project='cinder',
|
||||||
version=version.version_string())
|
version=version.version_string())
|
||||||
logging.setup("cinder")
|
logging.setup("cinder")
|
@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
"""Starter script for Cinder Volume Backup."""
|
"""Starter script for Cinder Volume Backup."""
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@ -29,14 +27,6 @@ from oslo.config import cfg
|
|||||||
|
|
||||||
eventlet.monkey_patch()
|
eventlet.monkey_patch()
|
||||||
|
|
||||||
# If ../cinder/__init__.py exists, add ../ to Python search path, so that
|
|
||||||
# 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]),
|
|
||||||
os.pardir,
|
|
||||||
os.pardir))
|
|
||||||
if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')):
|
|
||||||
sys.path.insert(0, possible_topdir)
|
|
||||||
|
|
||||||
from cinder import i18n
|
from cinder import i18n
|
||||||
i18n.enable_lazy()
|
i18n.enable_lazy()
|
||||||
|
|
||||||
@ -51,7 +41,7 @@ from cinder import version
|
|||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
CONF(sys.argv[1:], project='cinder',
|
CONF(sys.argv[1:], project='cinder',
|
||||||
version=version.version_string())
|
version=version.version_string())
|
||||||
logging.setup("cinder")
|
logging.setup("cinder")
|
@ -64,14 +64,6 @@ warnings.simplefilter('once', DeprecationWarning)
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from oslo import messaging
|
from oslo import messaging
|
||||||
|
|
||||||
# If ../cinder/__init__.py exists, add ../ to Python search path, so that
|
|
||||||
# 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]),
|
|
||||||
os.pardir,
|
|
||||||
os.pardir))
|
|
||||||
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')):
|
|
||||||
sys.path.insert(0, POSSIBLE_TOPDIR)
|
|
||||||
|
|
||||||
from cinder import i18n
|
from cinder import i18n
|
||||||
i18n.enable_lazy()
|
i18n.enable_lazy()
|
||||||
|
|
||||||
@ -546,6 +538,3 @@ def main():
|
|||||||
fn = CONF.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)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
@ -231,6 +231,3 @@ def main(argv=None):
|
|||||||
usage()
|
usage()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.exit(main())
|
|
@ -17,12 +17,9 @@
|
|||||||
|
|
||||||
"""Starter script for Cinder Scheduler."""
|
"""Starter script for Cinder Scheduler."""
|
||||||
|
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
|
|
||||||
eventlet.monkey_patch()
|
eventlet.monkey_patch()
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@ -30,14 +27,6 @@ warnings.simplefilter('once', DeprecationWarning)
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
# If ../cinder/__init__.py exists, add ../ to Python search path, so that
|
|
||||||
# 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]),
|
|
||||||
os.pardir,
|
|
||||||
os.pardir))
|
|
||||||
if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')):
|
|
||||||
sys.path.insert(0, possible_topdir)
|
|
||||||
|
|
||||||
from cinder import i18n
|
from cinder import i18n
|
||||||
i18n.enable_lazy()
|
i18n.enable_lazy()
|
||||||
|
|
||||||
@ -52,7 +41,7 @@ from cinder import version
|
|||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
CONF(sys.argv[1:], project='cinder',
|
CONF(sys.argv[1:], project='cinder',
|
||||||
version=version.version_string())
|
version=version.version_string())
|
||||||
logging.setup("cinder")
|
logging.setup("cinder")
|
@ -35,14 +35,6 @@ warnings.simplefilter('once', DeprecationWarning)
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
# If ../cinder/__init__.py exists, add ../ to Python search path, so that
|
|
||||||
# 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]),
|
|
||||||
os.pardir,
|
|
||||||
os.pardir))
|
|
||||||
if os.path.exists(os.path.join(possible_topdir, 'cinder', '__init__.py')):
|
|
||||||
sys.path.insert(0, possible_topdir)
|
|
||||||
|
|
||||||
from cinder import i18n
|
from cinder import i18n
|
||||||
i18n.enable_lazy()
|
i18n.enable_lazy()
|
||||||
|
|
||||||
@ -54,12 +46,14 @@ from cinder import utils
|
|||||||
from cinder import version
|
from cinder import version
|
||||||
|
|
||||||
|
|
||||||
host_opt = cfg.StrOpt('host',
|
deprecated_host_opt = cfg.DeprecatedOpt('host')
|
||||||
help='Backend override of host value.')
|
host_opt = cfg.StrOpt('backend_host', help='Backend override of host value.',
|
||||||
|
deprecated_opts=[deprecated_host_opt])
|
||||||
|
cfg.CONF.register_cli_opt(host_opt)
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
CONF(sys.argv[1:], project='cinder',
|
CONF(sys.argv[1:], project='cinder',
|
||||||
version=version.version_string())
|
version=version.version_string())
|
||||||
logging.setup("cinder")
|
logging.setup("cinder")
|
||||||
@ -67,8 +61,8 @@ if __name__ == '__main__':
|
|||||||
launcher = service.get_launcher()
|
launcher = service.get_launcher()
|
||||||
if CONF.enabled_backends:
|
if CONF.enabled_backends:
|
||||||
for backend in CONF.enabled_backends:
|
for backend in CONF.enabled_backends:
|
||||||
CONF.register_opts([host_opt], group=backend)
|
CONF.register_opt(host_opt, group=backend)
|
||||||
backend_host = getattr(CONF, backend).host
|
backend_host = getattr(CONF, backend).backend_host
|
||||||
host = "%s@%s" % (backend_host or CONF.host, backend)
|
host = "%s@%s" % (backend_host or CONF.host, backend)
|
||||||
server = service.Service.create(host=host,
|
server = service.Service.create(host=host,
|
||||||
service_name=backend,
|
service_name=backend,
|
@ -35,7 +35,6 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import warnings
|
import warnings
|
||||||
@ -44,14 +43,6 @@ warnings.simplefilter('once', DeprecationWarning)
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
# If ../cinder/__init__.py exists, add ../ to Python search path, so that
|
|
||||||
# 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]),
|
|
||||||
os.pardir,
|
|
||||||
os.pardir))
|
|
||||||
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')):
|
|
||||||
sys.path.insert(0, POSSIBLE_TOPDIR)
|
|
||||||
|
|
||||||
from cinder import i18n
|
from cinder import i18n
|
||||||
i18n.enable_lazy()
|
i18n.enable_lazy()
|
||||||
from cinder import context
|
from cinder import context
|
||||||
@ -84,7 +75,7 @@ script_opts = [
|
|||||||
CONF.register_cli_opts(script_opts)
|
CONF.register_cli_opts(script_opts)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
admin_context = context.get_admin_context()
|
admin_context = context.get_admin_context()
|
||||||
CONF(sys.argv[1:], project='cinder',
|
CONF(sys.argv[1:], project='cinder',
|
||||||
version=version.version_string())
|
version=version.version_string())
|
@ -32,6 +32,7 @@ import mox
|
|||||||
from oslo.concurrency import lockutils
|
from oslo.concurrency import lockutils
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from oslo.config import fixture as config_fixture
|
from oslo.config import fixture as config_fixture
|
||||||
|
from oslo.i18n import _lazy
|
||||||
from oslo.messaging import conffixture as messaging_conffixture
|
from oslo.messaging import conffixture as messaging_conffixture
|
||||||
from oslo.utils import strutils
|
from oslo.utils import strutils
|
||||||
from oslo.utils import timeutils
|
from oslo.utils import timeutils
|
||||||
@ -112,6 +113,9 @@ class TestCase(testtools.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()
|
||||||
|
|
||||||
|
# Unit tests do not need to use lazy gettext
|
||||||
|
_lazy.enable_lazy(enable=False)
|
||||||
|
|
||||||
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
|
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
|
||||||
try:
|
try:
|
||||||
test_timeout = int(test_timeout)
|
test_timeout = int(test_timeout)
|
||||||
|
1358
cinder/tests/test_cmd.py
Executable file
1358
cinder/tests/test_cmd.py
Executable file
File diff suppressed because it is too large
Load Diff
@ -190,7 +190,7 @@ function warn_on_flake8_without_venv {
|
|||||||
function run_pep8 {
|
function run_pep8 {
|
||||||
echo "Running flake8 ..."
|
echo "Running flake8 ..."
|
||||||
warn_on_flake8_without_venv
|
warn_on_flake8_without_venv
|
||||||
bash -c "${wrapper} flake8 cinder* bin/*"
|
bash -c "${wrapper} flake8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
17
setup.cfg
17
setup.cfg
@ -24,15 +24,6 @@ setup-hooks =
|
|||||||
[files]
|
[files]
|
||||||
packages =
|
packages =
|
||||||
cinder
|
cinder
|
||||||
scripts =
|
|
||||||
bin/cinder-all
|
|
||||||
bin/cinder-api
|
|
||||||
bin/cinder-backup
|
|
||||||
bin/cinder-manage
|
|
||||||
bin/cinder-rtstool
|
|
||||||
bin/cinder-scheduler
|
|
||||||
bin/cinder-volume
|
|
||||||
bin/cinder-volume-usage-audit
|
|
||||||
|
|
||||||
[entry_points]
|
[entry_points]
|
||||||
cinder.scheduler.filters =
|
cinder.scheduler.filters =
|
||||||
@ -49,7 +40,15 @@ cinder.scheduler.weights =
|
|||||||
ChanceWeigher = cinder.scheduler.weights.chance:ChanceWeigher
|
ChanceWeigher = cinder.scheduler.weights.chance:ChanceWeigher
|
||||||
VolumeNumberWeigher = cinder.scheduler.weights.volume_number:VolumeNumberWeigher
|
VolumeNumberWeigher = cinder.scheduler.weights.volume_number:VolumeNumberWeigher
|
||||||
console_scripts =
|
console_scripts =
|
||||||
|
cinder-all = cinder.cmd.all:main
|
||||||
|
cinder-api = cinder.cmd.api:main
|
||||||
|
cinder-backup = cinder.cmd.backup:main
|
||||||
|
cinder-manage = cinder.cmd.manage:main
|
||||||
cinder-rootwrap = oslo.rootwrap.cmd:main
|
cinder-rootwrap = oslo.rootwrap.cmd:main
|
||||||
|
cinder-rtstool = cinder.cmd.rtstool:main
|
||||||
|
cinder-scheduler = cinder.cmd.scheduler:main
|
||||||
|
cinder-volume = cinder.cmd.volume:main
|
||||||
|
cinder-volume-usage-audit = cinder.cmd.volume_usage_audit:main
|
||||||
# These are for backwards compat with Havana notification_driver configuration values
|
# These are for backwards compat with Havana notification_driver configuration values
|
||||||
oslo.messaging.notify.drivers =
|
oslo.messaging.notify.drivers =
|
||||||
cinder.openstack.common.notifier.log_notifier = oslo.messaging.notify._impl_log:LogDriver
|
cinder.openstack.common.notifier.log_notifier = oslo.messaging.notify._impl_log:LogDriver
|
||||||
|
1
tox.ini
1
tox.ini
@ -23,7 +23,6 @@ downloadcache = ~/cache/pip
|
|||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
commands =
|
commands =
|
||||||
flake8 {posargs} . cinder/common
|
flake8 {posargs} . cinder/common
|
||||||
flake8 --filename=cinder* bin
|
|
||||||
# Check that .po and .pot files are valid:
|
# Check that .po and .pot files are valid:
|
||||||
bash -c "find cinder -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null"
|
bash -c "find cinder -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user