summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--glanceclient/tests/unit/v2/test_shell_v2.py40
-rw-r--r--glanceclient/v2/shell.py2
2 files changed, 41 insertions, 1 deletions
diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py
index d75613f..064f5d9 100644
--- a/glanceclient/tests/unit/v2/test_shell_v2.py
+++ b/glanceclient/tests/unit/v2/test_shell_v2.py
@@ -157,6 +157,46 @@ class ShellV2Test(testtools.TestCase):
self.assertEqual('error: Must provide --disk-format when using stdin.',
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):
input = {
'limit': None,
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py
index c9f1fe1..4f358bc 100644
--- a/glanceclient/v2/shell.py
+++ b/glanceclient/v2/shell.py
@@ -30,7 +30,7 @@ import os
MEMBER_STATUS_VALUES = image_members.MEMBER_STATUS_VALUES
IMAGE_SCHEMA = None
-DATA_FIELDS = ('location', 'copy_from', 'file')
+DATA_FIELDS = ('location', 'copy_from', 'file', 'uri')
def get_image_schema():