Codebase list glance / ac98e08
Remove diff with upstream tag. Thomas Goirand 6 years ago
2 changed file(s) with 1 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
1515 """Storage preference based location strategy module"""
1616
1717 from oslo_config import cfg
18 from oslo_log import log as logging
1918 import six
2019 import six.moves.urllib.parse as urlparse
2120
22 from glance.i18n import _, _LW
21 from glance.i18n import _
2322
2423 store_type_opts = [
2524 cfg.ListOpt('store_type_preference',
101100 preferred_store = str(preferred_store).strip()
102101 if not preferred_store:
103102 continue
104 # NOTE(dharinic): The following conversion of ``filesystem`` and
105 # ``vmware_datastore`` to ``file`` and ``vmware`` respectively
106 # are to make store names consistent in Glance and glance_store
107 # and also be backward compatible.
108 # Reference: Bug 1615852
109 if preferred_store == 'filesystem':
110 preferred_store = 'file'
111 msg = _LW('The value ``filesystem`` is DEPRECATED for use '
112 'with ``store_type_preference``. It will be '
113 'removed in the Pike release. Please use ``file`` '
114 'instead. Please see the Glance Newton release '
115 'notes for more information.')
116 LOG.warn(msg)
117 if preferred_store == 'vmware_datastore':
118 preferred_store = 'vmware'
119 msg = _LW('The value ``vmware_datastore`` is DEPRECATED for '
120 'use with ``store_type_preference``. It will be '
121 'removed in the Pike release. Please use ``vmware`` '
122 'instead. Please see the Glance Newton release '
123 'notes for more information.')
124 LOG.warn(msg)
125103 yield preferred_store
126104
127105 if not locations:
182182 locs.sort(key=lambda loc: loc['metadata']['idx'])
183183 # The result will ordered by preferred store type order.
184184 self.assertEqual(locs, ordered_locs)
185
186 def test_get_ordered_locations_with_consistent_store_names(self):
187 """This test is for the change made with respect to making store names
188 in glance to be consistent with store names used in glance_store.
189 Reference: Bug #1615852
190 """
191 self.config(store_type_preference=[' rbd', 'sheepdog ', 'file',
192 'swift ', ' http ', 'vmware'],
193 group='store_type_location_strategy')
194 locs = [{'url': 'file://image0', 'metadata': {'idx': 3}},
195 {'url': 'rbd://image1', 'metadata': {'idx': 0}},
196 {'url': 'file://image3', 'metadata': {'idx': 4}},
197 {'url': 'swift://image4', 'metadata': {'idx': 6}},
198 {'url': 'cinder://image5', 'metadata': {'idx': 9}},
199 {'url': 'file://image6', 'metadata': {'idx': 5}},
200 {'url': 'rbd://image7', 'metadata': {'idx': 1}},
201 {'url': 'vsphere://image9', 'metadata': {'idx': 8}},
202 {'url': 'sheepdog://image8', 'metadata': {'idx': 2}}]
203 ordered_locs = store_type.get_ordered_locations(copy.deepcopy(locs))
204 locs.sort(key=lambda loc: loc['metadata']['idx'])
205 # The result will ordered by preferred store type order.
206 self.assertEqual(locs, ordered_locs)