You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2015/05/16 22:19:52 UTC

[3/4] libcloud git commit: Fix Python 2.5 compatibility issue, add a test case.

Fix Python 2.5 compatibility issue, add a test case.


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

Branch: refs/heads/trunk
Commit: 635c34e06ab86b91ce4648aa8212b71361c2afe1
Parents: 9f21f1f
Author: Tomaz Muraus <to...@tomaz.me>
Authored: Sat May 16 21:54:33 2015 +0200
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Sat May 16 21:54:33 2015 +0200

----------------------------------------------------------------------
 libcloud/compute/drivers/cloudstack.py                       | 8 ++++++--
 .../compute/fixtures/cloudstack/listProjects_default.json    | 4 ++--
 libcloud/test/compute/test_cloudstack.py                     | 2 ++
 3 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/635c34e0/libcloud/compute/drivers/cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudstack.py b/libcloud/compute/drivers/cloudstack.py
index c3c461f..9228760 100644
--- a/libcloud/compute/drivers/cloudstack.py
+++ b/libcloud/compute/drivers/cloudstack.py
@@ -15,6 +15,7 @@
 
 from __future__ import with_statement
 
+import sys
 import base64
 import warnings
 
@@ -35,9 +36,12 @@ from libcloud.utils.networking import is_private_subnet
 def transform_int_or_unlimited(value):
     try:
         return int(value)
-    except ValueError as e:
-        if value == 'Unlimited':
+    except ValueError:
+        e = sys.exc_info()[1]
+
+        if str(value).lower() == 'unlimited':
             return -1
+
         raise e
 
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/635c34e0/libcloud/test/compute/fixtures/cloudstack/listProjects_default.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/cloudstack/listProjects_default.json b/libcloud/test/compute/fixtures/cloudstack/listProjects_default.json
index b100edf..39e2f2a 100644
--- a/libcloud/test/compute/fixtures/cloudstack/listProjects_default.json
+++ b/libcloud/test/compute/fixtures/cloudstack/listProjects_default.json
@@ -18,7 +18,7 @@
             "memorylimit": 128000,
             "memorytotal": 56000,
             "networkavailable": 0,
-            "networklimit": 0,
+            "networklimit": "Unlimited",
             "networktotal": 0,
             "primarystorageavailable": 1204,
             "primarystoragelimit": 1600,
@@ -46,4 +46,4 @@
             "vpctotal": 0
         }
     ]
-} }
\ No newline at end of file
+} }

http://git-wip-us.apache.org/repos/asf/libcloud/blob/635c34e0/libcloud/test/compute/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudstack.py b/libcloud/test/compute/test_cloudstack.py
index 979b0b7..384f706 100644
--- a/libcloud/test/compute/test_cloudstack.py
+++ b/libcloud/test/compute/test_cloudstack.py
@@ -509,6 +509,8 @@ class CloudStackCommonTestCase(TestCaseMixin):
             self.assertEqual(
                 project.extra['cpulimit'],
                 fixture_projects[i]['cpulimit'])
+            # Note -1 represents unlimited
+            self.assertEqual(project.extra['networklimit'], -1)
 
     def test_create_volume(self):
         volumeName = 'vol-0'