components/openstack/glance/patches/14-launchpad-1471080.patch
changeset 6852 bf55de364b19
parent 6851 f984e52b96bb
child 6853 cf1567491b1b
equal deleted inserted replaced
6851:f984e52b96bb 6852:bf55de364b19
     1 commit 356e66c2397a4a1ae3dd1fca2870958f5969aceb
       
     2 Author: wangxiyuan <[email protected]>
       
     3 Date:   Fri Jul 3 11:45:57 2015 +0800
       
     4 
       
     5     Fix wrong check when create image without data.
       
     6     
       
     7     The default value of 'locations' is [].So there is a wrong check in
       
     8     db/sqlalchemy/api.py.
       
     9     When create an image without data, The function '_image_locations_set'
       
    10     should not be executed.
       
    11     
       
    12     Change-Id: Ie4cb29ab0d714d3ce67f717d5eaf641424efa5b7
       
    13     Closes-bug:#1471080
       
    14 
       
    15 --- glance-2015.1.2/glance/db/sqlalchemy/api.py.~1~	2015-10-13 09:38:23.000000000 -0700
       
    16 +++ glance-2015.1.2/glance/db/sqlalchemy/api.py	2016-03-04 01:02:00.749647525 -0800
       
    17 @@ -790,7 +790,7 @@ def _image_update(context, values, image
       
    18          _set_properties_for_image(context, image_ref, properties, purge_props,
       
    19                                    session)
       
    20  
       
    21 -        if location_data is not None:
       
    22 +        if location_data:
       
    23              _image_locations_set(context, image_ref.id, location_data,
       
    24                                   session=session)
       
    25  
       
    26 --- glance-2015.1.2/glance/tests/functional/db/base.py.~1~	2015-10-13 09:38:23.000000000 -0700
       
    27 +++ glance-2015.1.2/glance/tests/functional/db/base.py	2016-03-04 01:02:00.751553768 -0800
       
    28 @@ -191,6 +191,12 @@ class DriverTests(object):
       
    29                    for l in image['locations']]
       
    30          self.assertEqual(locations, actual)
       
    31  
       
    32 +    def test_image_create_without_locations(self):
       
    33 +        locations = []
       
    34 +        fixture = {'status': 'queued',
       
    35 +                   'locations': locations}
       
    36 +        self.db_api.image_create(self.context, fixture)
       
    37 +
       
    38      def test_image_create_with_location_data(self):
       
    39          location_data = [{'url': 'a', 'metadata': {'key': 'value'},
       
    40                            'status': 'active'},