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/06/06 12:23:16 UTC

[3/3] libcloud git commit: [LIBCLOUD-716] Fix port type error.

[LIBCLOUD-716] Fix port type error.

Closes #533

Signed-off-by: Tomaz Muraus <to...@tomaz.me>


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

Branch: refs/heads/trunk
Commit: 590c7197ab073f5b2145f02ae7115396ccdbf008
Parents: 1d1c357
Author: Avi Weit <we...@il.ibm.com>
Authored: Wed Jun 3 11:22:45 2015 +0000
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Sat Jun 6 18:18:59 2015 +0800

----------------------------------------------------------------------
 CHANGES.rst                             | 5 +++++
 libcloud/common/base.py                 | 6 +++++-
 libcloud/test/compute/test_openstack.py | 6 +++---
 3 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/590c7197/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index b8bd91f..95be3bd 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -22,6 +22,11 @@ General
   file would throw an exception if the text contained non-ascii characters.
   [Tomaz Muraus]
 
+- Fix a bug with connection code throwing an exception if a port was a unicode
+  type and not a str or int.
+  (GITHUB-533, LIBCLOUD-716)
+  [Avi Weit]
+
 Compute
 ~~~~~~~
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/590c7197/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index fa2f82a..d147ee3 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -532,7 +532,7 @@ class Connection(object):
 
         if ":" in netloc:
             netloc, port = netloc.rsplit(":")
-            port = port
+            port = int(port)
 
         if not port:
             if scheme == "http":
@@ -541,6 +541,7 @@ class Connection(object):
                 port = 443
 
         host = netloc
+        port = int(port)
 
         return (host, port, secure, request_path)
 
@@ -570,6 +571,9 @@ class Connection(object):
             host = host or self.host
             port = port or self.port
 
+        # Make sure port is an int
+        port = int(port)
+
         if not hasattr(kwargs, 'host'):
             kwargs.update({'host': host})
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/590c7197/libcloud/test/compute/test_openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
index d80d6ce..feb5a0c 100644
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -687,7 +687,7 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
 
         # assert that we use the base url and not the auth url
         self.assertEqual(self.driver.connection.host, 'ex_force_base_url.com')
-        self.assertEqual(self.driver.connection.port, '666')
+        self.assertEqual(self.driver.connection.port, 666)
         self.assertEqual(self.driver.connection.request_path, '/forced_url')
 
     def test_get_endpoint_populates_host_port_and_request_path(self):
@@ -699,7 +699,7 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
 
         # assert that we use the result of get endpoint
         self.assertEqual(self.driver.connection.host, 'endpoint_auth_url.com')
-        self.assertEqual(self.driver.connection.port, '1555')
+        self.assertEqual(self.driver.connection.port, 1555)
         self.assertEqual(self.driver.connection.request_path, '/service_url')
 
     def test_set_auth_token_populates_host_port_and_request_path(self):
@@ -712,7 +712,7 @@ class OpenStack_1_1_Tests(unittest.TestCase, TestCaseMixin):
         # assert that we use the base url and not the auth url
         self.assertEqual(
             self.driver.connection.host, 'some_other_ex_force_base_url.com')
-        self.assertEqual(self.driver.connection.port, '1222')
+        self.assertEqual(self.driver.connection.port, 1222)
         self.assertEqual(self.driver.connection.request_path, '/some-service')
 
     def test_auth_token_without_base_url_raises_exception(self):