libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From quent...@apache.org
Subject [1/4] libcloud git commit: Now destroy_node() raises exception on unexpected errors instead of returning False with no additional information. Updated tests.
Date Tue, 10 Oct 2017 05:12:53 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 12d8e9967 -> 7d442a1ab


Now destroy_node() raises exception on unexpected errors instead of returning False with no
additional information. Updated tests.

Signed-off-by: Quentin Pradet <quentinp@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8b41ed79
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8b41ed79
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8b41ed79

Branch: refs/heads/trunk
Commit: 8b41ed79f2fb29a0bd678922004e5478fadaf8d2
Parents: fbf015d
Author: Lucas Di Pentima <ldipentima@veritasgenetics.com>
Authored: Mon Oct 9 17:26:30 2017 -0300
Committer: Quentin Pradet <quentinp@apache.org>
Committed: Tue Oct 10 09:01:17 2017 +0400

----------------------------------------------------------------------
 libcloud/compute/drivers/azure_arm.py   | 17 +++++++----------
 libcloud/test/compute/test_azure_arm.py |  8 ++++----
 2 files changed, 11 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/8b41ed79/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py
index 3a5b648..3e5a3f1 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -695,12 +695,12 @@ class AzureNodeDriver(NodeDriver):
         this node (default True).
         :type node: ``bool``
 
-        :return: True if the destroy was successful, False otherwise.
+        :return: True if the destroy was successful, raises exception
+        otherwise.
         :rtype: ``bool``
         """
 
         do_node_polling = True
-        success = True
 
         # This returns a 202 (Accepted) which means that the delete happens
         # asynchronously.
@@ -718,7 +718,7 @@ class AzureNodeDriver(NodeDriver):
                 # No need to ask again, node already down.
                 do_node_polling = False
             else:
-                return False
+                raise
 
         # Need to poll until the node actually goes away.
         while do_node_polling:
@@ -731,7 +731,7 @@ class AzureNodeDriver(NodeDriver):
                 if h.code == 404:
                     break
                 else:
-                    return False
+                    raise
 
         # Optionally clean up the network
         # interfaces that were attached to this node.
@@ -753,9 +753,7 @@ class AzureNodeDriver(NodeDriver):
                         if h.code == 400 and inuse:
                             time.sleep(10)
                         else:
-                            # NIC cleanup failed, try cleaning up the VHD.
-                            success = False
-                            break
+                            raise
 
         # Optionally clean up OS disk VHD.
         vhd = node.extra["properties"]["storageProfile"]["osDisk"].get("vhd")
@@ -776,10 +774,9 @@ class AzureNodeDriver(NodeDriver):
                         # LibcloudError.  Wait a bit and try again.
                         time.sleep(10)
                     else:
-                        success = False
-                        break
+                        raise
 
-        return success
+        return True
 
     def create_volume(self, size, name, location=None, snapshot=None,
                       ex_resource_group=None, ex_account_type=None,

http://git-wip-us.apache.org/repos/asf/libcloud/blob/8b41ed79/libcloud/test/compute/test_azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_azure_arm.py b/libcloud/test/compute/test_azure_arm.py
index b12ee93..b4d4e8c 100644
--- a/libcloud/test/compute/test_azure_arm.py
+++ b/libcloud/test/compute/test_azure_arm.py
@@ -192,8 +192,8 @@ class AzureNodeDriverTests(LibcloudTestCase):
             # 500 - transient error when trying to clean up the NIC
             lambda f: error(BaseHTTPError, code=500, message="Cloud weather"),
         ]
-        ret = self.driver.destroy_node(node)
-        self.assertFalse(ret)
+        with self.assertRaises(BaseHTTPError):
+            self.driver.destroy_node(node)
 
     def test_destroy_node__failed(self):
         def error(e, **kwargs):
@@ -203,8 +203,8 @@ class AzureNodeDriverTests(LibcloudTestCase):
             # 403 - There was some problem with your request
             lambda f: error(BaseHTTPError, code=403, message='Forbidden'),
         ]
-        ret = self.driver.destroy_node(node)
-        self.assertFalse(ret)
+        with self.assertRaises(BaseHTTPError):
+            self.driver.destroy_node(node)
 
     def test_list_nodes(self):
         nodes = self.driver.list_nodes()


Mime
View raw message