diff --git a/.gitreview b/.gitreview index 047ac564..a33122ec 100644 --- a/.gitreview +++ b/.gitreview @@ -2,3 +2,4 @@ host=review.opendev.org port=29418 project=openstack/python-glanceclient.git +defaultbranch=unmaintained/2023.1 diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index e24ba357..f8c48dc5 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -40,7 +40,7 @@ LOG = logging.getLogger(__name__) USER_AGENT = 'python-glanceclient' -CHUNKSIZE = 1024 * 64 # 64kB +CHUNKSIZE = 1024 * 1024 # 1MiB REQ_ID_HEADER = 'X-OpenStack-Request-ID' TOKEN_HEADERS = ['X-Auth-Token', 'X-Service-Token'] diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py index 8acceaec..b2709830 100644 --- a/glanceclient/tests/unit/v2/test_shell_v2.py +++ b/glanceclient/tests/unit/v2/test_shell_v2.py @@ -2262,6 +2262,74 @@ def test_image_import_glance_download(self): all_stores=None, allow_failure=True, backend=None, stores=None) + @mock.patch('glanceclient.common.utils.exit') + def test_image_import_neg_no_glance_download_with_remote_region( + self, mock_utils_exit): + expected_msg = ("Import method should be 'glance-download' if " + "REMOTE REGION is provided.") + my_args = self.base_args.copy() + my_args['id'] = 'IMG-01' + my_args['remote-region'] = 'REGION2' + my_args['import_method'] = 'web-download' + my_args['uri'] = 'https://example.com/some/stuff' + args = self._make_args(my_args) + mock_utils_exit.side_effect = self._mock_utils_exit + with mock.patch.object(self.gc.images, + 'get_import_info') as mocked_info: + mocked_info.return_value = self.import_info_response + try: + test_shell.do_image_import(self.gc, args) + self.fail("utils.exit should have been called") + except SystemExit: + pass + mock_utils_exit.assert_called_once_with(expected_msg) + + @mock.patch('glanceclient.common.utils.exit') + def test_image_import_neg_no_glance_download_with_remote_id( + self, mock_utils_exit): + expected_msg = ("Import method should be 'glance-download' if " + "REMOTE IMAGE ID is provided.") + my_args = self.base_args.copy() + my_args['id'] = 'IMG-01' + my_args['remote-image-id'] = 'IMG-02' + my_args['import_method'] = 'web-download' + my_args['uri'] = 'https://example.com/some/stuff' + args = self._make_args(my_args) + mock_utils_exit.side_effect = self._mock_utils_exit + with mock.patch.object(self.gc.images, + 'get_import_info') as mocked_info: + mocked_info.return_value = self.import_info_response + try: + test_shell.do_image_import(self.gc, args) + self.fail("utils.exit should have been called") + except SystemExit: + pass + mock_utils_exit.assert_called_once_with(expected_msg) + + def test_image_import_glance_download_without_remote_service_interface( + self): + args = self._make_args( + {'id': 'IMG-01', 'uri': None, 'remote-region': 'REGION2', + 'remote-image-id': 'IMG-02', + 'import_method': 'glance-download'}) + with mock.patch.object(self.gc.images, 'image_import') as mock_import: + with mock.patch.object(self.gc.images, 'get') as mocked_get: + with mock.patch.object(self.gc.images, + 'get_import_info') as mocked_info: + mocked_get.return_value = {'status': 'queued', + 'container_format': 'bare', + 'disk_format': 'raw'} + mocked_info.return_value = self.import_info_response + mock_import.return_value = None + test_shell.do_image_import(self.gc, args) + mock_import.assert_called_once_with( + 'IMG-01', 'glance-download', + uri=None, remote_region='REGION2', + remote_image_id='IMG-02', + remote_service_interface=None, + all_stores=None, allow_failure=True, + backend=None, stores=None) + @mock.patch('glanceclient.common.utils.print_image') def test_image_import_no_print_image(self, mocked_utils_print_image): args = self._make_args( diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py index 93a93776..ce404ad6 100644 --- a/glanceclient/v2/shell.py +++ b/glanceclient/v2/shell.py @@ -834,9 +834,6 @@ def do_image_import(gc, args): if remote_image_id and args.import_method != 'glance-download': utils.exit("Import method should be 'glance-download' if " "REMOTE IMAGE ID is provided.") - if remote_service_interface and args.import_method != 'glance-download': - utils.exit("Import method should be 'glance-download' if " - "REMOTE SERVICE INTERFACE is provided.") if args.import_method == 'copy-image' and not (stores or all_stores): utils.exit("Provide either --stores or --all-stores for " diff --git a/tox.ini b/tox.ini index f5160703..e0e5dcbf 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ setenv = OS_STDOUT_NOCAPTURE=False # first one that is defined. If none of them is defined, we fallback to the # default value. deps = - -c{env:TOX_CONSTRAINTS_FILE:{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}} + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2023.1} -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands = stestr run --slowest {posargs} @@ -68,7 +68,7 @@ basepython = python3 # first one that is defined. If none of them is defined, we fallback to the # default value. deps = - -c{env:TOX_CONSTRAINTS_FILE:{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}} + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2023.1} -r{toxinidir}/doc/requirements.txt commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html