Don't update the barcode if user was not created
authorDan Scott <dscott@laurentian.ca>
Wed, 14 Sep 2011 20:47:38 +0000 (16:47 -0400)
committerDan Scott <dscott@laurentian.ca>
Tue, 7 May 2013 18:57:08 +0000 (14:57 -0400)
Check the return value and bail if the user creation was a failure.
For large updates, one can use --create and --push to update barcodes
for users who already exist.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
tools/patron-load/ldap_osrf_sync

index a79b405..2bab8b6 100755 (executable)
@@ -305,7 +305,8 @@ def find_ldap_users(con, ldap_filter, attributes, auth):
                 dump_data(result_data)
             if ARGS.create_users:
                 res = create_evergreen_user(auth, user)
-                update_ldap_barcode(con, user)
+                if res:
+                    update_ldap_barcode(con, user)
             if ARGS.push_barcode:
                 try:
                     uid = find_evergreen_user(auth, user)
@@ -457,6 +458,7 @@ def create_evergreen_user(auth, user):
     create_stat_cats(newau, user)
 
     print("Created: %s with barcode %s" % (newau.usrname(), user.barcode))
+    return user.barcode
 
 def update_ldap_barcode(con, user):
     """