#NEWLINE# def user_add( name , password , login_group , groups ) : #NEWLINE# #INDENT# cmd = [ ] #NEWLINE# cmd . append ( '/usr/sbin/useradd' ) #NEWLINE# if login_group : #NEWLINE# #INDENT# cmd . append ( '-g' ) #NEWLINE# cmd . append ( login_group ) #NEWLINE# #UNINDENT# if groups : #NEWLINE# #INDENT# groups_no_ws = re . sub ( '\\s' , '' , groups ) #NEWLINE# try : #NEWLINE# #INDENT# group_list = groups_no_ws . split ( ',' ) #NEWLINE# for group in group_list : #NEWLINE# #INDENT# groups . read ( group ) #NEWLINE# #UNINDENT# cmd . append ( '-G' ) #NEWLINE# cmd . append ( groups_no_ws ) #NEWLINE# #UNINDENT# except ResourceException : #NEWLINE# #INDENT# raise ResourceException ( 'Group does not exist' ) #NEWLINE# #UNINDENT# #UNINDENT# cmd . append ( login_group ) #NEWLINE# ret = exec_cmd ( ' ' . join ( cmd ) ) #NEWLINE# if ( ret [ 'returncode' ] != 0 ) : #NEWLINE# #INDENT# raise ResourceException ( ret [ 'stderr' ] ) #NEWLINE# #UNINDENT# if password : #NEWLINE# #INDENT# set_password ( name , password )