Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix File Storage failback and failover. #1204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
8 changes: 2 additions & 6 deletions SoftLayer/CLI/file/replication/failback.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@

@click.command()
@click.argument('volume-id')
@click.option('--replicant-id', help="ID of the replicant volume")
@environment.pass_env
def cli(env, volume_id, replicant_id):
def cli(env, volume_id):
"""Failback a file volume from the given replicant volume."""
file_storage_manager = SoftLayer.FileStorageManager(env.client)

success = file_storage_manager.failback_from_replicant(
volume_id,
replicant_id
)
success = file_storage_manager.failback_from_replicant(volume_id)

if success:
click.echo("Failback from replicant is now in progress.")
Expand Down
9 changes: 2 additions & 7 deletions SoftLayer/CLI/file/replication/failover.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@
@click.command()
@click.argument('volume-id')
@click.option('--replicant-id', help="ID of the replicant volume")
@click.option('--immediate',
is_flag=True,
default=False,
help="Failover to replicant immediately.")
@environment.pass_env
def cli(env, volume_id, replicant_id, immediate):
def cli(env, volume_id, replicant_id):
"""Failover a file volume to the given replicant volume."""
file_storage_manager = SoftLayer.FileStorageManager(env.client)

success = file_storage_manager.failover_to_replicant(
volume_id,
replicant_id,
immediate
replicant_id
)

if success:
Expand Down
11 changes: 4 additions & 7 deletions SoftLayer/managers/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,25 +496,22 @@ def cancel_file_volume(self, volume_id, reason='No longer needed', immediate=Fal
reason,
id=billing_item_id)

def failover_to_replicant(self, volume_id, replicant_id, immediate=False):
def failover_to_replicant(self, volume_id, replicant_id):
"""Failover to a volume replicant.

:param integer volume_id: The ID of the volume
:param integer replicant_id: ID of replicant to failover to
:param boolean immediate: Flag indicating if failover is immediate
:return: Returns whether failover was successful or not
"""

return self.client.call('Network_Storage', 'failoverToReplicant',
replicant_id, immediate, id=volume_id)
replicant_id, id=volume_id)

def failback_from_replicant(self, volume_id, replicant_id):
def failback_from_replicant(self, volume_id):
"""Failback from a volume replicant.

:param integer volume_id: The ID of the volume
:param integer replicant_id: ID of replicant to failback from
:return: Returns whether failback was successful or not
"""

return self.client.call('Network_Storage', 'failbackFromReplicant',
replicant_id, id=volume_id)
return self.client.call('Network_Storage', 'failbackFromReplicant', id=volume_id)
8 changes: 3 additions & 5 deletions tests/CLI/modules/file_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def test_snapshot_cancel(self):

def test_replicant_failover(self):
result = self.run_command(['file', 'replica-failover', '12345678',
'--replicant-id=5678', '--immediate'])
'--replicant-id=5678'])

self.assert_no_fail(result)
self.assertEqual('Failover to replicant is now in progress.\n',
Expand All @@ -461,8 +461,7 @@ def test_replicant_failover_unsuccessful(self, failover_mock):
result.output)

def test_replicant_failback(self):
result = self.run_command(['file', 'replica-failback', '12345678',
'--replicant-id=5678'])
result = self.run_command(['file', 'replica-failback', '12345678'])

self.assert_no_fail(result)
self.assertEqual('Failback from replicant is now in progress.\n',
Expand All @@ -472,8 +471,7 @@ def test_replicant_failback(self):
def test_replicant_failback_unsuccessful(self, failback_mock):
failback_mock.return_value = False

result = self.run_command(['file', 'replica-failback', '12345678',
'--replicant-id=5678'])
result = self.run_command(['file', 'replica-failback', '12345678'])

self.assertEqual('Failback operation could not be initiated.\n',
result.output)
Expand Down
7 changes: 3 additions & 4 deletions tests/managers/file_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,26 +274,25 @@ def test_cancel_snapshot_exception_snapshot_billing_item_not_found(self):
)

def test_replicant_failover(self):
result = self.file.failover_to_replicant(1234, 5678, immediate=True)
result = self.file.failover_to_replicant(1234, 5678)

self.assertEqual(
fixtures.SoftLayer_Network_Storage.failoverToReplicant, result)
self.assert_called_with(
'SoftLayer_Network_Storage',
'failoverToReplicant',
args=(5678, True),
args=(5678,),
identifier=1234,
)

def test_replicant_failback(self):
result = self.file.failback_from_replicant(1234, 5678)
result = self.file.failback_from_replicant(1234)

self.assertEqual(
fixtures.SoftLayer_Network_Storage.failbackFromReplicant, result)
self.assert_called_with(
'SoftLayer_Network_Storage',
'failbackFromReplicant',
args=(5678,),
identifier=1234,
)

Expand Down