From 77167a11df24ab91d75d1b809334b86eb3580827 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 27 Jul 2010 15:02:41 +0200 Subject: [PATCH 1/2] Delete duplicated functionality from oneauth --- src/authm_mad/oneauth | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/authm_mad/oneauth b/src/authm_mad/oneauth index b01875aa55..1f3d39c6f3 100755 --- a/src/authm_mad/oneauth +++ b/src/authm_mad/oneauth @@ -46,9 +46,6 @@ Usage: Commands: -* create (Creates a new user) - oneauth create - * quota set (sets quota for a user) oneauth quota set @@ -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 From d95647fbe604b370a8aebf5eaa710480edcf06d5 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 27 Jul 2010 15:44:05 +0200 Subject: [PATCH 2/2] Code documentation(cherry picked from commit 95743329837537136f45f0c8ab666ce2b3d060bd) --- src/authm_mad/one_auth_mad.rb | 1 + src/authm_mad/simple_auth.rb | 2 +- src/authm_mad/simple_permissions.rb | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/authm_mad/one_auth_mad.rb b/src/authm_mad/one_auth_mad.rb index 1c936ca0d2..6832e7cafc 100755 --- a/src/authm_mad/one_auth_mad.rb +++ b/src/authm_mad/one_auth_mad.rb @@ -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" diff --git a/src/authm_mad/simple_auth.rb b/src/authm_mad/simple_auth.rb index 4a07db3014..00bec0b3f5 100644 --- a/src/authm_mad/simple_auth.rb +++ b/src/authm_mad/simple_auth.rb @@ -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 diff --git a/src/authm_mad/simple_permissions.rb b/src/authm_mad/simple_permissions.rb index 81862e302f..b055779230 100644 --- a/src/authm_mad/simple_permissions.rb +++ b/src/authm_mad/simple_permissions.rb @@ -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'