You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by pq...@apache.org on 2010/09/21 19:16:34 UTC
svn commit: r999509 - /incubator/libcloud/trunk/libcloud/drivers/gogrid.py
Author: pquerna
Date: Tue Sep 21 17:16:34 2010
New Revision: 999509
URL: http://svn.apache.org/viewvc?rev=999509&view=rev
Log:
Better handle limited use API keys from GoGrid, which don't have permissions to access the password list API. This will silently ignore limited access, and just not provide the node's password in the resulting node object.
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=999509&r1=999508&r2=999509&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/gogrid.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/gogrid.py Tue Sep 21 17:16:34 2010
@@ -77,6 +77,8 @@ class GoGridResponse(Response):
def success(self):
if self.status == 403:
raise InvalidCredsError('Invalid credentials', GoGridNodeDriver)
+ if self.status == 401:
+ raise InvalidCredsError('API Key has insufficient rights', GoGridNodeDriver)
if not self.body:
return None
try:
@@ -186,11 +188,15 @@ class GoGridNodeDriver(NodeDriver):
passwords_map = {}
res = self._server_list()
- for password in self._password_list()['list']:
- try:
- passwords_map[password['server']['id']] = password['password']
- except KeyError:
- pass
+ try:
+ for password in self._password_list()['list']:
+ try:
+ passwords_map[password['server']['id']] = password['password']
+ except KeyError:
+ pass
+ except InvalidCredsError, e:
+ # some gogrid API keys don't have permission to access the password list.
+ pass
return [ self._to_node(el, passwords_map.get(el.get('id')))
for el