PyU4V 10.2.0.3__tar.gz → 10.4.0.0__tar.gz

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 (51) hide show
  1. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PKG-INFO +8 -9
  2. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/__init__.py +3 -2
  3. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/clone.py +17 -17
  4. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/common.py +31 -68
  5. pyu4v-10.4.0.0/PyU4V/enhanced_api.py +112 -0
  6. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/metro_dr.py +11 -12
  7. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/performance.py +0 -70
  8. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/performance_enhanced.py +37 -4
  9. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/provisioning.py +1 -1
  10. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/replication.py +24 -10
  11. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/rest_requests.py +78 -42
  12. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/scripts/replace_version.py +1 -0
  13. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/serviceability.py +36 -35
  14. pyu4v-10.4.0.0/PyU4V/settings.py +734 -0
  15. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/system.py +30 -12
  16. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/tools/generate_functions.py +5 -4
  17. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/univmax_conn.py +114 -30
  18. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/constants.py +4 -4
  19. pyu4v-10.4.0.0/PyU4V/version.py +6 -0
  20. pyu4v-10.4.0.0/PyU4V/workload_planner.py +42 -0
  21. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/README.rst +7 -8
  22. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/pyu4v.egg-info/PKG-INFO +8 -9
  23. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/pyu4v.egg-info/SOURCES.txt +2 -0
  24. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/setup.py +1 -1
  25. pyu4v-10.2.0.3/PyU4V/version.py +0 -6
  26. pyu4v-10.2.0.3/PyU4V/workload_planner.py +0 -102
  27. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/LICENSE +0 -0
  28. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/migration.py +0 -0
  29. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/real_time.py +0 -0
  30. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/scripts/__init__.py +0 -0
  31. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/snapshot_policy.py +0 -0
  32. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/storage_groups.py +0 -0
  33. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/tools/__init__.py +0 -0
  34. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/tools/openstack/__init__.py +0 -0
  35. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/tools/openstack/migrate.py +0 -0
  36. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/tools/openstack/migrate_utils.py +0 -0
  37. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/__init__.py +0 -0
  38. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/config_handler.py +0 -0
  39. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/console.py +0 -0
  40. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/decorators.py +0 -0
  41. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/exception.py +0 -0
  42. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/file_handler.py +0 -0
  43. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/performance_category_map.py +0 -0
  44. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/performance_constants.py +0 -0
  45. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/time_handler.py +0 -0
  46. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/utils/utils.py +0 -0
  47. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/PyU4V/volumes.py +0 -0
  48. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/pyu4v.egg-info/dependency_links.txt +0 -0
  49. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/pyu4v.egg-info/requires.txt +0 -0
  50. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/pyu4v.egg-info/top_level.txt +0 -0
  51. {pyu4v-10.2.0.3 → pyu4v-10.4.0.0}/setup.cfg +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyu4v
3
- Version: 10.2.0.3
3
+ Version: 10.4.0.0
4
4
  Summary: A Python library for use with Dell EMC's Unisphere for PowerMax REST API.
5
5
  Home-page: https://github.com/dell/PyU4V/
6
6
  Author: Dell Inc. or its subsidiaries
7
7
  Author-email: paule.martin@dell.com
8
8
  License: Apache 2.0
9
- Description: Welcome to PyU4V 10.2
9
+ Description: Welcome to PyU4V 10.4
10
10
  =====================
11
11
 
12
12
  | |Maintenance| |OpenSource| |AskUs| |License| |Test| |Build| |Docs|
@@ -28,15 +28,15 @@ Description: Welcome to PyU4V 10.2
28
28
  where ``{ip-address}`` is the IP address of your Unisphere server and
29
29
  ``{port}`` is the port it is listening on.
30
30
 
31
- PyU4V Version 10.2
31
+ PyU4V Version 10.4
32
32
  ------------------
33
33
 
34
34
  +-------------------------------+----------------------------+
35
35
  | **Author** | Dell EMC |
36
36
  +-------------------------------+----------------------------+
37
- | **PyU4V Version** | 10.2.0.3 |
37
+ | **PyU4V Version** | 10.4.0.0 |
38
38
  +-------------------------------+----------------------------+
39
- | **Minimum Unisphere Version** | 10.2.0.0 |
39
+ | **Minimum Unisphere Version** | 10.4.0 |
40
40
  +-------------------------------+----------------------------+
41
41
  | **Array Model** | VMAX-3, VMAX AFA, PowerMax |
42
42
  +-------------------------------+----------------------------+
@@ -55,7 +55,7 @@ Description: Welcome to PyU4V 10.2
55
55
  version of Unisphere older than 9.1.x
56
56
 
57
57
  Note
58
- PyU4V version 10.x is compatible with scripts written for PyU4V versions
58
+ PyU4V version 10.4 is compatible with scripts written for PyU4V versions
59
59
  >= 9.2. Please ensure to check change log to ensure that you are not
60
60
  using functions that have been marked as depreciated.
61
61
 
@@ -82,7 +82,7 @@ Description: Welcome to PyU4V 10.2
82
82
 
83
83
  $ pip install PyU4V
84
84
  # Install a specific version
85
- $ pip install PyU4V==10.2.0.0
85
+ $ pip install PyU4V==10.4
86
86
 
87
87
  Copy the sample ``PyU4V.conf`` provided with PyU4V to either your working
88
88
  directory or within a directory named ``.PyU4V`` in your current users home
@@ -171,7 +171,7 @@ Description: Welcome to PyU4V 10.2
171
171
 
172
172
  conn = PyU4V.U4VConn()
173
173
  conn.common.get_unisphere_version()
174
- >> {'version': 'V10.2.0.0'}
174
+ >> {'version': '10.4.0.0'}
175
175
 
176
176
  If you wish to query another array without changing the configuration file,
177
177
  call the connection ``set_array_id()`` function:
@@ -266,7 +266,6 @@ Description: Welcome to PyU4V 10.2
266
266
  .. _GitHub-Issues: https://github.com/dell/PyU4V/issues
267
267
  .. _StackOverFlow: https://stackoverflow.com/search?q=PyU4V
268
268
 
269
-
270
269
  Platform: UNKNOWN
271
270
  Classifier: Development Status :: 5 - Production/Stable
272
271
  Classifier: Intended Audience :: Developers
@@ -22,8 +22,9 @@
22
22
 
23
23
  from .univmax_conn import U4VConn # noqa: F401
24
24
  from . import version
25
+
25
26
  __title__ = 'pyu4v'
26
27
  __version__ = version.VERSION
27
- __author__ = 'Dell EMC or its subsidiaries'
28
+ __author__ = 'Dell Technologies'
28
29
  __license__ = 'Apache 2.0'
29
- __copyright__ = 'Copyright 2023 Dell EMC Inc'
30
+ __copyright__ = 'Copyright 2025 Dell Technologies'
@@ -46,7 +46,6 @@ class CloneFunctions(object):
46
46
  self.modify_resource = self.common.modify_resource
47
47
  self.delete_resource = self.common.delete_resource
48
48
  self.array_id = array_id
49
- self.version = constants.UNISPHERE_VERSION
50
49
 
51
50
  def get_clone_target_storage_group_list(
52
51
  self, storage_group_id, array_id=None, target_storage_group=None,
@@ -105,8 +104,9 @@ class CloneFunctions(object):
105
104
  'vse': vse, }
106
105
  array_id = array_id if array_id else self.array_id
107
106
  response = self.common.get_request(
108
- target_uri=f"/{self.version}/replication/symmetrix/{array_id}"
109
- f"/storagegroup/{storage_group_id}/clone/storagegroup",
107
+ target_uri=f"/{self.common.UNI_VERSION}/replication/symmetrix/"
108
+ f"{array_id}/storagegroup/{storage_group_id}"
109
+ f"/clone/storagegroup",
110
110
  resource_type=None, params=query_params)
111
111
  if response and response.get('clone_target_sg_names'):
112
112
  target_sg_names_list = response.get('clone_target_sg_names')
@@ -122,7 +122,7 @@ class CloneFunctions(object):
122
122
  """
123
123
  array_id = array_id if array_id else self.array_id
124
124
  return self.common.get_request(
125
- target_uri=f"/{self.version}/replication/symmetrix"
125
+ target_uri=f"/{self.common.UNI_VERSION}/replication/symmetrix"
126
126
  f"/{array_id}/storagegroup/{storage_group_id}"
127
127
  f"/clone/volume",
128
128
  resource_type=None)
@@ -139,9 +139,9 @@ class CloneFunctions(object):
139
139
  query_params = {}
140
140
  array_id = array_id if array_id else self.array_id
141
141
  return self.common.get_request(
142
- target_uri=f"/{self.version}/replication/symmetrix/{array_id}"
143
- f"/storagegroup/{storage_group_id}/clone/storagegroup/"
144
- f"{target_storage_group_id}",
142
+ target_uri=f"/{self.common.UNI_VERSION}/replication/symmetrix/"
143
+ f"{array_id}/storagegroup/{storage_group_id}/clone"
144
+ f"/storagegroup/{target_storage_group_id}",
145
145
  resource_type=None, params=query_params)
146
146
 
147
147
  def create_clone(
@@ -180,7 +180,7 @@ class CloneFunctions(object):
180
180
  }
181
181
  return self.common.create_resource(
182
182
  target_uri=(
183
- f"/{self.version}/replication/symmetrix"
183
+ f"/{self.common.UNI_VERSION}/replication/symmetrix"
184
184
  f"/{array_id}/storagegroup/{storage_group_id}"
185
185
  f"/clone/storagegroup"), payload=payload)
186
186
 
@@ -219,7 +219,7 @@ class CloneFunctions(object):
219
219
  "restored": restored
220
220
  }
221
221
  return self.common.delete_resource(
222
- target_uri=(f"/{self.version}/replication/symmetrix"
222
+ target_uri=(f"/{self.common.UNI_VERSION}/replication/symmetrix"
223
223
  f"/{array_id}/storagegroup/{storage_group_id}"
224
224
  f"/clone/storagegroup"),
225
225
  params=params)
@@ -264,8 +264,8 @@ class CloneFunctions(object):
264
264
  if _async:
265
265
  payload.update(ASYNC_UPDATE)
266
266
  return self.common.modify_resource(target_uri=(
267
- f"/{self.version}/replication/symmetrix/{array_id}/storagegroup/"
268
- f"{storage_group_id}/clone/storagegroup/"
267
+ f"/{self.common.UNI_VERSION}/replication/symmetrix/{array_id}"
268
+ f"/storagegroup/{storage_group_id}/clone/storagegroup/"
269
269
  f"{target_storage_group_id}"), resource_type=None, payload=payload)
270
270
 
271
271
  def split_clone(
@@ -298,9 +298,9 @@ class CloneFunctions(object):
298
298
  if _async:
299
299
  payload.update(ASYNC_UPDATE)
300
300
  return self.common.modify_resource(
301
- target_uri=f"/{self.version}/replication/symmetrix/{array_id}"
302
- f"/storagegroup/{storage_group_id}/clone/storagegroup/"
303
- f"{target_storage_group_id}",
301
+ target_uri=f"/{self.common.UNI_VERSION}/replication/symmetrix/"
302
+ f"{array_id}/storagegroup/{storage_group_id}/clone/"
303
+ f"storagegroup/{target_storage_group_id}",
304
304
  resource_type=None, payload=payload)
305
305
 
306
306
  def restore_clone(
@@ -332,7 +332,7 @@ class CloneFunctions(object):
332
332
  payload.update(ASYNC_UPDATE)
333
333
 
334
334
  return self.common.modify_resource(
335
- target_uri=f"/{self.version}/replication/symmetrix/{array_id}"
336
- f"/storagegroup/{storage_group_id}/clone/storagegroup/"
337
- f"{target_storage_group_id}",
335
+ target_uri=f"/{self.common.UNI_VERSION}/replication/symmetrix/"
336
+ f"{array_id}/storagegroup/{storage_group_id}/clone/"
337
+ f"storagegroup/{target_storage_group_id}",
338
338
  resource_type=None, payload=payload)
@@ -4,7 +4,7 @@
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
6
  #
7
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
8
  #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -12,7 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  """common.py."""
15
-
16
15
  import json
17
16
  import logging
18
17
  import math
@@ -20,7 +19,6 @@ import re
20
19
  import six
21
20
  import socket
22
21
  import time
23
-
24
22
  from PyU4V.utils import constants
25
23
  from PyU4V.utils import exception
26
24
 
@@ -61,20 +59,29 @@ HEADROOM = constants.HEADROOM
61
59
  class CommonFunctions(object):
62
60
  """CommonFunctions."""
63
61
 
64
- def __init__(self, rest_client):
65
- """__init__."""
62
+ def __init__(self, rest_client, u4v_version=None):
63
+ """__init__.
64
+ Honors explicit u4v_version, otherwise falls back to
65
+ rest_client.u4v_version if set, else constants.UNISPHERE_VERSION.
66
+ """
66
67
  self.rest_client = rest_client
67
68
  self.request = self.rest_client.rest_request
68
69
  self.interval = self.rest_client.interval
69
70
  self.retries = self.rest_client.retries
70
- self.UNI_VERSION = constants.UNISPHERE_VERSION
71
+
72
+ if u4v_version is not None:
73
+ self.UNI_VERSION = str(u4v_version)
74
+ elif (hasattr(self.rest_client, 'u4v_version') and (
75
+ self.rest_client.u4v_version)):
76
+ self.UNI_VERSION = str(self.rest_client.u4v_version)
77
+ else:
78
+ self.UNI_VERSION = constants.UNISPHERE_VERSION
71
79
 
72
80
  def wait_for_job_complete(self, job):
73
81
  """Given the job wait for it to complete.
74
-
75
82
  :param job: job details -- dict
76
83
  :returns: response code, result, status, task details -- int, str, str,
77
- list
84
+ list
78
85
  :raises: VolumeBackendAPIException
79
86
  """
80
87
  res, tasks = None, None
@@ -104,13 +111,11 @@ class CommonFunctions(object):
104
111
  LOG.exception(exception_message)
105
112
  raise exception.VolumeBackendAPIException(
106
113
  data=exception_message) from error
107
-
108
114
  return kwargs
109
115
 
110
116
  job_id = job['jobId']
111
117
  kwargs = {'retries': 0, 'wait_for_job_called': False,
112
118
  'rc': 0, 'result': None}
113
-
114
119
  while not kwargs['wait_for_job_called']:
115
120
  time.sleep(self.interval)
116
121
  kwargs = _wait_for_job_complete()
@@ -119,7 +124,6 @@ class CommonFunctions(object):
119
124
  'tries.'.format(cnt=kwargs['retries']))
120
125
  kwargs['rc'], kwargs['result'] = -1, kwargs['result']
121
126
  break
122
-
123
127
  LOG.debug('Return code is: {rc}. Result is {res}.'.format(
124
128
  rc=kwargs['rc'], res=kwargs['result']))
125
129
  return (kwargs['rc'], kwargs['result'],
@@ -127,7 +131,6 @@ class CommonFunctions(object):
127
131
 
128
132
  def get_job_by_id(self, job_id):
129
133
  """Get details of a specific job.
130
-
131
134
  :param job_id: job id -- str
132
135
  :returns: job details -- dict
133
136
  """
@@ -136,10 +139,9 @@ class CommonFunctions(object):
136
139
 
137
140
  def _is_job_finished(self, job_id):
138
141
  """Check if the job is finished.
139
-
140
142
  :param job_id: job id -- str
141
143
  :returns: job complete, result, response code, status, task
142
- details -- bool, str, int, str, list
144
+ details -- bool, str, int, str, list
143
145
  """
144
146
  complete, rc, status, result, task = False, 0, None, None, None
145
147
  job = self.get_job_by_id(job_id)
@@ -160,12 +162,14 @@ class CommonFunctions(object):
160
162
  @staticmethod
161
163
  def check_status_code_success(operation, status_code, message):
162
164
  """Check if a status code indicates success.
163
-
164
165
  :param operation: operation being performed -- str
165
166
  :param status_code: status code -- int
166
167
  :param message: server response -- str
167
168
  :raises: VolumeBackendAPIException
168
169
  """
170
+ if status_code == None:
171
+ raise exception.VolumeBackendAPIException(
172
+ data="Server unavailable or IP incorrect")
169
173
  if status_code not in [STATUS_200, STATUS_201,
170
174
  STATUS_202, STATUS_204]:
171
175
  exception_message = (
@@ -176,13 +180,11 @@ class CommonFunctions(object):
176
180
  data=exception_message)
177
181
  if status_code == STATUS_401:
178
182
  raise exception.UnauthorizedRequestException()
179
-
180
183
  raise exception.VolumeBackendAPIException(
181
184
  data=exception_message)
182
185
 
183
186
  def wait_for_job(self, operation, status_code, job):
184
187
  """Check if call is async, wait for it to complete.
185
-
186
188
  :param operation: operation being performed -- str
187
189
  :param status_code: status code -- int
188
190
  :param job: job id -- str
@@ -205,9 +207,7 @@ class CommonFunctions(object):
205
207
 
206
208
  def build_target_uri(self, **kwargs):
207
209
  """Build the target URI.
208
-
209
210
  This function calls into _build_uri() for access outside this class.
210
-
211
211
  :key version: Unisphere version -- int
212
212
  :key no_version: if versionless uri -- bool
213
213
  :key category: resource category e.g. sloprovisioning -- str
@@ -225,7 +225,6 @@ class CommonFunctions(object):
225
225
 
226
226
  def _build_uri(self, **kwargs):
227
227
  """Build the target URI.
228
-
229
228
  :key version: Unisphere version -- int
230
229
  :key no_version: if versionless uri -- bool
231
230
  :key category: resource category e.g. sloprovisioning -- str
@@ -240,50 +239,41 @@ class CommonFunctions(object):
240
239
  :returns: target URI -- str
241
240
  """
242
241
  target_uri, version = str(), None
243
-
244
242
  if kwargs.get('category') not in ['performance', 'common']:
245
243
  version = self._build_uri_get_version(kwargs.get('version'),
246
244
  kwargs.get('no_version'))
247
- if version:
248
- target_uri += '/{version}'.format(version=version)
249
-
245
+ if version:
246
+ target_uri += '/{version}'.format(version=version)
250
247
  target_uri += '/{category}'.format(
251
248
  category=kwargs.get('category'))
252
-
253
249
  if kwargs.get('resource_level'):
254
250
  target_uri += '/{resource_level}'.format(
255
251
  resource_level=kwargs.get('resource_level'))
256
-
257
252
  if kwargs.get('resource_level_id'):
258
253
  target_uri += '/{resource_level_id}'.format(
259
254
  resource_level_id=kwargs.get('resource_level_id'))
260
-
261
255
  if kwargs.get('resource_type'):
262
256
  target_uri += '/{resource_type}'.format(
263
257
  resource_type=kwargs.get('resource_type'))
264
- if kwargs.get('resource_type_id'):
265
- target_uri += '/{resource_type_id}'.format(
266
- resource_type_id=kwargs.get('resource_type_id'))
267
-
258
+ if kwargs.get('resource_type_id'):
259
+ target_uri += '/{resource_type_id}'.format(
260
+ resource_type_id=kwargs.get('resource_type_id'))
268
261
  if kwargs.get('resource'):
269
262
  target_uri += '/{resource}'.format(
270
263
  resource=kwargs.get('resource'))
271
- if kwargs.get('resource_id'):
272
- target_uri += '/{resource_id}'.format(
273
- resource_id=kwargs.get('resource_id'))
274
-
264
+ if kwargs.get('resource_id'):
265
+ target_uri += '/{resource_id}'.format(
266
+ resource_id=kwargs.get('resource_id'))
275
267
  if kwargs.get('object_type'):
276
268
  target_uri += '/{object_type}'.format(
277
269
  object_type=kwargs.get('object_type'))
278
- if kwargs.get('object_type_id'):
279
- target_uri += '/{object_type_id}'.format(
280
- object_type_id=kwargs.get('object_type_id'))
281
-
270
+ if kwargs.get('object_type_id'):
271
+ target_uri += '/{object_type_id}'.format(
272
+ object_type_id=kwargs.get('object_type_id'))
282
273
  return target_uri
283
274
 
284
275
  def _build_uri_get_version(self, version=None, no_version=False):
285
276
  """Get the Unisphere version for the target URI.
286
-
287
277
  :param version: version to use from kwargs -- str
288
278
  :param no_version: if URI should be versionless -- bool
289
279
  :returns: version -- str
@@ -301,7 +291,6 @@ class CommonFunctions(object):
301
291
 
302
292
  def get_request(self, target_uri, resource_type, params=None):
303
293
  """Send a GET request to the array.
304
-
305
294
  :param target_uri: target uri -- str
306
295
  :param resource_type: the resource type, e.g. maskingview -- str
307
296
  :param params: optional filter params -- dict
@@ -315,7 +304,6 @@ class CommonFunctions(object):
315
304
 
316
305
  def get_resource(self, *args, **kwargs):
317
306
  """Get resource details from the array.
318
-
319
307
  :key version: Unisphere version -- int
320
308
  :key no_version: if versionless uri -- bool
321
309
  :key category: resource category e.g. sloprovisioning -- str
@@ -341,7 +329,6 @@ class CommonFunctions(object):
341
329
 
342
330
  def create_resource(self, *args, **kwargs):
343
331
  """Create a resource.
344
-
345
332
  :key version: Unisphere version -- int
346
333
  :key no_version: if versionless uri -- bool
347
334
  :key category: resource category e.g. sloprovisioning -- str
@@ -373,7 +360,6 @@ class CommonFunctions(object):
373
360
 
374
361
  def modify_resource(self, *args, **kwargs):
375
362
  """Modify a resource.
376
-
377
363
  :key version: Unisphere version -- int
378
364
  :key no_version: if versionless uri -- bool
379
365
  :key category: resource category e.g. sloprovisioning -- str
@@ -405,7 +391,6 @@ class CommonFunctions(object):
405
391
 
406
392
  def delete_resource(self, *args, **kwargs):
407
393
  """Delete a resource.
408
-
409
394
  :key version: Unisphere version -- int
410
395
  :key no_version: if versionless uri -- bool
411
396
  :key category: resource category e.g. sloprovisioning -- str
@@ -436,7 +421,6 @@ class CommonFunctions(object):
436
421
 
437
422
  def download_file(self, **kwargs):
438
423
  """Download a file.
439
-
440
424
  :key version: Unisphere version -- int
441
425
  :key no_version: if versionless uri -- bool
442
426
  :key category: resource category e.g. sloprovisioning -- str
@@ -473,7 +457,6 @@ class CommonFunctions(object):
473
457
 
474
458
  def upload_file(self, **kwargs):
475
459
  """Upload a file.
476
-
477
460
  :key version: Unisphere version -- int
478
461
  :key no_version: if versionless uri -- bool
479
462
  :key category: resource category e.g. sloprovisioning -- str
@@ -516,7 +499,6 @@ class CommonFunctions(object):
516
499
 
517
500
  def get_uni_version(self):
518
501
  """Get the unisphere version from the server.
519
-
520
502
  :returns: version and major_version e.g. "V10.0.0.0", "100" -- str, str
521
503
  """
522
504
  version, major_version = None, None
@@ -529,17 +511,14 @@ class CommonFunctions(object):
529
511
 
530
512
  def get_uni_version_info(self):
531
513
  """Get the unisphere version from the server.
532
-
533
514
  :returns: {'version': 'T10.1.0.468', 'api_version': '101',
534
- 'supported_api_versions': ['101', '100', '92']} -- dict
515
+ 'supported_api_versions': ['101', '100', '92']} -- dict
535
516
  """
536
517
  response = self.get_resource(category=VERSION, no_version=True)
537
-
538
518
  return response
539
519
 
540
520
  def get_array_list(self, filters=None):
541
521
  """Return a list of arrays.
542
-
543
522
  :param filters: optional filters -- dict
544
523
  :returns: arrays ids -- list
545
524
  """
@@ -549,7 +528,6 @@ class CommonFunctions(object):
549
528
 
550
529
  def get_v3_or_newer_array_list(self, filters=None):
551
530
  """Return a list of V3 or newer arrays in the environment.
552
-
553
531
  :param filters: optional filters -- dict
554
532
  :returns: arrays ids -- list
555
533
  """
@@ -559,7 +537,6 @@ class CommonFunctions(object):
559
537
 
560
538
  def get_array(self, array_id):
561
539
  """Get array details.
562
-
563
540
  :param array_id: array id -- str
564
541
  :returns: array details -- dict
565
542
  """
@@ -568,7 +545,6 @@ class CommonFunctions(object):
568
545
 
569
546
  def get_iterator_page_list(self, iterator_id, start, end):
570
547
  """Get a page of results from an iterator instance.
571
-
572
548
  :param iterator_id: iterator id -- str
573
549
  :param start: the start number -- int
574
550
  :param end: the end number -- int
@@ -582,13 +558,11 @@ class CommonFunctions(object):
582
558
 
583
559
  def get_iterator_results(self, rest_response):
584
560
  """Get all results from all pages of an iterator if count > 1000.
585
-
586
561
  :param rest_response: response JSON from REST API -- dict
587
562
  :returns: all results -- dict
588
563
  """
589
564
  full_response = list()
590
565
  full_response += rest_response['resultList']['result']
591
-
592
566
  if rest_response.get('count') and int(rest_response.get('count')) > 0:
593
567
  count = rest_response.get('count')
594
568
  max_page_size = rest_response.get('maxPageSize')
@@ -609,7 +583,6 @@ class CommonFunctions(object):
609
583
  @staticmethod
610
584
  def check_ipv4(ipv4):
611
585
  """Check if a given string is a valid ipv6 address
612
-
613
586
  :param ipv4: ipv4 address -- str
614
587
  :returns: string is valid ipv4 address -- bool
615
588
  """
@@ -622,7 +595,6 @@ class CommonFunctions(object):
622
595
  @staticmethod
623
596
  def check_ipv6(ipv6):
624
597
  """Check if a given string is a valid ipv6 address
625
-
626
598
  :param ipv6: ipv6 address -- str
627
599
  :returns: string is valid ipv6 address -- bool
628
600
  """
@@ -635,7 +607,6 @@ class CommonFunctions(object):
635
607
  @staticmethod
636
608
  def convert_to_snake_case(camel_case_string):
637
609
  """Convert a string from camel case to snake case.
638
-
639
610
  :param camel_case_string: string for formatting -- str
640
611
  :returns: snake case variant -- str
641
612
  """
@@ -646,10 +617,8 @@ class CommonFunctions(object):
646
617
  @staticmethod
647
618
  def check_timestamp(in_timestamp):
648
619
  """Check that the timestamp is in the correct format
649
-
650
620
  :param in_timestamp: timestamp e.g. 2020-11-24 15:00 -- str
651
621
  """
652
-
653
622
  pattern = (r'^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) '
654
623
  r'(2[0-3]|[01][0-9]):[0-5][0-9]$')
655
624
  return re.match(pattern, in_timestamp)
@@ -657,10 +626,8 @@ class CommonFunctions(object):
657
626
  @staticmethod
658
627
  def check_epoch_timestamp(in_epoch_timestamp):
659
628
  """Check that the timestamp is in the correct format
660
-
661
629
  :param in_epoch_timestamp: timestamp e.g. 1554332400 -- str
662
630
  """
663
-
664
631
  pattern1 = r'^[0-9]{10}$'
665
632
  pattern2 = r'^[0-9]{13}$'
666
633
  return re.match(pattern1, in_epoch_timestamp) or re.match(
@@ -668,14 +635,11 @@ class CommonFunctions(object):
668
635
 
669
636
  def is_array_v4(self, array_id):
670
637
  """Check to see if array is a v4
671
-
672
638
  :param array_id: the array serial number
673
639
  :returns: bool
674
640
  """
675
-
676
641
  is_v4 = False
677
642
  array_details = self.get_array(array_id)
678
-
679
643
  if array_details:
680
644
  ucode_version = array_details.get(
681
645
  'ucode') or array_details.get('microcode')
@@ -683,5 +647,4 @@ class CommonFunctions(object):
683
647
  major_version = ucode_version.split('.')[0]
684
648
  if major_version >= constants.UCODE_6079:
685
649
  is_v4 = True
686
-
687
650
  return is_v4
@@ -0,0 +1,112 @@
1
+ # Copyright (c) 2023 Dell Inc. or its subsidiaries.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain 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,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """enhanced_api.py."""
15
+
16
+ import logging
17
+
18
+ from PyU4V.common import CommonFunctions
19
+ from PyU4V.utils import constants
20
+
21
+ LOG = logging.getLogger(__name__)
22
+
23
+
24
+ class EnhancedAPIFunctions(object):
25
+ """Enhanced Functions for retrieving data about provisioned storage
26
+ objects."""
27
+
28
+ def __init__(self, array_id, rest_client):
29
+ """__init__."""
30
+ self.common = CommonFunctions(rest_client)
31
+ self.get_resource = self.common.get_resource
32
+ self.array_id = array_id
33
+ self.enhanced_api_version = constants.ENHANCED_API_VERSION
34
+
35
+ def get_storage_object_meta_data(self, storage_object):
36
+ """Get details on available metadata for storage objects of the
37
+ specified type.
38
+
39
+ :param: storage_object, the storage object to get metadata for,
40
+ valid values are directors, hosts, initiators,
41
+ ip-interfaces, ip-routes, masking-views, port-groups, ports,
42
+ rdf-groups, storage-groups, volumes -- string
43
+ :returns: dictionary with list of attributes and descriptions of
44
+ attribute types used for filtering and selection -- dict
45
+ """
46
+ response = self.common.get_request(
47
+ target_uri=f"/{self.enhanced_api_version}/systems"
48
+ f"/{storage_object}/metadata",
49
+ resource_type=None)
50
+ return response
51
+
52
+ def get_storage_object_details(
53
+ self, storage_object, array_id=None, filters=None, select=None,
54
+ exclude=None):
55
+ """Get list of volumes from array with selected parameters.
56
+
57
+ :param: storage_object, the storage object to get metadata for,
58
+ valid values are directors, hosts, initiators,
59
+ ip-interfaces, ip-routes, masking-views, port-groups, ports,
60
+ rdf-groups, storage-groups, volumes -- string
61
+ :param array_id: The storage array ID -- string
62
+ :param filters: filter parameters, used to narrow down the result
63
+ list, filters can be any of the volume attributes,
64
+ and operators vary depending on type,
65
+ 'eq','ne','gt','ge','lt','le', equal, not equal,
66
+ greater than, greater than or equal, less than,
67
+ less than or equal, additional operators are
68
+ 'like','ilike' for string match, or case in-sensitive
69
+ string match, example
70
+ filters=['num_of_storage_groups eq 1',
71
+ 'identifier ilike findme'] -- list
72
+ :param select: selection of attributes to be in return, attributes
73
+ can be listed using get_volumes_meta_data function
74
+ If none selected base set of top level attributes are
75
+ returned, by default API will only return id,
76
+ to achieve this pass a list with empty string [''],
77
+ to extend the list of attributes returned to include
78
+ second level attributes you can pass along with list
79
+ from get_volumes_meta_data() e.g.
80
+ select=api.volumes.get_volumes_meta_data() +
81
+ ['snapshots.name'] -- list
82
+ :param exclude: list of attributes to exclude, by default rdf_infos
83
+ and snapshot details have been excluded as these can
84
+ extend the running of the API call, to override
85
+ simply pass an empty list or specify a list of
86
+ attribute names that you want to exclude from the
87
+ return, if values are passed in by select exclude is
88
+ ignored -- list
89
+ :returns: dict
90
+ """
91
+ array_id = array_id if array_id else self.array_id
92
+ if not exclude:
93
+ exclude = ['rdf_infos', 'snapshots']
94
+ if not select:
95
+ select = []
96
+ volume_metadata = self.get_storage_object_meta_data(
97
+ storage_object=storage_object)
98
+ for attribute in volume_metadata:
99
+ if attribute['name'] not in exclude:
100
+ select.append(attribute['name'])
101
+ select.append(attribute['name'])
102
+ select = ','.join(select)
103
+ if filters:
104
+ filters = '&filter=' + ','.join(filters)
105
+ else:
106
+ filters = ''
107
+ response = self.common.get_request(
108
+ target_uri=f"/{self.enhanced_api_version}/systems"
109
+ f"/{array_id}/{storage_object}"
110
+ f"?select={select}{filters}",
111
+ resource_type=None)
112
+ return response