-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from dell/RTSv1.7.0
Release version 1.7.0 for PyPowerFlex
- Loading branch information
Showing
9 changed files
with
215 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Copyright (c) 2023 Dell Inc. or its subsidiaries. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import logging | ||
|
||
import requests | ||
|
||
from PyPowerFlex import base_client | ||
from PyPowerFlex import exceptions | ||
|
||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
class ReplicationPair(base_client.EntityRequest): | ||
def get_statistics(self, id): | ||
"""Retrieve statistics for the specified ReplicationPair object. | ||
:type id: str | ||
:rtype: dict | ||
""" | ||
|
||
return self.get_related(id, | ||
'Statistics') | ||
|
||
def add(self, | ||
source_vol_id, | ||
dest_vol_id, | ||
rcg_id, | ||
copy_type, | ||
name=None): | ||
"""Add replication pair to PowerFlex RCG. | ||
:param source_vol_id: str | ||
:param dest_vol_id: str | ||
:param rcg_id: str | ||
:param copy_type: str | ||
:type name: str | ||
:return: dict | ||
""" | ||
|
||
params = dict( | ||
sourceVolumeId=source_vol_id, | ||
destinationVolumeId=dest_vol_id, | ||
replicationConsistencyGroupId=rcg_id, | ||
copyType=copy_type, | ||
name=name | ||
) | ||
|
||
return self._create_entity(params) | ||
|
||
def remove(self, id): | ||
"""Remove replication pair of PowerFlex RCG. | ||
:param id: str | ||
:return: None | ||
""" | ||
return self._delete_entity(id) | ||
|
||
def pause(self, id): | ||
"""Pause the progress of the specified ReplicationPair's initial copy. | ||
:param id: str | ||
:return: dict | ||
""" | ||
return self._perform_entity_operation_based_on_action\ | ||
(id, "pausePairInitialCopy", add_entity=False) | ||
|
||
def resume(self, id): | ||
"""Resume initial copy of the ReplicationPair. | ||
:param id: str | ||
:return: dict | ||
""" | ||
return self._perform_entity_operation_based_on_action\ | ||
(id, "resumePairInitialCopy", add_entity=False) | ||
|
||
def get_all_statistics(self): | ||
"""Retrieve statistics for all ReplicationPair objects. | ||
:return: dict | ||
""" | ||
r, response = self.send_post_request(self.list_statistics_url, | ||
entity=self.entity, | ||
action="querySelectedStatistics") | ||
if r.status_code != requests.codes.ok: | ||
msg = ('Failed to list statistics for all ReplicationPair objects. ' | ||
'Error: {response}'.format(response=response)) | ||
LOG.error(msg) | ||
raise exceptions.PowerFlexClientException(msg) | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Copyright (c) 2023 Dell Inc. or its subsidiaries. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from PyPowerFlex import exceptions | ||
from PyPowerFlex.objects import replication_pair | ||
import tests | ||
|
||
|
||
class TestReplicationPairClient(tests.PyPowerFlexTestCase): | ||
def setUp(self): | ||
super(TestReplicationPairClient, self).setUp() | ||
self.client.initialize() | ||
self.fake_replication_pair_id = '1' | ||
|
||
self.MOCK_RESPONSES = { | ||
self.RESPONSE_MODE.Valid: { | ||
'/types/ReplicationPair/instances': | ||
{'id': self.fake_replication_pair_id}, | ||
'/instances/ReplicationPair::{}'.format(self.fake_replication_pair_id): | ||
{'id': self.fake_replication_pair_id}, | ||
'/instances/ReplicationPair::{}' | ||
'/action/removeReplicationPair'.format(self.fake_replication_pair_id): | ||
{}, | ||
'/instances/ReplicationPair::{}' | ||
'/action/pausePairInitialCopy'.format(self.fake_replication_pair_id): | ||
{'id': self.fake_replication_pair_id}, | ||
'/instances/ReplicationPair::{}' | ||
'/action/resumePairInitialCopy'.format(self.fake_replication_pair_id): | ||
{'id': self.fake_replication_pair_id}, | ||
'/types/ReplicationPair/instances/action/querySelectedStatistics': | ||
{}, | ||
}, | ||
self.RESPONSE_MODE.Invalid: { | ||
'/types/ReplicationPair/instances': | ||
{}, | ||
} | ||
} | ||
|
||
def test_add_replication_pair(self): | ||
self.client.replication_pair.add\ | ||
(source_vol_id='1', dest_vol_id='1', | ||
rcg_id='1', copy_type='OnlineCopy', name='test') | ||
|
||
def test_remove_replication_pair(self): | ||
self.client.replication_pair.remove(self.fake_replication_pair_id) | ||
|
||
def test_pause_online_copy(self): | ||
self.client.replication_pair.pause(self.fake_replication_pair_id) | ||
|
||
def test_resume_online_copy(self): | ||
self.client.replication_pair.resume(self.fake_replication_pair_id) | ||
|
||
def test_get_all_statistics(self): | ||
self.client.replication_pair.get_all_statistics() | ||
|
||
def test_add_replication_pair_bad_status(self): | ||
with self.http_response_mode(self.RESPONSE_MODE.BadStatus): | ||
self.assertRaises(exceptions.PowerFlexFailCreating, | ||
self.client.replication_pair.add, | ||
source_vol_id='1', dest_vol_id='1', | ||
rcg_id='1', copy_type='OnlineCopy', name='test') | ||
|
||
def test_remove_replication_pair_bad_status(self): | ||
with self.http_response_mode(self.RESPONSE_MODE.BadStatus): | ||
self.assertRaises(exceptions.PowerFlexFailDeleting, | ||
self.client.replication_pair.remove, | ||
self.fake_replication_pair_id) | ||
|
||
def test_get_all_statistics_bad_status(self): | ||
with self.http_response_mode(self.RESPONSE_MODE.BadStatus): | ||
self.assertRaises(exceptions.PowerFlexClientException, | ||
self.client.replication_pair.get_all_statistics) |