summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-09-13 01:31:30 +0000
committerGerrit Code Review <review@openstack.org>2019-09-13 01:31:30 +0000
commit40c19aa44361e13ac997d325d357d3e4748fa063 (patch)
treed571975668ebd616e6e9637846dae5fe80db55e3
parentbaddc063a15408138e886feccc1ee90e90844cde (diff)
parentd61d1dd54655255be8e26b9a7c1e780ecb169ccf (diff)
downloadpython-glanceclient-40c19aa44361e13ac997d325d357d3e4748fa063.tar.gz
Merge "Rename --backend to --store"2.17.0
-rw-r--r--glanceclient/tests/unit/v2/test_shell_v2.py44
-rw-r--r--glanceclient/v2/shell.py42
2 files changed, 43 insertions, 43 deletions
diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py
index 84ef1f0..eb37500 100644
--- a/glanceclient/tests/unit/v2/test_shell_v2.py
+++ b/glanceclient/tests/unit/v2/test_shell_v2.py
@@ -95,7 +95,7 @@ class ShellV2Test(testtools.TestCase):
# dict directly, it throws an AttributeError.
class Args(object):
def __init__(self, entries):
- self.backend = None
+ self.store = None
self.__dict__.update(entries)
return Args(args)
@@ -782,9 +782,9 @@ class ShellV2Test(testtools.TestCase):
@mock.patch('glanceclient.common.utils.exit')
@mock.patch('os.access')
@mock.patch('sys.stdin', autospec=True)
- def test_neg_do_image_create_no_file_and_stdin_with_backend(
+ def test_neg_do_image_create_no_file_and_stdin_with_store(
self, mock_stdin, mock_access, mock_utils_exit):
- expected_msg = ('--backend option should only be provided with --file '
+ expected_msg = ('--store option should only be provided with --file '
'option or stdin.')
mock_utils_exit.side_effect = self._mock_utils_exit
mock_stdin.isatty = lambda: True
@@ -792,7 +792,7 @@ class ShellV2Test(testtools.TestCase):
args = self._make_args({'name': 'IMG-01',
'property': ['myprop=myval'],
'file': None,
- 'backend': 'file1',
+ 'store': 'file1',
'container_format': 'bare',
'disk_format': 'qcow2'})
@@ -805,16 +805,16 @@ class ShellV2Test(testtools.TestCase):
mock_utils_exit.assert_called_once_with(expected_msg)
@mock.patch('glanceclient.common.utils.exit')
- def test_neg_do_image_create_invalid_backend(
+ def test_neg_do_image_create_invalid_store(
self, mock_utils_exit):
- expected_msg = ("Backend 'dummy' is not valid for this cloud. "
+ expected_msg = ("Store 'dummy' is not valid for this cloud. "
"Valid values can be retrieved with stores-info "
"command.")
mock_utils_exit.side_effect = self._mock_utils_exit
args = self._make_args({'name': 'IMG-01',
'property': ['myprop=myval'],
'file': "somefile.txt",
- 'backend': 'dummy',
+ 'store': 'dummy',
'container_format': 'bare',
'disk_format': 'qcow2'})
@@ -873,13 +873,13 @@ class ShellV2Test(testtools.TestCase):
@mock.patch('glanceclient.common.utils.exit')
@mock.patch('os.access')
@mock.patch('sys.stdin', autospec=True)
- def test_neg_image_create_via_import_no_file_and_stdin_with_backend(
+ def test_neg_image_create_via_import_no_file_and_stdin_with_store(
self, mock_stdin, mock_access, mock_utils_exit):
- expected_msg = ('--backend option should only be provided with --file '
+ expected_msg = ('--store option should only be provided with --file '
'option or stdin for the glance-direct import method.')
my_args = self.base_args.copy()
my_args['import_method'] = 'glance-direct'
- my_args['backend'] = 'file1'
+ my_args['store'] = 'file1'
args = self._make_args(my_args)
mock_stdin.isatty = lambda: True
@@ -900,13 +900,13 @@ class ShellV2Test(testtools.TestCase):
@mock.patch('glanceclient.common.utils.exit')
@mock.patch('sys.stdin', autospec=True)
- def test_neg_image_create_via_import_no_uri_with_backend(
+ def test_neg_image_create_via_import_no_uri_with_store(
self, mock_stdin, mock_utils_exit):
- expected_msg = ('--backend option should only be provided with --uri '
+ expected_msg = ('--store option should only be provided with --uri '
'option for the web-download import method.')
my_args = self.base_args.copy()
my_args['import_method'] = 'web-download'
- my_args['backend'] = 'file1'
+ my_args['store'] = 'file1'
args = self._make_args(my_args)
mock_utils_exit.side_effect = self._mock_utils_exit
with mock.patch.object(self.gc.images,
@@ -925,14 +925,14 @@ class ShellV2Test(testtools.TestCase):
@mock.patch('glanceclient.common.utils.exit')
@mock.patch('os.access')
@mock.patch('sys.stdin', autospec=True)
- def test_neg_image_create_via_import_invalid_backend(
+ def test_neg_image_create_via_import_invalid_store(
self, mock_stdin, mock_access, mock_utils_exit):
- expected_msg = ("Backend 'dummy' is not valid for this cloud. "
+ expected_msg = ("Store 'dummy' is not valid for this cloud. "
"Valid values can be retrieved with stores-info"
" command.")
my_args = self.base_args.copy()
my_args['import_method'] = 'glance-direct'
- my_args['backend'] = 'dummy'
+ my_args['store'] = 'dummy'
args = self._make_args(my_args)
mock_stdin.isatty = lambda: True
@@ -1576,15 +1576,15 @@ class ShellV2Test(testtools.TestCase):
backend=None)
@mock.patch('glanceclient.common.utils.exit')
- def test_image_upload_invalid_backend(self, mock_utils_exit):
- expected_msg = ("Backend 'dummy' is not valid for this cloud. "
+ def test_image_upload_invalid_store(self, mock_utils_exit):
+ expected_msg = ("Store 'dummy' is not valid for this cloud. "
"Valid values can be retrieved with stores-info "
"command.")
mock_utils_exit.side_effect = self._mock_utils_exit
args = self._make_args(
{'id': 'IMG-01', 'file': 'test', 'size': 1024, 'progress': False,
- 'backend': 'dummy'})
+ 'store': 'dummy'})
with mock.patch.object(self.gc.images,
'get_stores_info') as mock_stores_info:
@@ -1743,15 +1743,15 @@ class ShellV2Test(testtools.TestCase):
mock_utils_exit.assert_called_once_with(expected_msg)
@mock.patch('glanceclient.common.utils.exit')
- def test_image_import_invalid_backend(self, mock_utils_exit):
- expected_msg = ("Backend 'dummy' is not valid for this cloud. "
+ def test_image_import_invalid_store(self, mock_utils_exit):
+ expected_msg = ("Store 'dummy' is not valid for this cloud. "
"Valid values can be retrieved with stores-info "
"command.")
mock_utils_exit.side_effect = self._mock_utils_exit
args = self._make_args(
{'id': 'IMG-01', 'import_method': 'glance-direct', 'uri': None,
- 'backend': 'dummy'})
+ 'store': 'dummy'})
with mock.patch.object(self.gc.images, 'get') as mocked_get:
with mock.patch.object(self.gc.images,
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py
index 61e5ec3..8b2c13b 100644
--- a/glanceclient/v2/shell.py
+++ b/glanceclient/v2/shell.py
@@ -71,8 +71,8 @@ def get_image_schema():
'passed to the client via stdin.'))
@utils.arg('--progress', action='store_true', default=False,
help=_('Show upload progress bar.'))
-@utils.arg('--backend', metavar='<STORE>',
- default=utils.env('OS_IMAGE_BACKEND', default=None),
+@utils.arg('--store', metavar='<STORE>',
+ default=utils.env('OS_IMAGE_STORE', default=None),
help='Backend store to upload image to.')
@utils.on_data_require_fields(DATA_FIELDS)
def do_image_create(gc, args):
@@ -90,12 +90,12 @@ def do_image_create(gc, args):
key, value = datum.split('=', 1)
fields[key] = value
- backend = args.backend
+ backend = args.store
file_name = fields.pop('file', None)
using_stdin = not sys.stdin.isatty()
- if args.backend and not (file_name or using_stdin):
- utils.exit("--backend option should only be provided with --file "
+ if args.store and not (file_name or using_stdin):
+ utils.exit("--store option should only be provided with --file "
"option or stdin.")
if backend:
@@ -108,7 +108,7 @@ def do_image_create(gc, args):
image = gc.images.create(**fields)
try:
if utils.get_data_file(args) is not None:
- backend = fields.get('backend', None)
+ backend = fields.get('store', None)
args.id = image['id']
args.size = None
do_image_upload(gc, args)
@@ -147,8 +147,8 @@ def do_image_create(gc, args):
'record if no import-method and no data is supplied'))
@utils.arg('--uri', metavar='<IMAGE_URL>', default=None,
help=_('URI to download the external image.'))
-@utils.arg('--backend', metavar='<STORE>',
- default=utils.env('OS_IMAGE_BACKEND', default=None),
+@utils.arg('--store', metavar='<STORE>',
+ default=utils.env('OS_IMAGE_STORE', default=None),
help='Backend store to upload image to.')
@utils.on_data_require_fields(DATA_FIELDS)
def do_image_create_via_import(gc, args):
@@ -198,8 +198,8 @@ def do_image_create_via_import(gc, args):
# determine if backend is valid
backend = None
- if args.backend:
- backend = args.backend
+ if args.store:
+ backend = args.store
_validate_backend(backend, gc)
# make sure we have all and only correct inputs for the requested method
@@ -209,7 +209,7 @@ def do_image_create_via_import(gc, args):
"method.")
if args.import_method == 'glance-direct':
if backend and not (file_name or using_stdin):
- utils.exit("--backend option should only be provided with --file "
+ utils.exit("--store option should only be provided with --file "
"option or stdin for the glance-direct import method.")
if args.uri:
utils.exit("You cannot specify a --uri with the glance-direct "
@@ -225,7 +225,7 @@ def do_image_create_via_import(gc, args):
"for the glance-direct import method.")
if args.import_method == 'web-download':
if backend and not args.uri:
- utils.exit("--backend option should only be provided with --uri "
+ utils.exit("--store option should only be provided with --uri "
"option for the web-download import method.")
if not args.uri:
utils.exit("URI is required for web-download import method. "
@@ -267,7 +267,7 @@ def _validate_backend(backend, gc):
break
if not valid_backend:
- utils.exit("Backend '%s' is not valid for this cloud. Valid "
+ utils.exit("Store '%s' is not valid for this cloud. Valid "
"values can be retrieved with stores-info command." %
backend)
@@ -559,14 +559,14 @@ def do_image_download(gc, args):
help=_('Show upload progress bar.'))
@utils.arg('id', metavar='<IMAGE_ID>',
help=_('ID of image to upload data to.'))
-@utils.arg('--backend', metavar='<STORE>',
- default=utils.env('OS_IMAGE_BACKEND', default=None),
+@utils.arg('--store', metavar='<STORE>',
+ default=utils.env('OS_IMAGE_STORE', default=None),
help='Backend store to upload image to.')
def do_image_upload(gc, args):
"""Upload data for a specific image."""
backend = None
- if args.backend:
- backend = args.backend
+ if args.store:
+ backend = args.store
# determine if backend is valid
_validate_backend(backend, gc)
@@ -614,14 +614,14 @@ def do_image_stage(gc, args):
help=_('URI to download the external image.'))
@utils.arg('id', metavar='<IMAGE_ID>',
help=_('ID of image to import.'))
-@utils.arg('--backend', metavar='<STORE>',
- default=utils.env('OS_IMAGE_BACKEND', default=None),
+@utils.arg('--store', metavar='<STORE>',
+ default=utils.env('OS_IMAGE_STORE', default=None),
help='Backend store to upload image to.')
def do_image_import(gc, args):
"""Initiate the image import taskflow."""
backend = None
- if args.backend:
- backend = args.backend
+ if args.store:
+ backend = args.store
# determine if backend is valid
_validate_backend(backend, gc)