diff options
author | Erno Kuvaja <jokke@usr.fi> | 2020-07-30 18:39:31 +0100 |
---|---|---|
committer | Erno Kuvaja <jokke@usr.fi> | 2020-07-30 18:39:31 +0100 |
commit | 77eab17cf9f3cf3f2578f73163cb816e425effa2 (patch) | |
tree | 8434f0ee075eab11538e4c6eda8511146f3f9e97 /glanceclient | |
parent | a29c6be97d923bdfb10bdb1d68a45190930e8212 (diff) | |
download | python-glanceclient-77eab17cf9f3cf3f2578f73163cb816e425effa2.tar.gz |
Fixes "stores" property added to the image3.2.1
"stores" property gets added to the image when
`glance image-create-via-import` is called with --stores
Change-Id: I514e6e3ac2f3a1f56fb7883ed403a04b1e7f13b0
Closes-Bug: #1889666
Diffstat (limited to 'glanceclient')
-rw-r--r-- | glanceclient/tests/unit/v2/test_shell_v2.py | 50 | ||||
-rw-r--r-- | glanceclient/v2/shell.py | 3 |
2 files changed, 53 insertions, 0 deletions
diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py index 4cf4d25..3f1d77a 100644 --- a/glanceclient/tests/unit/v2/test_shell_v2.py +++ b/glanceclient/tests/unit/v2/test_shell_v2.py @@ -1557,6 +1557,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 |