44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/wdmc/user.rb', line 44
def create( name )
password = Base64.strict_encode64(options[:password]) if options[:password]
user_exists = @wdmc.user_exists?( name )
abort "\nUser does not exist: ".color(:yellow) + "#{name}".color(:cyan) if user_exists.include?( name )
begin
groups = ['cloudholders']
groups.push options[:group_names] if options[:group_names]
data = {
:email => options[:email],
:username => name,
:password => password,
:fullname => options[:fullname],
:is_admin => options[:admin],
:group_names => groups.join(','),
:first_name => options[:first_name],
:last_name => options[:last_name]
}
puts "Create user:\s".color(:whitesmoke) + "OK".color(:green) if @wdmc.add_user( data )
rescue RestClient::ExceptionWithResponse => e
puts eval(e.response)[:users][:error_message].color(:orange)
end
end
|