Skip to content

Commit df7df4c

Browse files
Merge pull request #1200 from FernandoOjeda/fo_block_storage_failback
Fix block storage failback and failover.
2 parents b3bcb92 + 2b9215c commit df7df4c

File tree

5 files changed

+14
-29
lines changed

5 files changed

+14
-29
lines changed

SoftLayer/CLI/block/replication/failback.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@
88

99
@click.command()
1010
@click.argument('volume-id')
11-
@click.option('--replicant-id', help="ID of the replicant volume")
1211
@environment.pass_env
13-
def cli(env, volume_id, replicant_id):
12+
def cli(env, volume_id):
1413
"""Failback a block volume from the given replicant volume."""
1514
block_storage_manager = SoftLayer.BlockStorageManager(env.client)
1615

17-
success = block_storage_manager.failback_from_replicant(
18-
volume_id,
19-
replicant_id
20-
)
16+
success = block_storage_manager.failback_from_replicant(volume_id)
2117

2218
if success:
2319
click.echo("Failback from replicant is now in progress.")

SoftLayer/CLI/block/replication/failover.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@
99
@click.command()
1010
@click.argument('volume-id')
1111
@click.option('--replicant-id', help="ID of the replicant volume")
12-
@click.option('--immediate',
13-
is_flag=True,
14-
default=False,
15-
help="Failover to replicant immediately.")
1612
@environment.pass_env
17-
def cli(env, volume_id, replicant_id, immediate):
13+
def cli(env, volume_id, replicant_id):
1814
"""Failover a block volume to the given replicant volume."""
1915
block_storage_manager = SoftLayer.BlockStorageManager(env.client)
2016

2117
success = block_storage_manager.failover_to_replicant(
2218
volume_id,
23-
replicant_id,
24-
immediate
19+
replicant_id
2520
)
2621

2722
if success:

SoftLayer/managers/block.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -525,28 +525,25 @@ def cancel_block_volume(self, volume_id,
525525
reason,
526526
id=billing_item_id)
527527

528-
def failover_to_replicant(self, volume_id, replicant_id, immediate=False):
528+
def failover_to_replicant(self, volume_id, replicant_id):
529529
"""Failover to a volume replicant.
530530
531531
:param integer volume_id: The id of the volume
532532
:param integer replicant_id: ID of replicant to failover to
533-
:param boolean immediate: Flag indicating if failover is immediate
534533
:return: Returns whether failover was successful or not
535534
"""
536535

537536
return self.client.call('Network_Storage', 'failoverToReplicant',
538-
replicant_id, immediate, id=volume_id)
537+
replicant_id, id=volume_id)
539538

540-
def failback_from_replicant(self, volume_id, replicant_id):
539+
def failback_from_replicant(self, volume_id):
541540
"""Failback from a volume replicant.
542541
543542
:param integer volume_id: The id of the volume
544-
:param integer replicant_id: ID of replicant to failback from
545543
:return: Returns whether failback was successful or not
546544
"""
547545

548-
return self.client.call('Network_Storage', 'failbackFromReplicant',
549-
replicant_id, id=volume_id)
546+
return self.client.call('Network_Storage', 'failbackFromReplicant', id=volume_id)
550547

551548
def set_credential_password(self, access_id, password):
552549
"""Sets the password for an access host

tests/CLI/modules/block_tests.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def test_deauthorize_host_to_volume(self):
440440

441441
def test_replicant_failover(self):
442442
result = self.run_command(['block', 'replica-failover', '12345678',
443-
'--replicant-id=5678', '--immediate'])
443+
'--replicant-id=5678'])
444444

445445
self.assert_no_fail(result)
446446
self.assertEqual('Failover to replicant is now in progress.\n',
@@ -506,8 +506,7 @@ def test_replicant_failover_unsuccessful(self, failover_mock):
506506
result.output)
507507

508508
def test_replicant_failback(self):
509-
result = self.run_command(['block', 'replica-failback', '12345678',
510-
'--replicant-id=5678'])
509+
result = self.run_command(['block', 'replica-failback', '12345678'])
511510

512511
self.assert_no_fail(result)
513512
self.assertEqual('Failback from replicant is now in progress.\n',
@@ -517,8 +516,7 @@ def test_replicant_failback(self):
517516
def test_replicant_failback_unsuccessful(self, failback_mock):
518517
failback_mock.return_value = False
519518

520-
result = self.run_command(['block', 'replica-failback', '12345678',
521-
'--replicant-id=5678'])
519+
result = self.run_command(['block', 'replica-failback', '12345678'])
522520

523521
self.assertEqual('Failback operation could not be initiated.\n',
524522
result.output)

tests/managers/block_tests.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,26 +328,25 @@ def test_cancel_snapshot_exception_snapshot_billing_item_not_found(self):
328328
)
329329

330330
def test_replicant_failover(self):
331-
result = self.block.failover_to_replicant(1234, 5678, immediate=True)
331+
result = self.block.failover_to_replicant(1234, 5678)
332332

333333
self.assertEqual(
334334
fixtures.SoftLayer_Network_Storage.failoverToReplicant, result)
335335
self.assert_called_with(
336336
'SoftLayer_Network_Storage',
337337
'failoverToReplicant',
338-
args=(5678, True),
338+
args=(5678,),
339339
identifier=1234,
340340
)
341341

342342
def test_replicant_failback(self):
343-
result = self.block.failback_from_replicant(1234, 5678)
343+
result = self.block.failback_from_replicant(1234)
344344

345345
self.assertEqual(
346346
fixtures.SoftLayer_Network_Storage.failbackFromReplicant, result)
347347
self.assert_called_with(
348348
'SoftLayer_Network_Storage',
349349
'failbackFromReplicant',
350-
args=(5678,),
351350
identifier=1234,
352351
)
353352

0 commit comments

Comments
 (0)