Class: OpenNebula::User
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::User
- Defined in:
- lib/OpenNebula/User.rb
Constant Summary collapse
- USER_METHODS =
Constants and Class Methods
{ :info => "user.info", :allocate => "user.allocate", :delete => "user.delete", :passwd => "user.passwd", :chgrp => "user.chgrp" }
- SELF =
-1
Class Method Summary collapse
-
.build_xml(pe_id = nil) ⇒ Object
Creates a User description with just its identifier this method should be used to create plain User objects.
Instance Method Summary collapse
-
#allocate(username, password) ⇒ Object
Allocates a new User in OpenNebula.
-
#chgrp(gid) ⇒ Object
- Changes the main group gid
-
Integer the new group id.
-
#delete ⇒ Object
Deletes the User.
-
#gid ⇒ Object
Returns the group identifier [return] Integer the element’s group ID.
-
#info ⇒ Object
Retrieves the information of the given User.
-
#initialize(xml, client) ⇒ User
constructor
——————————————————————— Class constructor ———————————————————————.
-
#passwd(password) ⇒ Object
Changes the password of the given User.
Methods inherited from PoolElement
#id, #name, new_with_id, #to_str
Methods inherited from XMLElement
#[], #attr, #each, #each_xpath, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #text, #to_hash, #to_xml
Constructor Details
#initialize(xml, client) ⇒ User
Class constructor
54 55 56 57 58 |
# File 'lib/OpenNebula/User.rb', line 54 def initialize(xml, client) super(xml,client) @client = client end |
Class Method Details
.build_xml(pe_id = nil) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/OpenNebula/User.rb', line 41 def User.build_xml(pe_id=nil) if pe_id user_xml = "<USER><ID>#{pe_id}</ID></USER>" else user_xml = "<USER></USER>" end XMLElement.build_xml(user_xml, 'USER') end |
Instance Method Details
#allocate(username, password) ⇒ Object
Allocates a new User in OpenNebula
username Name of the new user.
password Password for the new user
74 75 76 |
# File 'lib/OpenNebula/User.rb', line 74 def allocate(username, password) super(USER_METHODS[:allocate], username, password) end |
#chgrp(gid) ⇒ Object
Changes the main group
- gid
-
Integer the new group id. Set to -1 to leave the current one
- return
-
nil in case of success or an Error object
98 99 100 101 102 103 104 105 |
# File 'lib/OpenNebula/User.rb', line 98 def chgrp(gid) return Error.new('ID not defined') if !@pe_id rc = @client.call(USER_METHODS[:chgrp],@pe_id, gid) rc = nil if !OpenNebula.is_error?(rc) return rc end |
#delete ⇒ Object
Deletes the User
79 80 81 |
# File 'lib/OpenNebula/User.rb', line 79 def delete() super(USER_METHODS[:delete]) end |
#gid ⇒ Object
Returns the group identifier
- return
-
Integer the element’s group ID
113 114 115 |
# File 'lib/OpenNebula/User.rb', line 113 def gid self['GID'].to_i end |
#info ⇒ Object
Retrieves the information of the given User.
65 66 67 |
# File 'lib/OpenNebula/User.rb', line 65 def info() super(USER_METHODS[:info], 'USER') end |
#passwd(password) ⇒ Object
Changes the password of the given User
password String containing the new password
86 87 88 89 90 91 92 93 |
# File 'lib/OpenNebula/User.rb', line 86 def passwd(password) return Error.new('ID not defined') if !@pe_id rc = @client.call(USER_METHODS[:passwd], @pe_id, password) rc = nil if !OpenNebula.is_error?(rc) return rc end |