1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

Merge branch 'one-2.0' of opennebula.org:one into one-2.0

This commit is contained in:
Jaime Melis 2010-07-27 15:46:52 +02:00
commit 4353a487c2
4 changed files with 8 additions and 15 deletions

View File

@ -51,6 +51,7 @@ class AuthorizationManager < OpenNebulaDriver
database_url=@config[:database]
@db=Sequel.connect(database_url)
# Get authentication driver
begin
driver_prefix=@config[:authentication].capitalize
driver_name="#{driver_prefix}Auth"

View File

@ -46,9 +46,6 @@ Usage:
Commands:
* create (Creates a new user)
oneauth create <username> <ssh public key>
* quota set (sets quota for a user)
oneauth quota set <id> <cpu> <memory>
@ -116,17 +113,6 @@ when "login"
ssh=SshAuth.new
ssh.login(user, time)
when "create"
user=OpenNebula::User.new(
OpenNebula::User.build_xml, OpenNebula::Client.new)
password = ARGV[1]
result=user.allocate(ARGV[0], password)
if !OpenNebula.is_error?(result)
puts "ID: " + user.id.to_s
exit 0
end
when "key"
ssh=SshAuth.new
puts ssh.extract_public_key

View File

@ -19,7 +19,7 @@
class SimpleAuth
# Method called by authentication driver. It should awnser true if
# successful or a string with the error message if failure. All
# parameters are string extracted from the authorization message.
# parameters are strings extracted from the authorization message.
#
# * user_id: OpenNebula user identifier
# * user: user name

View File

@ -9,10 +9,13 @@ class SimplePermissions
@quota_enabled=conf[:quota][:enabled]
end
# Returns message if result is false, true otherwise
def auth_message(result, message)
result ? true : message
end
# Extracts cpu and memory resources from the VM template sent in
# authorization message
def get_vm_usage(data)
vm_xml=Base64::decode64(data)
vm=OpenNebula::VirtualMachine.new(
@ -31,6 +34,7 @@ class SimplePermissions
VmUsage.new(cpu, memory)
end
# Method called by authorization driver
def auth(uid, tokens)
result=true
@ -43,6 +47,8 @@ class SimplePermissions
result
end
# Authorizes each of the tokens. All parameters are strings. Pub
# means public when "1" and private when "0"
def auth_object(uid, object, id, action, owner, pub)
return true if uid=='0'