Skip to content

Commit 83e9b75

Browse files
committed
Add volume_class support to volume.py
Fixes bug dell#37
1 parent 01ceef1 commit 83e9b75

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

PyPowerFlex/objects/volume.py

+42-12
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ class VolumeType:
5555
thin = 'ThinProvisioned'
5656

5757

58+
class VolumeClass:
59+
"""Volume class types."""
60+
61+
supported_vol_classes = (
62+
['defaultclass', 'replication', 'csi', 'openstack', 'vvol', 'datastore',
63+
'nasfs', 'nasvdm', 'nascluster', 'nas', 'management', 'snap_mobility',
64+
'ntnx'])
65+
for vol_class in supported_vol_classes:
66+
locals()[vol_class] = vol_class
67+
68+
5869
class Volume(base_client.EntityRequest):
5970
"""
6071
A class representing Volume client.
@@ -65,7 +76,8 @@ def add_mapped_sdc(self,
6576
sdc_guid=None,
6677
allow_multiple_mappings=None,
6778
allow_ext_managed=None,
68-
access_mode=None):
79+
access_mode=None,
80+
volume_class=VolumeClass.defaultclass):
6981
"""Map PowerFlex volume to SDC.
7082
7183
:param volume_id: str
@@ -74,6 +86,7 @@ def add_mapped_sdc(self,
7486
:param allow_multiple_mappings: bool
7587
:param allow_ext_managed: bool
7688
:type access_mode: str
89+
:param volume_class: str
7790
:return: dict
7891
"""
7992

@@ -87,7 +100,8 @@ def add_mapped_sdc(self,
87100
"guid": sdc_guid,
88101
"allowMultipleMappings": allow_multiple_mappings,
89102
"allowOnExtManagedVol": allow_ext_managed,
90-
"accessMode": access_mode
103+
"accessMode": access_mode,
104+
"volumeClass": volume_class
91105
}
92106

93107
r, response = self.send_post_request(self.base_action_url,
@@ -111,7 +125,8 @@ def create(self,
111125
name=None,
112126
volume_type=None,
113127
use_rmcache=None,
114-
compression_method=None):
128+
compression_method=None,
129+
volume_class=VolumeClass.defaultclass):
115130
"""Create PowerFlex volume.
116131
117132
:param storage_pool_id: str
@@ -123,6 +138,7 @@ def create(self,
123138
:param compression_method: one of predefined attributes of
124139
CompressionMethod
125140
:type compression_method: str
141+
:param volume_class: str
126142
:return: dict
127143
"""
128144

@@ -132,39 +148,47 @@ def create(self,
132148
'name': name,
133149
'volumeType': volume_type,
134150
'useRmcache': use_rmcache,
135-
'compressionMethod': compression_method
151+
'compressionMethod': compression_method,
152+
'volumeClass': volume_class
136153
}
137154

138155
return self._create_entity(params)
139156

140-
def delete(self, volume_id, remove_mode, allow_ext_managed=None):
157+
def delete(self, volume_id, remove_mode, allow_ext_managed=None,
158+
volume_class=VolumeClass.defaultclass):
141159
"""Remove PowerFlex volume.
142160
143161
:param volume_id: str
144162
:param remove_mode: one of predefined attributes of RemoveMode
145163
:param allow_ext_managed: bool
164+
:param volume_class: str
146165
:return: None
147166
"""
148167

149168
params = {
150169
"removeMode": remove_mode,
151-
"allowOnExtManagedVol": allow_ext_managed
170+
"allowOnExtManagedVol": allow_ext_managed,
171+
"volumeClass": volume_class
152172
}
153173

154174
return self._delete_entity(volume_id, params)
155175

156-
def extend(self, volume_id, size_in_gb, allow_ext_managed=None):
176+
def extend(self, volume_id, size_in_gb, allow_ext_managed=None,
177+
volume_class=VolumeClass.defaultclass):
157178
"""Extend PowerFlex volume.
158179
159180
:param volume_id: str
160181
:param size_in_gb: int
161182
:param allow_ext_managed: bool
183+
:param volume_class: str
162184
:return: dict
163185
"""
164186

165187
action = 'setVolumeSize'
166188

167-
params = {"sizeInGB": size_in_gb, "allowOnExtManagedVol": allow_ext_managed}
189+
params = {"sizeInGB": size_in_gb,
190+
"allowOnExtManagedVol": allow_ext_managed,
191+
"volumeClass": volume_class}
168192

169193
r, response = self.send_post_request(self.base_action_url,
170194
action=action,
@@ -223,7 +247,8 @@ def remove_mapped_sdc(self,
223247
sdc_guid=None,
224248
all_sdcs=None,
225249
skip_appliance_validation=None,
226-
allow_ext_managed=None):
250+
allow_ext_managed=None,
251+
volume_class=VolumeClass.defaultclass):
227252
"""Unmap PowerFlex volume from SDC.
228253
229254
:param volume_id: str
@@ -232,6 +257,7 @@ def remove_mapped_sdc(self,
232257
:param all_sdcs: bool
233258
:param skip_appliance_validation: bool
234259
:param allow_ext_managed: bool
260+
:param volume_class: str
235261
:return: dict
236262
"""
237263

@@ -249,7 +275,8 @@ def remove_mapped_sdc(self,
249275
"guid": sdc_guid,
250276
"allSdcs": all_sdcs,
251277
"skipApplianceValidation": skip_appliance_validation,
252-
"allowOnExtManagedVol": allow_ext_managed
278+
"allowOnExtManagedVol": allow_ext_managed,
279+
"volumeClass": volume_class
253280
}
254281

255282
r, response = self.send_post_request(self.base_action_url,
@@ -267,20 +294,23 @@ def remove_mapped_sdc(self,
267294

268295
return self.get(entity_id=volume_id)
269296

270-
def rename(self, volume_id, name, allow_ext_managed=None):
297+
def rename(self, volume_id, name, allow_ext_managed=None,
298+
volume_class=VolumeClass.defaultclass):
271299
"""Rename PowerFlex volume.
272300
273301
:param volume_id: str
274302
:param name: str
275303
:param allow_ext_managed: bool
304+
:param volume_class: str
276305
:return: dict
277306
"""
278307

279308
action = 'setVolumeName'
280309

281310
params = {
282311
"newName": name,
283-
"allowOnExtManagedVol": allow_ext_managed
312+
"allowOnExtManagedVol": allow_ext_managed,
313+
"volume_class": volume_class
284314
}
285315

286316
return self._rename_entity(action, volume_id, params)

0 commit comments

Comments
 (0)