Class: OpenNebula::User
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::User
- Defined in:
- OpenNebula/User.rb
Constant Summary
- USER_METHODS =
Constants and Class Methods
{ :info => "user.info", :allocate => "user.allocate", :delete => "user.delete", :passwd => "user.passwd", :chgrp => "user.chgrp", :update => "user.update", :chauth => "user.chauth" }
- SELF =
-1
- CORE_AUTH =
Driver name for default core authentication
"core"
- CIPHER_AUTH =
Driver name for default core authentication
"server_cipher"
- SSH_AUTH =
Driver name for ssh authentication
"ssh"
- X509_AUTH =
Driver name for x509 authentication
"x509"
- X509_PROXY_AUTH =
Driver name for x509 proxy authentication
"x509_proxy"
Class Method Summary (collapse)
-
+ (Object) build_xml(pe_id = nil)
Creates a User description with just its identifier this method should be used to create plain User objects.
Instance Method Summary (collapse)
-
- (Object) allocate(username, password, driver = CORE_AUTH)
Allocates a new User in OpenNebula.
-
- (nil, OpenNebula::Error) chauth(auth, password = "")
Changes the auth driver and the password of the given User.
-
- (Object) chgrp(gid)
Changes the main group
gid
Integer the new group id.
-
- (Object) delete
Deletes the User.
-
- (Object) gid
Returns the group identifier
- return
-
Integer the element's group ID.
-
- (Object) info
Retrieves the information of the given User.
-
- (User) initialize(xml, client)
constructor
Class constructor.
-
- (Object) passwd(password)
Changes the password of the given User.
-
- (Object) update(new_template)
Replaces the template contents.
Methods inherited from PoolElement
#id, #name, new_with_id, #to_str
Methods inherited from XMLElement
#[], #add_element, #attr, #delete_element, #each, #each_xpath, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml
Constructor Details
- (User) initialize(xml, client)
Class constructor
71 72 73 74 75 |
# File 'OpenNebula/User.rb', line 71 def initialize(xml, client) super(xml,client) @client = client end |
Class Method Details
+ (Object) build_xml(pe_id = nil)
Creates a User description with just its identifier this method should be used to create plain User objects. id the id of the user
Example:
user = User.new(User.build_xml(3),rpc_client)
60 61 62 63 64 65 66 67 68 |
# File 'OpenNebula/User.rb', line 60 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
- (Object) allocate(username, password, driver = CORE_AUTH)
Allocates a new User in OpenNebula
username Name of the new user.
password Password for the new user
91 92 93 |
# File 'OpenNebula/User.rb', line 91 def allocate(username, password, driver=CORE_AUTH) super(USER_METHODS[:allocate], username, password, driver) end |
- (nil, OpenNebula::Error) chauth(auth, password = "")
Changes the auth driver and the password of the given User
138 139 140 141 142 143 144 145 |
# File 'OpenNebula/User.rb', line 138 def chauth(auth, password="") return Error.new('ID not defined') if !@pe_id rc = @client.call(USER_METHODS[:chauth],@pe_id, auth, password) rc = nil if !OpenNebula.is_error?(rc) return rc end |
- (Object) chgrp(gid)
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
122 123 124 125 126 127 128 129 |
# File 'OpenNebula/User.rb', line 122 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 |
- (Object) delete
Deletes the User
103 104 105 |
# File 'OpenNebula/User.rb', line 103 def delete() super(USER_METHODS[:delete]) end |
- (Object) gid
Returns the group identifier
- return
-
Integer the element's group ID
153 154 155 |
# File 'OpenNebula/User.rb', line 153 def gid self['GID'].to_i end |
- (Object) info
Retrieves the information of the given User.
82 83 84 |
# File 'OpenNebula/User.rb', line 82 def info() super(USER_METHODS[:info], 'USER') end |
- (Object) passwd(password)
Changes the password of the given User
password String containing the new password
110 111 112 113 114 115 116 117 |
# File 'OpenNebula/User.rb', line 110 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 |
- (Object) update(new_template)
Replaces the template contents
new_template New template contents
98 99 100 |
# File 'OpenNebula/User.rb', line 98 def update(new_template) super(USER_METHODS[:update], new_template) end |