Skip to content

Commit 504f4db

Browse files
Merge pull request #1204 from FernandoOjeda/fo_file_storage_failback
Fix File Storage failback and failover.
2 parents bc4c693 + 867d58c commit 504f4db

File tree

5 files changed

+14
-29
lines changed

5 files changed

+14
-29
lines changed

SoftLayer/CLI/file/replication/failback.py

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

1010
@click.command()
1111
@click.argument('volume-id')
12-
@click.option('--replicant-id', help="ID of the replicant volume")
1312
@environment.pass_env
14-
def cli(env, volume_id, replicant_id):
13+
def cli(env, volume_id):
1514
"""Failback a file volume from the given replicant volume."""
1615
file_storage_manager = SoftLayer.FileStorageManager(env.client)
1716

18-
success = file_storage_manager.failback_from_replicant(
19-
volume_id,
20-
replicant_id
21-
)
17+
success = file_storage_manager.failback_from_replicant(volume_id)
2218

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

SoftLayer/CLI/file/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 file volume to the given replicant volume."""
1915
file_storage_manager = SoftLayer.FileStorageManager(env.client)
2016

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

2722
if success:

SoftLayer/managers/file.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,25 +496,22 @@ def cancel_file_volume(self, volume_id, reason='No longer needed', immediate=Fal
496496
reason,
497497
id=billing_item_id)
498498

499-
def failover_to_replicant(self, volume_id, replicant_id, immediate=False):
499+
def failover_to_replicant(self, volume_id, replicant_id):
500500
"""Failover to a volume replicant.
501501
502502
:param integer volume_id: The ID of the volume
503503
:param integer replicant_id: ID of replicant to failover to
504-
:param boolean immediate: Flag indicating if failover is immediate
505504
:return: Returns whether failover was successful or not
506505
"""
507506

508507
return self.client.call('Network_Storage', 'failoverToReplicant',
509-
replicant_id, immediate, id=volume_id)
508+
replicant_id, id=volume_id)
510509

511-
def failback_from_replicant(self, volume_id, replicant_id):
510+
def failback_from_replicant(self, volume_id):
512511
"""Failback from a volume replicant.
513512
514513
:param integer volume_id: The ID of the volume
515-
:param integer replicant_id: ID of replicant to failback from
516514
:return: Returns whether failback was successful or not
517515
"""
518516

519-
return self.client.call('Network_Storage', 'failbackFromReplicant',
520-
replicant_id, id=volume_id)
517+
return self.client.call('Network_Storage', 'failbackFromReplicant', id=volume_id)

tests/CLI/modules/file_tests.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def test_snapshot_cancel(self):
444444

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

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

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

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

475-
result = self.run_command(['file', 'replica-failback', '12345678',
476-
'--replicant-id=5678'])
474+
result = self.run_command(['file', 'replica-failback', '12345678'])
477475

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

tests/managers/file_tests.py

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

276276
def test_replicant_failover(self):
277-
result = self.file.failover_to_replicant(1234, 5678, immediate=True)
277+
result = self.file.failover_to_replicant(1234, 5678)
278278

279279
self.assertEqual(
280280
fixtures.SoftLayer_Network_Storage.failoverToReplicant, result)
281281
self.assert_called_with(
282282
'SoftLayer_Network_Storage',
283283
'failoverToReplicant',
284-
args=(5678, True),
284+
args=(5678,),
285285
identifier=1234,
286286
)
287287

288288
def test_replicant_failback(self):
289-
result = self.file.failback_from_replicant(1234, 5678)
289+
result = self.file.failback_from_replicant(1234)
290290

291291
self.assertEqual(
292292
fixtures.SoftLayer_Network_Storage.failbackFromReplicant, result)
293293
self.assert_called_with(
294294
'SoftLayer_Network_Storage',
295295
'failbackFromReplicant',
296-
args=(5678,),
297296
identifier=1234,
298297
)
299298

0 commit comments

Comments
 (0)