1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

feature #286: oneuser command now supports new passwd sub-command to change password.

This commit is contained in:
Carlos Martín 2010-07-21 11:45:31 +02:00 committed by Ruben S. Montero
parent 841f6c416d
commit fa96d8a7e2
2 changed files with 32 additions and 2 deletions

View File

@ -103,6 +103,9 @@ Commands:
* list (Lists all the users in the pool)
oneuser list
* passwd (Changes the given user's password)
oneuser passwd <id> password
EOT
def text_commands
@ -181,7 +184,23 @@ when "delete"
puts "User deleted" if ops[:verbose]
end
end
when "passwd"
check_parameters("passwd", 2)
user_id=get_user_id(ARGV[0])
user=OpenNebula::User.new_with_id(user_id, get_one_client)
sha_password = Digest::SHA1.hexdigest(ARGV[1])
result=user.passwd(sha_password)
if !OpenNebula.is_error?(result)
puts "Password changed" if ops[:verbose]
else
puts
end
when "list"
if !ops[:xml]
uplist=UPShow.new

View File

@ -8,7 +8,8 @@ module OpenNebula
USER_METHODS = {
:info => "user.info",
:allocate => "user.allocate",
:delete => "user.delete"
:delete => "user.delete",
:passwd => "user.passwd"
}
# Creates a User description with just its identifier
@ -51,5 +52,15 @@ module OpenNebula
def delete()
super(USER_METHODS[:delete])
end
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
end
end