diff --git a/include/RequestManagerDelete.h b/include/RequestManagerDelete.h index 84aaf81223..bf665bfc48 100644 --- a/include/RequestManagerDelete.h +++ b/include/RequestManagerDelete.h @@ -166,6 +166,10 @@ public: }; ~UserDelete(){}; + + /* -------------------------------------------------------------------- */ + + int drop(int oid, PoolObjectSQL * object, string& error_msg); }; /* -------------------------------------------------------------------------- */ diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index f153b5cd61..3a9219d4be 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -7,19 +7,23 @@ PACKAGES=%w{optional sunstone quota cloud ozones_client ozones_server DEFAULT=%w{optional sunstone quota cloud ozones_server acct} -SQLITE='sqlite3-ruby --version 1.2.0' +if defined?(RUBY_VERSION) && RUBY_VERSION>="1.8.7" + SQLITE='sqlite3' +else + SQLITE='sqlite3-ruby --version 1.2.0' +end GROUPS={ :optional => %w{nokogiri xmlparser}, :quota => [SQLITE, 'sequel'], - :sunstone => %w{json rack sinatra thin}, + :sunstone => ['json', 'rack', 'sinatra', 'thin', 'sequel', SQLITE], :cloud => %w{amazon-ec2 rack sinatra thin uuid curb}, :ozones_client => %w{json}, - :ozones_server => %w{json datamapper dm-sqlite-adapter dm-mysql-adapter}+[ + :ozones_server => %w{json data_mapper dm-sqlite-adapter dm-mysql-adapter}+[ SQLITE, 'mysql' ], - :ozones_server_sqlite => %w{json datamapper dm-sqlite-adapter}< %w{json datamapper dm-mysql-adapter mysql}, + :ozones_server_sqlite => %w{json data_mapper dm-sqlite-adapter}< %w{json data_mapper dm-mysql-adapter mysql}, :acct => ['sequel', SQLITE, 'mysql'], :acct_sqlite => ['sequel', SQLITE], :acct_mysql => ['sequel', 'mysql'] @@ -105,9 +109,17 @@ def get_gems(packages) end def detect_distro - lsb_info=`lsb_release -a` - if $?!=0 && false - STDERR.puts("lsb_release command not found") + begin + lsb_info=`lsb_release -a` + rescue + end + + if $?.exitstatus!=0 + STDERR.puts(<<-EOT.unindent(12)) + lsb_release command not found. If you are using a RedHat based + distribution install redhat-lsb + +EOT return nil end diff --git a/share/scripts/one b/share/scripts/one index 3b26c0e55c..b54de174b8 100755 --- a/share/scripts/one +++ b/share/scripts/one @@ -40,6 +40,8 @@ else LOCK_FILE=$ONE_LOCATION/var/.lock fi +KILL_9_SECONDS=5 + #------------------------------------------------------------------------------ # Function that checks for running daemons and gets PORT from conf #------------------------------------------------------------------------------ @@ -81,7 +83,19 @@ setup() stop() { if [ -f $ONE_PID ]; then - kill `cat $ONE_PID` > /dev/null 2>&1 + PID=$(cat $ONE_PID) + kill $PID > /dev/null 2>&1 + + counter=0 + while ps $PID > /dev/null 2>&1; do + let counter=counter+1 + if [ $counter -gt $KILL_9_SECONDS ]; then + kill -9 $PID > /dev/null 2>&1 + break + fi + sleep 1 + done + rm -f $ONE_PID > /dev/null 2>&1 fi diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 7ab77512f8..bfd52313e9 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -375,7 +375,7 @@ EOT def OpenNebulaHelper.update_template(id, resource) require 'tempfile' - tmp = Tempfile.new(id) + tmp = Tempfile.new(id.to_s) path = tmp.path tmp << resource.template_str diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index ed05c6cdcc..c055ee36bd 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -65,7 +65,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper def format_resource(vm) str_h1="%-80s" str="%-20s: %-20s" - + CLIHelper.print_header( str_h1 % "VIRTUAL MACHINE #{vm['ID']} INFORMATION") puts str % ["ID", vm.id.to_s] @@ -77,8 +77,10 @@ class OneVMHelper < OpenNebulaHelper::OneHelper puts str % ["HOSTNAME", vm['/VM/HISTORY_RECORDS/HISTORY[last()]/HOSTNAME']] if %w{ACTIVE SUSPENDED}.include? vm.state_str - puts str % ["START TIME", OpenNebulaHelper.time_to_str(vm['STIME'])] - puts str % ["END TIME", OpenNebulaHelper.time_to_str(vm['ETIME'])] + puts str % ["START TIME", + OpenNebulaHelper.time_to_str(vm['/VM/STIME'])] + puts str % ["END TIME", + OpenNebulaHelper.time_to_str(vm['/VM/ETIME'])] value=vm['DEPLOY_ID'] puts str % ["DEPLOY ID", value=="" ? "-" : value] diff --git a/src/oca/ruby/OpenNebula/VirtualMachine.rb b/src/oca/ruby/OpenNebula/VirtualMachine.rb index c2292bc6a4..75e0aeaae5 100644 --- a/src/oca/ruby/OpenNebula/VirtualMachine.rb +++ b/src/oca/ruby/OpenNebula/VirtualMachine.rb @@ -213,14 +213,16 @@ module OpenNebula # Set the specified vm's disk to be saved in a new image # when the VirtualMachine shutdowns # - # +disk_id+ ID of the disk to be saved + # @param disk_id [Integer] ID of the disk to be saved + # @param image_name [String] Name for the new image where the + # disk will be saved # - # +image_name+ Name for the new image where the disk will be saved + # @return [Integer, OpenNebula::Error] the new Image ID in case of + # success, error otherwise def save_as(disk_id, image_name) return Error.new('ID not defined') if !@pe_id rc = @client.call(VM_METHODS[:savedisk], @pe_id, disk_id, image_name) - rc = nil if !OpenNebula.is_error?(rc) return rc end diff --git a/src/ozones/Client/bin/onevdc b/src/ozones/Client/bin/onevdc index fbf44a0986..49514be190 100755 --- a/src/ozones/Client/bin/onevdc +++ b/src/ozones/Client/bin/onevdc @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby ONE_LOCATION=ENV["ONE_LOCATION"] @@ -15,7 +15,7 @@ require 'command_parser' require 'ozones_helper/vdc_helper.rb' cmd=CommandParser::CmdParser.new(ARGV) do - usage "ovdcs COMMAND [args..] [options..]" + usage "`ovdcs` command [] []" version OpenNebulaHelper::ONE_VERSION ######################################################################## diff --git a/src/ozones/Client/bin/onezone b/src/ozones/Client/bin/onezone index f613c84b09..e2076f93c4 100755 --- a/src/ozones/Client/bin/onezone +++ b/src/ozones/Client/bin/onezone @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby ONE_LOCATION=ENV["ONE_LOCATION"] @@ -15,7 +15,7 @@ require 'command_parser' require 'ozones_helper/zones_helper.rb' cmd=CommandParser::CmdParser.new(ARGV) do - usage "ozones COMMAND [args..] [options..]" + usage "`ozones` [] []" version OpenNebulaHelper::ONE_VERSION ######################################################################## diff --git a/src/ozones/Server/bin/ozones-server b/src/ozones/Server/bin/ozones-server index 4e00f2fa8a..ac76d2f6c3 100755 --- a/src/ozones/Server/bin/ozones-server +++ b/src/ozones/Server/bin/ozones-server @@ -66,12 +66,15 @@ start() echo "The port $PORT is being used. Please specify a different one." exit 1 fi - + # Start the ozones daemon touch $OZONES_LOCK_FILE rackup $OZONES_SERVER -s thin -p $PORT -o $HOST \ -P $OZONES_PID &> $OZONES_LOG & + sleep 2 + ps -p $(cat $OZONES_PID 2>/dev/null) > /dev/null 2>&1 + if [ $? -ne 0 ]; then echo "Error executing $OZONES_SERVER, please check the log $OZONES_LOG" exit 1 diff --git a/src/rm/RequestManagerDelete.cc b/src/rm/RequestManagerDelete.cc index 6ae29b82fe..6d947d8b66 100644 --- a/src/rm/RequestManagerDelete.cc +++ b/src/rm/RequestManagerDelete.cc @@ -70,3 +70,32 @@ int ImageDelete::drop(int oid, PoolObjectSQL * object, string& error_msg) return rc; } +/* ------------------------------------------------------------------------- */ + +int UserDelete::drop(int oid, PoolObjectSQL * object, string& error_msg) +{ + User * user = static_cast(object); + int group_id = user->get_gid(); + + int rc = pool->drop(object, error_msg); + + object->unlock(); + + if ( rc == 0 ) + { + Nebula& nd = Nebula::instance(); + GroupPool * gpool = nd.get_gpool(); + + Group * group = gpool->get(group_id, true); + + if( group != 0 ) + { + group->del_user(oid); + gpool->update(group); + + group->unlock(); + } + } + + return rc; +}