Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 4 additions & 34 deletions PyPowerFlex/objects/gen2/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class Device(base_client.EntityRequest):

def create(self,
current_pathname,
media_type,
device_group_id,
node_id,
force=None,
media_type=None,
name=None):
"""Create PowerFlex device.

Expand All @@ -58,8 +58,8 @@ def create(self,
:rtype: dict
"""

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

params = {
Expand Down Expand Up @@ -98,37 +98,8 @@ def rename(self, device_id, name):

return self._rename_entity(action, device_id, params)

def update_pathname(self, device_id, new_pathname):
"""Update PowerFlex device pathname.
TODO TTHE make sure this API is valid after the latest dev build is ready

:type device_id: str
:type new_pathname: str
:rtype: dict
"""

action = 'updateDeviceOriginalPathname'
params = {"updateDeviceOriginalPathname": new_pathname}
r, response = self.send_post_request(self.base_action_url,
action=action,
entity=self.entity,
entity_id=device_id,
params=params)
if r.status_code != requests.codes.ok:
msg = (
f"Failed to update pathname for PowerFlex {self.entity} "
f"with id {device_id}. "
f"Error: {response}"
)
LOG.error(msg)
raise exceptions.PowerFlexClientException(msg)

return self.get(entity_id=device_id)

def set_capacity_limit(self, device_id, capacity_limit_gb):
"""Update PowerFlex device capacity limit in GB.
TODO TTHE make sure this API is valid after the latest dev build is ready

:type device_id: str
:type capacity_limit_gb: int
:rtype: dict
Expand All @@ -154,9 +125,8 @@ def set_capacity_limit(self, device_id, capacity_limit_gb):

def clear_errors(self, device_id, force=None):
"""Clear PowerFlex device errors.
TODO TTHE make sure this field - `forceClear` is valid after the latest dev build is ready

:type device_id: str
:type force: bool
:rtype: dict
"""

Expand Down
11 changes: 2 additions & 9 deletions PyPowerFlex/objects/gen2/device_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,12 @@ def create(self,

return self._create_entity(params)

def delete(self, device_group_id, force=None):
def delete(self, device_group_id):
"""Remove PowerFlex device group.
TODO TTHE make sure this `force` field is valid after the latest dev build is ready

:type device_group_id: str
:type force: bool
:rtype: None
"""
params = {
"force": force
}

return self._delete_entity(device_group_id, params)
return self._delete_entity(device_group_id)

def modify(self,
device_group_id,
Expand Down
28 changes: 28 additions & 0 deletions PyPowerFlex/objects/gen2/storage_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,31 @@ def set_ip_role(self, node_id, ip, role):
raise exceptions.PowerFlexClientException(msg)

return self.get(entity_id=node_id)

def update_original_pathnames(self, node_id, force=None):
"""Update original pathnames for PowerFlex Storage Node.

:type node_id: str
:type force: bool
:rtype: dict
"""

action = 'updateNodeOriginalPathnames'

params = {"forceFailedDevices": force}

r, response = self.send_post_request(self.base_action_url,
action=action,
entity=self.entity,
entity_id=node_id,
params=params)
if r.status_code != requests.codes.ok:
msg = (
f"Failed to update original pathnames for PowerFlex {self.entity} "
f"with id {node_id}. "
f"Error: {response}"
)
LOG.error(msg)
raise exceptions.PowerFlexClientException(msg)

return self.get(entity_id=node_id)
22 changes: 0 additions & 22 deletions tests/gen2/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ def setUp(self):
'/action/setDeviceCapacityLimit':
{},
f'/instances/Device::{self.fake_device_id}'
'/action/updateDeviceOriginalPathname':
{},
f'/instances/Device::{self.fake_device_id}'
'/action/clearDeviceError':
{},
f'/instances/Device::{self.fake_device_id}'
Expand Down Expand Up @@ -152,25 +149,6 @@ def test_device_rename_bad_status(self):
self.fake_device_id,
name='new_name')

def test_device_update_pathname(self):
"""
Test device update_pathname.
"""
self.client.device.update_pathname(
self.fake_device_id,
new_pathname='/dev/sdb')

def test_device_update_pathname_bad_status(self):
"""
Test device update_pathname with bad status.
"""
with self.http_response_mode(self.RESPONSE_MODE.BadStatus):
self.assertRaises(
exceptions.PowerFlexClientException,
self.client.device.update_pathname,
self.fake_device_id,
new_pathname='/dev/sdb')

def test_device_set_capacity_limit(self):
"""
Test device set_capacity_limit.
Expand Down
18 changes: 18 additions & 0 deletions tests/gen2/test_storage_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def setUp(self):
{},
f'/instances/Node::{self.fake_node_id}/action/modifyIpRole':
{},
f'/instances/Node::{self.fake_node_id}/action/updateNodeOriginalPathnames':
{},
},
self.RESPONSE_MODE.Invalid: {
'/types/Node/instances':
Expand Down Expand Up @@ -178,3 +180,19 @@ def test_storage_node_set_ip_role_bad_status(self):
self.fake_node_id,
ip='1.2.3.4',
role=StorageNodeIpRoles.storage_and_app)

def test_storage_node_update_original_pathnames(self):
"""
Test storage_node update_original_pathnames.
"""
self.client.storage_node.update_original_pathnames(self.fake_node_id)

def test_storage_node_update_original_pathnames_bad_status(self):
"""
Test storage_node update_original_pathnames with a bad status.
"""
with self.http_response_mode(self.RESPONSE_MODE.BadStatus):
self.assertRaises(
exceptions.PowerFlexClientException,
self.client.storage_node.update_original_pathnames,
self.fake_node_id)