From 57d4107c9ac4f1e88d65ca86be6ca48596af9ccc Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 6 Sep 2011 18:15:16 +0200 Subject: [PATCH 01/13] bug #793: Fix ONE_AUTH errors when not present --- src/cli/one_helper.rb | 8 +++++++- src/cli/one_helper/oneuser_helper.rb | 2 +- src/cli/oneuser | 17 ++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 20b649c3bc..f1ce493baa 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -65,7 +65,13 @@ EOT class OneHelper def initialize(secret=nil, endpoint=nil, hash=true) - @client = OpenNebula::Client.new(secret,endpoint,hash) + begin + @client = OpenNebula::Client.new(secret,endpoint,hash) + rescue Exception => e + puts e.message + exit -1 + end + @translation_hash = nil end diff --git a/src/cli/one_helper/oneuser_helper.rb b/src/cli/one_helper/oneuser_helper.rb index bca7a4c27c..1fa41d3c58 100644 --- a/src/cli/one_helper/oneuser_helper.rb +++ b/src/cli/one_helper/oneuser_helper.rb @@ -84,7 +84,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper end end - def login(username, options) + def self.login(username, options) if options[:ssh] require 'ssh_auth' diff --git a/src/cli/oneuser b/src/cli/oneuser index e46b8a757b..b866e6e1a9 100755 --- a/src/cli/oneuser +++ b/src/cli/oneuser @@ -34,8 +34,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do usage "`oneuser` [] []" version OpenNebulaHelper::ONE_VERSION - helper = OneUserHelper.new - ######################################################################## # Global Options ######################################################################## @@ -118,10 +116,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do end set :format, :userid, OneUserHelper.to_id_desc do |arg| + helper = OneUserHelper.new helper.to_id(arg) end set :format, :userid_list, OneUserHelper.list_to_id_desc do |arg| + helper = OneUserHelper.new helper.list_to_id(arg) end @@ -145,6 +145,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :create, create_desc, :username, [:password, nil], :options=>create_options do + helper = OneUserHelper.new + if args[1] pass = args[1] else @@ -171,9 +173,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do --time 72000 EOT - command :login, login_desc, :username, [:password, nil], - :options=>login_options do - helper.login(args[0], options) + command :login, login_desc, :username, :options=>login_options do + OneUserHelper.login(args[0], options) end key_desc = <<-EOT.unindent @@ -202,6 +203,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :delete, delete_desc, [:range, :userid_list] do + helper = OneUserHelper.new helper.perform_actions(args[0],options,"deleted") do |user| user.delete end @@ -213,6 +215,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :passwd, passwd_desc, :userid, [:password, nil], :options=>create_options do + helper = OneUserHelper.new + if args[1] pass = args[1] else @@ -234,6 +238,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :chgrp, chgrp_desc, [:range, :userid_list], :groupid do + helper = OneUserHelper.new helper.perform_actions(args[0],options,"Group changed") do |user| user.chgrp(args[1].to_i) end @@ -244,6 +249,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do EOT command :list, list_desc, :options=>list_options do + helper = OneUserHelper.new helper.list_pool(options) end @@ -254,6 +260,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :show, show_desc, [:userid, nil], :options=>OpenNebulaHelper::XML do user=args[0] || OpenNebula::User::SELF + helper = OneUserHelper.new helper.show_resource(user,options) end From 92356b0c55af5947e4c792de0b1bdfac6c5392f3 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 7 Sep 2011 12:27:34 +0200 Subject: [PATCH 02/13] bug #750: Fix ozones etc files install --- install.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index 5c9ecb41ef..e33d064816 100755 --- a/install.sh +++ b/install.sh @@ -76,7 +76,7 @@ while true ; do -l) LINK="yes" ; shift ;; -c) CLIENT="yes"; INSTALL_ETC="no" ; shift ;; -s) SUNSTONE="yes"; shift ;; - -o) OZONES="yes"; INSTALL_ETC="no" ; shift ;; + -o) OZONES="yes"; shift ;; -u) ONEADMIN_USER="$2" ; shift 2;; -g) ONEADMIN_GROUP="$2"; shift 2;; -d) ROOT="$2" ; shift 2 ;; @@ -107,7 +107,7 @@ if [ -z "$ROOT" ] ; then MAN_LOCATION="/usr/share/man/man1" if [ "$CLIENT" = "yes" ]; then - MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION" + MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION" DELETE_DIRS="" @@ -120,7 +120,8 @@ if [ -z "$ROOT" ] ; then CHOWN_DIRS="" elif [ "$OZONES" = "yes" ]; then - MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION $OZONES_LOCATION" + MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION $OZONES_LOCATION \ + $ETC_LOCATION" DELETE_DIRS="$MAKE_DIRS" @@ -150,7 +151,7 @@ else MAN_LOCATION="$ROOT/share/man/man1" if [ "$CLIENT" = "yes" ]; then - MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $CONF_LOCATION" + MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION" DELETE_DIRS="$MAKE_DIRS" elif [ "$SUNSTONE" = "yes" ]; then @@ -286,7 +287,7 @@ LIB_OCA_CLIENT_DIRS="$LIB_LOCATION/ruby \ LIB_CLI_CLIENT_DIRS="$LIB_LOCATION/ruby/cli \ $LIB_LOCATION/ruby/cli/one_helper" -CONF_CLI_DIRS="$CONF_LOCATION/cli" +CONF_CLI_DIRS="$ETC_LOCATION/cli" if [ "$CLIENT" = "yes" ]; then MAKE_DIRS="$MAKE_DIRS $LIB_ECO_CLIENT_DIRS $LIB_OCCI_CLIENT_DIRS \ @@ -374,7 +375,7 @@ INSTALL_CLIENT_FILES=( OZONES_BIN_CLIENT_FILES:$BIN_LOCATION OZONES_LIB_CLIENT_CLI_FILES:$LIB_LOCATION/ruby/cli OZONES_LIB_CLIENT_CLI_HELPER_FILES:$LIB_LOCATION/ruby/cli/ozones_helper - CLI_CONF_FILES:$CONF_LOCATION/cli + CLI_CONF_FILES:$ETC_LOCATION/cli OCA_LIB_FILES:$LIB_LOCATION/ruby RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula ) @@ -415,7 +416,6 @@ INSTALL_OZONES_RUBY_FILES=( INSTALL_OZONES_FILES=( OZONES_FILES:$OZONES_LOCATION OZONES_BIN_FILES:$BIN_LOCATION - OZONES_ETC_FILES:$ETC_LOCATION OZONES_MODELS_FILES:$OZONES_LOCATION/models OZONES_TEMPLATE_FILES:$OZONES_LOCATION/templates OZONES_LIB_FILES:$OZONES_LOCATION/lib @@ -435,6 +435,10 @@ INSTALL_OZONES_FILES=( OZONES_LIB_CLIENT_CLI_HELPER_FILES:$LIB_LOCATION/ruby/cli/ozones_helper ) +INSTALL_OZONES_ETC_FILES=( + OZONES_ETC_FILES:$ETC_LOCATION +) + INSTALL_ETC_FILES=( ETC_FILES:$ETC_LOCATION VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2 @@ -1189,9 +1193,12 @@ done if [ "$INSTALL_ETC" = "yes" ] ; then if [ "$SUNSTONE" = "yes" ]; then INSTALL_ETC_SET="${INSTALL_SUNSTONE_ETC_FILES[@]}" + elif [ "$OZONES" = "yes" ]; then + INSTALL_ETC_SET="${INSTALL_OZONES_ETC_FILES[@]}" else INSTALL_ETC_SET="${INSTALL_ETC_FILES[@]} \ - ${INSTALL_SUNSTONE_ETC_FILES[@]}" + ${INSTALL_SUNSTONE_ETC_FILES[@]} \ + ${INSTALL_OZONES_ETC_FILES[@]}" fi for i in ${INSTALL_ETC_SET[@]}; do From 3e54d5e6962d77a10a1d16fe835688b11ad01d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 7 Sep 2011 15:55:25 +0200 Subject: [PATCH 03/13] Fix ruby require capitalization for quotas --- src/authm_mad/remotes/quota/authorize | 2 +- src/authm_mad/remotes/quota/test/helper/test_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/authm_mad/remotes/quota/authorize b/src/authm_mad/remotes/quota/authorize index fe8644c176..70b7d18618 100755 --- a/src/authm_mad/remotes/quota/authorize +++ b/src/authm_mad/remotes/quota/authorize @@ -29,7 +29,7 @@ end $: << RUBY_LIB_LOCATION require 'scripts_common' -require 'opennebula' +require 'OpenNebula' require 'quota' user_id = ARGV.shift diff --git a/src/authm_mad/remotes/quota/test/helper/test_helper.rb b/src/authm_mad/remotes/quota/test/helper/test_helper.rb index 0735253de4..3f40bb8d58 100644 --- a/src/authm_mad/remotes/quota/test/helper/test_helper.rb +++ b/src/authm_mad/remotes/quota/test/helper/test_helper.rb @@ -13,7 +13,7 @@ $: << '.' $: << '..' require 'mock_client' -require 'opennebula' +require 'OpenNebula' require 'quota' class Quota From 0e9ecc565536beec430bf6d76846c9a45b0da752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 7 Sep 2011 16:32:44 +0200 Subject: [PATCH 04/13] Fix bug: quota authorization ignored the ACL decision. --- src/authm_mad/remotes/quota/authorize | 2 +- src/authm_mad/remotes/quota/quota.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/authm_mad/remotes/quota/authorize b/src/authm_mad/remotes/quota/authorize index 70b7d18618..040ac90eb1 100755 --- a/src/authm_mad/remotes/quota/authorize +++ b/src/authm_mad/remotes/quota/authorize @@ -35,7 +35,7 @@ require 'quota' user_id = ARGV.shift overall_evalutation = ARGV.pop -exit -1 if overall_evalutation == 0 +exit -1 if overall_evalutation.to_i == 0 quota = Quota.new diff --git a/src/authm_mad/remotes/quota/quota.rb b/src/authm_mad/remotes/quota/quota.rb index a32232ef83..37304120e2 100644 --- a/src/authm_mad/remotes/quota/quota.rb +++ b/src/authm_mad/remotes/quota/quota.rb @@ -169,7 +169,7 @@ class Quota def authorize(user_id, request) obj, template_or_id, op, owner, pub, acl_eval = request.split(':') - if acl_eval == 0 + if acl_eval.to_i == 0 return "ACL evaluation denied" end @@ -204,7 +204,7 @@ class Quota msg << " #{qname.to_s.upcase} quota exceeded " msg << "(Quota: #{limit}, " msg << "Used: #{used}, " - msg << "Asked: #{request})." + msg << "Requested: #{request})" end } From a97f0c40fb63402e3b6a4da9f49eeb82f19ffbc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 7 Sep 2011 18:14:53 +0200 Subject: [PATCH 05/13] Bug #477: Let the authorization errors reach the user --- src/authm/AuthManager.cc | 37 +++++++++++++++++++++++++++- src/authm_mad/remotes/quota/quota.rb | 4 +++ src/rm/Request.cc | 13 ++++++---- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/authm/AuthManager.cc b/src/authm/AuthManager.cc index 99d8667825..aeb40d0ba1 100644 --- a/src/authm/AuthManager.cc +++ b/src/authm/AuthManager.cc @@ -117,6 +117,28 @@ void AuthRequest::add_auth(Object ob, self_authorize = self_authorize && auth; auths.push_back(oss.str()); + + if ( auth == false ) + { + ostringstream oss; + + oss << message; + + if ( !message.empty() ) + { + oss << "; "; + } + + oss << "Not authorized to perform " << Operation_to_str(op) + << " " << Object_to_str(ob); + + if ( ob_id_int != -1 ) + { + oss << " [" << ob_id << "]"; + } + + message = oss.str(); + } } /* -------------------------------------------------------------------------- */ @@ -417,7 +439,20 @@ void AuthManager::notify_request(int auth_id,bool result,const string& message) } ar->result = result; - ar->message= message; + + if ( message != "-" ) + { + ostringstream oss; + + if ( !ar->message.empty() ) + { + oss << ar->message << "; "; + } + + oss << message; + + ar->message = oss.str(); + } ar->notify(); } diff --git a/src/authm_mad/remotes/quota/quota.rb b/src/authm_mad/remotes/quota/quota.rb index 37304120e2..1f13234e45 100644 --- a/src/authm_mad/remotes/quota/quota.rb +++ b/src/authm_mad/remotes/quota/quota.rb @@ -190,6 +190,7 @@ class Quota quota = get_quota(user_id) msg = "" + separator = "" info.each { |qname, quota_requested| unless quota[qname] next @@ -201,10 +202,13 @@ class Quota spent = used + request if spent > limit + msg << separator msg << " #{qname.to_s.upcase} quota exceeded " msg << "(Quota: #{limit}, " msg << "Used: #{used}, " msg << "Requested: #{request})" + + separator = ";" end } diff --git a/src/rm/Request.cc b/src/rm/Request.cc index 606d5d203d..5a3c2b73be 100644 --- a/src/rm/Request.cc +++ b/src/rm/Request.cc @@ -189,13 +189,16 @@ string Request::authorization_error (const string &message, { ostringstream oss; - oss << "[" << method_name << "]" << " User [" << att.uid << "] not authorized" - << " to perform action on " << object_name(auth_object) << "."; + oss << "[" << method_name << "]" << " User [" << att.uid << "] "; - - if ( !message.empty() ) + if ( message.empty() ) { - oss << message ; + oss << "not authorized to perform action on " + << object_name(auth_object) << "."; + } + else + { + oss << ": " << message << "."; } return oss.str(); From df90e53dce72a604172c606b1f661ec04cf25e55 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 8 Sep 2011 11:30:37 +0200 Subject: [PATCH 06/13] Select the authentication protocols available --- src/authm_mad/one_auth_mad.rb | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/authm_mad/one_auth_mad.rb b/src/authm_mad/one_auth_mad.rb index c1b9d6cd06..0b26c92f45 100755 --- a/src/authm_mad/one_auth_mad.rb +++ b/src/authm_mad/one_auth_mad.rb @@ -49,7 +49,9 @@ class AuthDriver < OpenNebulaDriver # # @param [String] the authorization method to be used, nil to use the # built-in ACL engine - def initialize(authZ, nthreads) + # @param [Array] authentication modules enabled, nil will use any + # any method existing in remotes directory + def initialize(authZ, authN, nthreads) super( "auth", :concurrency => nthreads, @@ -66,6 +68,20 @@ class AuthDriver < OpenNebulaDriver else @authZ_cmd = nil end + + if authN == nil + # get the directories from remotes dir that have an authenticate + # script + @authN_protocols=Dir[@local_scripts_path+"/*/authenticate"].map do |d| + d.split('/')[-2] + end + else + if authN.class==String + @authN_protocols=[authN] + else + @authN_protocols=authN + end + end end # Authenticate a user based in a string of the form user:secret when using the @@ -88,6 +104,14 @@ class AuthDriver < OpenNebulaDriver secret_attr.shift end + unless @authN_protocols.include?(protocol) + return send_message( + ACTION[:authN], + RESULT[:failure], + request_id, + "Authentication rotocol '#{protocol}' not available") + end + #build path for the auth action #/var/lib/one/remotes/auth//authenticate authN_path = File.join(@local_scripts_path, protocol) @@ -133,11 +157,13 @@ end # Auth Driver Main program opts = GetoptLong.new( [ '--threads', '-t', GetoptLong::REQUIRED_ARGUMENT ], - [ '--authz', '-z', GetoptLong::REQUIRED_ARGUMENT ] + [ '--authz', '-z', GetoptLong::REQUIRED_ARGUMENT ], + [ '--authn', '-n', GetoptLong::REQUIRED_ARGUMENT ] ) threads = 15 authz = nil +authn = nil begin opts.each do |opt, arg| @@ -146,12 +172,14 @@ begin threads = arg.to_i when '--authz' authz = arg + when '--authn' + authn = arg.split(',').map {|a| a.strip } end end rescue Exception => e exit(-1) end -auth_driver = AuthDriver.new(authz, threads) +auth_driver = AuthDriver.new(authz, authn, threads) auth_driver.start_driver From 3c10a8ed6032346ea9f61a495bf37feb1213bd25 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 8 Sep 2011 11:56:55 +0200 Subject: [PATCH 07/13] Bug: Fix wrong return value handling in oneuser (cherry picked from commit 124ba59cf5e663db0929710249de526af38430de) --- src/cli/one_helper/oneuser_helper.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cli/one_helper/oneuser_helper.rb b/src/cli/one_helper/oneuser_helper.rb index 1fa41d3c58..f76ace7cc8 100644 --- a/src/cli/one_helper/oneuser_helper.rb +++ b/src/cli/one_helper/oneuser_helper.rb @@ -117,12 +117,11 @@ class OneUserHelper < OpenNebulaHelper::OneHelper begin proxy = File.read(options[:proxy]) - rc = proxy.scan(/(-+BEGIN CERTIFICATE-+\n[^-]*\n-+END CERTIFICATE-+)/) - certs = rc.flatten! + certs = proxy.scan(/(-+BEGIN CERTIFICATE-+\n[^-]*\n-+END CERTIFICATE-+)/) + certs.flatten! rc = proxy.match(/(-+BEGIN RSA PRIVATE KEY-+\n[^-]*\n-+END RSA PRIVATE KEY-+)/) - - key = rc[1] + key= rc[1] auth = X509Auth.new(:certs_pem=>certs, :key_pem=>key) rescue => e From 355d88ed80d14cc6caf3ae4a5c76706c983de9e4 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 8 Sep 2011 11:37:51 +0200 Subject: [PATCH 08/13] bug #798: Path to du util set to /usr/bin/du (cherry picked from commit 706de92525c2054451ecb09174a0288ed2d7fbf4) --- src/mad/sh/scripts_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 221c997959..61ba330d0d 100755 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -20,7 +20,7 @@ BASH=/bin/bash CUT=cut DATE=/bin/date DD=/bin/dd -DU=/bin/du +DU=/usr/bin/du LVCREATE=/sbin/lvcreate LVREMOVE=/sbin/lvremove LVS=/sbin/lvs From 28e5fb3813ffe849b51aa1d6f7fc0c04768f04de Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 8 Sep 2011 15:26:22 +0200 Subject: [PATCH 09/13] bug #730: Add zone and vdc id format --- src/ozones/Client/bin/onevdc | 6 ++++- src/ozones/Client/bin/onezone | 46 ++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/ozones/Client/bin/onevdc b/src/ozones/Client/bin/onevdc index c15193e244..e93478416e 100755 --- a/src/ozones/Client/bin/onevdc +++ b/src/ozones/Client/bin/onevdc @@ -18,6 +18,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do usage "`onevdc` command [] []" version OpenNebulaHelper::ONE_VERSION + set :format, :vdcid, "VDC ID" do |arg| + arg.match(/^[0123456789]+$/) ? [0,arg] : [-1] + end + ######################################################################## # Global Options ######################################################################## @@ -34,7 +38,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper.create_resource(args[0]) end - command :show, 'Show information of a particular VDC', :text do + command :show, 'Show information of a particular VDC', :vdcid do helper.show_resource(args[0],options) end diff --git a/src/ozones/Client/bin/onezone b/src/ozones/Client/bin/onezone index 861dddec88..ff97efa6f7 100755 --- a/src/ozones/Client/bin/onezone +++ b/src/ozones/Client/bin/onezone @@ -17,15 +17,19 @@ require 'ozones_helper/zones_helper.rb' cmd=CommandParser::CmdParser.new(ARGV) do usage "`onezone` [] []" version OpenNebulaHelper::ONE_VERSION - + + set :format, :zoneid, "Zone ID" do |arg| + arg.match(/^[0123456789]+$/) ? [0,arg] : [-1] + end + ######################################################################## # Global Options - ######################################################################## + ######################################################################## set :option, CommandParser::OPTIONS - + begin helper = ZonesHelper.new "zone" - rescue Exception => e + rescue Exception => e warn e.message exit -1 end @@ -33,8 +37,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :create, 'Create a new Zone', :file do helper.create_resource(args[0]) end - - command :show, 'Show information of a particular Zone', :text, [:text, nil] do + + show_desc = <<-EOT.unindent + Show information of a particular Zone + Available resources: host, vm, image, vn, template, user + Examples: + onezone show 4 + onezone show 4 host + EOT + + command :show, show_desc, :zoneid, [:resource, nil] do zone=helper.show_resource(args[0],options)[1] case args[1] @@ -44,54 +56,54 @@ cmd=CommandParser::CmdParser.new(ARGV) do zone['endpoint'], false) - aux_helper.list_pool(options) + aux_helper.list_pool(options) when "vm" aux_helper = OneVMHelper.new( zone['onename'] + ":" + zone['onepass'], zone['endpoint'], false) - aux_helper.list_pool(options) + aux_helper.list_pool(options) when "image" aux_helper = OneImageHelper.new( zone['onename'] + ":" + zone['onepass'], zone['endpoint'], false) - aux_helper.list_pool(options) + aux_helper.list_pool(options) when "vn" aux_helper = OneVNetHelper.new( zone['onename'] + ":" + zone['onepass'], zone['endpoint'], false) - aux_helper.list_pool(options) - + aux_helper.list_pool(options) + when "template" aux_helper = OneTemplateHelper.new( zone['onename'] + ":" + zone['onepass'], zone['endpoint'], false) - aux_helper.list_pool(options) - + aux_helper.list_pool(options) + when "user" aux_helper = OneUserHelper.new( zone['onename'] + ":" + zone['onepass'], zone['endpoint'], false) - aux_helper.list_pool(options) + aux_helper.list_pool(options) end 0 end - - command :list, 'Lists Zones in the pool', + + command :list, 'Lists Zones in the pool', :options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS do helper.list_pool(options) end command :delete, 'Deletes a Zone', :zoneid do - helper.delete_resource(args[0],options) + helper.delete_resource(args[0],options) end end From 45b400a510d1f0d433f600e88d0ea092f864f171 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 8 Sep 2011 17:32:05 +0200 Subject: [PATCH 10/13] Typo in auth module --- src/authm_mad/one_auth_mad.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/authm_mad/one_auth_mad.rb b/src/authm_mad/one_auth_mad.rb index 0b26c92f45..b1d40bcaf9 100755 --- a/src/authm_mad/one_auth_mad.rb +++ b/src/authm_mad/one_auth_mad.rb @@ -109,7 +109,7 @@ class AuthDriver < OpenNebulaDriver ACTION[:authN], RESULT[:failure], request_id, - "Authentication rotocol '#{protocol}' not available") + "Authentication protocol '#{protocol}' not available") end #build path for the auth action From 78247256ce74a06d7db681a51213469a62c303a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 8 Sep 2011 17:47:49 +0200 Subject: [PATCH 11/13] Bug #477: Small change in error string generation --- src/authm/AuthManager.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/authm/AuthManager.cc b/src/authm/AuthManager.cc index aeb40d0ba1..8ed3a16b9b 100644 --- a/src/authm/AuthManager.cc +++ b/src/authm/AuthManager.cc @@ -442,16 +442,12 @@ void AuthManager::notify_request(int auth_id,bool result,const string& message) if ( message != "-" ) { - ostringstream oss; - if ( !ar->message.empty() ) { - oss << ar->message << "; "; + ar->message.append("; "); } - oss << message; - - ar->message = oss.str(); + ar->message.append(message); } ar->notify(); From 6d66dac27bec82cf223ad18af76fa2f9036e7567 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 7 Sep 2011 19:43:20 +0200 Subject: [PATCH 12/13] Small oZones fixes This patch improves the login screen and adjust some visual elements in oZones: - Login form submission is handled in a nicer way - Login failure message fade in on top of the login box - Login screen compacts in screens with small resolutions - Some column widths in the tables are adjusted --- src/ozones/Server/public/css/login.css | 2 +- src/ozones/Server/public/js/login.js | 29 +++++++------------ .../public/js/plugins/aggregated-tab.js | 5 ++-- .../Server/public/js/plugins/dashboard-tab.js | 3 -- .../Server/public/js/plugins/zones-tab.js | 5 ++-- src/ozones/Server/templates/index.html | 2 +- src/ozones/Server/templates/login.html | 20 ++++++------- 7 files changed, 29 insertions(+), 37 deletions(-) diff --git a/src/ozones/Server/public/css/login.css b/src/ozones/Server/public/css/login.css index b6bda684cc..e119e9189a 100644 --- a/src/ozones/Server/public/css/login.css +++ b/src/ozones/Server/public/css/login.css @@ -135,7 +135,7 @@ div#login input#login_btn:hover { .error_message { display: none; position: relative; - top: 150px; + top: 80px; font-family: Arial, Helvetica, sans-serif; color:red; font-size:1.6em; diff --git a/src/ozones/Server/public/js/login.js b/src/ozones/Server/public/js/login.js index fa6e3260c7..ff5eb25faa 100644 --- a/src/ozones/Server/public/js/login.js +++ b/src/ozones/Server/public/js/login.js @@ -25,11 +25,11 @@ function auth_error(req, error){ switch (status){ case 401: $("#one_error").hide(); - $("#auth_error").show(); + $("#auth_error").fadeIn("slow"); break; case 500: $("#auth_error").hide(); - $("#one_error").show(); + $("#one_error").fadeIn("slow"); break; } } @@ -47,25 +47,18 @@ function authenticate(){ }); } -function logout(){ - oZones.Auth.logout(); -} - - $(document).ready(function(){ - $("#login_btn").click(function () { + $("#login_form").submit(function (){ authenticate(); + return false; }); - $("input").keydown(function (e){ - if (e.keyCode == 13) { - authenticate(); - } - }); + //compact login elements according to screen height + if (screen.height <= 600){ + $('div#logo_sunstone').css("top","15px"); + $('div#login').css("top","10px"); + $('.error_message').css("top","10px"); + }; - $("#logout_btn").click(function () { - logout(); - }); - - $("input#username.box").get(0).focus(); + $("input#username.box").focus(); }); diff --git a/src/ozones/Server/public/js/plugins/aggregated-tab.js b/src/ozones/Server/public/js/plugins/aggregated-tab.js index 710e5fa53b..b340bc6dd3 100644 --- a/src/ozones/Server/public/js/plugins/aggregated-tab.js +++ b/src/ozones/Server/public/js/plugins/aggregated-tab.js @@ -555,7 +555,8 @@ $(document).ready(function(){ "bAutoWidth":false, "aoColumnDefs": [ { "sWidth": "35px", "aTargets": [0,2] }, - { "sWidth": "100px", "aTargets": [1,3,4,5,10] } + { "sWidth": "60px", "aTargets": [7,8] }, + { "sWidth": "100px", "aTargets": [1,3,4,6,10] } ] }); @@ -579,7 +580,7 @@ $(document).ready(function(){ "aoColumnDefs": [ { "sWidth": "60px", "aTargets": [10] }, { "sWidth": "35px", "aTargets": [0,2,8,9,11] }, - { "sWidth": "100px", "aTargets": [1,3,4,5,7] } + { "sWidth": "100px", "aTargets": [1,3,4,6,7] } ] }); diff --git a/src/ozones/Server/public/js/plugins/dashboard-tab.js b/src/ozones/Server/public/js/plugins/dashboard-tab.js index 34553f45ab..a0b43908e1 100644 --- a/src/ozones/Server/public/js/plugins/dashboard-tab.js +++ b/src/ozones/Server/public/js/plugins/dashboard-tab.js @@ -139,9 +139,6 @@ var dashboard_tab_content =
\

\ Images\ -
\ - +\ -
\

\
\ \ diff --git a/src/ozones/Server/public/js/plugins/zones-tab.js b/src/ozones/Server/public/js/plugins/zones-tab.js index 920d024609..33bdc05b25 100644 --- a/src/ozones/Server/public/js/plugins/zones-tab.js +++ b/src/ozones/Server/public/js/plugins/zones-tab.js @@ -463,7 +463,8 @@ function updateZoneInfo(req,zone_json){ "bAutoWidth":false, "aoColumnDefs": [ { "sWidth": "35px", "aTargets": [0] }, - { "sWidth": "100px", "aTargets": [1,2,3,4] } + { "sWidth": "60px", "aTargets": [5,6] }, + { "sWidth": "100px", "aTargets": [1,2,4,8] } ] }); @@ -488,7 +489,7 @@ function updateZoneInfo(req,zone_json){ "aoColumnDefs": [ { "sWidth": "60px", "aTargets": [8] }, { "sWidth": "35px", "aTargets": [0,6,7,9] }, - { "sWidth": "100px", "aTargets": [1,2,3,5] } + { "sWidth": "100px", "aTargets": [1,2,4,5] } ] }); diff --git a/src/ozones/Server/templates/index.html b/src/ozones/Server/templates/index.html index 19036e3156..3490be79c7 100644 --- a/src/ozones/Server/templates/index.html +++ b/src/ozones/Server/templates/index.html @@ -1,7 +1,7 @@ - oZones Admin Console + OpenNebula oZones diff --git a/src/ozones/Server/templates/login.html b/src/ozones/Server/templates/login.html index e4b793e2fa..89847c4c35 100644 --- a/src/ozones/Server/templates/login.html +++ b/src/ozones/Server/templates/login.html @@ -1,7 +1,7 @@ - oZones Admin Console Login + OpenNebula oZones Login @@ -23,6 +23,14 @@
+ +
+ Invalid username or password +
+
+ OpenNebula is not running +
+
@@ -33,18 +41,10 @@
- +
- -
- Invalid username or password -
-
- OpenNebula is not running -
- From 66baf1d0537948a7f83aeef71b7bca11c7f013bb Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 7 Sep 2011 19:46:23 +0200 Subject: [PATCH 13/13] Small Sunstone fixes This commit contains small improvement and fixes in Sunstone javascript client code: - Columns widths in some tables have been adjusted - Login form submission is handled in a better way - Login error message fade in on top of the login box - Login screen compacts in screens with smaller resolution - +/- icon toggle in the create template dialog has been improved - Dashboards left table expands to take 100% of available width - Host/VM plots have a bit less width, so no scroll bar appears - Page title changed to "OpenNebula Sunstone" --- src/sunstone/public/css/login.css | 5 +- src/sunstone/public/js/login.js | 39 +++++++------- .../public/js/plugins/dashboard-tab.js | 2 +- .../public/js/plugins/dashboard-users-tab.js | 2 +- src/sunstone/public/js/plugins/hosts-tab.js | 1 + src/sunstone/public/js/plugins/images-tab.js | 9 ++-- .../public/js/plugins/templates-tab.js | 54 +++++++++++-------- src/sunstone/public/js/plugins/vms-tab.js | 7 +-- src/sunstone/public/js/plugins/vnets-tab.js | 2 +- src/sunstone/public/js/sunstone-util.js | 6 +-- src/sunstone/templates/login.html | 23 ++++---- src/sunstone/views/index.erb | 2 +- 12 files changed, 81 insertions(+), 71 deletions(-) diff --git a/src/sunstone/public/css/login.css b/src/sunstone/public/css/login.css index b4236d267f..4843efacf9 100644 --- a/src/sunstone/public/css/login.css +++ b/src/sunstone/public/css/login.css @@ -52,8 +52,7 @@ div#logo_sunstone { top: 80px; margin-left: auto; margin-right: auto; - background: url(../images/opennebula-sunstone-big.png) no-repeat center ; - + background: url(../images/opennebula-sunstone-big.png) no-repeat center; vertical-align: center; } @@ -135,7 +134,7 @@ div#login input#login_btn:hover { .error_message { display: none; position: relative; - top: 150px; + top: 80px; font-family: Arial, Helvetica, sans-serif; color:red; font-size:1.6em; diff --git a/src/sunstone/public/js/login.js b/src/sunstone/public/js/login.js index 99cfb9d856..608ea609e5 100644 --- a/src/sunstone/public/js/login.js +++ b/src/sunstone/public/js/login.js @@ -23,15 +23,15 @@ function auth_error(req, error){ var status = error.error.http_status; switch (status){ - case 401: - $("#one_error").hide(); - $("#auth_error").show(); - break; - case 500: - $("#auth_error").hide(); - $("#one_error").show(); - break; - } + case 401: + $("#one_error").hide(); + $("#auth_error").fadeIn("slow"); + break; + case 500: + $("#auth_error").hide(); + $("#one_error").fadeIn("slow"); + break; + }; } function authenticate(){ @@ -47,21 +47,18 @@ function authenticate(){ }); } -function logout(){ - OpenNebula.Auth.logout(); -} - - $(document).ready(function(){ - $("#login_btn").click(function () { + $("#login_form").submit(function (){ authenticate(); + return false; }); - $("input").keydown(function (e){ - if (e.keyCode == 13) { - authenticate(); - } - }); + //compact login elements according to screen height + if (screen.height <= 600){ + $('div#logo_sunstone').css("top","15px"); + $('div#login').css("top","10px"); + $('.error_message').css("top","10px"); + }; - $("input#username.box").get(0).focus(); + $("input#username.box").focus(); }); diff --git a/src/sunstone/public/js/plugins/dashboard-tab.js b/src/sunstone/public/js/plugins/dashboard-tab.js index 56b2b475e8..92a38ba49c 100644 --- a/src/sunstone/public/js/plugins/dashboard-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-tab.js @@ -46,7 +46,7 @@ var dashboard_tab_content = '
\ \
\ -\ +
\ \
\
\ diff --git a/src/sunstone/public/js/plugins/dashboard-users-tab.js b/src/sunstone/public/js/plugins/dashboard-users-tab.js index b05de8be29..1c5aa7f386 100644 --- a/src/sunstone/public/js/plugins/dashboard-users-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-users-tab.js @@ -46,7 +46,7 @@ var dashboard_tab_content = '\ \
\ -\ +
\ \ \ \ \ - \ + \ \ \ \ @@ -750,9 +750,10 @@ $(document).ready(function(){ "sPaginationType": "full_numbers", "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, - { "sWidth": "60px", "aTargets": [0,3] }, - { "sWidth": "35px", "aTargets": [1] }, - { "sWidth": "100px", "aTargets": [2,3,4] } + { "sWidth": "60px", "aTargets": [0,2,3,5,7,8,9] }, + { "sWidth": "35px", "aTargets": [1,10] }, + { "sWidth": "100px", "aTargets": [9] }, + { "sWidth": "150px", "aTargets": [6] } ] }); diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index abdaa9e914..cd7db8af35 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -1259,15 +1259,35 @@ function setupCreateTemplateDialog(){ //Toggles the icon when a section is folded/unfolded var iconToggle = function(){ - $('.icon_right',dialog).toggle( - function(e){ - $('span',e.currentTarget).removeClass("ui-icon-plusthick"); - $('span',e.currentTarget).addClass("ui-icon-minusthick"); - },function(e){ - $('span',e.currentTarget).removeClass("ui-icon-minusthick"); - $('span',e.currentTarget).addClass("ui-icon-plusthick"); + $('.icon_left',$create_template_dialog).click(function(e){ + if ($('span',e.currentTarget).hasClass("ui-icon-plus")){ + $('span',e.currentTarget).removeClass("ui-icon-plus"); + $('span',e.currentTarget).addClass("ui-icon-minus"); + } else { + $('span',e.currentTarget).removeClass("ui-icon-minus"); + $('span',e.currentTarget).addClass("ui-icon-plus"); + }; + }); + }; + + //Fold/unfold all sections button + var foldUnfoldToggle = function() { + $('#fold_unfold_vm_params',$create_template_dialog).toggle( + function(){ + $('.vm_section fieldset',$create_template_dialog).show(); + $('.icon_left span',$create_template_dialog).removeClass("ui-icon-plus"); + $('.icon_left span',$create_template_dialog).addClass("ui-icon-minus"); + return false; + }, + function(){ + $('.vm_section fieldset',$create_template_dialog).hide(); + //Show capacity opts + $('.vm_section fieldset',$create_template_dialog).first().show(); + $('.icon_left span',$create_template_dialog).removeClass("ui-icon-minus"); + $('.icon_left span',$create_template_dialog).addClass("ui-icon-plus"); + return false; }); - } + }; // Set ups the capacity section var capacity_setup = function(){ @@ -1795,18 +1815,7 @@ filled in"); vmTabChange(0,{index : 0}); //enable kvm - //Fold/unfold all sections button - $('#fold_unfold_vm_params',dialog).toggle( - function(){ - $('.vm_section fieldset',$create_template_dialog).show(); - return false; - }, - function(){ - $('.vm_section fieldset',$create_template_dialog).hide(); - //Show capacity opts - $('.vm_section fieldset',$create_template_dialog).first().show(); - return false; - }); + foldUnfoldToggle(); //initialise all sections capacity_setup(); @@ -1969,9 +1978,10 @@ $(document).ready(function(){ "sPaginationType": "full_numbers", "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, - { "sWidth": "60px", "aTargets": [0] }, + { "sWidth": "60px", "aTargets": [0,6] }, { "sWidth": "35px", "aTargets": [1] }, - { "sWidth": "100px", "aTargets": [2,3,4] } + { "sWidth": "150px", "aTargets": [5] }, + { "sWidth": "100px", "aTargets": [2,3] } ] }); diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index f05696bf17..062c1e7e6f 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -1075,9 +1075,10 @@ $(document).ready(function(){ "bAutoWidth":false, "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, - { "sWidth": "60px", "aTargets": [0] }, - { "sWidth": "35px", "aTargets": [1,9] }, - { "sWidth": "100px", "aTargets": [2,3,4] } + { "sWidth": "60px", "aTargets": [0,6,7] }, + { "sWidth": "35px", "aTargets": [1,10] }, + { "sWidth": "150px", "aTargets": [5,9] }, + { "sWidth": "100px", "aTargets": [2,3] } ] }); diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index f72d58da42..e57afb2abd 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -30,7 +30,7 @@ var vnets_tab_content = \ \ \ - \ + \ \ \ \ diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index a5084ac401..25d1b6af3e 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -511,9 +511,9 @@ function escapeDoubleQuotes(string){ //of plotting comes, we can put the data in the right place. function generateMonitoringDivs(graphs, id_prefix){ var str = ""; - //42% of the width of the screen minus + //43% of the width of the screen minus //129px (left menu size) - var width = ($(window).width()-129)*42/100; + var width = ($(window).width()-129)*40/100; var id_suffix=""; var label=""; var id=""; @@ -614,7 +614,7 @@ function setupTemplateUpdateDialog(){ //Put HTML in place dialog.html( '\ -

Update the template here:

\ +

Please, choose and modify the template you want to update:

\
\ \ \ diff --git a/src/sunstone/templates/login.html b/src/sunstone/templates/login.html index a5bfc6de47..8e1294ca3f 100644 --- a/src/sunstone/templates/login.html +++ b/src/sunstone/templates/login.html @@ -1,7 +1,7 @@ - OpenNebula Admin Console Login + OpenNebula Sunstone Login @@ -24,6 +24,14 @@
+ +
+ Invalid username or password +
+
+ OpenNebula is not running +
+
@@ -32,20 +40,13 @@ Password
- + - + +
- -
- Invalid username or password -
-
- OpenNebula is not running -
- diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb index 00d6331d3d..4e70b668e0 100644 --- a/src/sunstone/views/index.erb +++ b/src/sunstone/views/index.erb @@ -1,7 +1,7 @@ - OpenNebula Admin Console + OpenNebula Sunstone: Cloud Operations Center
\
\ diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index cbe5aa87c2..497e585f61 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -594,6 +594,7 @@ $(document).ready(function(){ { "bSortable": false, "aTargets": ["check"] }, { "sWidth": "60px", "aTargets": [0,3] }, { "sWidth": "35px", "aTargets": [1] }, + { "sWidth": "100px", "aTargets": [6] }, { "sWidth": "200px", "aTargets": [4,5] } ] }); diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index 158e8a97e7..d47357002e 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -32,7 +32,7 @@ var images_tab_content =
Registration timePublicPersistentStateStatus#VMS
NameTypeBridgePublic?PublicTotal Leases