Repository: softlayer/softlayer-python
Pull request #1200 (2019-12-17 21:56:44)

Fix block storage failback and failover.
Fix block storage failback and failover https://github.com/softlayer/softlayer-python/issues/1199.


Patch:
diff --git a/SoftLayer/CLI/block/replication/failback.py b/SoftLayer/CLI/block/replication/failback.py
index 3887c29c..88ab6d62 100644
--- a/SoftLayer/CLI/block/replication/failback.py
+++ b/SoftLayer/CLI/block/replication/failback.py
@@ -8,16 +8,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 block volume from the given replicant volume."""
     block_storage_manager = SoftLayer.BlockStorageManager(env.client)
 
-    success = block_storage_manager.failback_from_replicant(
-        volume_id,
-        replicant_id
-    )
+    success = block_storage_manager.failback_from_replicant(volume_id)
 
     if success:
         click.echo("Failback from replicant is now in progress.")
diff --git a/SoftLayer/CLI/block/replication/failover.py b/SoftLayer/CLI/block/replication/failover.py
index 545175c4..cd36b227 100644
--- a/SoftLayer/CLI/block/replication/failover.py
+++ b/SoftLayer/CLI/block/replication/failover.py
@@ -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 block volume to the given replicant volume."""
     block_storage_manager = SoftLayer.BlockStorageManager(env.client)
 
     success = block_storage_manager.failover_to_replicant(
         volume_id,
-        replicant_id,
-        immediate
+        replicant_id
     )
 
     if success:
diff --git a/SoftLayer/managers/block.py b/SoftLayer/managers/block.py
index 42cc97e7..1f8c6ec5 100644
--- a/SoftLayer/managers/block.py
+++ b/SoftLayer/managers/block.py
@@ -525,28 +525,25 @@ def cancel_block_volume(self, volume_id,
             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)
 
     def set_credential_password(self, access_id, password):
         """Sets the password for an access host


Test patch:
diff --git a/tests/CLI/modules/block_tests.py b/tests/CLI/modules/block_tests.py
index 22547697..b8629de8 100644
--- a/tests/CLI/modules/block_tests.py
+++ b/tests/CLI/modules/block_tests.py
@@ -440,7 +440,7 @@ def test_deauthorize_host_to_volume(self):
 
     def test_replicant_failover(self):
         result = self.run_command(['block', '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',
@@ -506,8 +506,7 @@ def test_replicant_failover_unsuccessful(self, failover_mock):
                          result.output)
 
     def test_replicant_failback(self):
-        result = self.run_command(['block', 'replica-failback', '12345678',
-                                   '--replicant-id=5678'])
+        result = self.run_command(['block', 'replica-failback', '12345678'])
 
         self.assert_no_fail(result)
         self.assertEqual('Failback from replicant is now in progress.\n',
@@ -517,8 +516,7 @@ def test_replicant_failback(self):
     def test_replicant_failback_unsuccessful(self, failback_mock):
         failback_mock.return_value = False
 
-        result = self.run_command(['block', 'replica-failback', '12345678',
-                                   '--replicant-id=5678'])
+        result = self.run_command(['block', 'replica-failback', '12345678'])
 
         self.assertEqual('Failback operation could not be initiated.\n',
                          result.output)
diff --git a/tests/managers/block_tests.py b/tests/managers/block_tests.py
index bd5ab9d3..f5b3b437 100644
--- a/tests/managers/block_tests.py
+++ b/tests/managers/block_tests.py
@@ -328,26 +328,25 @@ def test_cancel_snapshot_exception_snapshot_billing_item_not_found(self):
         )
 
     def test_replicant_failover(self):
-        result = self.block.failover_to_replicant(1234, 5678, immediate=True)
+        result = self.block.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.block.failback_from_replicant(1234, 5678)
+        result = self.block.failback_from_replicant(1234)
 
         self.assertEqual(
             fixtures.SoftLayer_Network_Storage.failbackFromReplicant, result)
         self.assert_called_with(
             'SoftLayer_Network_Storage',
             'failbackFromReplicant',
-            args=(5678,),
             identifier=1234,
         )