diff --git a/bin/glance b/bin/glance index f651cd1a..a86a08bd 100755 --- a/bin/glance +++ b/bin/glance @@ -164,7 +164,7 @@ Field names of note: id Optional. If not specified, an image identifier will be automatically assigned. -name Required. A name for the image. +name Optional. A name for the image. size Optional. Should be size in bytes of the image if specified. is_public Optional. If specified, interpreted as a boolean value @@ -217,12 +217,8 @@ EXAMPLES print e return FAILURE - if 'name' not in fields.keys(): - print "Please specify a name for the image using name=VALUE" - return FAILURE - image_meta = {'id': fields.pop('id', None), - 'name': fields.pop('name'), + 'name': fields.pop('name', None), 'is_public': utils.bool_from_string( fields.pop('is_public', False)), 'protected': utils.bool_from_string( diff --git a/glance/tests/functional/store_utils.py b/glance/tests/functional/store_utils.py index de2e4d0a..533e756a 100644 --- a/glance/tests/functional/store_utils.py +++ b/glance/tests/functional/store_utils.py @@ -173,7 +173,9 @@ def teardown_swift(test): def get_swift_uri(test, image_id): - uri = ('swift+http://%(swift_store_user)s:%(swift_store_key)s' % + # Apparently we must use HTTPS with Cloud Files now, otherwise + # we will get a 301 Moved.... :( + uri = ('swift+https://%(swift_store_user)s:%(swift_store_key)s' % test.__dict__) uri += ('@%(swift_store_auth_address)s/%(swift_store_container)s/' % test.__dict__) diff --git a/glance/tests/functional/test_bin_glance.py b/glance/tests/functional/test_bin_glance.py index 6b713232..aac95d56 100644 --- a/glance/tests/functional/test_bin_glance.py +++ b/glance/tests/functional/test_bin_glance.py @@ -145,6 +145,47 @@ class TestBinGlance(functional.FunctionalTest): self.assertEqual('0', size, "Expected image to be 0 bytes in size, " "but got %s. " % size) + def test_add_no_name(self): + self.cleanup() + self.start_servers(**self.__dict__.copy()) + + api_port = self.api_port + registry_port = self.registry_port + + # 0. Verify no public images + cmd = "bin/glance --port=%d index" % api_port + + exitcode, out, err = execute(cmd) + + self.assertEqual(0, exitcode) + self.assertEqual('', out.strip()) + + # 1. Add public image + # Can't use minimal_add_command since that uses + # name... + cmd = ("bin/glance --port=%d add is_public=True" + " disk_format=raw container_format=ovf" + " %s" % (api_port, 'location=http://example.com')) + exitcode, out, err = execute(cmd) + + self.assertEqual(0, exitcode) + self.assertTrue(out.strip().startswith('Added new image with ID:')) + + # 2. Verify image added as public image + cmd = "bin/glance --port=%d index" % api_port + + exitcode, out, err = execute(cmd) + + self.assertEqual(0, exitcode) + lines = out.split("\n")[2:-1] + self.assertEqual(1, len(lines)) + + line = lines[0] + + image_id, name, disk_format, container_format, size = \ + [c.strip() for c in line.split()] + self.assertEqual('None', name) + @requires(setup_http, teardown_http) def test_add_copying_from(self): self.cleanup()