Check for container,disk_format on web-download
Fail image-create-via-import requests for the web-download import method that don't include values for container_format or disk_format. Closes-bug: #1757927 Change-Id: Ic5c81916823ff32f2dbddd32b40e825de0697dc9
This commit is contained in:
@@ -157,6 +157,46 @@ class ShellV2Test(testtools.TestCase):
|
|||||||
self.assertEqual('error: Must provide --disk-format when using stdin.',
|
self.assertEqual('error: Must provide --disk-format when using stdin.',
|
||||||
e.message)
|
e.message)
|
||||||
|
|
||||||
|
@mock.patch('sys.stderr')
|
||||||
|
def test_create_via_import_glance_direct_missing_disk_format(self, __):
|
||||||
|
e = self.assertRaises(exc.CommandError, self._run_command,
|
||||||
|
'--os-image-api-version 2 '
|
||||||
|
'image-create-via-import '
|
||||||
|
'--file fake_src --container-format bare')
|
||||||
|
self.assertEqual('error: Must provide --disk-format when using '
|
||||||
|
'--file.', e.message)
|
||||||
|
|
||||||
|
@mock.patch('sys.stderr')
|
||||||
|
def test_create_via_import_glance_direct_missing_container_format(
|
||||||
|
self, __):
|
||||||
|
e = self.assertRaises(exc.CommandError, self._run_command,
|
||||||
|
'--os-image-api-version 2 '
|
||||||
|
'image-create-via-import '
|
||||||
|
'--file fake_src --disk-format qcow2')
|
||||||
|
self.assertEqual('error: Must provide --container-format when '
|
||||||
|
'using --file.', e.message)
|
||||||
|
|
||||||
|
@mock.patch('sys.stderr')
|
||||||
|
def test_create_via_import_web_download_missing_disk_format(self, __):
|
||||||
|
e = self.assertRaises(exc.CommandError, self._run_command,
|
||||||
|
'--os-image-api-version 2 '
|
||||||
|
'image-create-via-import ' +
|
||||||
|
'--import-method web-download ' +
|
||||||
|
'--uri fake_uri --container-format bare')
|
||||||
|
self.assertEqual('error: Must provide --disk-format when using '
|
||||||
|
'--uri.', e.message)
|
||||||
|
|
||||||
|
@mock.patch('sys.stderr')
|
||||||
|
def test_create_via_import_web_download_missing_container_format(
|
||||||
|
self, __):
|
||||||
|
e = self.assertRaises(exc.CommandError, self._run_command,
|
||||||
|
'--os-image-api-version 2 '
|
||||||
|
'image-create-via-import '
|
||||||
|
'--import-method web-download '
|
||||||
|
'--uri fake_uri --disk-format qcow2')
|
||||||
|
self.assertEqual('error: Must provide --container-format when '
|
||||||
|
'using --uri.', e.message)
|
||||||
|
|
||||||
def test_do_image_list(self):
|
def test_do_image_list(self):
|
||||||
input = {
|
input = {
|
||||||
'limit': None,
|
'limit': None,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import os
|
|||||||
|
|
||||||
MEMBER_STATUS_VALUES = image_members.MEMBER_STATUS_VALUES
|
MEMBER_STATUS_VALUES = image_members.MEMBER_STATUS_VALUES
|
||||||
IMAGE_SCHEMA = None
|
IMAGE_SCHEMA = None
|
||||||
DATA_FIELDS = ('location', 'copy_from', 'file')
|
DATA_FIELDS = ('location', 'copy_from', 'file', 'uri')
|
||||||
|
|
||||||
|
|
||||||
def get_image_schema():
|
def get_image_schema():
|
||||||
|
|||||||
Reference in New Issue
Block a user