python-manilaclient 5.7.1__py3-none-any.whl → 6.0.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 (65) hide show
  1. manilaclient/api_versions.py +5 -1
  2. manilaclient/common/constants.py +9 -0
  3. manilaclient/osc/plugin.py +1 -1
  4. manilaclient/osc/v2/data/manila.csv +2 -0
  5. manilaclient/osc/v2/qos_types.py +390 -0
  6. manilaclient/osc/v2/services.py +16 -1
  7. manilaclient/osc/v2/share.py +18 -0
  8. manilaclient/osc/v2/share_replicas.py +163 -5
  9. manilaclient/osc/v2/share_servers.py +2 -3
  10. manilaclient/tests/functional/osc/base.py +33 -0
  11. manilaclient/tests/functional/osc/test_qos_types.py +146 -0
  12. manilaclient/tests/unit/osc/v2/fakes.py +76 -0
  13. manilaclient/tests/unit/osc/v2/test_qos_types.py +440 -0
  14. manilaclient/tests/unit/osc/v2/test_share_replicas.py +171 -3
  15. manilaclient/tests/unit/osc/v2/test_share_servers.py +9 -0
  16. manilaclient/tests/unit/test_api_versions.py +0 -5
  17. manilaclient/tests/unit/v2/fakes.py +56 -0
  18. manilaclient/tests/unit/v2/test_client.py +99 -90
  19. manilaclient/tests/unit/v2/test_qos_types.py +180 -0
  20. manilaclient/tests/unit/v2/test_share_replicas.py +23 -0
  21. manilaclient/tests/unit/v2/test_shares.py +22 -0
  22. manilaclient/v1/client.py +49 -39
  23. manilaclient/v2/client.py +49 -39
  24. manilaclient/v2/qos_types.py +185 -0
  25. manilaclient/v2/share_replicas.py +40 -6
  26. manilaclient/v2/shares.py +34 -1
  27. {python_manilaclient-5.7.1.dist-info → python_manilaclient-6.0.0.dist-info}/METADATA +2 -2
  28. {python_manilaclient-5.7.1.dist-info → python_manilaclient-6.0.0.dist-info}/RECORD +34 -59
  29. {python_manilaclient-5.7.1.dist-info → python_manilaclient-6.0.0.dist-info}/WHEEL +1 -1
  30. {python_manilaclient-5.7.1.dist-info → python_manilaclient-6.0.0.dist-info}/entry_points.txt +7 -3
  31. {python_manilaclient-5.7.1.dist-info → python_manilaclient-6.0.0.dist-info}/licenses/AUTHORS +2 -0
  32. python_manilaclient-6.0.0.dist-info/pbr.json +1 -0
  33. manilaclient/shell.py +0 -858
  34. manilaclient/tests/functional/base.py +0 -649
  35. manilaclient/tests/functional/client.py +0 -2379
  36. manilaclient/tests/functional/test_availability_zones.py +0 -59
  37. manilaclient/tests/functional/test_common.py +0 -77
  38. manilaclient/tests/functional/test_export_locations.py +0 -173
  39. manilaclient/tests/functional/test_limits.py +0 -29
  40. manilaclient/tests/functional/test_messages.py +0 -80
  41. manilaclient/tests/functional/test_quotas.py +0 -395
  42. manilaclient/tests/functional/test_scheduler_stats.py +0 -49
  43. manilaclient/tests/functional/test_security_services.py +0 -80
  44. manilaclient/tests/functional/test_services.py +0 -44
  45. manilaclient/tests/functional/test_share_access.py +0 -384
  46. manilaclient/tests/functional/test_share_network_subnets.py +0 -129
  47. manilaclient/tests/functional/test_share_networks.py +0 -695
  48. manilaclient/tests/functional/test_share_replica_export_locations.py +0 -122
  49. manilaclient/tests/functional/test_share_replicas.py +0 -51
  50. manilaclient/tests/functional/test_share_servers.py +0 -405
  51. manilaclient/tests/functional/test_share_transfers.py +0 -100
  52. manilaclient/tests/functional/test_share_types.py +0 -627
  53. manilaclient/tests/functional/test_shares.py +0 -339
  54. manilaclient/tests/functional/test_shares_listing.py +0 -414
  55. manilaclient/tests/functional/test_shares_metadata.py +0 -155
  56. manilaclient/tests/functional/test_snapshot_access.py +0 -221
  57. manilaclient/tests/functional/test_snapshot_instances.py +0 -140
  58. manilaclient/tests/functional/test_snapshot_instances_export_locations.py +0 -131
  59. manilaclient/tests/functional/test_snapshots_export_locations.py +0 -96
  60. manilaclient/tests/unit/test_shell.py +0 -556
  61. manilaclient/tests/unit/v2/test_shell.py +0 -4859
  62. manilaclient/v2/shell.py +0 -7907
  63. python_manilaclient-5.7.1.dist-info/pbr.json +0 -1
  64. {python_manilaclient-5.7.1.dist-info → python_manilaclient-6.0.0.dist-info}/licenses/LICENSE +0 -0
  65. {python_manilaclient-5.7.1.dist-info → python_manilaclient-6.0.0.dist-info}/top_level.txt +0 -0
@@ -18,6 +18,8 @@ import logging
18
18
  import re
19
19
  import warnings
20
20
 
21
+ from oslo_utils import strutils
22
+
21
23
  import manilaclient
22
24
  from manilaclient.common._i18n import _
23
25
  from manilaclient.common import cliutils
@@ -27,7 +29,7 @@ from manilaclient import utils
27
29
 
28
30
  LOG = logging.getLogger(__name__)
29
31
 
30
- MAX_VERSION = '2.91'
32
+ MAX_VERSION = '2.95'
31
33
  MIN_VERSION = '2.0'
32
34
  DEPRECATED_VERSION = '1.0'
33
35
  _VERSIONED_METHOD_MAP = {}
@@ -231,6 +233,8 @@ def check_version_deprecated(api_version):
231
233
  def get_api_version(version_string):
232
234
  """Returns checked APIVersion object."""
233
235
  version_string = str(version_string)
236
+ if strutils.is_int_like(version_string):
237
+ version_string = f"{version_string}.0"
234
238
 
235
239
  api_version = APIVersion(version_string)
236
240
  check_version_supported(api_version)
@@ -113,6 +113,14 @@ BACKUP_SORT_KEY_VALUES = (
113
113
  'project_id',
114
114
  )
115
115
 
116
+ QOS_TYPE_SORT_KEY_VALUES = (
117
+ 'id',
118
+ 'name',
119
+ 'created_at',
120
+ 'updated_at',
121
+ )
122
+
123
+
116
124
  TASK_STATE_MIGRATION_SUCCESS = 'migration_success'
117
125
  TASK_STATE_MIGRATION_ERROR = 'migration_error'
118
126
  TASK_STATE_MIGRATION_CANCELLED = 'migration_cancelled'
@@ -172,3 +180,4 @@ REPLICA_GRADUATION_VERSION = '2.56'
172
180
  REPLICA_PRE_GRADUATION_VERSION = '2.55'
173
181
  SHARE_TRANSFER_VERSION = '2.77'
174
182
  RESOURCE_LOCK_VERSION = '2.81'
183
+ QOS_TYPE_VERSION = '2.94'
@@ -121,7 +121,7 @@ def build_option_parser(parser):
121
121
  ),
122
122
  help='Shared File System API version, default='
123
123
  + default_api_version
124
- + 'version supported by both the client and the server). '
124
+ + ' (version supported by both the client and the server) '
125
125
  '(Env: OS_SHARE_API_VERSION)',
126
126
  )
127
127
  parser.add_argument(
@@ -1,3 +1,5 @@
1
+ # NOTE: The legacy "manila" CLI has been removed. This file is maintained
2
+ # for historical reference and migration purposes.
1
3
  manila command,openstack command,command description
2
4
  --version,module list,List the client software version
3
5
  absolute-limits,share limits show --absolute,Print a list of absolute limits for a user
@@ -0,0 +1,390 @@
1
+ # Copyright (c) 2025 Cloudification GmbH.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+ # not use this file except in compliance with the License. You may obtain
5
+ # a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ # License for the specific language governing permissions and limitations
13
+ # under the License.
14
+
15
+ import logging
16
+
17
+ from osc_lib.cli import parseractions
18
+ from osc_lib.command import command
19
+ from osc_lib import exceptions
20
+ from osc_lib import utils as oscutils
21
+
22
+ from manilaclient.common._i18n import _
23
+ from manilaclient.common.apiclient import utils as apiutils
24
+ from manilaclient.common import constants
25
+ from manilaclient.osc import utils
26
+
27
+ LOG = logging.getLogger(__name__)
28
+
29
+ ATTRIBUTES = [
30
+ 'id',
31
+ 'name',
32
+ 'description',
33
+ 'specs',
34
+ 'created_at',
35
+ 'updated_at',
36
+ ]
37
+
38
+
39
+ def format_qos_type(qos_type, formatter='table'):
40
+ specs = qos_type.specs
41
+ if formatter == 'table':
42
+ qos_type._info.update({'specs': utils.format_properties(specs)})
43
+ else:
44
+ qos_type._info.update({'specs': specs})
45
+ return qos_type
46
+
47
+
48
+ class CreateQosType(command.ShowOne):
49
+ """Create new qos type."""
50
+
51
+ _description = _("Create new qos type")
52
+
53
+ def get_parser(self, prog_name):
54
+ parser = super().get_parser(prog_name)
55
+ parser.add_argument(
56
+ 'name',
57
+ metavar="<name>",
58
+ help=_('QoS type name. This must be unique.'),
59
+ )
60
+ parser.add_argument(
61
+ "--description",
62
+ metavar="<description>",
63
+ default=None,
64
+ help=_("QoS type description."),
65
+ )
66
+ parser.add_argument(
67
+ "--spec",
68
+ type=str,
69
+ metavar='<key=value>',
70
+ action='append',
71
+ default=None,
72
+ help=_(
73
+ "Spec key and value of QoS type that will be"
74
+ " used for QoS type creation. OPTIONAL: Default=None."
75
+ " Example: --spec qos_type='fixed' --spec peak_iops=300."
76
+ ),
77
+ )
78
+ return parser
79
+
80
+ def take_action(self, parsed_args):
81
+ share_client = self.app.client_manager.share
82
+
83
+ kwargs = {'name': parsed_args.name}
84
+ if parsed_args.description:
85
+ kwargs['description'] = parsed_args.description
86
+
87
+ if parsed_args.spec:
88
+ specs = utils.extract_properties(parsed_args.spec)
89
+ kwargs['specs'] = specs
90
+
91
+ qos_type = share_client.qos_types.create(**kwargs)
92
+ formatted_type = format_qos_type(qos_type, parsed_args.formatter)
93
+
94
+ return (
95
+ ATTRIBUTES,
96
+ oscutils.get_dict_properties(formatted_type._info, ATTRIBUTES),
97
+ )
98
+
99
+
100
+ class DeleteQosType(command.Command):
101
+ """Delete a qos type."""
102
+
103
+ _description = _("Delete a qos type")
104
+
105
+ def get_parser(self, prog_name):
106
+ parser = super().get_parser(prog_name)
107
+ parser.add_argument(
108
+ 'qos_types',
109
+ metavar="<qos_types>",
110
+ nargs="+",
111
+ help=_("Name or ID of the qos type(s) to delete"),
112
+ )
113
+ return parser
114
+
115
+ def take_action(self, parsed_args):
116
+ share_client = self.app.client_manager.share
117
+ result = 0
118
+
119
+ for qos_type in parsed_args.qos_types:
120
+ try:
121
+ qos_type_obj = apiutils.find_resource(
122
+ share_client.qos_types, qos_type
123
+ )
124
+
125
+ share_client.qos_types.delete(qos_type_obj)
126
+ except Exception as e:
127
+ result += 1
128
+ LOG.error(
129
+ _(
130
+ "Failed to delete qos type with "
131
+ "name or ID '%(qos_type)s': %(e)s"
132
+ ),
133
+ {'qos_type': qos_type, 'e': e},
134
+ )
135
+
136
+ if result > 0:
137
+ total = len(parsed_args.qos_types)
138
+ msg = _("%(result)s of %(total)s qos types failed to delete.") % {
139
+ 'result': result,
140
+ 'total': total,
141
+ }
142
+ raise exceptions.CommandError(msg)
143
+
144
+
145
+ class SetQosType(command.Command):
146
+ """Set qos type description or specs."""
147
+
148
+ _description = _("Set qos type description or specs")
149
+
150
+ def get_parser(self, prog_name):
151
+ parser = super().get_parser(prog_name)
152
+ parser.add_argument(
153
+ 'qos_type',
154
+ metavar="<qos_type>",
155
+ help=_("Name or ID of the qos type to modify"),
156
+ )
157
+ parser.add_argument(
158
+ "--description",
159
+ metavar="<description>",
160
+ default=None,
161
+ help=_("New description of qos type."),
162
+ )
163
+ parser.add_argument(
164
+ "--spec",
165
+ type=str,
166
+ metavar='<key=value>',
167
+ action='append',
168
+ default=None,
169
+ help=_(
170
+ "Spec key and value of qos type that will be "
171
+ "used for QoS type. OPTIONAL: Default=None. For "
172
+ "example --spec qos_type='fixed' --spec peak_iops=300"
173
+ ),
174
+ )
175
+ return parser
176
+
177
+ def take_action(self, parsed_args):
178
+ share_client = self.app.client_manager.share
179
+
180
+ qos_type = apiutils.find_resource(
181
+ share_client.qos_types, parsed_args.qos_type
182
+ )
183
+
184
+ kwargs = {}
185
+ if parsed_args.description:
186
+ kwargs['description'] = parsed_args.description
187
+ if kwargs:
188
+ try:
189
+ qos_type.update(**kwargs)
190
+ except Exception as e:
191
+ raise exceptions.CommandError(
192
+ _("Failed to set qos type description: %s") % e
193
+ )
194
+
195
+ # These are dict of key=value to be added as qos type specs.
196
+ if parsed_args.spec:
197
+ specs = utils.extract_properties(parsed_args.spec)
198
+ try:
199
+ qos_type.set_keys(specs)
200
+ except Exception as e:
201
+ raise exceptions.CommandError(
202
+ _("Failed to set qos type spec: %s") % e
203
+ )
204
+
205
+
206
+ class UnsetQosType(command.Command):
207
+ """Unset qos type specs."""
208
+
209
+ _description = _("Unset qos type specs")
210
+
211
+ def get_parser(self, prog_name):
212
+ parser = super().get_parser(prog_name)
213
+ parser.add_argument(
214
+ 'qos_type',
215
+ metavar="<qos_type>",
216
+ help=_("Name or ID of the qos type to modify"),
217
+ )
218
+ parser.add_argument(
219
+ "--description",
220
+ action='store_true',
221
+ help=_("Unset qos type description."),
222
+ )
223
+ parser.add_argument(
224
+ '--spec',
225
+ metavar='<key>',
226
+ action='append',
227
+ help=_('Remove specified spec from this qos type'),
228
+ )
229
+ return parser
230
+
231
+ def take_action(self, parsed_args):
232
+ share_client = self.app.client_manager.share
233
+
234
+ qos_type = apiutils.find_resource(
235
+ share_client.qos_types, parsed_args.qos_type
236
+ )
237
+
238
+ kwargs = {}
239
+ if parsed_args.description:
240
+ kwargs['description'] = None
241
+ if kwargs:
242
+ try:
243
+ qos_type.update(**kwargs)
244
+ except Exception as e:
245
+ raise exceptions.CommandError(
246
+ _("Failed to unset qos type description: %s") % e
247
+ )
248
+
249
+ # These are list of keys to be deleted from qos type specs.
250
+ if parsed_args.spec:
251
+ try:
252
+ qos_type.unset_keys(parsed_args.spec)
253
+ except Exception as e:
254
+ raise exceptions.CommandError(
255
+ _("Failed to remove qos type spec: %s") % e
256
+ )
257
+
258
+
259
+ class ListQosType(command.Lister):
260
+ """List Qos Types."""
261
+
262
+ _description = _("List qos types")
263
+
264
+ def get_parser(self, prog_name):
265
+ parser = super().get_parser(prog_name)
266
+ parser.add_argument(
267
+ '--name',
268
+ metavar="<name>",
269
+ default=None,
270
+ help=_('Filter results by name. Default=None.'),
271
+ )
272
+ parser.add_argument(
273
+ '--description',
274
+ metavar="<description>",
275
+ default=None,
276
+ help=_("Filter results by description. Default=None."),
277
+ )
278
+ parser.add_argument(
279
+ "--name~",
280
+ metavar="<name~>",
281
+ default=None,
282
+ help=_("Filter results matching a qos name pattern. "),
283
+ )
284
+ parser.add_argument(
285
+ '--description~',
286
+ metavar="<description~>",
287
+ default=None,
288
+ help=_("Filter results matching a qos description pattern."),
289
+ )
290
+ parser.add_argument(
291
+ "--limit",
292
+ metavar="<num-qos-types>",
293
+ type=int,
294
+ default=None,
295
+ action=parseractions.NonNegativeAction,
296
+ help=_("Limit the number of qos types returned. Default=None."),
297
+ )
298
+ parser.add_argument(
299
+ '--offset',
300
+ metavar="<offset>",
301
+ default=None,
302
+ help=_('Start position of qos type records listing.'),
303
+ )
304
+ parser.add_argument(
305
+ '--sort-key',
306
+ '--sort_key',
307
+ metavar='<sort_key>',
308
+ type=str,
309
+ default=None,
310
+ help=_(
311
+ 'Key to be sorted with, available keys are '
312
+ '%(keys)s. Default=None.'
313
+ )
314
+ % {'keys': constants.QOS_TYPE_SORT_KEY_VALUES},
315
+ )
316
+ parser.add_argument(
317
+ '--sort-dir',
318
+ '--sort_dir',
319
+ metavar='<sort_dir>',
320
+ type=str,
321
+ default=None,
322
+ help=_(
323
+ 'Sort direction, available values are '
324
+ '%(dirs)s. OPTIONAL: Default=None.'
325
+ )
326
+ % {'dirs': constants.SORT_DIR_VALUES},
327
+ )
328
+ return parser
329
+
330
+ def take_action(self, parsed_args):
331
+ share_client = self.app.client_manager.share
332
+
333
+ search_opts = {
334
+ 'name': parsed_args.name,
335
+ 'description': parsed_args.description,
336
+ 'limit': parsed_args.limit,
337
+ 'offset': parsed_args.offset,
338
+ }
339
+ search_opts['name~'] = getattr(parsed_args, 'name~')
340
+ search_opts['description~'] = getattr(parsed_args, 'description~')
341
+
342
+ qos_types = share_client.qos_types.list(
343
+ search_opts=search_opts,
344
+ sort_key=parsed_args.sort_key,
345
+ sort_dir=parsed_args.sort_dir,
346
+ )
347
+
348
+ formatted_types = []
349
+ for qos_type in qos_types:
350
+ formatted_types.append(
351
+ format_qos_type(qos_type, parsed_args.formatter)
352
+ )
353
+
354
+ values = (
355
+ oscutils.get_dict_properties(s._info, ATTRIBUTES)
356
+ for s in formatted_types
357
+ )
358
+
359
+ columns = utils.format_column_headers(ATTRIBUTES)
360
+
361
+ return (columns, values)
362
+
363
+
364
+ class ShowQosType(command.ShowOne):
365
+ """Show a qos type."""
366
+
367
+ _description = _("Display qos type details")
368
+
369
+ def get_parser(self, prog_name):
370
+ parser = super().get_parser(prog_name)
371
+ parser.add_argument(
372
+ 'qos_type',
373
+ metavar="<qos_type>",
374
+ help=_("Qos type to display (name or ID)"),
375
+ )
376
+ return parser
377
+
378
+ def take_action(self, parsed_args):
379
+ share_client = self.app.client_manager.share
380
+
381
+ qos_type = apiutils.find_resource(
382
+ share_client.qos_types, parsed_args.qos_type
383
+ )
384
+
385
+ formatted_type = format_qos_type(qos_type, parsed_args.formatter)
386
+
387
+ return (
388
+ ATTRIBUTES,
389
+ oscutils.get_dict_properties(formatted_type._info, ATTRIBUTES),
390
+ )
@@ -138,6 +138,13 @@ class ListShareService(command.Lister):
138
138
  default=None,
139
139
  help=_("Filter services by their availability zone."),
140
140
  )
141
+ parser.add_argument(
142
+ "--ensuring",
143
+ metavar="<ensuring>",
144
+ choices=['True', 'False'],
145
+ default=None,
146
+ help=_("Filter services running ensure shares or not."),
147
+ )
141
148
  return parser
142
149
 
143
150
  def take_action(self, parsed_args):
@@ -150,6 +157,14 @@ class ListShareService(command.Lister):
150
157
  'state': parsed_args.state,
151
158
  'zone': parsed_args.zone,
152
159
  }
160
+ if parsed_args.ensuring:
161
+ if share_client.api_version < api_versions.APIVersion("2.93"):
162
+ raise exceptions.CommandError(
163
+ "Filtering services whether they are running ensure "
164
+ "shares or not is only supported by manila API version "
165
+ ">= 2.93"
166
+ )
167
+ search_opts['ensuring'] = parsed_args.ensuring
153
168
 
154
169
  services = share_client.services.list(search_opts=search_opts)
155
170
 
@@ -164,7 +179,7 @@ class ListShareService(command.Lister):
164
179
  ]
165
180
  if share_client.api_version >= api_versions.APIVersion("2.83"):
166
181
  columns.append('Disabled Reason')
167
- if share_client.api_version >= api_versions.APIVersion("2.86"):
182
+ if share_client.api_version >= api_versions.APIVersion("2.93"):
168
183
  columns.append('Ensuring')
169
184
 
170
185
  data = (
@@ -1171,6 +1171,15 @@ class AdoptShare(command.ShowOne):
1171
1171
  '(Default=None)'
1172
1172
  ),
1173
1173
  )
1174
+ parser.add_argument(
1175
+ '--mount-point-name',
1176
+ metavar="<mount_point_name>",
1177
+ default=None,
1178
+ help=_(
1179
+ 'Optional custom export location. Available only for '
1180
+ 'microversion >= 2.92. (Default=None)'
1181
+ ),
1182
+ )
1174
1183
  parser.add_argument(
1175
1184
  "--wait",
1176
1185
  action='store_true',
@@ -1221,6 +1230,15 @@ class AdoptShare(command.ShowOne):
1221
1230
  'API microversion >= 2.49'
1222
1231
  )
1223
1232
 
1233
+ if parsed_args.mount_point_name:
1234
+ if share_client.api_version >= api_versions.APIVersion("2.92"):
1235
+ kwargs['mount_point_name'] = parsed_args.mount_point_name
1236
+ else:
1237
+ raise exceptions.CommandError(
1238
+ 'Setting share mount point name is available only for '
1239
+ 'API microversion >= 2.92'
1240
+ )
1241
+
1224
1242
  share = share_client.shares.manage(**kwargs)
1225
1243
 
1226
1244
  if parsed_args.wait: