Merge lp:~devcamcar/django-nova/fix_get_user into lp:django-nova

Proposed by Devin Carlen
Status: Merged
Approved by: Devin Carlen
Approved revision: 12
Merged at revision: 12
Proposed branch: lp:~devcamcar/django-nova/fix_get_user
Merge into: lp:django-nova
Diff against target: 28 lines (+7/-4)
1 file modified
src/django_nova/adminclient.py (+7/-4)
To merge this branch: bzr merge lp:~devcamcar/django-nova/fix_get_user
Reviewer Review Type Date Requested Status
Devin Carlen Approve
Review via email: mp+47861@code.launchpad.net

Description of the change

Made adminclient get_user return None instead of throwing EC2Exception if requested user not available

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/django_nova/adminclient.py'
2--- src/django_nova/adminclient.py 2011-01-12 20:02:06 +0000
3+++ src/django_nova/adminclient.py 2011-01-28 20:44:57 +0000
4@@ -21,6 +21,7 @@
5
6 import base64
7 import boto
8+import boto.exception
9 import httplib
10 import re
11 import string
12@@ -332,10 +333,12 @@
13
14 def get_user(self, name):
15 """ grab a single user by name """
16- user = self.apiconn.get_object('DescribeUser', {'Name': name}, UserInfo)
17-
18- if user.username != None:
19- return user
20+ try:
21+ return self.apiconn.get_object('DescribeUser', {'Name': name}, UserInfo)
22+ except boto.exception.BotoServerError, e:
23+ if e.status == 400 and e.error_code == 'NotFound':
24+ return None
25+ raise
26
27 def has_user(self, username):
28 """ determine if user exists """

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: