Remove diff with upstream tag.
Thomas Goirand
6 years ago
15 | 15 | """Storage preference based location strategy module""" |
16 | 16 | |
17 | 17 | from oslo_config import cfg |
18 | from oslo_log import log as logging | |
19 | 18 | import six |
20 | 19 | import six.moves.urllib.parse as urlparse |
21 | 20 | |
22 | from glance.i18n import _, _LW | |
21 | from glance.i18n import _ | |
23 | 22 | |
24 | 23 | store_type_opts = [ |
25 | 24 | cfg.ListOpt('store_type_preference', |
101 | 100 | preferred_store = str(preferred_store).strip() |
102 | 101 | if not preferred_store: |
103 | 102 | 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) | |
125 | 103 | yield preferred_store |
126 | 104 | |
127 | 105 | if not locations: |
182 | 182 | locs.sort(key=lambda loc: loc['metadata']['idx']) |
183 | 183 | # The result will ordered by preferred store type order. |
184 | 184 | 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) |