python-manilaclient 4.9.1__py3-none-any.whl → 5.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. manilaclient/api_versions.py +1 -1
  2. manilaclient/osc/v2/share.py +122 -1
  3. manilaclient/osc/v2/share_replicas.py +15 -0
  4. manilaclient/osc/v2/share_servers.py +39 -0
  5. manilaclient/tests/unit/osc/v2/fakes.py +2 -0
  6. manilaclient/tests/unit/osc/v2/test_share.py +142 -0
  7. manilaclient/tests/unit/osc/v2/test_share_replicas.py +27 -1
  8. manilaclient/tests/unit/osc/v2/test_share_servers.py +50 -0
  9. manilaclient/tests/unit/v2/fakes.py +50 -4
  10. manilaclient/tests/unit/v2/test_client.py +6 -55
  11. manilaclient/tests/unit/v2/test_shares.py +1 -1
  12. manilaclient/tests/unit/v2/test_shell.py +146 -1
  13. manilaclient/v1/client.py +23 -38
  14. manilaclient/v2/client.py +23 -38
  15. manilaclient/v2/share_export_locations.py +23 -1
  16. manilaclient/v2/shell.py +59 -6
  17. {python_manilaclient-4.9.1.dist-info → python_manilaclient-5.1.0.dist-info}/AUTHORS +2 -0
  18. {python_manilaclient-4.9.1.dist-info → python_manilaclient-5.1.0.dist-info}/METADATA +3 -4
  19. {python_manilaclient-4.9.1.dist-info → python_manilaclient-5.1.0.dist-info}/RECORD +24 -24
  20. {python_manilaclient-4.9.1.dist-info → python_manilaclient-5.1.0.dist-info}/entry_points.txt +2 -0
  21. python_manilaclient-5.1.0.dist-info/pbr.json +1 -0
  22. python_manilaclient-4.9.1.dist-info/pbr.json +0 -1
  23. {python_manilaclient-4.9.1.dist-info → python_manilaclient-5.1.0.dist-info}/LICENSE +0 -0
  24. {python_manilaclient-4.9.1.dist-info → python_manilaclient-5.1.0.dist-info}/WHEEL +0 -0
  25. {python_manilaclient-4.9.1.dist-info → python_manilaclient-5.1.0.dist-info}/top_level.txt +0 -0
@@ -27,7 +27,7 @@ from manilaclient import utils
27
27
 
28
28
  LOG = logging.getLogger(__name__)
29
29
 
30
- MAX_VERSION = '2.84'
30
+ MAX_VERSION = '2.87'
31
31
  MIN_VERSION = '2.0'
32
32
  DEPRECATED_VERSION = '1.0'
33
33
  _VERSIONED_METHOD_MAP = {}
@@ -1179,8 +1179,15 @@ class ShareExportLocationShow(command.ShowOne):
1179
1179
  share=share,
1180
1180
  export_location=parsed_args.export_location
1181
1181
  )
1182
+ data = export_location._info
1183
+ data.update(
1184
+ {
1185
+ 'properties':
1186
+ format_columns.DictColumn(data.pop('metadata', {})),
1187
+ },
1188
+ )
1182
1189
 
1183
- return self.dict2columns(export_location._info)
1190
+ return self.dict2columns(data)
1184
1191
 
1185
1192
 
1186
1193
  class ShareExportLocationList(command.Lister):
@@ -1218,6 +1225,120 @@ class ShareExportLocationList(command.Lister):
1218
1225
  (s, list_of_keys) for s in export_locations))
1219
1226
 
1220
1227
 
1228
+ class ShareExportLocationSet(command.Command):
1229
+ """Set an export location property."""
1230
+
1231
+ _description = _("Set an export location property.")
1232
+
1233
+ def get_parser(self, prog_name):
1234
+ parser = super(ShareExportLocationSet, self).get_parser(
1235
+ prog_name)
1236
+
1237
+ parser.add_argument(
1238
+ 'share',
1239
+ metavar="<share>",
1240
+ help=_('Name or ID of share')
1241
+ )
1242
+ parser.add_argument(
1243
+ 'export_location',
1244
+ metavar="<export_location>",
1245
+ help=_('ID of the export location')
1246
+ )
1247
+ parser.add_argument(
1248
+ "--property",
1249
+ metavar="<key=value>",
1250
+ default={},
1251
+ action=parseractions.KeyValueAction,
1252
+ help=_("Set a property to this export location "
1253
+ "(repeat option to set multiple properties). "
1254
+ "Available only for microversion >= 2.87."),
1255
+ )
1256
+ return parser
1257
+
1258
+ def take_action(self, parsed_args):
1259
+ share_client = self.app.client_manager.share
1260
+ share_id = apiutils.find_resource(
1261
+ share_client.shares,
1262
+ parsed_args.share).id
1263
+
1264
+ if (parsed_args.property and
1265
+ share_client.api_version < api_versions.APIVersion("2.87")):
1266
+ raise exceptions.CommandError(
1267
+ "Property can be specified only with manila API "
1268
+ "version >= 2.87.")
1269
+
1270
+ if parsed_args.property:
1271
+ try:
1272
+ share_client.share_export_locations.set_metadata(
1273
+ share_id,
1274
+ parsed_args.property,
1275
+ subresource=parsed_args.export_location)
1276
+ except Exception as e:
1277
+ raise exceptions.CommandError(_(
1278
+ "Failed to set export location property "
1279
+ "'%(properties)s': %(e)s") %
1280
+ {'properties': parsed_args.property, 'e': e}
1281
+ )
1282
+
1283
+
1284
+ class ShareExportLocationUnset(command.Command):
1285
+ """Unset a share export location property"""
1286
+ _description = _("Unset a share export location property")
1287
+
1288
+ def get_parser(self, prog_name):
1289
+ parser = super(ShareExportLocationUnset, self).get_parser(
1290
+ prog_name)
1291
+
1292
+ parser.add_argument(
1293
+ 'share',
1294
+ metavar="<share>",
1295
+ help=_('Name or ID of share')
1296
+ )
1297
+ parser.add_argument(
1298
+ 'export_location',
1299
+ metavar="<export_location>",
1300
+ help=_('ID of the export location')
1301
+ )
1302
+ parser.add_argument(
1303
+ "--property",
1304
+ metavar="<key>",
1305
+ action='append',
1306
+ help=_("Remove a property from export location "
1307
+ "(repeat option to remove multiple properties). "
1308
+ "Available only for microversion >= 2.87."),
1309
+ )
1310
+ return parser
1311
+
1312
+ def take_action(self, parsed_args):
1313
+ share_client = self.app.client_manager.share
1314
+ share_id = apiutils.find_resource(
1315
+ share_client.shares,
1316
+ parsed_args.share).id
1317
+
1318
+ if (parsed_args.property and
1319
+ share_client.api_version < api_versions.APIVersion("2.87")):
1320
+ raise exceptions.CommandError(
1321
+ "Property can be specified only with manila API "
1322
+ "version >= 2.87.")
1323
+
1324
+ if parsed_args.property:
1325
+ result = 0
1326
+ for key in parsed_args.property:
1327
+ try:
1328
+ share_client.share_export_locations.delete_metadata(
1329
+ share_id, [key],
1330
+ subresource=parsed_args.export_location)
1331
+ except Exception as e:
1332
+ result += 1
1333
+ LOG.error("Failed to unset export location property "
1334
+ "'%(key)s': %(e)s", {'key': key, 'e': e})
1335
+ if result > 0:
1336
+ total = len(parsed_args.property)
1337
+ raise exceptions.CommandError(
1338
+ f"{result} of {total} export location properties failed "
1339
+ f"to be unset.")
1340
+
1341
+
1221
1342
  class ShowShareProperties(command.ShowOne):
1222
1343
  """Show properties of a share"""
1223
1344
  _description = _("Show share properties")
@@ -356,6 +356,12 @@ class PromoteShareReplica(command.Command):
356
356
  help=_('Quiesce wait time in seconds. Available for '
357
357
  'microversion >= 2.75')
358
358
  )
359
+ parser.add_argument(
360
+ '--wait',
361
+ action='store_true',
362
+ default=False,
363
+ help=_('Wait for share replica promotion')
364
+ )
359
365
  return parser
360
366
 
361
367
  def take_action(self, parsed_args):
@@ -377,6 +383,15 @@ class PromoteShareReplica(command.Command):
377
383
 
378
384
  try:
379
385
  share_client.share_replicas.promote(*args)
386
+ if parsed_args.wait:
387
+ if not osc_utils.wait_for_status(
388
+ status_f=share_client.share_replicas.get,
389
+ res_id=replica.id,
390
+ success_status=['active'],
391
+ status_field='replica_state'
392
+ ):
393
+ LOG.error(_("ERROR: Share replica is in error state."))
394
+
380
395
  except Exception as e:
381
396
  raise exceptions.CommandError(_(
382
397
  "Failed to promote replica to 'active': %s" % (e)))
@@ -146,6 +146,23 @@ class ListShareServer(command.Lister):
146
146
  "Available for microversion >= 2.51 (Optional, "
147
147
  "Default=None)")
148
148
  )
149
+ parser.add_argument(
150
+ '--source-share-server-id',
151
+ metavar='<source-share-server-id>',
152
+ type=str,
153
+ default=None,
154
+ help=_("Share server ID to be used as a filter. Available for "
155
+ "microversion >= 2.57 (Optional, Default=None)")
156
+ )
157
+ parser.add_argument(
158
+ '--identifier',
159
+ metavar='<identifier>',
160
+ type=str,
161
+ default=None,
162
+ help=_("Identifier of the share server in the share back end. "
163
+ "Available for microversion >= 2.49 "
164
+ "(Optional, Default=None)")
165
+ )
149
166
  identity_common.add_project_domain_option_to_parser(parser)
150
167
  return parser
151
168
 
@@ -160,12 +177,24 @@ class ListShareServer(command.Lister):
160
177
  parsed_args.project,
161
178
  parsed_args.project_domain).id
162
179
 
180
+ if (parsed_args.identifier and
181
+ share_client.api_version < api_versions.APIVersion("2.49")):
182
+ raise exceptions.CommandError(
183
+ "Filtering by identifier is only allowed with manila API "
184
+ "version >= 2.49."
185
+ )
163
186
  if (parsed_args.share_network_subnet and
164
187
  share_client.api_version < api_versions.APIVersion("2.51")):
165
188
  raise exceptions.CommandError(
166
189
  "Share network subnet can be specified only with manila API "
167
190
  "version >= 2.51"
168
191
  )
192
+ if (parsed_args.source_share_server_id and
193
+ share_client.api_version < api_versions.APIVersion("2.57")):
194
+ raise exceptions.CommandError(
195
+ "Filtering by source_share_server_id is only allowed with "
196
+ "manila API version >= 2.57."
197
+ )
169
198
 
170
199
  columns = [
171
200
  'ID',
@@ -187,6 +216,16 @@ class ListShareServer(command.Lister):
187
216
  parsed_args.share_network).id
188
217
  search_opts['share_network'] = share_network_id
189
218
 
219
+ if parsed_args.source_share_server_id:
220
+ search_opts['source_share_server_id'] = (
221
+ parsed_args.source_share_server_id
222
+ )
223
+
224
+ if parsed_args.identifier:
225
+ search_opts['identifier'] = (
226
+ parsed_args.identifier
227
+ )
228
+
190
229
  if parsed_args.share_network_subnet:
191
230
  search_opts['share_network_subnet_id'] = (
192
231
  parsed_args.share_network_subnet)
@@ -330,6 +330,7 @@ class FakeShareExportLocation(object):
330
330
  "id": "id-" + uuid.uuid4().hex,
331
331
  "is_admin_only": False,
332
332
  "preferred": False,
333
+ "properties": {},
333
334
  "updated_at": 'time-' + uuid.uuid4().hex,
334
335
  }
335
336
 
@@ -1495,6 +1496,7 @@ class FakeShareServer(object):
1495
1496
  'share_network_name': None,
1496
1497
  'share_network_id': str(uuid.uuid4()),
1497
1498
  'share_network_subnet_id': str(uuid.uuid4()),
1499
+ 'source_share_server_id': str(uuid.uuid4()),
1498
1500
  'created_at': datetime.datetime.now().isoformat(),
1499
1501
  'is_auto_deletable': False,
1500
1502
  'identifier': str(uuid.uuid4())
@@ -1910,6 +1910,148 @@ class TestShareExportLocationList(TestShare):
1910
1910
  self.assertCountEqual(self.values, data)
1911
1911
 
1912
1912
 
1913
+ class TestExportLocationSet(TestShare):
1914
+
1915
+ def setUp(self):
1916
+ super(TestExportLocationSet, self).setUp()
1917
+
1918
+ self._share = manila_fakes.FakeShare.create_one_share(
1919
+ methods={"set_metadata": None}
1920
+ )
1921
+ self.shares_mock.get.return_value = self._share
1922
+
1923
+ self._export_location = (
1924
+ manila_fakes.FakeShareExportLocation.create_one_export_location(
1925
+ {'fake_share_instance_id': self._share.id}))
1926
+
1927
+ self.export_locations_mock.get.return_value = (
1928
+ self._export_location
1929
+ )
1930
+
1931
+ self.cmd = osc_shares.ShareExportLocationSet(self.app, None)
1932
+
1933
+ def test_share_set_export_location_property(self):
1934
+ self.app.client_manager.share.api_version = api_versions.APIVersion(
1935
+ '2.87'
1936
+ )
1937
+ arglist = [
1938
+ self._share.id,
1939
+ self._export_location.id,
1940
+ '--property', 'Bobcat=manila',
1941
+
1942
+ ]
1943
+ verifylist = [
1944
+ ('share', self._share.id),
1945
+ ('export_location', self._export_location.id),
1946
+ ('property', {'Bobcat': 'manila'}),
1947
+ ]
1948
+
1949
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1950
+ self.cmd.take_action(parsed_args)
1951
+ self.export_locations_mock.set_metadata.assert_called_once_with(
1952
+ self._share.id, {'Bobcat': 'manila'},
1953
+ subresource=self._export_location.id)
1954
+
1955
+ def test_share_set_export_location_property_exception(self):
1956
+ self.app.client_manager.share.api_version = api_versions.APIVersion(
1957
+ '2.87'
1958
+ )
1959
+ arglist = [
1960
+ self._share.id,
1961
+ self._export_location.id,
1962
+ '--property', 'key=',
1963
+ ]
1964
+ verifylist = [
1965
+ ('share', self._share.id),
1966
+ ('export_location', self._export_location.id),
1967
+ ('property', {'key': ''}),
1968
+ ]
1969
+
1970
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1971
+ self.cmd.take_action(parsed_args)
1972
+
1973
+ self.export_locations_mock.set_metadata.assert_called_once_with(
1974
+ self._share.id, {'key': ''},
1975
+ subresource=self._export_location.id)
1976
+
1977
+ self.export_locations_mock.set_metadata.side_effect = (
1978
+ exceptions.BadRequest)
1979
+ self.assertRaises(
1980
+ osc_exceptions.CommandError, self.cmd.take_action,
1981
+ parsed_args)
1982
+
1983
+
1984
+ class TestExportLocationUnset(TestShare):
1985
+
1986
+ def setUp(self):
1987
+ super(TestExportLocationUnset, self).setUp()
1988
+
1989
+ self._share = manila_fakes.FakeShare.create_one_share(
1990
+ methods={"set_metadata": None}
1991
+ )
1992
+ self.shares_mock.get.return_value = self._share
1993
+
1994
+ self._export_location = (
1995
+ manila_fakes.FakeShareExportLocation.create_one_export_location(
1996
+ {'fake_share_instance_id': self._share.id}))
1997
+
1998
+ self.export_locations_mock.get.return_value = (
1999
+ self._export_location
2000
+ )
2001
+
2002
+ self.cmd = osc_shares.ShareExportLocationUnset(self.app, None)
2003
+
2004
+ def test_share_unset_export_location_property(self):
2005
+ self.app.client_manager.share.api_version = api_versions.APIVersion(
2006
+ '2.87'
2007
+ )
2008
+ arglist = [
2009
+ self._share.id,
2010
+ self._export_location.id,
2011
+ '--property', 'Bobcat',
2012
+
2013
+ ]
2014
+ verifylist = [
2015
+ ('share', self._share.id),
2016
+ ('export_location', self._export_location.id),
2017
+ ('property', ['Bobcat']),
2018
+ ]
2019
+
2020
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
2021
+ self.cmd.take_action(parsed_args)
2022
+ self.export_locations_mock.delete_metadata.assert_called_once_with(
2023
+ self._share.id, ['Bobcat'],
2024
+ subresource=self._export_location.id)
2025
+
2026
+ def test_share_unset_export_location_property_exception(self):
2027
+ self.app.client_manager.share.api_version = api_versions.APIVersion(
2028
+ '2.87'
2029
+ )
2030
+ arglist = [
2031
+ self._share.id,
2032
+ self._export_location.id,
2033
+ '--property', 'key',
2034
+ ]
2035
+ verifylist = [
2036
+ ('share', self._share.id),
2037
+ ('export_location', self._export_location.id),
2038
+ ('property', ['key']),
2039
+ ]
2040
+
2041
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
2042
+ self.cmd.take_action(parsed_args)
2043
+
2044
+ self.export_locations_mock.delete_metadata.assert_has_calls([
2045
+ mock.call(self._share.id, ['key'],
2046
+ subresource=self._export_location.id)])
2047
+
2048
+ self.export_locations_mock.delete_metadata.side_effect = (
2049
+ exceptions.NotFound)
2050
+ self.assertRaises(
2051
+ osc_exceptions.CommandError, self.cmd.take_action,
2052
+ parsed_args)
2053
+
2054
+
1913
2055
  class TestShowShareProperties(TestShare):
1914
2056
 
1915
2057
  properties = {
@@ -617,7 +617,10 @@ class TestShareReplicaPromote(TestShareReplica):
617
617
  super(TestShareReplicaPromote, self).setUp()
618
618
 
619
619
  self.share_replica = (
620
- manila_fakes.FakeShareReplica.create_one_replica()
620
+ manila_fakes.FakeShareReplica.create_one_replica(
621
+ attrs={
622
+ 'status': 'available'}
623
+ )
621
624
  )
622
625
  self.replicas_mock.get.return_value = self.share_replica
623
626
 
@@ -630,6 +633,7 @@ class TestShareReplicaPromote(TestShareReplica):
630
633
  ]
631
634
  verifylist = [
632
635
  ('replica', self.share_replica.id),
636
+ ('wait', False)
633
637
  ]
634
638
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
635
639
 
@@ -658,6 +662,28 @@ class TestShareReplicaPromote(TestShareReplica):
658
662
  wait_time)
659
663
  self.assertIsNone(result)
660
664
 
665
+ @mock.patch.object(osc_share_replicas.osc_utils, 'wait_for_status',
666
+ mock.Mock())
667
+ def test_share_replica_promote_wait(self):
668
+ arglist = [
669
+ self.share_replica.id,
670
+ '--wait'
671
+ ]
672
+ verifylist = [
673
+ ('replica', self.share_replica.id),
674
+ ('wait', True)
675
+ ]
676
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
677
+
678
+ result = self.cmd.take_action(parsed_args)
679
+
680
+ self.replicas_mock.promote.assert_called_with(
681
+ self.share_replica)
682
+ self.assertIsNone(result)
683
+ osc_share_replicas.osc_utils.wait_for_status.assert_called_once_with(
684
+ status_f=self.replicas_mock.get, res_id=self.share_replica.id,
685
+ success_status=['active'], status_field='replica_state')
686
+
661
687
  def test_share_replica_promote_exception(self):
662
688
  arglist = [
663
689
  self.share_replica.id,
@@ -219,6 +219,56 @@ class TestListShareServer(TestShareServer):
219
219
  self.assertEqual(self.columns, columns)
220
220
  self.assertEqual(list(self.values), list(data))
221
221
 
222
+ def test_share_server_list_by_source_share_server(self):
223
+ expected_source_share_server_id = (
224
+ self.servers_list[0].source_share_server_id
225
+ )
226
+ arglist = [
227
+ '--source-share-server-id', expected_source_share_server_id,
228
+ ]
229
+ verifylist = [
230
+ ('source_share_server_id', expected_source_share_server_id),
231
+ ]
232
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
233
+
234
+ columns, data = self.cmd.take_action(parsed_args)
235
+
236
+ search_opts = {
237
+ 'status': None,
238
+ 'host': None,
239
+ 'project_id': None,
240
+ 'source_share_server_id': expected_source_share_server_id,
241
+ }
242
+
243
+ self.servers_mock.list.assert_called_once_with(
244
+ search_opts=search_opts,
245
+ )
246
+
247
+ self.assertEqual(self.columns, columns)
248
+ self.assertEqual(list(self.values), list(data))
249
+
250
+ def test_share_server_list_by_identifier(self):
251
+ expected_identifier = self.servers_list[0].identifier
252
+ arglist = ['--identifier', expected_identifier,]
253
+ verifylist = [('identifier', expected_identifier),]
254
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
255
+
256
+ columns, data = self.cmd.take_action(parsed_args)
257
+
258
+ search_opts = {
259
+ 'status': None,
260
+ 'host': None,
261
+ 'project_id': None,
262
+ 'identifier': expected_identifier,
263
+ }
264
+
265
+ self.servers_mock.list.assert_called_once_with(
266
+ search_opts=search_opts,
267
+ )
268
+
269
+ self.assertEqual(self.columns, columns)
270
+ self.assertEqual(list(self.values), list(data))
271
+
222
272
 
223
273
  class TestAdoptShareServer(TestShareServer):
224
274
 
@@ -224,12 +224,15 @@ class FakeHTTPClient(fakes.FakeHTTPClient):
224
224
 
225
225
  def get_shares_detail(self, **kw):
226
226
  endpoint = "http://127.0.0.1:8786/v2"
227
- share_id = '1234'
227
+ share_id1234 = '1234'
228
+ share_id1111 = '1111'
229
+ share_id2222 = '2222'
230
+ share_id3333 = '3333'
228
231
 
229
232
  shares = {
230
233
  'shares': [
231
234
  {
232
- 'id': share_id,
235
+ 'id': share_id1234,
233
236
  'name': 'sharename',
234
237
  'status': 'fake_status',
235
238
  'size': 1,
@@ -237,9 +240,52 @@ class FakeHTTPClient(fakes.FakeHTTPClient):
237
240
  'export_location': 'fake_export_location',
238
241
  'snapshot_id': 'fake_snapshot_id',
239
242
  'links': [
240
- {"href": endpoint + "/fake_project/shares/" + share_id,
241
- "rel": "self"},
243
+ {"href": endpoint + "/fake_project/shares/"
244
+ + share_id1234, "rel": "self"},
245
+ ],
246
+ 'metadata': {}
247
+ },
248
+ {
249
+ 'id': share_id1111,
250
+ 'name': 'sharename1',
251
+ 'status': 'fake_status1',
252
+ 'size': 1,
253
+ 'host': 'fake_host',
254
+ 'export_location': 'fake_export_location',
255
+ 'snapshot_id': 'fake_snapshot_id',
256
+ 'links': [
257
+ {"href": endpoint + "/fake_project/shares/"
258
+ + share_id1111, "rel": "self"},
259
+ ],
260
+ 'metadata': {}
261
+ },
262
+ {
263
+ 'id': share_id2222,
264
+ 'name': 'sharename2',
265
+ 'status': 'fake_status2',
266
+ 'size': 1,
267
+ 'host': 'fake_host',
268
+ 'export_location': 'fake_export_location',
269
+ 'snapshot_id': 'fake_snapshot_id',
270
+ 'links': [
271
+ {"href": endpoint + "/fake_project/shares/"
272
+ + share_id2222, "rel": "self"},
273
+ ],
274
+ 'metadata': {'key1': 'value1'}
275
+ },
276
+ {
277
+ 'id': share_id3333,
278
+ 'name': 'sharename3',
279
+ 'status': 'fake_status3',
280
+ 'size': 1,
281
+ 'host': 'fake_host',
282
+ 'export_location': 'fake_export_location',
283
+ 'snapshot_id': 'fake_snapshot_id',
284
+ 'links': [
285
+ {"href": endpoint + "/fake_project/shares/"
286
+ + share_id3333, "rel": "self"},
242
287
  ],
288
+ 'metadata': {'key1': 'value1', 'key2': 'value2'}
243
289
  },
244
290
  ],
245
291
  }
@@ -139,7 +139,7 @@ class ClientTest(utils.TestCase):
139
139
 
140
140
  def _get_client_args(self, **kwargs):
141
141
  client_args = {
142
- 'auth_url': 'both',
142
+ 'auth_url': 'http://identity.example.com',
143
143
  'api_version': manilaclient.API_DEPRECATED_VERSION,
144
144
  'username': 'fake_username',
145
145
  'service_type': 'sharev2',
@@ -160,17 +160,17 @@ class ClientTest(utils.TestCase):
160
160
  return client_args
161
161
 
162
162
  @ddt.data(
163
- {'auth_url': 'only_v3', 'password': 'password_backward_compat',
164
- 'endpoint_type': 'publicURL', 'project_id': 'foo_tenant_project_id'},
163
+ {'auth_url': 'http://identity.example.com',
164
+ 'password': 'password_backward_compat',
165
+ 'endpoint_type': 'publicURL',
166
+ 'project_id': 'foo_tenant_project_id'},
165
167
  {'password': 'renamed_api_key', 'endpoint_type': 'public',
166
168
  'tenant_id': 'foo_tenant_project_id'},
167
169
  )
168
- def test_client_init_no_session_no_auth_token_v3(self, kwargs):
170
+ def test_client_init_no_session_no_auth_token(self, kwargs):
169
171
  def fake_url_for(version):
170
172
  if version == 'v3.0':
171
173
  return 'url_v3.0'
172
- elif version == 'v2.0' and self.auth_url == 'both':
173
- return 'url_v2.0'
174
174
  else:
175
175
  return None
176
176
 
@@ -232,55 +232,6 @@ class ClientTest(utils.TestCase):
232
232
  client_args['service_type'])
233
233
  mocked_ks_client.authenticate.assert_called_with()
234
234
 
235
- @ddt.data(
236
- {'auth_url': 'only_v2', 'password': 'foo', 'project_id': 'bar'},
237
- {'password': 'foo', 'tenant_id': 'bar'},
238
- )
239
- def test_client_init_no_session_no_auth_token_v2(self, kwargs):
240
- self.mock_object(client.httpclient, 'HTTPClient')
241
- self.mock_object(client.ks_client, 'Client')
242
- self.mock_object(client.session.discover, 'Discover')
243
- self.mock_object(client.session, 'Session')
244
- client_args = self._get_client_args(**kwargs)
245
- client_args['api_version'] = manilaclient.API_MIN_VERSION
246
- self.auth_url = client_args['auth_url']
247
- catalog = {
248
- 'share': [
249
- {'region': 'SecondRegion', 'publicUrl': 'http://4.4.4.4'},
250
- ],
251
- 'sharev2': [
252
- {'region': 'FirstRegion', 'publicUrl': 'http://1.1.1.1'},
253
- {'region': 'secondregion', 'publicUrl': 'http://2.2.2.2'},
254
- {'region': 'SecondRegion', 'internalUrl': 'http://3.3.3.1',
255
- 'publicUrl': 'http://3.3.3.3', 'adminUrl': 'http://3.3.3.2'},
256
- ],
257
- }
258
- client.session.discover.Discover.return_value.url_for.side_effect = (
259
- lambda v: 'url_v2.0' if v == 'v2.0' else None)
260
- client.ks_client.Client.return_value.auth_token.return_value = (
261
- 'fake_token')
262
- mocked_ks_client = client.ks_client.Client.return_value
263
- mocked_ks_client.service_catalog.get_endpoints.return_value = catalog
264
-
265
- client.Client(**client_args)
266
-
267
- client.httpclient.HTTPClient.assert_called_with(
268
- 'http://3.3.3.3', mock.ANY, 'python-manilaclient', insecure=False,
269
- cacert=None, cert=client_args['cert'], timeout=None, retries=None,
270
- http_log_debug=False, api_version=manilaclient.API_MIN_VERSION)
271
- client.ks_client.Client.assert_called_with(
272
- session=mock.ANY, version=(2, 0), auth_url='url_v2.0',
273
- username=client_args['username'],
274
- password=client_args.get('password'),
275
- tenant_id=client_args.get('tenant_id',
276
- client_args.get('project_id')),
277
- tenant_name=client_args['project_name'],
278
- region_name=client_args['region_name'], cert=client_args['cert'],
279
- use_keyring=False, force_new_token=False, stale_duration=300)
280
- mocked_ks_client.service_catalog.get_endpoints.assert_called_with(
281
- client_args['service_type'])
282
- mocked_ks_client.authenticate.assert_called_with()
283
-
284
235
  @mock.patch.object(client.ks_client, 'Client', mock.Mock())
285
236
  @mock.patch.object(client.session.discover, 'Discover', mock.Mock())
286
237
  @mock.patch.object(client.session, 'Session', mock.Mock())