Merge "Rename --backend to --store"

This commit is contained in:
Zuul
2019-09-13 01:31:30 +00:00
committed by Gerrit Code Review
2 changed files with 43 additions and 43 deletions

View File

@@ -95,7 +95,7 @@ class ShellV2Test(testtools.TestCase):
# dict directly, it throws an AttributeError. # dict directly, it throws an AttributeError.
class Args(object): class Args(object):
def __init__(self, entries): def __init__(self, entries):
self.backend = None self.store = None
self.__dict__.update(entries) self.__dict__.update(entries)
return Args(args) return Args(args)
@@ -782,9 +782,9 @@ class ShellV2Test(testtools.TestCase):
@mock.patch('glanceclient.common.utils.exit') @mock.patch('glanceclient.common.utils.exit')
@mock.patch('os.access') @mock.patch('os.access')
@mock.patch('sys.stdin', autospec=True) @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): 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.') 'option or stdin.')
mock_utils_exit.side_effect = self._mock_utils_exit mock_utils_exit.side_effect = self._mock_utils_exit
mock_stdin.isatty = lambda: True mock_stdin.isatty = lambda: True
@@ -792,7 +792,7 @@ class ShellV2Test(testtools.TestCase):
args = self._make_args({'name': 'IMG-01', args = self._make_args({'name': 'IMG-01',
'property': ['myprop=myval'], 'property': ['myprop=myval'],
'file': None, 'file': None,
'backend': 'file1', 'store': 'file1',
'container_format': 'bare', 'container_format': 'bare',
'disk_format': 'qcow2'}) 'disk_format': 'qcow2'})
@@ -805,16 +805,16 @@ class ShellV2Test(testtools.TestCase):
mock_utils_exit.assert_called_once_with(expected_msg) mock_utils_exit.assert_called_once_with(expected_msg)
@mock.patch('glanceclient.common.utils.exit') @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): 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 " "Valid values can be retrieved with stores-info "
"command.") "command.")
mock_utils_exit.side_effect = self._mock_utils_exit mock_utils_exit.side_effect = self._mock_utils_exit
args = self._make_args({'name': 'IMG-01', args = self._make_args({'name': 'IMG-01',
'property': ['myprop=myval'], 'property': ['myprop=myval'],
'file': "somefile.txt", 'file': "somefile.txt",
'backend': 'dummy', 'store': 'dummy',
'container_format': 'bare', 'container_format': 'bare',
'disk_format': 'qcow2'}) 'disk_format': 'qcow2'})
@@ -873,13 +873,13 @@ class ShellV2Test(testtools.TestCase):
@mock.patch('glanceclient.common.utils.exit') @mock.patch('glanceclient.common.utils.exit')
@mock.patch('os.access') @mock.patch('os.access')
@mock.patch('sys.stdin', autospec=True) @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): 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.') 'option or stdin for the glance-direct import method.')
my_args = self.base_args.copy() my_args = self.base_args.copy()
my_args['import_method'] = 'glance-direct' my_args['import_method'] = 'glance-direct'
my_args['backend'] = 'file1' my_args['store'] = 'file1'
args = self._make_args(my_args) args = self._make_args(my_args)
mock_stdin.isatty = lambda: True mock_stdin.isatty = lambda: True
@@ -900,13 +900,13 @@ class ShellV2Test(testtools.TestCase):
@mock.patch('glanceclient.common.utils.exit') @mock.patch('glanceclient.common.utils.exit')
@mock.patch('sys.stdin', autospec=True) @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): 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.') 'option for the web-download import method.')
my_args = self.base_args.copy() my_args = self.base_args.copy()
my_args['import_method'] = 'web-download' my_args['import_method'] = 'web-download'
my_args['backend'] = 'file1' my_args['store'] = 'file1'
args = self._make_args(my_args) args = self._make_args(my_args)
mock_utils_exit.side_effect = self._mock_utils_exit mock_utils_exit.side_effect = self._mock_utils_exit
with mock.patch.object(self.gc.images, with mock.patch.object(self.gc.images,
@@ -925,14 +925,14 @@ class ShellV2Test(testtools.TestCase):
@mock.patch('glanceclient.common.utils.exit') @mock.patch('glanceclient.common.utils.exit')
@mock.patch('os.access') @mock.patch('os.access')
@mock.patch('sys.stdin', autospec=True) @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): 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" "Valid values can be retrieved with stores-info"
" command.") " command.")
my_args = self.base_args.copy() my_args = self.base_args.copy()
my_args['import_method'] = 'glance-direct' my_args['import_method'] = 'glance-direct'
my_args['backend'] = 'dummy' my_args['store'] = 'dummy'
args = self._make_args(my_args) args = self._make_args(my_args)
mock_stdin.isatty = lambda: True mock_stdin.isatty = lambda: True
@@ -1576,15 +1576,15 @@ class ShellV2Test(testtools.TestCase):
backend=None) backend=None)
@mock.patch('glanceclient.common.utils.exit') @mock.patch('glanceclient.common.utils.exit')
def test_image_upload_invalid_backend(self, mock_utils_exit): def test_image_upload_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 " "Valid values can be retrieved with stores-info "
"command.") "command.")
mock_utils_exit.side_effect = self._mock_utils_exit mock_utils_exit.side_effect = self._mock_utils_exit
args = self._make_args( args = self._make_args(
{'id': 'IMG-01', 'file': 'test', 'size': 1024, 'progress': False, {'id': 'IMG-01', 'file': 'test', 'size': 1024, 'progress': False,
'backend': 'dummy'}) 'store': 'dummy'})
with mock.patch.object(self.gc.images, with mock.patch.object(self.gc.images,
'get_stores_info') as mock_stores_info: '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_utils_exit.assert_called_once_with(expected_msg)
@mock.patch('glanceclient.common.utils.exit') @mock.patch('glanceclient.common.utils.exit')
def test_image_import_invalid_backend(self, mock_utils_exit): def test_image_import_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 " "Valid values can be retrieved with stores-info "
"command.") "command.")
mock_utils_exit.side_effect = self._mock_utils_exit mock_utils_exit.side_effect = self._mock_utils_exit
args = self._make_args( args = self._make_args(
{'id': 'IMG-01', 'import_method': 'glance-direct', 'uri': None, {'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, 'get') as mocked_get:
with mock.patch.object(self.gc.images, with mock.patch.object(self.gc.images,

View File

@@ -71,8 +71,8 @@ def get_image_schema():
'passed to the client via stdin.')) 'passed to the client via stdin.'))
@utils.arg('--progress', action='store_true', default=False, @utils.arg('--progress', action='store_true', default=False,
help=_('Show upload progress bar.')) help=_('Show upload progress bar.'))
@utils.arg('--backend', metavar='<STORE>', @utils.arg('--store', metavar='<STORE>',
default=utils.env('OS_IMAGE_BACKEND', default=None), default=utils.env('OS_IMAGE_STORE', default=None),
help='Backend store to upload image to.') help='Backend store to upload image to.')
@utils.on_data_require_fields(DATA_FIELDS) @utils.on_data_require_fields(DATA_FIELDS)
def do_image_create(gc, args): def do_image_create(gc, args):
@@ -90,12 +90,12 @@ def do_image_create(gc, args):
key, value = datum.split('=', 1) key, value = datum.split('=', 1)
fields[key] = value fields[key] = value
backend = args.backend backend = args.store
file_name = fields.pop('file', None) file_name = fields.pop('file', None)
using_stdin = not sys.stdin.isatty() using_stdin = not sys.stdin.isatty()
if args.backend and not (file_name or using_stdin): if args.store 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.") "option or stdin.")
if backend: if backend:
@@ -108,7 +108,7 @@ def do_image_create(gc, args):
image = gc.images.create(**fields) image = gc.images.create(**fields)
try: try:
if utils.get_data_file(args) is not None: if utils.get_data_file(args) is not None:
backend = fields.get('backend', None) backend = fields.get('store', None)
args.id = image['id'] args.id = image['id']
args.size = None args.size = None
do_image_upload(gc, args) 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')) 'record if no import-method and no data is supplied'))
@utils.arg('--uri', metavar='<IMAGE_URL>', default=None, @utils.arg('--uri', metavar='<IMAGE_URL>', default=None,
help=_('URI to download the external image.')) help=_('URI to download the external image.'))
@utils.arg('--backend', metavar='<STORE>', @utils.arg('--store', metavar='<STORE>',
default=utils.env('OS_IMAGE_BACKEND', default=None), default=utils.env('OS_IMAGE_STORE', default=None),
help='Backend store to upload image to.') help='Backend store to upload image to.')
@utils.on_data_require_fields(DATA_FIELDS) @utils.on_data_require_fields(DATA_FIELDS)
def do_image_create_via_import(gc, args): 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 # determine if backend is valid
backend = None backend = None
if args.backend: if args.store:
backend = args.backend backend = args.store
_validate_backend(backend, gc) _validate_backend(backend, gc)
# make sure we have all and only correct inputs for the requested method # 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.") "method.")
if args.import_method == 'glance-direct': if args.import_method == 'glance-direct':
if backend and not (file_name or using_stdin): 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.") "option or stdin for the glance-direct import method.")
if args.uri: if args.uri:
utils.exit("You cannot specify a --uri with the glance-direct " 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.") "for the glance-direct import method.")
if args.import_method == 'web-download': if args.import_method == 'web-download':
if backend and not args.uri: 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.") "option for the web-download import method.")
if not args.uri: if not args.uri:
utils.exit("URI is required for web-download import method. " utils.exit("URI is required for web-download import method. "
@@ -267,7 +267,7 @@ def _validate_backend(backend, gc):
break break
if not valid_backend: 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." % "values can be retrieved with stores-info command." %
backend) backend)
@@ -559,14 +559,14 @@ def do_image_download(gc, args):
help=_('Show upload progress bar.')) help=_('Show upload progress bar.'))
@utils.arg('id', metavar='<IMAGE_ID>', @utils.arg('id', metavar='<IMAGE_ID>',
help=_('ID of image to upload data to.')) help=_('ID of image to upload data to.'))
@utils.arg('--backend', metavar='<STORE>', @utils.arg('--store', metavar='<STORE>',
default=utils.env('OS_IMAGE_BACKEND', default=None), default=utils.env('OS_IMAGE_STORE', default=None),
help='Backend store to upload image to.') help='Backend store to upload image to.')
def do_image_upload(gc, args): def do_image_upload(gc, args):
"""Upload data for a specific image.""" """Upload data for a specific image."""
backend = None backend = None
if args.backend: if args.store:
backend = args.backend backend = args.store
# determine if backend is valid # determine if backend is valid
_validate_backend(backend, gc) _validate_backend(backend, gc)
@@ -614,14 +614,14 @@ def do_image_stage(gc, args):
help=_('URI to download the external image.')) help=_('URI to download the external image.'))
@utils.arg('id', metavar='<IMAGE_ID>', @utils.arg('id', metavar='<IMAGE_ID>',
help=_('ID of image to import.')) help=_('ID of image to import.'))
@utils.arg('--backend', metavar='<STORE>', @utils.arg('--store', metavar='<STORE>',
default=utils.env('OS_IMAGE_BACKEND', default=None), default=utils.env('OS_IMAGE_STORE', default=None),
help='Backend store to upload image to.') help='Backend store to upload image to.')
def do_image_import(gc, args): def do_image_import(gc, args):
"""Initiate the image import taskflow.""" """Initiate the image import taskflow."""
backend = None backend = None
if args.backend: if args.store:
backend = args.backend backend = args.store
# determine if backend is valid # determine if backend is valid
_validate_backend(backend, gc) _validate_backend(backend, gc)