PyU4V 10.3.0.0__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.
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PKG-INFO +8 -8
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/clone.py +17 -17
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/common.py +28 -68
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/performance.py +0 -84
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/performance_enhanced.py +18 -2
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/provisioning.py +1 -1
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/replication.py +11 -5
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/rest_requests.py +76 -31
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/serviceability.py +36 -35
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/settings.py +37 -36
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/system.py +12 -12
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/univmax_conn.py +109 -30
- pyu4v-10.4.0.0/PyU4V/version.py +6 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/README.rst +7 -7
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/pyu4v.egg-info/PKG-INFO +8 -8
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/setup.py +1 -1
- pyu4v-10.3.0.0/PyU4V/version.py +0 -6
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/LICENSE +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/__init__.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/enhanced_api.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/metro_dr.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/migration.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/real_time.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/scripts/__init__.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/scripts/replace_version.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/snapshot_policy.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/storage_groups.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/tools/__init__.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/tools/generate_functions.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/tools/openstack/__init__.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/tools/openstack/migrate.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/tools/openstack/migrate_utils.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/__init__.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/config_handler.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/console.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/constants.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/decorators.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/exception.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/file_handler.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/performance_category_map.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/performance_constants.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/time_handler.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/utils/utils.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/volumes.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/PyU4V/workload_planner.py +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/pyu4v.egg-info/SOURCES.txt +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/pyu4v.egg-info/dependency_links.txt +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/pyu4v.egg-info/requires.txt +0 -0
- {pyu4v-10.3.0.0 → pyu4v-10.4.0.0}/pyu4v.egg-info/top_level.txt +0 -0
- {pyu4v-10.3.0.0 → 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.
|
|
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.
|
|
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.3
|
|
|
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.
|
|
31
|
+
PyU4V Version 10.4
|
|
32
32
|
------------------
|
|
33
33
|
|
|
34
34
|
+-------------------------------+----------------------------+
|
|
35
35
|
| **Author** | Dell EMC |
|
|
36
36
|
+-------------------------------+----------------------------+
|
|
37
|
-
| **PyU4V Version** | 10.
|
|
37
|
+
| **PyU4V Version** | 10.4.0.0 |
|
|
38
38
|
+-------------------------------+----------------------------+
|
|
39
|
-
| **Minimum Unisphere Version** | 10.
|
|
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.3
|
|
|
55
55
|
version of Unisphere older than 9.1.x
|
|
56
56
|
|
|
57
57
|
Note
|
|
58
|
-
PyU4V version 10.
|
|
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.3
|
|
|
82
82
|
|
|
83
83
|
$ pip install PyU4V
|
|
84
84
|
# Install a specific version
|
|
85
|
-
$ pip install PyU4V==10.
|
|
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.3
|
|
|
171
171
|
|
|
172
172
|
conn = PyU4V.U4VConn()
|
|
173
173
|
conn.common.get_unisphere_version()
|
|
174
|
-
>> {'version': '10.
|
|
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:
|
|
@@ -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.
|
|
109
|
-
f"/storagegroup/{storage_group_id}
|
|
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.
|
|
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.
|
|
143
|
-
f"/storagegroup/{storage_group_id}/clone
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
302
|
-
f"/storagegroup/{storage_group_id}/clone/
|
|
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.
|
|
336
|
-
f"/storagegroup/{storage_group_id}/clone/
|
|
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
|
-
#
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,7 +162,6 @@ 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
|
|
@@ -169,7 +170,6 @@ class CommonFunctions(object):
|
|
|
169
170
|
if status_code == None:
|
|
170
171
|
raise exception.VolumeBackendAPIException(
|
|
171
172
|
data="Server unavailable or IP incorrect")
|
|
172
|
-
|
|
173
173
|
if status_code not in [STATUS_200, STATUS_201,
|
|
174
174
|
STATUS_202, STATUS_204]:
|
|
175
175
|
exception_message = (
|
|
@@ -185,7 +185,6 @@ class CommonFunctions(object):
|
|
|
185
185
|
|
|
186
186
|
def wait_for_job(self, operation, status_code, job):
|
|
187
187
|
"""Check if call is async, wait for it to complete.
|
|
188
|
-
|
|
189
188
|
:param operation: operation being performed -- str
|
|
190
189
|
:param status_code: status code -- int
|
|
191
190
|
:param job: job id -- str
|
|
@@ -208,9 +207,7 @@ class CommonFunctions(object):
|
|
|
208
207
|
|
|
209
208
|
def build_target_uri(self, **kwargs):
|
|
210
209
|
"""Build the target URI.
|
|
211
|
-
|
|
212
210
|
This function calls into _build_uri() for access outside this class.
|
|
213
|
-
|
|
214
211
|
:key version: Unisphere version -- int
|
|
215
212
|
:key no_version: if versionless uri -- bool
|
|
216
213
|
:key category: resource category e.g. sloprovisioning -- str
|
|
@@ -228,7 +225,6 @@ class CommonFunctions(object):
|
|
|
228
225
|
|
|
229
226
|
def _build_uri(self, **kwargs):
|
|
230
227
|
"""Build the target URI.
|
|
231
|
-
|
|
232
228
|
:key version: Unisphere version -- int
|
|
233
229
|
:key no_version: if versionless uri -- bool
|
|
234
230
|
:key category: resource category e.g. sloprovisioning -- str
|
|
@@ -243,50 +239,41 @@ class CommonFunctions(object):
|
|
|
243
239
|
:returns: target URI -- str
|
|
244
240
|
"""
|
|
245
241
|
target_uri, version = str(), None
|
|
246
|
-
|
|
247
242
|
if kwargs.get('category') not in ['performance', 'common']:
|
|
248
243
|
version = self._build_uri_get_version(kwargs.get('version'),
|
|
249
244
|
kwargs.get('no_version'))
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
245
|
+
if version:
|
|
246
|
+
target_uri += '/{version}'.format(version=version)
|
|
253
247
|
target_uri += '/{category}'.format(
|
|
254
248
|
category=kwargs.get('category'))
|
|
255
|
-
|
|
256
249
|
if kwargs.get('resource_level'):
|
|
257
250
|
target_uri += '/{resource_level}'.format(
|
|
258
251
|
resource_level=kwargs.get('resource_level'))
|
|
259
|
-
|
|
260
252
|
if kwargs.get('resource_level_id'):
|
|
261
253
|
target_uri += '/{resource_level_id}'.format(
|
|
262
254
|
resource_level_id=kwargs.get('resource_level_id'))
|
|
263
|
-
|
|
264
255
|
if kwargs.get('resource_type'):
|
|
265
256
|
target_uri += '/{resource_type}'.format(
|
|
266
257
|
resource_type=kwargs.get('resource_type'))
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
258
|
+
if kwargs.get('resource_type_id'):
|
|
259
|
+
target_uri += '/{resource_type_id}'.format(
|
|
260
|
+
resource_type_id=kwargs.get('resource_type_id'))
|
|
271
261
|
if kwargs.get('resource'):
|
|
272
262
|
target_uri += '/{resource}'.format(
|
|
273
263
|
resource=kwargs.get('resource'))
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
264
|
+
if kwargs.get('resource_id'):
|
|
265
|
+
target_uri += '/{resource_id}'.format(
|
|
266
|
+
resource_id=kwargs.get('resource_id'))
|
|
278
267
|
if kwargs.get('object_type'):
|
|
279
268
|
target_uri += '/{object_type}'.format(
|
|
280
269
|
object_type=kwargs.get('object_type'))
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
270
|
+
if kwargs.get('object_type_id'):
|
|
271
|
+
target_uri += '/{object_type_id}'.format(
|
|
272
|
+
object_type_id=kwargs.get('object_type_id'))
|
|
285
273
|
return target_uri
|
|
286
274
|
|
|
287
275
|
def _build_uri_get_version(self, version=None, no_version=False):
|
|
288
276
|
"""Get the Unisphere version for the target URI.
|
|
289
|
-
|
|
290
277
|
:param version: version to use from kwargs -- str
|
|
291
278
|
:param no_version: if URI should be versionless -- bool
|
|
292
279
|
:returns: version -- str
|
|
@@ -304,7 +291,6 @@ class CommonFunctions(object):
|
|
|
304
291
|
|
|
305
292
|
def get_request(self, target_uri, resource_type, params=None):
|
|
306
293
|
"""Send a GET request to the array.
|
|
307
|
-
|
|
308
294
|
:param target_uri: target uri -- str
|
|
309
295
|
:param resource_type: the resource type, e.g. maskingview -- str
|
|
310
296
|
:param params: optional filter params -- dict
|
|
@@ -318,7 +304,6 @@ class CommonFunctions(object):
|
|
|
318
304
|
|
|
319
305
|
def get_resource(self, *args, **kwargs):
|
|
320
306
|
"""Get resource details from the array.
|
|
321
|
-
|
|
322
307
|
:key version: Unisphere version -- int
|
|
323
308
|
:key no_version: if versionless uri -- bool
|
|
324
309
|
:key category: resource category e.g. sloprovisioning -- str
|
|
@@ -344,7 +329,6 @@ class CommonFunctions(object):
|
|
|
344
329
|
|
|
345
330
|
def create_resource(self, *args, **kwargs):
|
|
346
331
|
"""Create a resource.
|
|
347
|
-
|
|
348
332
|
:key version: Unisphere version -- int
|
|
349
333
|
:key no_version: if versionless uri -- bool
|
|
350
334
|
:key category: resource category e.g. sloprovisioning -- str
|
|
@@ -376,7 +360,6 @@ class CommonFunctions(object):
|
|
|
376
360
|
|
|
377
361
|
def modify_resource(self, *args, **kwargs):
|
|
378
362
|
"""Modify a resource.
|
|
379
|
-
|
|
380
363
|
:key version: Unisphere version -- int
|
|
381
364
|
:key no_version: if versionless uri -- bool
|
|
382
365
|
:key category: resource category e.g. sloprovisioning -- str
|
|
@@ -408,7 +391,6 @@ class CommonFunctions(object):
|
|
|
408
391
|
|
|
409
392
|
def delete_resource(self, *args, **kwargs):
|
|
410
393
|
"""Delete a resource.
|
|
411
|
-
|
|
412
394
|
:key version: Unisphere version -- int
|
|
413
395
|
:key no_version: if versionless uri -- bool
|
|
414
396
|
:key category: resource category e.g. sloprovisioning -- str
|
|
@@ -439,7 +421,6 @@ class CommonFunctions(object):
|
|
|
439
421
|
|
|
440
422
|
def download_file(self, **kwargs):
|
|
441
423
|
"""Download a file.
|
|
442
|
-
|
|
443
424
|
:key version: Unisphere version -- int
|
|
444
425
|
:key no_version: if versionless uri -- bool
|
|
445
426
|
:key category: resource category e.g. sloprovisioning -- str
|
|
@@ -476,7 +457,6 @@ class CommonFunctions(object):
|
|
|
476
457
|
|
|
477
458
|
def upload_file(self, **kwargs):
|
|
478
459
|
"""Upload a file.
|
|
479
|
-
|
|
480
460
|
:key version: Unisphere version -- int
|
|
481
461
|
:key no_version: if versionless uri -- bool
|
|
482
462
|
:key category: resource category e.g. sloprovisioning -- str
|
|
@@ -519,7 +499,6 @@ class CommonFunctions(object):
|
|
|
519
499
|
|
|
520
500
|
def get_uni_version(self):
|
|
521
501
|
"""Get the unisphere version from the server.
|
|
522
|
-
|
|
523
502
|
:returns: version and major_version e.g. "V10.0.0.0", "100" -- str, str
|
|
524
503
|
"""
|
|
525
504
|
version, major_version = None, None
|
|
@@ -532,17 +511,14 @@ class CommonFunctions(object):
|
|
|
532
511
|
|
|
533
512
|
def get_uni_version_info(self):
|
|
534
513
|
"""Get the unisphere version from the server.
|
|
535
|
-
|
|
536
514
|
:returns: {'version': 'T10.1.0.468', 'api_version': '101',
|
|
537
|
-
|
|
515
|
+
'supported_api_versions': ['101', '100', '92']} -- dict
|
|
538
516
|
"""
|
|
539
517
|
response = self.get_resource(category=VERSION, no_version=True)
|
|
540
|
-
|
|
541
518
|
return response
|
|
542
519
|
|
|
543
520
|
def get_array_list(self, filters=None):
|
|
544
521
|
"""Return a list of arrays.
|
|
545
|
-
|
|
546
522
|
:param filters: optional filters -- dict
|
|
547
523
|
:returns: arrays ids -- list
|
|
548
524
|
"""
|
|
@@ -552,7 +528,6 @@ class CommonFunctions(object):
|
|
|
552
528
|
|
|
553
529
|
def get_v3_or_newer_array_list(self, filters=None):
|
|
554
530
|
"""Return a list of V3 or newer arrays in the environment.
|
|
555
|
-
|
|
556
531
|
:param filters: optional filters -- dict
|
|
557
532
|
:returns: arrays ids -- list
|
|
558
533
|
"""
|
|
@@ -562,7 +537,6 @@ class CommonFunctions(object):
|
|
|
562
537
|
|
|
563
538
|
def get_array(self, array_id):
|
|
564
539
|
"""Get array details.
|
|
565
|
-
|
|
566
540
|
:param array_id: array id -- str
|
|
567
541
|
:returns: array details -- dict
|
|
568
542
|
"""
|
|
@@ -571,7 +545,6 @@ class CommonFunctions(object):
|
|
|
571
545
|
|
|
572
546
|
def get_iterator_page_list(self, iterator_id, start, end):
|
|
573
547
|
"""Get a page of results from an iterator instance.
|
|
574
|
-
|
|
575
548
|
:param iterator_id: iterator id -- str
|
|
576
549
|
:param start: the start number -- int
|
|
577
550
|
:param end: the end number -- int
|
|
@@ -585,13 +558,11 @@ class CommonFunctions(object):
|
|
|
585
558
|
|
|
586
559
|
def get_iterator_results(self, rest_response):
|
|
587
560
|
"""Get all results from all pages of an iterator if count > 1000.
|
|
588
|
-
|
|
589
561
|
:param rest_response: response JSON from REST API -- dict
|
|
590
562
|
:returns: all results -- dict
|
|
591
563
|
"""
|
|
592
564
|
full_response = list()
|
|
593
565
|
full_response += rest_response['resultList']['result']
|
|
594
|
-
|
|
595
566
|
if rest_response.get('count') and int(rest_response.get('count')) > 0:
|
|
596
567
|
count = rest_response.get('count')
|
|
597
568
|
max_page_size = rest_response.get('maxPageSize')
|
|
@@ -612,7 +583,6 @@ class CommonFunctions(object):
|
|
|
612
583
|
@staticmethod
|
|
613
584
|
def check_ipv4(ipv4):
|
|
614
585
|
"""Check if a given string is a valid ipv6 address
|
|
615
|
-
|
|
616
586
|
:param ipv4: ipv4 address -- str
|
|
617
587
|
:returns: string is valid ipv4 address -- bool
|
|
618
588
|
"""
|
|
@@ -625,7 +595,6 @@ class CommonFunctions(object):
|
|
|
625
595
|
@staticmethod
|
|
626
596
|
def check_ipv6(ipv6):
|
|
627
597
|
"""Check if a given string is a valid ipv6 address
|
|
628
|
-
|
|
629
598
|
:param ipv6: ipv6 address -- str
|
|
630
599
|
:returns: string is valid ipv6 address -- bool
|
|
631
600
|
"""
|
|
@@ -638,7 +607,6 @@ class CommonFunctions(object):
|
|
|
638
607
|
@staticmethod
|
|
639
608
|
def convert_to_snake_case(camel_case_string):
|
|
640
609
|
"""Convert a string from camel case to snake case.
|
|
641
|
-
|
|
642
610
|
:param camel_case_string: string for formatting -- str
|
|
643
611
|
:returns: snake case variant -- str
|
|
644
612
|
"""
|
|
@@ -649,10 +617,8 @@ class CommonFunctions(object):
|
|
|
649
617
|
@staticmethod
|
|
650
618
|
def check_timestamp(in_timestamp):
|
|
651
619
|
"""Check that the timestamp is in the correct format
|
|
652
|
-
|
|
653
620
|
:param in_timestamp: timestamp e.g. 2020-11-24 15:00 -- str
|
|
654
621
|
"""
|
|
655
|
-
|
|
656
622
|
pattern = (r'^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) '
|
|
657
623
|
r'(2[0-3]|[01][0-9]):[0-5][0-9]$')
|
|
658
624
|
return re.match(pattern, in_timestamp)
|
|
@@ -660,10 +626,8 @@ class CommonFunctions(object):
|
|
|
660
626
|
@staticmethod
|
|
661
627
|
def check_epoch_timestamp(in_epoch_timestamp):
|
|
662
628
|
"""Check that the timestamp is in the correct format
|
|
663
|
-
|
|
664
629
|
:param in_epoch_timestamp: timestamp e.g. 1554332400 -- str
|
|
665
630
|
"""
|
|
666
|
-
|
|
667
631
|
pattern1 = r'^[0-9]{10}$'
|
|
668
632
|
pattern2 = r'^[0-9]{13}$'
|
|
669
633
|
return re.match(pattern1, in_epoch_timestamp) or re.match(
|
|
@@ -671,14 +635,11 @@ class CommonFunctions(object):
|
|
|
671
635
|
|
|
672
636
|
def is_array_v4(self, array_id):
|
|
673
637
|
"""Check to see if array is a v4
|
|
674
|
-
|
|
675
638
|
:param array_id: the array serial number
|
|
676
639
|
:returns: bool
|
|
677
640
|
"""
|
|
678
|
-
|
|
679
641
|
is_v4 = False
|
|
680
642
|
array_details = self.get_array(array_id)
|
|
681
|
-
|
|
682
643
|
if array_details:
|
|
683
644
|
ucode_version = array_details.get(
|
|
684
645
|
'ucode') or array_details.get('microcode')
|
|
@@ -686,5 +647,4 @@ class CommonFunctions(object):
|
|
|
686
647
|
major_version = ucode_version.split('.')[0]
|
|
687
648
|
if major_version >= constants.UCODE_6079:
|
|
688
649
|
is_v4 = True
|
|
689
|
-
|
|
690
650
|
return is_v4
|
|
@@ -882,90 +882,6 @@ class PerformanceFunctions(object):
|
|
|
882
882
|
resource_type=pc.UPDATE, resource_type_id=category,
|
|
883
883
|
payload=payload)
|
|
884
884
|
|
|
885
|
-
def generate_threshold_settings_csv(self, output_csv_path, category=None):
|
|
886
|
-
"""Generate a csv file with threshold settings.
|
|
887
|
-
|
|
888
|
-
Creates a CSV file with current alert configuration for the given
|
|
889
|
-
unisphere instance category, metric, first_threshold, second_threshold,
|
|
890
|
-
alert_user, kpi.
|
|
891
|
-
|
|
892
|
-
:param output_csv_path: filename for CSV to be generated -- str
|
|
893
|
-
:param category: threshold specific category -- str
|
|
894
|
-
"""
|
|
895
|
-
LOG.warning("Warning: This function is deprecated and will be removed "
|
|
896
|
-
"in future version 10.4. Please explore API Calls in new "
|
|
897
|
-
"settings Category for getting and setting thresholds")
|
|
898
|
-
category_list = (
|
|
899
|
-
self.get_threshold_categories() if not category else [category])
|
|
900
|
-
data_for_csv = list()
|
|
901
|
-
data_for_csv.append([pc.CATEGORY, pc.METRIC, pc.FIRST_THRESH,
|
|
902
|
-
pc.SEC_THRESH, pc.ALERT_ERR, pc.KPI])
|
|
903
|
-
for category in category_list:
|
|
904
|
-
metric_setting = self.get_threshold_category_settings(category)
|
|
905
|
-
threshold_settings = metric_setting.get(pc.PERF_THRESH)
|
|
906
|
-
for threshold in threshold_settings:
|
|
907
|
-
data_for_csv.append([
|
|
908
|
-
category, threshold.get(pc.METRIC),
|
|
909
|
-
threshold.get("firstUpperThreshold"),
|
|
910
|
-
threshold.get("secondUpperThreshold"),
|
|
911
|
-
threshold.get(pc.ALERT_ERR), threshold.get(pc.KPI)])
|
|
912
|
-
file_handler.write_to_csv_file(output_csv_path, data_for_csv)
|
|
913
|
-
|
|
914
|
-
def set_thresholds_from_csv(self, csv_file_path, kpi_only=True):
|
|
915
|
-
"""Set performance thresholds using a CSV file.
|
|
916
|
-
|
|
917
|
-
Reads CSV file and sets performance threshold metrics on the values
|
|
918
|
-
contained within. The following headers are required:
|
|
919
|
-
category, metric, firstthreshold, secondthreshold, notify, kpi
|
|
920
|
-
|
|
921
|
-
It is advisable to generate the CSV file from the function
|
|
922
|
-
performance.generate_threshold_settings_csv() and edit those values
|
|
923
|
-
within that you would like to change.
|
|
924
|
-
|
|
925
|
-
:param csv_file_path: path to CSV file -- str
|
|
926
|
-
:param kpi_only: set only KPI thresholds -- bool
|
|
927
|
-
"""
|
|
928
|
-
LOG.warning("Warning: This function is deprecated and will be removed "
|
|
929
|
-
"in version 10.4. Please explore API Calls in new "
|
|
930
|
-
"settings Category for getting and setting thresholds")
|
|
931
|
-
|
|
932
|
-
def _str_to_bool(str_in):
|
|
933
|
-
return str_in == 'True'
|
|
934
|
-
|
|
935
|
-
data = file_handler.read_csv_values(csv_file_path)
|
|
936
|
-
category_list = data.get(pc.CATEGORY)
|
|
937
|
-
metric_list = data.get(pc.METRIC)
|
|
938
|
-
notify_list = data.get(pc.ALERT_ERR)
|
|
939
|
-
f_threshold_list = data.get("firstThreshold")
|
|
940
|
-
s_threshold_list = data.get("secondThreshold")
|
|
941
|
-
is_kpi = data.get(pc.KPI)
|
|
942
|
-
|
|
943
|
-
for i in range(0, len(metric_list)):
|
|
944
|
-
if not _str_to_bool(is_kpi[i]) and kpi_only:
|
|
945
|
-
continue
|
|
946
|
-
if not (f_threshold_list[i]) or not (s_threshold_list[i]):
|
|
947
|
-
LOG.warning(
|
|
948
|
-
'Not setting performance metric {m} threshold as '
|
|
949
|
-
'values are not in file'.format(
|
|
950
|
-
m=metric_list[i], ))
|
|
951
|
-
continue
|
|
952
|
-
if (f_threshold_list[i]) >= (s_threshold_list[i]):
|
|
953
|
-
LOG.warning(
|
|
954
|
-
'Not setting performance metric {m} threshold, second '
|
|
955
|
-
'threshold value {f} must be greater than first threshold '
|
|
956
|
-
'value {s}.'.format(
|
|
957
|
-
m=metric_list[i], f=f_threshold_list[i],
|
|
958
|
-
s=s_threshold_list[i]))
|
|
959
|
-
continue
|
|
960
|
-
try:
|
|
961
|
-
self.update_threshold_settings(
|
|
962
|
-
category=category_list[i], metric=metric_list[i],
|
|
963
|
-
alert=notify_list[i], first_threshold=f_threshold_list[i],
|
|
964
|
-
second_threshold=s_threshold_list[i],
|
|
965
|
-
include_realtime_trace=False)
|
|
966
|
-
except Exception as e:
|
|
967
|
-
LOG.error('Error updating threshold settings: {e}'.format(e=e))
|
|
968
|
-
|
|
969
885
|
def get_array_keys(self):
|
|
970
886
|
"""List Arrays registered for performance data collection.
|
|
971
887
|
|
|
@@ -56,21 +56,37 @@ class EnhancedPerformanceFunctions(object):
|
|
|
56
56
|
category_list = []
|
|
57
57
|
return category_list
|
|
58
58
|
|
|
59
|
-
def get_all_performance_metrics_for_system(self, array_id=None
|
|
59
|
+
def get_all_performance_metrics_for_system(self, array_id=None,
|
|
60
|
+
filters=None):
|
|
60
61
|
"""Get latest data for all KPI metrics.
|
|
61
62
|
|
|
62
63
|
:param array_id: 12 Digit Serial Number of Array -- int
|
|
64
|
+
:param filters: users can filter on the time_range and component id,
|
|
65
|
+
these can be combined in single query,
|
|
66
|
+
e.g. filters=['time_range eq 1','id ilike Oracle',
|
|
67
|
+
'data_format eq Maximum']
|
|
68
|
+
valid values for time range are 1,2,4,8,12,
|
|
69
|
+
24 in hours, you can also specify data_format to
|
|
70
|
+
return Average or Maximum values, note for max
|
|
71
|
+
values to be retuned you must be registered for
|
|
72
|
+
realtime statistics -- list
|
|
63
73
|
:returns: data for all available categories for the specified PowerMax
|
|
64
74
|
Array diagnostic level metrics only, 5 min interval -- dict
|
|
65
75
|
"""
|
|
66
76
|
array_id = array_id if array_id else self.array_id
|
|
67
77
|
category_list = self.get_performance_categories_list(array_id=array_id)
|
|
68
78
|
full_metric_collection = []
|
|
79
|
+
"""Build the optional filter part – empty string when no filters are
|
|
80
|
+
given.
|
|
81
|
+
"""
|
|
82
|
+
filter_part = ''
|
|
83
|
+
if filters: # filters is not None/empty
|
|
84
|
+
filter_part = '?filter=' + ','.join(filters)
|
|
69
85
|
for category in category_list:
|
|
70
86
|
response = self.common.get_request(
|
|
71
87
|
target_uri=f"/{self.enhanced_api_version}/systems"
|
|
72
88
|
f"/{array_id}/performance-categories/"
|
|
73
|
-
f"{category['id']}",
|
|
89
|
+
f"{category['id']}{filter_part}",
|
|
74
90
|
resource_type=None)
|
|
75
91
|
if response is not None:
|
|
76
92
|
full_metric_collection.append(response)
|
|
@@ -1782,7 +1782,7 @@ class ProvisioningFunctions(object):
|
|
|
1782
1782
|
}}}
|
|
1783
1783
|
try:
|
|
1784
1784
|
return self.common.modify_resource(
|
|
1785
|
-
target_uri=f"/{self.
|
|
1785
|
+
target_uri=f"/{self.common.UNI_VERSION}/sloprovisioning/"
|
|
1786
1786
|
f"symmetrix/{array_id}/volume/{device_id}",
|
|
1787
1787
|
resource_type=None, payload=payload)
|
|
1788
1788
|
except Exception as e:
|