libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject git commit: Allow user to pass proxy_url argument to Connection class.
Date Tue, 19 Aug 2014 18:42:19 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 3eaa60bc2 -> b968247c6


Allow user to pass proxy_url argument to Connection class.


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

Branch: refs/heads/trunk
Commit: b968247c6acbaeafaf0ffcde62c5baab00b0e0bd
Parents: 3eaa60b
Author: Tomaz Muraus <tomaz@apache.org>
Authored: Tue Aug 19 20:39:42 2014 +0200
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Tue Aug 19 20:39:42 2014 +0200

----------------------------------------------------------------------
 libcloud/common/base.py | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/b968247c/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index daf04d2..ae0e699 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -444,7 +444,7 @@ class Connection(object):
     allow_insecure = True
 
     def __init__(self, secure=True, host=None, port=None, url=None,
-                 timeout=None):
+                 timeout=None, proxy_url=None):
         self.secure = secure and 1 or 0
         self.ua = []
         self.context = {}
@@ -475,6 +475,8 @@ class Connection(object):
         if timeout:
             self.timeout = timeout
 
+        self.proxy_url = proxy_url
+
     def set_context(self, context):
         if not isinstance(context, dict):
             raise TypeError('context needs to be a dictionary')
@@ -543,6 +545,9 @@ class Connection(object):
         if self.timeout and not PY25:
             kwargs.update({'timeout': self.timeout})
 
+        if self.proxy_url:
+            kwargs.update({'proxy_url': self.proxy_url})
+
         connection = self.conn_classes[secure](**kwargs)
         # You can uncoment this line, if you setup a reverse proxy server
         # which proxies to your endpoint, and lets you easily capture
@@ -893,14 +898,15 @@ class ConnectionKey(Connection):
     Base connection class which accepts a single ``key`` argument.
     """
     def __init__(self, key, secure=True, host=None, port=None, url=None,
-                 timeout=None):
+                 timeout=None, proxy_url=None):
         """
         Initialize `user_id` and `key`; set `secure` to an ``int`` based on
         passed value.
         """
         super(ConnectionKey, self).__init__(secure=secure, host=host,
                                             port=port, url=url,
-                                            timeout=timeout)
+                                            timeout=timeout,
+                                            proxy_url=proxy_url)
         self.key = key
 
 
@@ -911,11 +917,12 @@ class ConnectionUserAndKey(ConnectionKey):
 
     user_id = None
 
-    def __init__(self, user_id, key, secure=True,
-                 host=None, port=None, url=None, timeout=None):
+    def __init__(self, user_id, key, secure=True, host=None, port=None,
+                 url=None, timeout=None, proxy_url=None):
         super(ConnectionUserAndKey, self).__init__(key, secure=secure,
                                                    host=host, port=port,
-                                                   url=url, timeout=timeout)
+                                                   url=url, timeout=timeout,
+                                                   proxy_url=proxy_url)
         self.user_id = user_id
 
 


Mime
View raw message