summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--glanceclient/tests/unit/v2/test_shell_v2.py50
-rw-r--r--glanceclient/v2/shell.py3
-rw-r--r--releasenotes/notes/fix_1889666-22dc97ce577eccc6.yaml6
3 files changed, 59 insertions, 0 deletions
diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py
index 9d10ff2..e7dfd5c 100644
--- a/glanceclient/tests/unit/v2/test_shell_v2.py
+++ b/glanceclient/tests/unit/v2/test_shell_v2.py
@@ -1556,6 +1556,56 @@ class ShellV2Test(testtools.TestCase):
'id': 'pass', 'name': 'IMG-01', 'disk_format': 'vhd',
'container_format': 'bare', 'status': 'queued'})
+ @mock.patch('glanceclient.v2.shell.do_image_import')
+ @mock.patch('glanceclient.v2.shell.do_image_stage')
+ @mock.patch('sys.stdin', autospec=True)
+ def test_do_image_create_via_import_with_web_download_with_stores(
+ self, mock_stdin, mock_do_image_stage, mock_do_image_import):
+ temp_args = {'name': 'IMG-01',
+ 'disk_format': 'vhd',
+ 'container_format': 'bare',
+ 'uri': 'http://example.com/image.qcow',
+ 'import_method': 'web-download',
+ 'progress': False,
+ 'stores': 'file1,file2'}
+ tmp2_args = {'name': 'IMG-01',
+ 'disk_format': 'vhd',
+ 'container_format': 'bare',
+ 'uri': 'http://example.com/image.qcow',
+ 'import_method': 'web-download',
+ 'progress': False}
+ args = self._make_args(temp_args)
+ with mock.patch.object(self.gc.images, 'create') as mocked_create:
+ with mock.patch.object(self.gc.images, 'get') as mocked_get:
+ with mock.patch.object(self.gc.images,
+ 'get_import_info') as mocked_info:
+ with mock.patch.object(self.gc.images,
+ 'get_stores_info') as m_stores_info:
+
+ ignore_fields = ['self', 'access', 'schema']
+ expect_image = dict([(field, field) for field in
+ ignore_fields])
+ expect_image['id'] = 'pass'
+ expect_image['name'] = 'IMG-01'
+ expect_image['disk_format'] = 'vhd'
+ expect_image['container_format'] = 'bare'
+ expect_image['status'] = 'queued'
+ mocked_create.return_value = expect_image
+ mocked_get.return_value = expect_image
+ mocked_info.return_value = self.import_info_response
+ m_stores_info.return_value = self.stores_info_response
+ mock_stdin.isatty = lambda: True
+
+ test_shell.do_image_create_via_import(self.gc, args)
+ mock_do_image_stage.assert_not_called()
+ mock_do_image_import.assert_called_once()
+ mocked_create.assert_called_once_with(**tmp2_args)
+ mocked_get.assert_called_with('pass')
+ utils.print_dict.assert_called_with({
+ 'id': 'pass', 'name': 'IMG-01',
+ 'disk_format': 'vhd',
+ 'container_format': 'bare', 'status': 'queued'})
+
def test_do_image_update_no_user_props(self):
args = self._make_args({'id': 'pass', 'name': 'IMG-01',
'disk_format': 'vhd',
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py
index 8414308..592b2da 100644
--- a/glanceclient/v2/shell.py
+++ b/glanceclient/v2/shell.py
@@ -235,6 +235,9 @@ def do_image_create_via_import(gc, args):
# determine if backend is valid
_validate_backend(backend, gc)
elif stores:
+ # NOTE(jokke): Making sure here that we do not include the stores in
+ # the create call
+ fields.pop("stores")
stores = str(stores).split(',')
for store in stores:
# determine if backend is valid
diff --git a/releasenotes/notes/fix_1889666-22dc97ce577eccc6.yaml b/releasenotes/notes/fix_1889666-22dc97ce577eccc6.yaml
new file mode 100644
index 0000000..553c377
--- /dev/null
+++ b/releasenotes/notes/fix_1889666-22dc97ce577eccc6.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+ - |
+ Bug 1889666_: 'stores' property added when using image-create-via-import --stores <list>
+
+ .. _1889666: https://bugs.launchpad.net/glance/+bug/1889666