python-manilaclient 4.7.0__py3-none-any.whl → 4.9.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 (37) hide show
  1. manilaclient/api_versions.py +1 -1
  2. manilaclient/base.py +2 -2
  3. manilaclient/common/cliutils.py +2 -2
  4. manilaclient/osc/v2/quotas.py +0 -1
  5. manilaclient/osc/v2/services.py +26 -2
  6. manilaclient/osc/v2/share.py +19 -2
  7. manilaclient/osc/v2/share_network_subnets.py +10 -0
  8. manilaclient/tests/functional/base.py +1 -1
  9. manilaclient/tests/functional/client.py +4 -16
  10. manilaclient/tests/functional/osc/base.py +4 -2
  11. manilaclient/tests/functional/osc/test_resource_locks.py +4 -4
  12. manilaclient/tests/functional/osc/test_share_access_rules.py +2 -2
  13. manilaclient/tests/functional/osc/test_share_network_subnets.py +2 -2
  14. manilaclient/tests/functional/osc/test_share_services.py +2 -1
  15. manilaclient/tests/functional/osc/test_share_snapshot_instances.py +75 -0
  16. manilaclient/tests/unit/fakes.py +1 -1
  17. manilaclient/tests/unit/osc/v2/fakes.py +1 -0
  18. manilaclient/tests/unit/osc/v2/test_quotas.py +17 -7
  19. manilaclient/tests/unit/osc/v2/test_services.py +69 -12
  20. manilaclient/tests/unit/osc/v2/test_share.py +59 -5
  21. manilaclient/tests/unit/v2/fakes.py +3 -2
  22. manilaclient/tests/unit/v2/test_limits.py +2 -2
  23. manilaclient/tests/unit/v2/test_share_networks.py +2 -2
  24. manilaclient/tests/unit/v2/test_shares.py +23 -0
  25. manilaclient/tests/unit/v2/test_shell.py +125 -2
  26. manilaclient/v2/services.py +10 -2
  27. manilaclient/v2/shares.py +10 -1
  28. manilaclient/v2/shell.py +51 -30
  29. {python_manilaclient-4.7.0.dist-info → python_manilaclient-4.9.0.dist-info}/AUTHORS +7 -0
  30. {python_manilaclient-4.7.0.dist-info → python_manilaclient-4.9.0.dist-info}/METADATA +3 -1
  31. {python_manilaclient-4.7.0.dist-info → python_manilaclient-4.9.0.dist-info}/RECORD +36 -35
  32. python_manilaclient-4.9.0.dist-info/pbr.json +1 -0
  33. python_manilaclient-4.7.0.dist-info/pbr.json +0 -1
  34. {python_manilaclient-4.7.0.dist-info → python_manilaclient-4.9.0.dist-info}/LICENSE +0 -0
  35. {python_manilaclient-4.7.0.dist-info → python_manilaclient-4.9.0.dist-info}/WHEEL +0 -0
  36. {python_manilaclient-4.7.0.dist-info → python_manilaclient-4.9.0.dist-info}/entry_points.txt +0 -0
  37. {python_manilaclient-4.7.0.dist-info → python_manilaclient-4.9.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.82'
30
+ MAX_VERSION = '2.84'
31
31
  MIN_VERSION = '2.0'
32
32
  DEPRECATED_VERSION = '1.0'
33
33
  _VERSIONED_METHOD_MAP = {}
manilaclient/base.py CHANGED
@@ -129,8 +129,8 @@ class Manager(utils.HookableMixin):
129
129
  # pair
130
130
  username = cliutils.env('OS_USERNAME', 'MANILA_USERNAME')
131
131
  url = cliutils.env('OS_URL', 'MANILA_URL')
132
- uniqifier = hashlib.sha1(username.encode('utf-8') +
133
- url.encode('utf-8')).hexdigest()
132
+ uniqifier = hashlib.sha256(username.encode('utf-8') +
133
+ url.encode('utf-8')).hexdigest()
134
134
 
135
135
  cache_dir = os.path.expanduser(os.path.join(base_dir, uniqifier))
136
136
 
@@ -251,8 +251,8 @@ def get_service_type(f):
251
251
  return getattr(f, 'service_type', None)
252
252
 
253
253
 
254
- def pretty_choice_list(l):
255
- return ', '.join("'%s'" % i for i in l)
254
+ def pretty_choice_list(choices):
255
+ return ', '.join("'%s'" % choice for choice in choices)
256
256
 
257
257
 
258
258
  def exit(msg=''):
@@ -160,7 +160,6 @@ class QuotaSet(command.Command):
160
160
  "gigabytes": parsed_args.gigabytes,
161
161
  "snapshot_gigabytes": parsed_args.snapshot_gigabytes,
162
162
  "share_networks": parsed_args.share_networks,
163
- "per_share_gigabytes": parsed_args.per_share_gigabytes,
164
163
  }
165
164
 
166
165
  if parsed_args.share_type is not None:
@@ -13,6 +13,7 @@ from osc_lib.command import command
13
13
  from osc_lib import exceptions
14
14
  from osc_lib import utils as osc_utils
15
15
 
16
+ from manilaclient import api_versions
16
17
  from manilaclient.common._i18n import _
17
18
 
18
19
 
@@ -44,9 +45,20 @@ class SetShareService(command.Command):
44
45
  action='store_true',
45
46
  help=_('Disable share service'),
46
47
  )
48
+ parser.add_argument(
49
+ "--disable-reason",
50
+ metavar="<reason>",
51
+ help=_("Reason for disabling the service "
52
+ "(should be used with --disable option)")
53
+ )
47
54
  return parser
48
55
 
49
56
  def take_action(self, parsed_args):
57
+ if parsed_args.disable_reason and not parsed_args.disable:
58
+ msg = _("Cannot specify option --disable-reason without "
59
+ "--disable specified.")
60
+ raise exceptions.CommandError(msg)
61
+
50
62
  share_client = self.app.client_manager.share
51
63
 
52
64
  if parsed_args.enable:
@@ -58,9 +70,19 @@ class SetShareService(command.Command):
58
70
  "Failed to enable service: %s" % e))
59
71
 
60
72
  if parsed_args.disable:
73
+ if parsed_args.disable_reason:
74
+ if share_client.api_version < api_versions.APIVersion("2.83"):
75
+ raise exceptions.CommandError(
76
+ "Service disable reason can be specified only with "
77
+ "manila API version >= 2.83")
61
78
  try:
62
- share_client.services.disable(
63
- parsed_args.host, parsed_args.binary)
79
+ if parsed_args.disable_reason:
80
+ share_client.services.disable(
81
+ parsed_args.host, parsed_args.binary,
82
+ disable_reason=parsed_args.disable_reason)
83
+ else:
84
+ share_client.services.disable(
85
+ parsed_args.host, parsed_args.binary)
64
86
  except Exception as e:
65
87
  raise exceptions.CommandError(_(
66
88
  "Failed to disable service: %s" % e))
@@ -127,6 +149,8 @@ class ListShareService(command.Lister):
127
149
  'State',
128
150
  'Updated At'
129
151
  ]
152
+ if share_client.api_version >= api_versions.APIVersion("2.83"):
153
+ columns.append('Disabled Reason')
130
154
 
131
155
  data = (osc_utils.get_dict_properties(
132
156
  service._info, columns) for service in services)
@@ -188,6 +188,13 @@ class CreateShare(command.ShowOne):
188
188
  "possible keys are same_host, different_host."
189
189
  "(repeat option to set multiple hints)"),
190
190
  )
191
+ parser.add_argument(
192
+ '--mount-point-name',
193
+ metavar="<mount_point_name>",
194
+ default=None,
195
+ help=_('Optional custom export location. Available for '
196
+ 'microversion >= 2.84')
197
+ )
191
198
 
192
199
  return parser
193
200
 
@@ -232,6 +239,15 @@ class CreateShare(command.ShowOne):
232
239
  snapshot_id = snapshot.id
233
240
  size = max(size or 0, snapshot.size)
234
241
 
242
+ mount_point_name = None
243
+ if parsed_args.mount_point_name:
244
+ if share_client.api_version < api_versions.APIVersion('2.84'):
245
+ raise exceptions.CommandError(
246
+ 'Setting share mount point name is '
247
+ 'available only for API microversion >= 2.84')
248
+ else:
249
+ mount_point_name = parsed_args.mount_point_name
250
+
235
251
  scheduler_hints = {}
236
252
  if parsed_args.scheduler_hint:
237
253
  if share_client.api_version < api_versions.APIVersion('2.65'):
@@ -271,7 +287,8 @@ class CreateShare(command.ShowOne):
271
287
  'is_public': parsed_args.public,
272
288
  'availability_zone': parsed_args.availability_zone,
273
289
  'share_group_id': share_group,
274
- 'scheduler_hints': scheduler_hints
290
+ 'scheduler_hints': scheduler_hints,
291
+ 'mount_point_name': mount_point_name,
275
292
  }
276
293
 
277
294
  share = share_client.shares.create(**body)
@@ -350,7 +367,7 @@ class DeleteShare(command.Command):
350
367
 
351
368
  if parsed_args.force:
352
369
  share_client.shares.force_delete(share_obj)
353
- if parsed_args.soft:
370
+ elif parsed_args.soft:
354
371
  if share_client.api_version >= api_versions.APIVersion(
355
372
  '2.69'):
356
373
  share_client.shares.soft_delete(share_obj)
@@ -21,6 +21,7 @@ from osc_lib import utils as oscutils
21
21
 
22
22
  from manilaclient import api_versions
23
23
  from manilaclient.common._i18n import _
24
+ from manilaclient.common import cliutils
24
25
 
25
26
 
26
27
  LOG = logging.getLogger(__name__)
@@ -135,6 +136,15 @@ class CreateShareNetworkSubnet(command.ShowOne):
135
136
  share_network_id=share_network_id)
136
137
  )
137
138
  subnet_data = subnet_create_check[1]
139
+ if subnet_data:
140
+ if parsed_args.formatter == 'table':
141
+ for k, v in subnet_data.items():
142
+ if isinstance(v, dict):
143
+ capabilities_list = [v]
144
+ dict_values = cliutils.convert_dict_list_to_string(
145
+ capabilities_list
146
+ )
147
+ subnet_data[k] = dict_values
138
148
  else:
139
149
  share_network_subnet = share_client.share_network_subnets.create(
140
150
  neutron_net_id=parsed_args.neutron_net_id,
@@ -98,7 +98,7 @@ class BaseTestCase(base.ClientTestBase):
98
98
  res["deleted"] = False
99
99
  if "client" not in res:
100
100
  res["client"] = cls.get_cleanup_client()
101
- if not(res["deleted"]):
101
+ if not res["deleted"]:
102
102
  res_id = res["id"]
103
103
  client = res["client"]
104
104
  deletion_params = res.get("deletion_params")
@@ -453,24 +453,19 @@ class ManilaCLIClient(base.CLIClient):
453
453
  # Share networks
454
454
 
455
455
  def create_share_network(self, name=None, description=None,
456
- nova_net_id=None, neutron_net_id=None,
457
- neutron_subnet_id=None, availability_zone=None,
456
+ neutron_net_id=None, neutron_subnet_id=None,
457
+ availability_zone=None,
458
458
  microversion=None):
459
459
  """Creates share network.
460
460
 
461
461
  :param name: text -- desired name of new share network
462
462
  :param description: text -- desired description of new share network
463
- :param nova_net_id: text -- ID of Nova network
464
463
  :param neutron_net_id: text -- ID of Neutron network
465
464
  :param neutron_subnet_id: text -- ID of Neutron subnet
466
-
467
- NOTE: 'nova_net_id' and 'neutron_net_id'/'neutron_subnet_id' are
468
- mutually exclusive.
469
465
  """
470
466
  params = self._combine_share_network_data(
471
467
  name=name,
472
468
  description=description,
473
- nova_net_id=nova_net_id,
474
469
  neutron_net_id=neutron_net_id,
475
470
  neutron_subnet_id=neutron_subnet_id,
476
471
  availability_zone=availability_zone
@@ -481,7 +476,7 @@ class ManilaCLIClient(base.CLIClient):
481
476
  return share_network
482
477
 
483
478
  def _combine_share_network_data(self, name=None, description=None,
484
- nova_net_id=None, neutron_net_id=None,
479
+ neutron_net_id=None,
485
480
  neutron_subnet_id=None,
486
481
  availability_zone=None):
487
482
  """Combines params for share network operations 'create' and 'update'.
@@ -493,8 +488,6 @@ class ManilaCLIClient(base.CLIClient):
493
488
  data['--name'] = name
494
489
  if description is not None:
495
490
  data['--description'] = description
496
- if nova_net_id is not None:
497
- data['--nova_net_id'] = nova_net_id
498
491
  if neutron_net_id is not None:
499
492
  data['--neutron_net_id'] = neutron_net_id
500
493
  if neutron_subnet_id is not None:
@@ -516,23 +509,18 @@ class ManilaCLIClient(base.CLIClient):
516
509
 
517
510
  @not_found_wrapper
518
511
  def update_share_network(self, share_network, name=None, description=None,
519
- nova_net_id=None, neutron_net_id=None,
512
+ neutron_net_id=None,
520
513
  neutron_subnet_id=None, microversion=None):
521
514
  """Updates share-network by its name or ID.
522
515
 
523
516
  :param name: text -- new name for share network
524
517
  :param description: text -- new description for share network
525
- :param nova_net_id: text -- ID of some Nova network
526
518
  :param neutron_net_id: text -- ID of some Neutron network
527
519
  :param neutron_subnet_id: text -- ID of some Neutron subnet
528
-
529
- NOTE: 'nova_net_id' and 'neutron_net_id'/'neutron_subnet_id' are
530
- mutually exclusive.
531
520
  """
532
521
  sn_params = self._combine_share_network_data(
533
522
  name=name,
534
523
  description=description,
535
- nova_net_id=nova_net_id,
536
524
  neutron_net_id=neutron_net_id,
537
525
  neutron_subnet_id=neutron_subnet_id)
538
526
  share_network_raw = self.manila(
@@ -145,7 +145,7 @@ class OSCClientTestBase(base.ClientTestBase):
145
145
  snapshot_id=None, properties=None, share_network=None,
146
146
  description=None, public=False, share_type=None,
147
147
  availability_zone=None, share_group=None,
148
- add_cleanup=True, client=None,
148
+ add_cleanup=True, client=None, wait=None,
149
149
  wait_for_status='available'):
150
150
 
151
151
  name = name or data_utils.rand_name('autotest_share_name')
@@ -174,6 +174,8 @@ class OSCClientTestBase(base.ClientTestBase):
174
174
  cmd = cmd + ' --availability-zone %s' % availability_zone
175
175
  if share_group:
176
176
  cmd = cmd + ' --share-group %s' % share_group
177
+ if wait:
178
+ cmd = cmd + ' --wait'
177
179
 
178
180
  share_object = self.dict_result('share', cmd, client=client)
179
181
  self._wait_for_object_status(
@@ -422,7 +424,7 @@ class OSCClientTestBase(base.ClientTestBase):
422
424
  if availability_zone:
423
425
  cmd += f' --availability-zone {availability_zone}'
424
426
  if restart_check:
425
- cmd += f' --restart-check'
427
+ cmd += ' --restart-check'
426
428
 
427
429
  check_result = self.dict_result('share', cmd)
428
430
  return check_result
@@ -109,7 +109,7 @@ class ResourceLockTests(base.OSCClientTestBase):
109
109
  'lock list --lock-context user '
110
110
  f' --resource {self.share["id"]}')
111
111
  self.assertEqual(2, len(locks))
112
- self.assertNotIn(lock_3['id'], [l['ID'] for l in locks])
112
+ self.assertNotIn(lock_3['id'], [lock['ID'] for lock in locks])
113
113
 
114
114
  locks = self.listing_result('share',
115
115
  'lock list --lock-context user'
@@ -118,9 +118,9 @@ class ResourceLockTests(base.OSCClientTestBase):
118
118
  ' --sort-dir desc '
119
119
  ' --limit 1')
120
120
  self.assertEqual(1, len(locks))
121
- self.assertIn(lock_2['id'], [l['ID'] for l in locks])
122
- self.assertNotIn(lock_1['id'], [l['ID'] for l in locks])
123
- self.assertNotIn(lock_3['id'], [l['ID'] for l in locks])
121
+ self.assertIn(lock_2['id'], [lock['ID'] for lock in locks])
122
+ self.assertNotIn(lock_1['id'], [lock['ID'] for lock in locks])
123
+ self.assertNotIn(lock_3['id'], [lock['ID'] for lock in locks])
124
124
 
125
125
  def test_lock_set_unset_lock_reason(self):
126
126
  lock = self.create_resource_lock(self.share['id'],
@@ -186,7 +186,7 @@ class ListShareAccessRulesTestCase(base.OSCClientTestBase):
186
186
  output = self.openstack(
187
187
  'share',
188
188
  params=f'access list {share["id"]} --access-to {access_to_filter}',
189
- flags=f'--os-share-api-version 2.82')
189
+ flags='--os-share-api-version 2.82')
190
190
  access_rule_list = self.parser.listing(output)
191
191
 
192
192
  self.assertTrue(len(access_rule_list) == 1)
@@ -214,7 +214,7 @@ class ShowShareAccessRulesTestCase(base.OSCClientTestBase):
214
214
  self.assertEqual(access_rule_show['created_at'],
215
215
  access_rule['created_at'])
216
216
  self.assertEqual(access_rule_show['properties'], '')
217
- self.assertTrue('updated_at' in access_rule_show)
217
+ self.assertIn('updated_at', access_rule_show)
218
218
 
219
219
 
220
220
  class SetShareAccessTestCase(base.OSCClientTestBase):
@@ -25,7 +25,7 @@ class ShareNetworkSubnetsCLITest(base.OSCClientTestBase):
25
25
  share_network['id'])
26
26
 
27
27
  self.assertEqual('True', check_result['compatible'])
28
- self.assertEqual('{}', check_result['hosts_check_result'])
28
+ self.assertEqual('', check_result['hosts_check_result'])
29
29
 
30
30
  def test_openstack_share_network_create_check_restart(self):
31
31
  share_network = self.create_share_network()
@@ -34,4 +34,4 @@ class ShareNetworkSubnetsCLITest(base.OSCClientTestBase):
34
34
  share_network['id'], restart_check=True)
35
35
 
36
36
  self.assertEqual('True', check_result['compatible'])
37
- self.assertEqual('{}', check_result['hosts_check_result'])
37
+ self.assertEqual('', check_result['hosts_check_result'])
@@ -45,11 +45,12 @@ class ShareServicesTestCase(base.OSCClientTestBase):
45
45
  first_service = service[0]
46
46
  self.openstack(f'share service set {first_service["Host"]} '
47
47
  f'{first_service["Binary"]} '
48
- '--disable')
48
+ '--disable --disable-reason test')
49
49
  result = self.listing_result('share service',
50
50
  'list --status disabled')
51
51
  self.assertEqual(first_service['ID'], result[0]['ID'])
52
52
  self.assertEqual('disabled', result[0]['Status'])
53
+ self.assertEqual('test', result[0]['Disabled Reason'])
53
54
 
54
55
  # enable the share service again
55
56
  self.openstack(f'share service set {first_service["Host"]} '
@@ -0,0 +1,75 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+ # not use this file except in compliance with the License. You may obtain
3
+ # a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+ # License for the specific language governing permissions and limitations
11
+ # under the License.
12
+
13
+ from manilaclient.tests.functional.osc import base
14
+
15
+
16
+ class ShareSnapshotInstancesCLITest(base.OSCClientTestBase):
17
+
18
+ def test_openstack_share_snapshot_instance_list(self):
19
+ share = self.create_share()
20
+ snapshot = self.create_snapshot(share['id'])
21
+ share_snapshot_instances_list = self.listing_result(
22
+ 'share snapshot instance', 'list --detailed')
23
+ self.assertTableStruct(share_snapshot_instances_list, [
24
+ 'ID',
25
+ 'Snapshot ID',
26
+ 'Status',
27
+ 'Created At',
28
+ 'Updated At',
29
+ 'Share ID',
30
+ 'Share Instance ID',
31
+ 'Progress',
32
+ 'Provider Location'
33
+ ])
34
+ self.assertIn(snapshot['id'],
35
+ [item['Snapshot ID'] for item in (
36
+ share_snapshot_instances_list)])
37
+
38
+ def test_openstack_share_snapshot_instance_show(self):
39
+ share = self.create_share()
40
+ snapshot = self.create_snapshot(share['id'], wait=True)
41
+
42
+ share_snapshot_instance = self.listing_result(
43
+ "share snapshot instance", f'list --snapshot {snapshot["id"]}')
44
+ result = self.dict_result('share snapshot instance',
45
+ f'show {share_snapshot_instance[0]["ID"]}')
46
+
47
+ self.assertEqual(share_snapshot_instance[0]['ID'], result['id'])
48
+ self.assertEqual(share_snapshot_instance[0]['Snapshot ID'],
49
+ result['snapshot_id'])
50
+
51
+ listing_result = self.listing_result(
52
+ 'share snapshot instance', f'show '
53
+ f'{share_snapshot_instance[0]["ID"]}')
54
+ self.assertTableStruct(listing_result, [
55
+ 'Field',
56
+ 'Value'
57
+ ])
58
+
59
+ def test_openstack_share_snapshot_instance_set(self):
60
+ share = self.create_share()
61
+ snapshot = self.create_snapshot(share['id'], wait=True)
62
+ share_snapshot_instance = self.listing_result(
63
+ "share snapshot instance", f'list --snapshot {snapshot["id"]}')
64
+ result1 = self.dict_result('share snapshot instance',
65
+ f'show {share_snapshot_instance[0]["ID"]}')
66
+ self.assertEqual(share_snapshot_instance[0]['ID'], result1['id'])
67
+ self.assertEqual(snapshot['id'], result1['snapshot_id'])
68
+ self.assertEqual('available', result1['status'])
69
+
70
+ self.openstack('share snapshot instance set '
71
+ f'{share_snapshot_instance[0]["ID"]} --status error')
72
+ result2 = self.dict_result('share snapshot instance',
73
+ f'show {share_snapshot_instance[0]["ID"]}')
74
+ self.assertEqual(share_snapshot_instance[0]["ID"], result2['id'])
75
+ self.assertEqual('error', result2['status'])
@@ -65,7 +65,7 @@ class FakeClient(object):
65
65
  break
66
66
 
67
67
  assert found, 'Expected %s %s; got %s' % (
68
- expected, self.client.callstack)
68
+ expected[0], expected[1], self.client.callstack)
69
69
 
70
70
  if body is not None:
71
71
  try:
@@ -139,6 +139,7 @@ class FakeShare(object):
139
139
  "revert_to_snapshot_support": False,
140
140
  "source_share_group_snapshot_member_id": None,
141
141
  "scheduler_hints": {},
142
+ "mount_point_name": None,
142
143
  }
143
144
 
144
145
  # Overwrite default attributes.
@@ -78,8 +78,7 @@ class TestQuotaSet(TestQuotas):
78
78
  share_networks=None,
79
79
  shares=40,
80
80
  snapshot_gigabytes=None,
81
- snapshots=None,
82
- per_share_gigabytes=None)
81
+ snapshots=None)
83
82
  self.assertIsNone(result)
84
83
  mock_find_resource.assert_not_called()
85
84
  self.quotas_mock.assert_not_called()
@@ -107,7 +106,6 @@ class TestQuotaSet(TestQuotas):
107
106
  shares=40,
108
107
  snapshot_gigabytes=None,
109
108
  snapshots=None,
110
- per_share_gigabytes=None,
111
109
  tenant_id=self.project.id,
112
110
  user_id=None)
113
111
  self.assertIsNone(result)
@@ -135,7 +133,6 @@ class TestQuotaSet(TestQuotas):
135
133
  shares=None,
136
134
  snapshot_gigabytes=None,
137
135
  snapshots=None,
138
- per_share_gigabytes=None,
139
136
  tenant_id=self.project.id,
140
137
  user_id=None)
141
138
  self.assertIsNone(result)
@@ -164,7 +161,6 @@ class TestQuotaSet(TestQuotas):
164
161
  shares=None,
165
162
  snapshot_gigabytes=None,
166
163
  snapshots=None,
167
- per_share_gigabytes=None,
168
164
  tenant_id=self.project.id,
169
165
  user_id=None)
170
166
  self.assertIsNone(result)
@@ -195,7 +191,6 @@ class TestQuotaSet(TestQuotas):
195
191
  snapshot_gigabytes=None,
196
192
  snapshots=None,
197
193
  tenant_id=self.project.id,
198
- per_share_gigabytes=None,
199
194
  user_id=None)
200
195
  self.assertIsNone(result)
201
196
 
@@ -290,7 +285,6 @@ class TestQuotaSet(TestQuotas):
290
285
  shares=None,
291
286
  snapshot_gigabytes=None,
292
287
  snapshots=None,
293
- per_share_gigabytes=None,
294
288
  tenant_id=self.project.id,
295
289
  user_id=None)
296
290
  self.assertIsNone(result)
@@ -311,6 +305,22 @@ class TestQuotaSet(TestQuotas):
311
305
  self.assertRaises(
312
306
  exceptions.CommandError, self.cmd.take_action, parsed_args)
313
307
 
308
+ def test_quota_set_per_share_gigabytes_exception(self):
309
+ self.app.client_manager.share.api_version = api_versions.APIVersion(
310
+ '2.61')
311
+ arglist = [
312
+ self.project.id,
313
+ '--per-share-gigabytes', '10',
314
+ ]
315
+ verifylist = [
316
+ ('project', self.project.id),
317
+ ('per_share_gigabytes', 10)
318
+ ]
319
+
320
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
321
+ self.assertRaises(
322
+ exceptions.CommandError, self.cmd.take_action, parsed_args)
323
+
314
324
  def test_quota_set_per_share_gigabytes(self):
315
325
  arglist = [
316
326
  self.project.id,
@@ -10,9 +10,11 @@
10
10
  # License for the specific language governing permissions and limitations
11
11
  # under the License.
12
12
  #
13
+ import ddt
13
14
  from osc_lib import exceptions
14
15
  from osc_lib import utils as oscutils
15
16
 
17
+ from manilaclient import api_versions
16
18
  from manilaclient.osc import utils
17
19
  from manilaclient.osc.v2 import services as osc_services
18
20
  from manilaclient.tests.unit.osc.v2 import fakes as manila_fakes
@@ -96,6 +98,33 @@ class TestShareServiceSet(TestShareService):
96
98
  self.share_service.binary)
97
99
  self.assertIsNone(result)
98
100
 
101
+ def test_service_set_disable_with_reason(self):
102
+ self.app.client_manager.share.api_version = api_versions.APIVersion(
103
+ "2.83")
104
+ reason = 'earthquake'
105
+ arglist = [
106
+ '--disable',
107
+ '--disable-reason', reason,
108
+ self.share_service.host,
109
+ self.share_service.binary,
110
+ ]
111
+ verifylist = [
112
+ ('host', self.share_service.host),
113
+ ('binary', self.share_service.binary),
114
+ ('disable', True),
115
+ ('disable_reason', reason),
116
+ ]
117
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
118
+
119
+ result = self.cmd.take_action(parsed_args)
120
+
121
+ self.services_mock.disable.assert_called_with(
122
+ self.share_service.host,
123
+ self.share_service.binary,
124
+ disable_reason=reason
125
+ )
126
+ self.assertIsNone(result)
127
+
99
128
  def test_share_service_set_disable_exception(self):
100
129
  arglist = [
101
130
  self.share_service.host,
@@ -116,6 +145,7 @@ class TestShareServiceSet(TestShareService):
116
145
  parsed_args)
117
146
 
118
147
 
148
+ @ddt.ddt
119
149
  class TestShareServiceList(TestShareService):
120
150
 
121
151
  columns = [
@@ -127,22 +157,31 @@ class TestShareServiceList(TestShareService):
127
157
  'state',
128
158
  'updated_at'
129
159
  ]
160
+ columns_with_reason = columns + ['disabled_reason']
130
161
 
131
162
  column_headers = utils.format_column_headers(columns)
163
+ column_headers_with_reason = utils.format_column_headers(
164
+ columns_with_reason)
132
165
 
133
166
  def setUp(self):
134
167
  super(TestShareServiceList, self).setUp()
135
168
 
136
169
  self.services_list = (
137
- manila_fakes.FakeShareService.create_fake_services()
170
+ manila_fakes.FakeShareService.create_fake_services(
171
+ {'disabled_reason': ''})
138
172
  )
139
173
  self.services_mock.list.return_value = self.services_list
140
174
  self.values = (oscutils.get_dict_properties(
141
175
  i._info, self.columns) for i in self.services_list)
176
+ self.values_with_reason = (oscutils.get_dict_properties(
177
+ i._info, self.columns_with_reason) for i in self.services_list)
142
178
 
143
179
  self.cmd = osc_services.ListShareService(self.app, None)
144
180
 
145
- def test_share_service_list(self):
181
+ @ddt.data('2.82', '2.83')
182
+ def test_share_service_list(self, version):
183
+ self.app.client_manager.share.api_version = api_versions.APIVersion(
184
+ version)
146
185
  arglist = []
147
186
  verifylist = []
148
187
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -157,10 +196,17 @@ class TestShareServiceList(TestShareService):
157
196
  'state': None,
158
197
  'zone': None
159
198
  })
160
- self.assertEqual(self.column_headers, columns)
161
- self.assertEqual(list(self.values), list(data))
162
-
163
- def test_share_service_list_host_status(self):
199
+ if api_versions.APIVersion(version) >= api_versions.APIVersion("2.83"):
200
+ self.assertEqual(self.column_headers_with_reason, columns)
201
+ self.assertEqual(list(self.values_with_reason), list(data))
202
+ else:
203
+ self.assertEqual(self.column_headers, columns)
204
+ self.assertEqual(list(self.values), list(data))
205
+
206
+ @ddt.data('2.82', '2.83')
207
+ def test_share_service_list_host_status(self, version):
208
+ self.app.client_manager.share.api_version = api_versions.APIVersion(
209
+ version)
164
210
  arglist = [
165
211
  '--host', self.services_list[0].host,
166
212
  '--status', self.services_list[1].status
@@ -181,10 +227,17 @@ class TestShareServiceList(TestShareService):
181
227
  'state': None,
182
228
  'zone': None
183
229
  })
184
- self.assertEqual(self.column_headers, columns)
185
- self.assertEqual(list(self.values), list(data))
186
-
187
- def test_share_service_list_binary_state_zone(self):
230
+ if api_versions.APIVersion(version) >= api_versions.APIVersion("2.83"):
231
+ self.assertEqual(self.column_headers_with_reason, columns)
232
+ self.assertEqual(list(self.values_with_reason), list(data))
233
+ else:
234
+ self.assertEqual(self.column_headers, columns)
235
+ self.assertEqual(list(self.values), list(data))
236
+
237
+ @ddt.data('2.82', '2.83')
238
+ def test_share_service_list_binary_state_zone(self, version):
239
+ self.app.client_manager.share.api_version = api_versions.APIVersion(
240
+ version)
188
241
  arglist = [
189
242
  '--binary', self.services_list[0].binary,
190
243
  '--state', self.services_list[1].state,
@@ -207,5 +260,9 @@ class TestShareServiceList(TestShareService):
207
260
  'state': self.services_list[1].state,
208
261
  'zone': self.services_list[1].zone
209
262
  })
210
- self.assertEqual(self.column_headers, columns)
211
- self.assertEqual(list(self.values), list(data))
263
+ if api_versions.APIVersion(version) >= api_versions.APIVersion("2.83"):
264
+ self.assertEqual(self.column_headers_with_reason, columns)
265
+ self.assertEqual(list(self.values_with_reason), list(data))
266
+ else:
267
+ self.assertEqual(self.column_headers, columns)
268
+ self.assertEqual(list(self.values), list(data))