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

Feature #4614: Search by user password in oca and cli

This commit is contained in:
Carlos Martín 2016-06-30 18:39:45 +02:00
parent e8f0c4e9fc
commit c7bc4ed774
2 changed files with 36 additions and 0 deletions

View File

@ -516,4 +516,18 @@ cmd=CommandParser::CmdParser.new(ARGV) do
0
end
passwdsearch_desc = <<-EOT.unindent
Searches for users with a specific auth driver that has the given
string in their password field
EOT
command :passwdsearch, passwdsearch_desc, :driver, :password,
:options=>[CLIHelper::CSV_OPT, OpenNebulaHelper::XML] do
options[:list] = ["ID", "NAME", "AUTH", "PASSWORD"]
options[:filter] = ["AUTH=#{args[0]}", "PASSWORD=#{args[1]}"]
helper.list_pool(options)
end
end

View File

@ -51,5 +51,27 @@ module OpenNebula
end
alias_method :info!, :info
#######################################################################
# Helpers to get information
#######################################################################
# Returns a list of user IDs that have the given password. info() needs
# to be called before.
#
# @param driver [String] auth driver to match
# @param password [String] password to match
# @return [Array] an array of IDs
def users_with_password(driver, password)
ids = []
each do |user|
if user["PASSWORD"] == password
ids << user["ID"]
end
end
return ids
end
end
end