Skip to content

Commit

Permalink
Added sync_period and snap_frequency validation (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansarars authored and sneharai4 committed Dec 6, 2018
1 parent 0b45ac8 commit 74e5c41
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Modules/hpe3par_remote_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,16 @@ def modify_remote_copy_group(
elif key == 'remote_snap_cpg':
target['remoteSnapCPG'] = target_dict.get(key)
elif key == 'sync_period':
if target_dict[key] and target_dict[key] not in range(300, 31622401):
return (False, False, "Remote Copy Group modification failed. Valid range of %s is 300-31622400." % key, {})
target['syncPeriod'] = target_dict.get(key)
elif key == 'rm_sync_period':
target['rmSyncPeriod'] = target_dict.get(key)
elif key == 'target_mode':
target['mode'] = target_dict.get(key)
elif key == 'snap_frequency':
if target_dict[key] and target_dict[key] not in range(300, 31622401):
return (False, False, "Remote Copy Group modification failed. Valid range of %s is 300-31622400." % key, {})
target['snapFrequency'] = target_dict.get(key)
elif key == 'rm_snap_frequency':
target['rmSnapFrequency'] = target_dict.get(key)
Expand Down
22 changes: 22 additions & 0 deletions test/unit/test_hpe3par_remote_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,28 @@ def test_modify_remote_copy_group(self, mock_client):
False,
False
), (True, True, "Modify Remote Copy Group %s successfully." % 'rcg_1', {}))

self.assertEqual(hpe3par_remote_copy.modify_remote_copy_group(mock_client.HPE3ParClient,
'USER',
'PASS',
'rcg_1',
'localusrcpg1',
'snap_cpg1',
[{'target_name': 'CSSOS-SSA04','remote_user_cpg': 'FC_r1','remote_snap_cpg':'FC_r6','snap_frequency':30}],
False,
False
), (False, False, "Remote Copy Group modification failed. Valid range of snap_frequency is 300-31622400.", {}))

self.assertEqual(hpe3par_remote_copy.modify_remote_copy_group(mock_client.HPE3ParClient,
'USER',
'PASS',
'rcg_1',
'localusrcpg1',
'snap_cpg1',
[{'target_name': 'CSSOS-SSA04','remote_user_cpg': 'FC_r1','remote_snap_cpg':'FC_r6','sync_period':30}],
False,
False
), (False, False, "Remote Copy Group modification failed. Valid range of sync_period is 300-31622400.", {}))
mock_client.HPE3ParClient.remoteCopyGroupExists.return_value = False

self.assertEqual(hpe3par_remote_copy.modify_remote_copy_group(mock_client.HPE3ParClient,
Expand Down

0 comments on commit 74e5c41

Please sign in to comment.