Forum Discussion
Adding a user with Ruby & iControl
Hello.
I've been knocking my brains out trying to get the Ruby iControl gem to add a user to a device. The complex type on this one is throwing me for a loop. If I can get the simple code down, I can expand it, but I can't get my head around the structure of user_info_3.
Here's my simple code:
bigip = F5::IControl.new(bigip_address, bigip_user, bigip_pass, ["Management.UserManagement"]).get_interfaces
bigip["Management.UserManagement"].create_user_3([[{'name' => 'Guest', 'full_name' => 'Guest User'}], [{'is_encrypted' => false, 'password' => 'abcd'}], [{'role' => 'USER_ROLE_GUEST', 'partition' => 'Common'}], ['/bin/false']])
Any ideas?
Thanks.
rjwiii
3 Replies
- Update:
The error I was getting with the code above was: ": Could not find element by name: name (SOAP::FaultError)"
I have since tried the following:
bigip["Management.UserManagement"].create_user_3([{'user' => [{'name' => 'Guest', 'full_name' => 'Guest User'}], 'password' => [{'is_encrypted' => 'false', 'password' => 'abcd'}], 'permissions' => [{'role' => 'USER_ROLE_GUEST', 'partition' => 'Common'}], 'login_shell' => ['/bin/false']}])
and I get a new error: ": Cannot convert null value to a boolean. (SOAP::FaultError)"
Is this progress? :)
Any help? - George_Watkins_Historic F5 Account
Rich,
Here you go:bigip['Management.UserManagement'].create_user_3([{'user' => {'name' => 'Guest', 'full_name' => 'Guest User'}, 'password' => {'is_encrypted' => 'false', 'password' => 'abcd'}, 'permissions' => [ {'role' => 'USER_ROLE_GUEST', 'partition' => 'Common'} ], 'login_shell' => '/bin/false'}])
Best regards,
George Mr. Watkins,
I had extra [] pairs in there I didn't need ... Your code worked like a charm.
I am using Ruby 1.9.3, so when using the F5 gem, I had to install the soap4r-ruby1.9 gem as mentioned in a previous post. All the warning messages associated with plain soap4r have dissapeared save one:
/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use Stringencode instead.
I'm not sure if it is related to soap4r-ruby1.9 ...
I have also been playing around using iControl with the Savon gem (http://savonrb.com) with good results. Have you considered giving Savon a try?
I also use rvm (http://rvm.io) to test with different versions of Ruby.
I am a life long geek, but I will admit to being fairly new to Ruby and very new to soap & F5 devices ... :) Wish me luck.
A HUGE thank you for your help.
rjwiii
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com