summaryrefslogtreecommitdiffstats
path: root/nova/adminclient.py
diff options
context:
space:
mode:
authorDevin Carlen <devin.carlen@gmail.com>2011-01-28 12:32:21 -0800
committerDevin Carlen <devin.carlen@gmail.com>2011-01-28 12:32:21 -0800
commit3f3f169d6b9cdf0b0d4dca308dbded38bf9a87b9 (patch)
treeeb779c6ce5b7cee88ca2fbd0fccdcdd35a5e9af8 /nova/adminclient.py
parent396b02f876030f1f54b7af32cf94fccbbe1fe46b (diff)
downloadnova-3f3f169d6b9cdf0b0d4dca308dbded38bf9a87b9.tar.gz
nova-3f3f169d6b9cdf0b0d4dca308dbded38bf9a87b9.tar.xz
nova-3f3f169d6b9cdf0b0d4dca308dbded38bf9a87b9.zip
Made adminclient get_user return None instead of throwing EC2Exception if requested user not available
Diffstat (limited to 'nova/adminclient.py')
-rw-r--r--nova/adminclient.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/nova/adminclient.py b/nova/adminclient.py
index 3cdd8347f..6b7549d26 100644
--- a/nova/adminclient.py
+++ b/nova/adminclient.py
@@ -21,6 +21,7 @@ Nova User API client library.
import base64
import boto
+import boto.exception
import httplib
from boto.ec2.regioninfo import RegionInfo
@@ -287,11 +288,13 @@ class NovaAdminClient(object):
return self.apiconn.get_list('DescribeUsers', {}, [('item', UserInfo)])
def get_user(self, name):
- """Grab a single user by name."""
- user = self.apiconn.get_object('DescribeUser', {'Name': name},
- UserInfo)
- if user.username != None:
- return user
+ """ grab a single user by name """
+ try:
+ return self.apiconn.get_object('DescribeUser', {'Name': name}, UserInfo)
+ except boto.exception.BotoServerError, e:
+ if e.status == 400 and e.error_code == 'NotFound':
+ return None
+ raise
def has_user(self, username):
"""Determine if user exists."""