Repository: softlayer/softlayer-python
Pull request #1204 (2019-12-20 17:29:58)

Fix File Storage failback and failover.
Fix File Storage failback and failover.


Patch:
diff --git a/SoftLayer/CLI/file/replication/failback.py b/SoftLayer/CLI/file/replication/failback.py
index 6fc2e9b7..d56142b1 100644
--- a/SoftLayer/CLI/file/replication/failback.py
+++ b/SoftLayer/CLI/file/replication/failback.py
@@ -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.")
diff --git a/SoftLayer/CLI/file/replication/failover.py b/SoftLayer/CLI/file/replication/failover.py
index d5695fb5..8ceedd08 100644
--- a/SoftLayer/CLI/file/replication/failover.py
+++ b/SoftLayer/CLI/file/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 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:
diff --git a/SoftLayer/managers/file.py b/SoftLayer/managers/file.py
index b6d16053..c0d8fcae 100644
--- a/SoftLayer/managers/file.py
+++ b/SoftLayer/managers/file.py
@@ -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)


Test patch:
diff --git a/tests/CLI/modules/file_tests.py b/tests/CLI/modules/file_tests.py
index 465e9ec0..f64b1962 100644
--- a/tests/CLI/modules/file_tests.py
+++ b/tests/CLI/modules/file_tests.py
@@ -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',
@@ -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',
@@ -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)
diff --git a/tests/managers/file_tests.py b/tests/managers/file_tests.py
index 08658b6a..9e69d7fc 100644
--- a/tests/managers/file_tests.py
+++ b/tests/managers/file_tests.py
@@ -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,
         )