# Update user info using Ruby OpenNebula Cloud API

**URL:** <https://forum.opennebula.io/t/update-user-info-using-ruby-opennebula-cloud-api/2836>\
**Category:** Product Support\
**Created:** [August 30, 2016, 7:36am UTC](https://forum.opennebula.io/t/update-user-info-using-ruby-opennebula-cloud-api/2836 "2016-08-30T07:36:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anandharaj](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@anandharaj](https://forum.opennebula.io/u/anandharaj)\
**Post date:** [August 30, 2016, 7:36am UTC](https://forum.opennebula.io/t/update-user-info-using-ruby-opennebula-cloud-api/2836/1 "2016-08-30T07:36:44Z")

</div>

Hi,

I need to update/add user information (eg. department) using ruby command. I follow the guide in [http://docs.opennebula.org/4.12/integration/system\_interfaces/ruby.html](http://docs.opennebula.org/4.12/integration/system_interfaces/ruby.html) and host hook script (host\_error.rb)

In my script, i already done up to the initiate new client / authentication. After this, what is the API to update the user? The update will be for 1 user only as the script will be executed by providing the userid.

The manual way i do this is using oneuser command  
`oneuser update <user_id> <file> -a`

the file content:  
DEPARTMENT=IT

---

<div class="post-metadata">

**Author:** ![cmartin](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cmartin/32/4278_2.png) [@cmartin](https://forum.opennebula.io/u/cmartin)\
**Post date:** [August 31, 2016, 9:09am UTC](https://forum.opennebula.io/t/update-user-info-using-ruby-opennebula-cloud-api/2836/2 "2016-08-31T09:09:12Z")

</div>

Hi,

The ‘oneuser update’ command uses this method internally:  
[http://docs.opennebula.org/doc/5.0/oca/ruby/OpenNebula/User.html#update-instance\_method](http://docs.opennebula.org/doc/5.0/oca/ruby/OpenNebula/User.html#update-instance_method)

---

<div class="post-metadata">

**Author:** ![anandharaj](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@anandharaj](https://forum.opennebula.io/u/anandharaj)\
**Post date:** [September 1, 2016, 4:06am UTC](https://forum.opennebula.io/t/update-user-info-using-ruby-opennebula-cloud-api/2836/3 "2016-09-01T04:06:34Z")

</div>

Hi Carlos,

Thank you for the info. Is the following codes is correct?

```
template = <<-EOT
DEPARTMENT = "IT Dept"
FULL_NAME = "My name is "
EOT

xml = OpenNebula::User.build_xml
user = OpenNebula::User.new(xml, client)

rc = user.update(template, append = true)
if OpenNebula.is_error?(rc)
    STDERR.puts rc.message
    exit(-1)
else
    puts "Success"
end

```

EDIT:  
How do i pass the userid parameter?

---

<div class="post-metadata">

**Author:** ![cmartin](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cmartin/32/4278_2.png) [@cmartin](https://forum.opennebula.io/u/cmartin)\
**Post date:** [September 1, 2016, 8:35am UTC](https://forum.opennebula.io/t/update-user-info-using-ruby-opennebula-cloud-api/2836/4 "2016-09-01T08:35:42Z")

</div>

> [@anandharaj](#):
>
> How do i pass the userid parameter?

Use the new\_with\_id method:  
[http://docs.opennebula.org/doc/5.0/oca/ruby/OpenNebula/PoolElement.html#new\_with\_id-class\_method](http://docs.opennebula.org/doc/5.0/oca/ruby/OpenNebula/PoolElement.html#new_with_id-class_method)
