You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by rb...@apache.org on 2010/12/14 19:10:32 UTC

svn commit: r1049201 - /incubator/libcloud/trunk/libcloud/drivers/gogrid.py

Author: rbogorodskiy
Date: Tue Dec 14 18:10:31 2010
New Revision: 1049201

URL: http://svn.apache.org/viewvc?rev=1049201&view=rev
Log:
Add support filtering images by location to GoGrid driver.

Modified:
    incubator/libcloud/trunk/libcloud/drivers/gogrid.py

Modified: incubator/libcloud/trunk/libcloud/drivers/gogrid.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/gogrid.py?rev=1049201&r1=1049200&r2=1049201&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/gogrid.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/gogrid.py Tue Dec 14 18:10:31 2010
@@ -25,8 +25,10 @@ import hashlib
 
 # JSON is included in the standard library starting with Python 2.6.  For 2.5
 # and 2.4, there's a simplejson egg at: http://pypi.python.org/pypi/simplejson
-try: import json
-except: import simplejson as json
+try:
+    import json
+except ImportError:
+    import simplejson as json
 
 HOST = 'api.gogrid.com'
 PORTS_BY_SECURITY = { True: 443, False: 80 }
@@ -194,8 +196,11 @@ class GoGridNodeDriver(NodeDriver):
                 for el in object['list']]
 
     def list_images(self, location=None):
+        params = {}
+        if location is not None:
+            params["datacenter"] = location.id
         images = self._to_images(
-                    self.connection.request('/api/grid/image/list').object)
+                self.connection.request('/api/grid/image/list', params).object)
         return images
 
     def list_nodes(self):