Skip to content

Commit 15ee0a0

Browse files
committed
Update device, device and node functions
1 parent e2478a2 commit 15ee0a0

5 files changed

Lines changed: 52 additions & 65 deletions

File tree

‎PyPowerFlex/objects/gen2/device.py‎

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ class Device(base_client.EntityRequest):
4141

4242
def create(self,
4343
current_pathname,
44+
media_type,
4445
device_group_id,
4546
node_id,
4647
force=None,
47-
media_type=None,
4848
name=None):
4949
"""Create PowerFlex device.
5050
@@ -58,8 +58,8 @@ def create(self,
5858
:rtype: dict
5959
"""
6060

61-
if not all([current_pathname, device_group_id, node_id]):
62-
msg = 'current_pathname, device_group_id and node_id must be set.'
61+
if not all([current_pathname, media_type, device_group_id, node_id]):
62+
msg = 'current_pathname, media_type, device_group_id and node_id must be set.'
6363
raise exceptions.InvalidInput(msg)
6464

6565
params = {
@@ -98,37 +98,8 @@ def rename(self, device_id, name):
9898

9999
return self._rename_entity(action, device_id, params)
100100

101-
def update_pathname(self, device_id, new_pathname):
102-
"""Update PowerFlex device pathname.
103-
TODO TTHE make sure this API is valid after the latest dev build is ready
104-
105-
:type device_id: str
106-
:type new_pathname: str
107-
:rtype: dict
108-
"""
109-
110-
action = 'updateDeviceOriginalPathname'
111-
params = {"updateDeviceOriginalPathname": new_pathname}
112-
r, response = self.send_post_request(self.base_action_url,
113-
action=action,
114-
entity=self.entity,
115-
entity_id=device_id,
116-
params=params)
117-
if r.status_code != requests.codes.ok:
118-
msg = (
119-
f"Failed to update pathname for PowerFlex {self.entity} "
120-
f"with id {device_id}. "
121-
f"Error: {response}"
122-
)
123-
LOG.error(msg)
124-
raise exceptions.PowerFlexClientException(msg)
125-
126-
return self.get(entity_id=device_id)
127-
128101
def set_capacity_limit(self, device_id, capacity_limit_gb):
129102
"""Update PowerFlex device capacity limit in GB.
130-
TODO TTHE make sure this API is valid after the latest dev build is ready
131-
132103
:type device_id: str
133104
:type capacity_limit_gb: int
134105
:rtype: dict
@@ -154,9 +125,8 @@ def set_capacity_limit(self, device_id, capacity_limit_gb):
154125

155126
def clear_errors(self, device_id, force=None):
156127
"""Clear PowerFlex device errors.
157-
TODO TTHE make sure this field - `forceClear` is valid after the latest dev build is ready
158-
159128
:type device_id: str
129+
:type force: bool
160130
:rtype: dict
161131
"""
162132

‎PyPowerFlex/objects/gen2/device_group.py‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,12 @@ def create(self,
6969

7070
return self._create_entity(params)
7171

72-
def delete(self, device_group_id, force=None):
72+
def delete(self, device_group_id):
7373
"""Remove PowerFlex device group.
74-
TODO TTHE make sure this `force` field is valid after the latest dev build is ready
75-
7674
:type device_group_id: str
77-
:type force: bool
7875
:rtype: None
7976
"""
80-
params = {
81-
"force": force
82-
}
83-
84-
return self._delete_entity(device_group_id, params)
77+
return self._delete_entity(device_group_id)
8578

8679
def modify(self,
8780
device_group_id,

‎PyPowerFlex/objects/gen2/storage_node.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,31 @@ def set_ip_role(self, node_id, ip, role):
190190
raise exceptions.PowerFlexClientException(msg)
191191

192192
return self.get(entity_id=node_id)
193+
194+
def update_original_pathnames(self, node_id, force=None):
195+
"""Update original pathnames for PowerFlex Storage Node.
196+
197+
:type node_id: str
198+
:type force: bool
199+
:rtype: dict
200+
"""
201+
202+
action = 'updateNodeOriginalPathnames'
203+
204+
params = {"forceFailedDevices": force}
205+
206+
r, response = self.send_post_request(self.base_action_url,
207+
action=action,
208+
entity=self.entity,
209+
entity_id=node_id,
210+
params=params)
211+
if r.status_code != requests.codes.ok:
212+
msg = (
213+
f"Failed to update original pathnames for PowerFlex {self.entity} "
214+
f"with id {node_id}. "
215+
f"Error: {response}"
216+
)
217+
LOG.error(msg)
218+
raise exceptions.PowerFlexClientException(msg)
219+
220+
return self.get(entity_id=node_id)

‎tests/gen2/test_device.py‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ def setUp(self):
5454
'/action/setDeviceCapacityLimit':
5555
{},
5656
f'/instances/Device::{self.fake_device_id}'
57-
'/action/updateDeviceOriginalPathname':
58-
{},
59-
f'/instances/Device::{self.fake_device_id}'
6057
'/action/clearDeviceError':
6158
{},
6259
f'/instances/Device::{self.fake_device_id}'
@@ -152,25 +149,6 @@ def test_device_rename_bad_status(self):
152149
self.fake_device_id,
153150
name='new_name')
154151

155-
def test_device_update_pathname(self):
156-
"""
157-
Test device update_pathname.
158-
"""
159-
self.client.device.update_pathname(
160-
self.fake_device_id,
161-
new_pathname='/dev/sdb')
162-
163-
def test_device_update_pathname_bad_status(self):
164-
"""
165-
Test device update_pathname with bad status.
166-
"""
167-
with self.http_response_mode(self.RESPONSE_MODE.BadStatus):
168-
self.assertRaises(
169-
exceptions.PowerFlexClientException,
170-
self.client.device.update_pathname,
171-
self.fake_device_id,
172-
new_pathname='/dev/sdb')
173-
174152
def test_device_set_capacity_limit(self):
175153
"""
176154
Test device set_capacity_limit.

‎tests/gen2/test_storage_node.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def setUp(self):
5656
{},
5757
f'/instances/Node::{self.fake_node_id}/action/modifyIpRole':
5858
{},
59+
f'/instances/Node::{self.fake_node_id}/action/updateNodeOriginalPathnames':
60+
{},
5961
},
6062
self.RESPONSE_MODE.Invalid: {
6163
'/types/Node/instances':
@@ -178,3 +180,19 @@ def test_storage_node_set_ip_role_bad_status(self):
178180
self.fake_node_id,
179181
ip='1.2.3.4',
180182
role=StorageNodeIpRoles.storage_and_app)
183+
184+
def test_storage_node_update_original_pathnames(self):
185+
"""
186+
Test storage_node update_original_pathnames.
187+
"""
188+
self.client.storage_node.update_original_pathnames(self.fake_node_id)
189+
190+
def test_storage_node_update_original_pathnames_bad_status(self):
191+
"""
192+
Test storage_node update_original_pathnames with a bad status.
193+
"""
194+
with self.http_response_mode(self.RESPONSE_MODE.BadStatus):
195+
self.assertRaises(
196+
exceptions.PowerFlexClientException,
197+
self.client.storage_node.update_original_pathnames,
198+
self.fake_node_id)

0 commit comments

Comments
 (0)