diff --git a/include/Nebula.h b/include/Nebula.h index 41fabb9a7a..784a255ce0 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -156,6 +156,25 @@ public: // Environment & Configuration // -------------------------------------------------------------- + /** + * Returns the value of DEBUG_LEVEL in oned.conf file + * @return the debug level, to instantiate Log'ers + */ + Log::MessageType get_debug_level() const + { + Log::MessageType clevel = Log::ERROR; + int log_level_int; + + nebula_configuration->get("DEBUG_LEVEL", log_level_int); + + if (0 <= log_level_int && log_level_int <= 3 ) + { + clevel = static_cast(log_level_int); + } + + return clevel; + } + /** * Returns the value of ONE_LOCATION env variable. When this variable is * not defined the nebula location is "/". diff --git a/install.sh b/install.sh index 84b0157313..7c5d3c4f32 100755 --- a/install.sh +++ b/install.sh @@ -185,7 +185,6 @@ SHARE_DIRS="$SHARE_LOCATION/examples \ ETC_DIRS="$ETC_LOCATION/im_ec2 \ $ETC_LOCATION/vmm_ec2 \ $ETC_LOCATION/vmm_exec \ - $ETC_LOCATION/tm \ $ETC_LOCATION/hm \ $ETC_LOCATION/auth \ $ETC_LOCATION/auth/certificates \ @@ -227,7 +226,6 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/vnm/vmware \ $VAR_LOCATION/remotes/tm/ \ $VAR_LOCATION/remotes/tm/dummy \ - $VAR_LOCATION/remotes/tm/lvm \ $VAR_LOCATION/remotes/tm/shared \ $VAR_LOCATION/remotes/tm/qcow2 \ $VAR_LOCATION/remotes/tm/ssh \ @@ -392,7 +390,6 @@ INSTALL_FILES=( TM_VMWARE_FILES:$VAR_LOCATION/remotes/tm/vmware TM_ISCSI_FILES:$VAR_LOCATION/remotes/tm/iscsi TM_DUMMY_FILES:$VAR_LOCATION/remotes/tm/dummy - TM_LVM_FILES:$VAR_LOCATION/remotes/tm/lvm DATASTORE_DRIVER_COMMON_SCRIPTS:$VAR_LOCATION/remotes/datastore/ DATASTORE_DRIVER_DUMMY_SCRIPTS:$VAR_LOCATION/remotes/datastore/dummy DATASTORE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/datastore/fs @@ -539,7 +536,6 @@ INSTALL_ETC_FILES=( VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2 VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2 - TM_LVM_ETC_FILES:$ETC_LOCATION/tm/ HM_ETC_FILES:$ETC_LOCATION/hm AUTH_ETC_FILES:$ETC_LOCATION/auth ECO_ETC_FILES:$ETC_LOCATION @@ -766,8 +762,9 @@ NETWORK_VMWARE_FILES="src/vnm_mad/remotes/vmware/clean \ # - SHARED TM, $VAR_LOCATION/tm/shared # - QCOW2 TM, $VAR_LOCATION/tm/qcow2 # - SSH TM, $VAR_LOCATION/tm/ssh -# - dummy TM, $VAR_LOCATION/tm/dummy -# - LVM TM, $VAR_LOCATION/tm/lvm +# - DUMMY TM, $VAR_LOCATION/tm/dummy +# - VMWARE TM, $VAR_LOCATION/tm/vmware +# - ISCSI TM, $VAR_LOCATION/tm/iscsi #------------------------------------------------------------------------------- TM_FILES="src/tm_mad/tm_common.sh" @@ -808,14 +805,6 @@ TM_DUMMY_FILES="src/tm_mad/dummy/clone \ src/tm_mad/dummy/context \ src/tm_mad/dummy/mvds" -TM_LVM_FILES="src/tm_mad/lvm/clone \ - src/tm_mad/lvm/delete \ - src/tm_mad/lvm/ln \ - src/tm_mad/lvm/mkswap \ - src/tm_mad/lvm/mkimage \ - src/tm_mad/lvm/mv \ - src/tm_mad/lvm/context" - TM_VMWARE_FILES="src/tm_mad/vmware/clone \ src/tm_mad/vmware/delete src/tm_mad/vmware/ln \ @@ -869,6 +858,7 @@ ONEDB_MIGRATOR_FILES="src/onedb/2.0_to_2.9.80.rb \ src/onedb/3.2.0_to_3.2.1.rb \ src/onedb/3.2.1_to_3.3.0.rb \ src/onedb/3.3.0_to_3.3.80.rb \ + src/onedb/3.3.80_to_3.4.0.rb \ src/onedb/onedb.rb \ src/onedb/onedb_backend.rb" @@ -905,16 +895,6 @@ VMM_EXEC_ETC_FILES="src/vmm_mad/exec/vmm_execrc \ IM_EC2_ETC_FILES="src/im_mad/ec2/im_ec2rc \ src/im_mad/ec2/im_ec2.conf" -#------------------------------------------------------------------------------- -# Storage drivers config. files, to be installed under $ETC_LOCATION -# - shared, $ETC_LOCATION/tm_shared -# - ssh, $ETC_LOCATION/tm_ssh -# - dummy, $ETC_LOCATION/tm_dummy -# - lvm, $ETC_LOCATION/tm_lvm -#------------------------------------------------------------------------------- - -TM_LVM_ETC_FILES="src/tm_mad/lvm/lvm.conf" - #------------------------------------------------------------------------------- # Hook Manager driver config. files, to be installed under $ETC_LOCATION/hm #------------------------------------------------------------------------------- @@ -1080,10 +1060,12 @@ OCCI_LIB_CLIENT_FILES="src/cloud/occi/lib/OCCIClient.rb" OCCI_BIN_FILES="src/cloud/occi/bin/occi-server \ src/cloud/occi/bin/occi-compute \ src/cloud/occi/bin/occi-network \ + src/cloud/occi/bin/occi-instance-type \ src/cloud/occi/bin/occi-storage" OCCI_BIN_CLIENT_FILES="src/cloud/occi/bin/occi-compute \ src/cloud/occi/bin/occi-network \ + src/cloud/occi/bin/occi-instance-type \ src/cloud/occi/bin/occi-storage" OCCI_ETC_FILES="src/cloud/occi/etc/occi-server.conf" diff --git a/src/cloud/ec2/bin/econe-server b/src/cloud/ec2/bin/econe-server index 5b1d23a9f2..1327de4ed1 100755 --- a/src/cloud/ec2/bin/econe-server +++ b/src/cloud/ec2/bin/econe-server @@ -21,12 +21,14 @@ if [ -z "$ONE_LOCATION" ]; then ECONE_SERVER=/usr/lib/one/ruby/cloud/econe/econe-server.rb ECONE_LOCK_FILE=/var/lock/one/.econe.lock ECONE_LOG=/var/log/one/econe-server.log + ECONE_LOG_ERROR=/var/log/one/econe-server.error ECONE_ETC=/etc/one/econe.conf else ECONE_PID=$ONE_LOCATION/var/econe-server.pid ECONE_SERVER=$ONE_LOCATION/lib/ruby/cloud/econe/econe-server.rb ECONE_LOCK_FILE=$ONE_LOCATION/var/.econe.lock ECONE_LOG=$ONE_LOCATION/var/econe-server.log + ECONE_LOG_ERROR=$ONE_LOCATION/var/econe-server.error ECONE_ETC=$ONE_LOCATION/etc/econe.conf fi @@ -58,7 +60,7 @@ start() fi # Start the econe-server daemon - ruby $ECONE_SERVER > $ECONE_LOG 2>&1 & + ruby $ECONE_SERVER >$ECONE_LOG 2>$ECONE_LOG_ERROR & LASTRC=$? LASTPID=$! diff --git a/src/cloud/occi/bin/occi-compute b/src/cloud/occi/bin/occi-compute index 63b813ddb8..85277961e4 100755 --- a/src/cloud/occi/bin/occi-compute +++ b/src/cloud/occi/bin/occi-compute @@ -75,6 +75,9 @@ Options: --debug, -D Enables verbosity +--verbose + Show resources in verbose mode + EOT require 'occi/OCCIClient' @@ -83,13 +86,14 @@ require 'getoptlong' include CloudCLI opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--version', '-v',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--timeout', '-T',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] + ['--help', '-h',GetoptLong::NO_ARGUMENT], + ['--version', '-v',GetoptLong::NO_ARGUMENT], + ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], + ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], + ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], + ['--timeout', '-T',GetoptLong::REQUIRED_ARGUMENT], + ['--debug', '-D',GetoptLong::NO_ARGUMENT], + ['--verbose', GetoptLong::NO_ARGUMENT] ) url = nil @@ -98,6 +102,7 @@ password = nil auth = nil timeout = nil debug = false +verbose = false begin opts.each do |opt, arg| @@ -118,6 +123,8 @@ begin timeout = arg when '--debug' debug = true + when '--verbose' + verbose = true end end rescue Exception => e @@ -139,7 +146,7 @@ end case ARGV[0].downcase when 'list' - rc = occi_client.get_vms + rc = occi_client.get_vms(verbose) when 'create' vm_xml = ARGV[1] diff --git a/src/cloud/occi/bin/occi-instance-type b/src/cloud/occi/bin/occi-instance-type new file mode 100755 index 0000000000..f4482fabc9 --- /dev/null +++ b/src/cloud/occi/bin/occi-instance-type @@ -0,0 +1,147 @@ +#!/usr/bin/env ruby +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +ONE_LOCATION=ENV["ONE_LOCATION"] + +if !ONE_LOCATION + RUBY_LIB_LOCATION="/usr/lib/one/ruby" +else + RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" + TEMPLATES_LOCATION=ONE_LOCATION+"/etc/occi_templates" + CONF_LOCATION=ONE_LOCATION+"/etc" +end + +$: << RUBY_LIB_LOCATION +$: << RUBY_LIB_LOCATION+"/cloud" + +COMMANDS_HELP=<<-EOT +occi-instance-type - Retrieve instance types + +Usage: + occi-instance-type [OPTIONS] + +Commands: + +* list + lists available instance types + +Options: + +--help, -h + Show help + +--username , -U + The username of the user + +--password , -P + The password of the user + +--url , -R + Set url as the web service url to use + +--timeout , -T + Sets a timeout for the http connection + +--debug, -D + Enables verbosity + +--verbose + Show resources in verbose mode + +EOT + +require 'occi/OCCIClient' +require 'getoptlong' + +include CloudCLI + +opts = GetoptLong.new( + ['--help', '-h',GetoptLong::NO_ARGUMENT], + ['--version', '-v',GetoptLong::NO_ARGUMENT], + ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], + ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], + ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], + ['--timeout', '-T',GetoptLong::REQUIRED_ARGUMENT], + ['--debug', '-D',GetoptLong::NO_ARGUMENT], + ['--verbose', GetoptLong::NO_ARGUMENT] + ) + +url = nil +username = nil +password = nil +auth = nil +timeout = nil +debug = false +verbose = false + +begin + opts.each do |opt, arg| + case opt + when '--help' + puts COMMANDS_HELP + return + when '--version' + puts CloudCLI.version_text + exit 0 + when '--username' + username = arg + when '--password' + password = arg + when '--url' + url = arg + when '--timeout' + timeout = arg + when '--debug' + debug = true + when '--verbose' + verbose = true + end + end +rescue Exception => e + exit(-1) +end + +begin + occi_client = OCCIClient::Client.new(url,username,password, timeout, debug) +rescue Exception => e + puts "#{cmd_name}: #{e.message}" + exit(-1) +end + +if !ARGV[0] + puts "#{cmd_name}: [COMMAND] not present" + puts "#{cmd_name}: Execute #{cmd_name} -h for help." + exit(-1) +end + +case ARGV[0].downcase + when 'list' + rc = occi_client.get_instance_types(verbose) + else + puts "Command #{ARGV[0]} not valid." + exit(-1) +end + +if CloudClient::is_error?(rc) + puts rc.to_s() + exit(-1) +else + str, code = print_xml(rc) + puts str + exit(code) +end + diff --git a/src/cloud/occi/bin/occi-network b/src/cloud/occi/bin/occi-network index 7ab3548fa1..d2377bb31c 100755 --- a/src/cloud/occi/bin/occi-network +++ b/src/cloud/occi/bin/occi-network @@ -76,25 +76,25 @@ Options: --debug, -D Enables verbosity ---multipart, -M - Use 'multipart-post' library instead of Curb/Curl +--verbose + Show resources in verbose mode EOT require 'occi/OCCIClient' -require 'CloudClient' require 'getoptlong' include CloudCLI opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--version', '-v',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--timeout', '-T',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT] + ['--help', '-h',GetoptLong::NO_ARGUMENT], + ['--version', '-v',GetoptLong::NO_ARGUMENT], + ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], + ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], + ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], + ['--timeout', '-T',GetoptLong::REQUIRED_ARGUMENT], + ['--debug', '-D',GetoptLong::NO_ARGUMENT], + ['--verbose', GetoptLong::NO_ARGUMENT] ) url = nil @@ -103,6 +103,7 @@ password = nil auth = nil timeout = nil debug = false +verbose = false begin opts.each do |opt, arg| @@ -123,13 +124,14 @@ begin timeout = arg when '--debug' debug = true + when '--verbose' + verbose = true end end rescue Exception => e exit(-1) end - begin occi_client = OCCIClient::Client.new(url,username,password,timeout,debug) rescue Exception => e @@ -156,7 +158,7 @@ case ARGV[0].downcase rc = occi_client.post_network(network_xml) when 'list' - rc = occi_client.get_networks + rc = occi_client.get_networks(verbose) when 'show' network_id = ARGV[1] diff --git a/src/cloud/occi/bin/occi-server b/src/cloud/occi/bin/occi-server index 5218f42e77..e9615a2108 100755 --- a/src/cloud/occi/bin/occi-server +++ b/src/cloud/occi/bin/occi-server @@ -21,12 +21,14 @@ if [ -z "$ONE_LOCATION" ]; then OCCI_SERVER=/usr/lib/one/ruby/cloud/occi/occi-server.rb OCCI_LOCK_FILE=/var/lock/one/.occi.lock OCCI_LOG=/var/log/one/occi-server.log + OCCI_LOG_ERROR=/var/log/one/occi-server.error OCCI_ETC=/etc/one/occi-server.conf else OCCI_PID=$ONE_LOCATION/var/occi-server.pid OCCI_SERVER=$ONE_LOCATION/lib/ruby/cloud/occi/occi-server.rb OCCI_LOCK_FILE=$ONE_LOCATION/var/.occi.lock OCCI_LOG=$ONE_LOCATION/var/occi-server.log + OCCI_LOG_ERROR=$ONE_LOCATION/var/occi-server.error OCCI_ETC=$ONE_LOCATION/etc/occi-server.conf fi @@ -58,7 +60,7 @@ start() fi # Start the occi-server daemon - ruby $OCCI_SERVER > $OCCI_LOG 2>&1 & + ruby $OCCI_SERVER >$OCCI_LOG 2>$OCCI_LOG_ERROR & LASTRC=$? LASTPID=$! diff --git a/src/cloud/occi/bin/occi-storage b/src/cloud/occi/bin/occi-storage index af4cb9f4a8..fb9eddb375 100755 --- a/src/cloud/occi/bin/occi-storage +++ b/src/cloud/occi/bin/occi-storage @@ -79,6 +79,9 @@ Options: --multipart, -M Use 'multipart-post' library instead of Curb/Curl +--verbose + Show resources in verbose mode + EOT require 'occi/OCCIClient' @@ -88,14 +91,15 @@ require 'getoptlong' include CloudCLI opts = GetoptLong.new( - ['--help', '-h',GetoptLong::NO_ARGUMENT], - ['--version', '-v',GetoptLong::NO_ARGUMENT], - ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], - ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], - ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], - ['--debug', '-D',GetoptLong::NO_ARGUMENT], - ['--timeout', '-T',GetoptLong::REQUIRED_ARGUMENT], - ['--multipart', '-M',GetoptLong::NO_ARGUMENT] + ['--help', '-h',GetoptLong::NO_ARGUMENT], + ['--version', '-v',GetoptLong::NO_ARGUMENT], + ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT], + ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT], + ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT], + ['--debug', '-D',GetoptLong::NO_ARGUMENT], + ['--timeout', '-T',GetoptLong::REQUIRED_ARGUMENT], + ['--multipart', '-M',GetoptLong::NO_ARGUMENT], + ['--verbose', GetoptLong::NO_ARGUMENT] ) url = nil @@ -105,6 +109,7 @@ auth = nil timeout = nil debug = false curb = true +verbose = false begin opts.each do |opt, arg| @@ -127,6 +132,8 @@ begin debug = true when '--multipart' curb = false + when '--verbose' + verbose = true end end rescue Exception => e @@ -159,7 +166,7 @@ case ARGV[0].downcase rc = occi_client.post_image(image_xml, curb) when 'list' - rc = occi_client.get_images + rc = occi_client.get_images(verbose) when 'show' image_id = ARGV[1] diff --git a/src/cloud/occi/lib/OCCIClient.rb b/src/cloud/occi/lib/OCCIClient.rb index c600599a18..1844d90e58 100755 --- a/src/cloud/occi/lib/OCCIClient.rb +++ b/src/cloud/occi/lib/OCCIClient.rb @@ -74,8 +74,8 @@ module OCCIClient ###################################################################### # Retieves the available Instance types ###################################################################### - def get_instance_types - get('/instance_type') + def get_instance_types(verbose=false) + get('/instance_type', verbose) end ###################################################################### @@ -89,8 +89,8 @@ module OCCIClient ###################################################################### # Retieves the pool of Virtual Machines ###################################################################### - def get_vms - get('/compute') + def get_vms(verbose=false) + get('/compute', verbose) end ###################################################################### @@ -104,8 +104,8 @@ module OCCIClient ###################################################################### # Retieves the pool of Virtual Networks ###################################################################### - def get_networks - get('/network') + def get_networks(verbose=false) + get('/network', verbose) end ###################################################################### @@ -202,8 +202,8 @@ module OCCIClient ###################################################################### # Retieves the pool of Images owned by the user ###################################################################### - def get_images - get('/storage') + def get_images(verbose=false) + get('/storage', verbose) end @@ -281,7 +281,8 @@ module OCCIClient private - def get(path) + def get(path, verbose=false) + path += "?verbose=true" if verbose url = URI.parse(@endpoint+path) req = Net::HTTP::Get.new(url.path) diff --git a/src/datastore_mad/remotes/fs/rm b/src/datastore_mad/remotes/fs/rm index 2284c21289..4bedba1d15 100755 --- a/src/datastore_mad/remotes/fs/rm +++ b/src/datastore_mad/remotes/fs/rm @@ -39,12 +39,28 @@ DRV_ACTION=$1 ID=$2 XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION" -SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE` + +unset i XPATH_ELEMENTS + +while IFS= read -r -d '' element; do + XPATH_ELEMENTS[i++]="$element" +done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE \ + /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH) + +SRC="${XPATH_ELEMENTS[0]}" +BASE_PATH="${XPATH_ELEMENTS[1]}" + +BASENAME_SRC=`basename "${SRC##$BASE_PATH}"` # ------------ Remove the image from the repository ------------ -if [ -e $SRC ] ; then +if [ -f "$SRC" -a `dirname "$SRC"` = "$BASE_PATH" -a -n "$BASENAME_SRC" ] +then log "Removing $SRC from the image repository" - exec_and_log "rm -r $SRC" \ + + exec_and_log "rm -f $SRC" \ "Error deleting $SRC" +else + log_error "Bad formed or unavailable Image source: ${SRC}" + exit 1 fi diff --git a/src/datastore_mad/remotes/libfs.sh b/src/datastore_mad/remotes/libfs.sh index a4d180a94c..199ba2244f 100644 --- a/src/datastore_mad/remotes/libfs.sh +++ b/src/datastore_mad/remotes/libfs.sh @@ -72,7 +72,15 @@ function generate_image_path { $CANONICAL_STR EOF ) - echo "${BASE_PATH}/`echo $CANONICAL_MD5 | cut -d ' ' -f1`" + IMAGE_HASH=$(echo $CANONICAL_MD5 | cut -d ' ' -f1) + IMAGE_HASH=$(basename "$IMAGE_HASH") + + if [ -z "$IMAGE_HASH" -o -z "$BASE_PATH" ]; then + log_error "Error generating the path in generate_image_path." + exit 1 + fi + + echo "${BASE_PATH}/${IMAGE_HASH}" } #------------------------------------------------------------------------------- diff --git a/src/datastore_mad/remotes/vmware/rm b/src/datastore_mad/remotes/vmware/rm index 2284c21289..bb3ac1601f 100755 --- a/src/datastore_mad/remotes/vmware/rm +++ b/src/datastore_mad/remotes/vmware/rm @@ -39,12 +39,28 @@ DRV_ACTION=$1 ID=$2 XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION" -SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE` + +unset i XPATH_ELEMENTS + +while IFS= read -r -d '' element; do + XPATH_ELEMENTS[i++]="$element" +done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE \ + /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH) + +SRC="${XPATH_ELEMENTS[0]}" +BASE_PATH="${XPATH_ELEMENTS[1]}" + +BASENAME_SRC=`basename "${SRC##$BASE_PATH}"` # ------------ Remove the image from the repository ------------ -if [ -e $SRC ] ; then +if [ -d "$SRC" -a `dirname "$SRC"` = "$BASE_PATH" -a -n "$BASENAME_SRC" ] +then log "Removing $SRC from the image repository" + exec_and_log "rm -r $SRC" \ "Error deleting $SRC" +else + log_error "Bad formed or unavailable Image source: ${SRC}" + exit 1 fi diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 71acc0800b..9889741187 100755 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -30,7 +30,7 @@ LVS=lvs LN=ln MD5SUM=md5sum MKFS=mkfs -MKISOFS=mkisofs +MKISOFS=genisoimage MKSWAP=mkswap QEMU_IMG=qemu-img READLINK=readlink diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 3d279aba54..7ccb90c74b 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -85,18 +85,11 @@ void Nebula::start() try { - string log_fname; - int log_level_int; - Log::MessageType clevel = Log::ERROR; + string log_fname; + Log::MessageType clevel; log_fname = log_location + "oned.log"; - - nebula_configuration->get("DEBUG_LEVEL", log_level_int); - - if (0 <= log_level_int && log_level_int <= 3 ) - { - clevel = static_cast(log_level_int); - } + clevel = get_debug_level(); // Initializing ONE Daemon log system diff --git a/src/oca/ruby/OpenNebula/Pool.rb b/src/oca/ruby/OpenNebula/Pool.rb index 46ddc68652..3aaa3bbada 100644 --- a/src/oca/ruby/OpenNebula/Pool.rb +++ b/src/oca/ruby/OpenNebula/Pool.rb @@ -178,7 +178,7 @@ module OpenNebula def update(xml_method, new_template) return Error.new('ID not defined') if !@pe_id - new_template ||= template_xml.delete("\n").gsub(/\s+/m,'') + new_template ||= template_xml rc = @client.call(xml_method,@pe_id, new_template) rc = nil if !OpenNebula.is_error?(rc) diff --git a/src/onedb/2.0_to_2.9.80.rb b/src/onedb/2.0_to_2.9.80.rb index a3e9afe400..8650fe8d45 100644 --- a/src/onedb/2.0_to_2.9.80.rb +++ b/src/onedb/2.0_to_2.9.80.rb @@ -1,17 +1,18 @@ -# -------------------------------------------------------------------------- * -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # -# Licensed under the Apache License, Version 2.0 (the "License"); you may * -# not use this file except in compliance with the License. You may obtain * -# a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# -------------------------------------------------------------------------- * +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # require "rexml/document" diff --git a/src/onedb/2.9.80_to_2.9.85.rb b/src/onedb/2.9.80_to_2.9.85.rb index 83ff29e797..cc80dc470d 100644 --- a/src/onedb/2.9.80_to_2.9.85.rb +++ b/src/onedb/2.9.80_to_2.9.85.rb @@ -1,17 +1,18 @@ -# -------------------------------------------------------------------------- * -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # -# Licensed under the Apache License, Version 2.0 (the "License"); you may * -# not use this file except in compliance with the License. You may obtain * -# a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# -------------------------------------------------------------------------- * +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # require "rexml/document" include REXML diff --git a/src/onedb/2.9.85_to_2.9.90.rb b/src/onedb/2.9.85_to_2.9.90.rb index 53a7d084ae..8857c15d5a 100644 --- a/src/onedb/2.9.85_to_2.9.90.rb +++ b/src/onedb/2.9.85_to_2.9.90.rb @@ -1,17 +1,18 @@ -# -------------------------------------------------------------------------- * -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # -# Licensed under the Apache License, Version 2.0 (the "License"); you may * -# not use this file except in compliance with the License. You may obtain * -# a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# -------------------------------------------------------------------------- * +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # require "rexml/document" include REXML diff --git a/src/onedb/2.9.90_to_3.0.0.rb b/src/onedb/2.9.90_to_3.0.0.rb index 10a14e6f23..97d320df2e 100644 --- a/src/onedb/2.9.90_to_3.0.0.rb +++ b/src/onedb/2.9.90_to_3.0.0.rb @@ -1,17 +1,18 @@ -# -------------------------------------------------------------------------- * -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # -# Licensed under the Apache License, Version 2.0 (the "License"); you may * -# not use this file except in compliance with the License. You may obtain * -# a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# -------------------------------------------------------------------------- * +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # require "rexml/document" include REXML diff --git a/src/onedb/3.0.0_to_3.1.0.rb b/src/onedb/3.0.0_to_3.1.0.rb index c7ebf0caa5..8a29680eb0 100644 --- a/src/onedb/3.0.0_to_3.1.0.rb +++ b/src/onedb/3.0.0_to_3.1.0.rb @@ -1,17 +1,18 @@ -# -------------------------------------------------------------------------- * -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # -# Licensed under the Apache License, Version 2.0 (the "License"); you may * -# not use this file except in compliance with the License. You may obtain * -# a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# -------------------------------------------------------------------------- * +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # require 'digest/sha1' require "rexml/document" diff --git a/src/onedb/3.1.0_to_3.1.80.rb b/src/onedb/3.1.0_to_3.1.80.rb index a84917ecd4..0c6fdfacba 100644 --- a/src/onedb/3.1.0_to_3.1.80.rb +++ b/src/onedb/3.1.0_to_3.1.80.rb @@ -1,17 +1,18 @@ -# -------------------------------------------------------------------------- * -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # -# Licensed under the Apache License, Version 2.0 (the "License"); you may * -# not use this file except in compliance with the License. You may obtain * -# a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# -------------------------------------------------------------------------- * +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # require 'digest/sha1' require "rexml/document" diff --git a/src/onedb/3.1.80_to_3.2.0.rb b/src/onedb/3.1.80_to_3.2.0.rb index 8be9d510e1..0932268498 100644 --- a/src/onedb/3.1.80_to_3.2.0.rb +++ b/src/onedb/3.1.80_to_3.2.0.rb @@ -1,17 +1,18 @@ -# -------------------------------------------------------------------------- * -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # -# Licensed under the Apache License, Version 2.0 (the "License"); you may * -# not use this file except in compliance with the License. You may obtain * -# a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# -------------------------------------------------------------------------- * +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # require "rexml/document" include REXML diff --git a/src/onedb/3.2.0_to_3.2.1.rb b/src/onedb/3.2.0_to_3.2.1.rb index 2ae7cca937..c6f0754fa8 100644 --- a/src/onedb/3.2.0_to_3.2.1.rb +++ b/src/onedb/3.2.0_to_3.2.1.rb @@ -1,17 +1,18 @@ -# -------------------------------------------------------------------------- * -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # -# Licensed under the Apache License, Version 2.0 (the "License"); you may * -# not use this file except in compliance with the License. You may obtain * -# a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# -------------------------------------------------------------------------- * +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # module Migrator def db_version diff --git a/src/onedb/3.2.1_to_3.3.0.rb b/src/onedb/3.2.1_to_3.3.0.rb index b2d439c2f7..9044892d14 100644 --- a/src/onedb/3.2.1_to_3.3.0.rb +++ b/src/onedb/3.2.1_to_3.3.0.rb @@ -1,17 +1,18 @@ -# -------------------------------------------------------------------------- * -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # -# Licensed under the Apache License, Version 2.0 (the "License"); you may * -# not use this file except in compliance with the License. You may obtain * -# a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# -------------------------------------------------------------------------- * +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # module Migrator def db_version diff --git a/src/onedb/3.3.0_to_3.3.80.rb b/src/onedb/3.3.0_to_3.3.80.rb index b162249390..a82d58d6e9 100644 --- a/src/onedb/3.3.0_to_3.3.80.rb +++ b/src/onedb/3.3.0_to_3.3.80.rb @@ -1,17 +1,18 @@ -# -------------------------------------------------------------------------- * -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # -# Licensed under the Apache License, Version 2.0 (the "License"); you may * -# not use this file except in compliance with the License. You may obtain * -# a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# -------------------------------------------------------------------------- * +# -------------------------------------------------------------------------- # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # require "rexml/document" include REXML diff --git a/src/tm_mad/lvm/ln b/src/onedb/3.3.80_to_3.4.0.rb old mode 100755 new mode 100644 similarity index 73% rename from src/tm_mad/lvm/ln rename to src/onedb/3.3.80_to_3.4.0.rb index 40d8e6f2e5..4b5974e5de --- a/src/tm_mad/lvm/ln +++ b/src/onedb/3.3.80_to_3.4.0.rb @@ -1,5 +1,3 @@ -#!/bin/bash - # -------------------------------------------------------------------------- # # Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # # # @@ -16,19 +14,16 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -SRC=$1 -DST=$2 +module Migrator + def db_version + "3.4.0" + end -if [ -z "${ONE_LOCATION}" ]; then - TMCOMMON=/usr/lib/one/mads/tm_common.sh - TM_COMMANDS_LOCATION=/usr/lib/one/tm_commands/ -else - TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh - TM_COMMANDS_LOCATION=$ONE_LOCATION/lib/tm_commands/ -fi + def one_version + "OpenNebula 3.4.0" + end -. $TMCOMMON - -log "Link $SRC_PATH (non shared dir, will clone)" -#exec_and_log "ln -s $SRC_PATH $DST_PATH" -exec $TM_COMMANDS_LOCATION/ssh/tm_clone.sh $SRC $DST + def up + return true + end +end diff --git a/src/onedb/onedb b/src/onedb/onedb index 6fd05d5237..c502d386af 100755 --- a/src/onedb/onedb +++ b/src/onedb/onedb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # # # # Licensed under the Apache License, Version 2.0 (the "License"); you may # # not use this file except in compliance with the License. You may obtain # diff --git a/src/onedb/onedb.rb b/src/onedb/onedb.rb index 967b27962b..a925b6d853 100644 --- a/src/onedb/onedb.rb +++ b/src/onedb/onedb.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # # # # Licensed under the Apache License, Version 2.0 (the "License"); you may # # not use this file except in compliance with the License. You may obtain # diff --git a/src/onedb/onedb_backend.rb b/src/onedb/onedb_backend.rb index b57ba32a1b..fdd7e33b35 100644 --- a/src/onedb/onedb_backend.rb +++ b/src/onedb/onedb_backend.rb @@ -1,5 +1,5 @@ # -------------------------------------------------------------------------- # -# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # +# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # # # # Licensed under the Apache License, Version 2.0 (the "License"); you may # # not use this file except in compliance with the License. You may obtain # diff --git a/src/scheduler/src/client/Client.cc b/src/scheduler/src/client/Client.cc index 72f3f74246..54cdf61f27 100644 --- a/src/scheduler/src/client/Client.cc +++ b/src/scheduler/src/client/Client.cc @@ -28,6 +28,9 @@ #include +#include +#include + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/src/template/Template.cc b/src/template/Template.cc index d41f248fce..18227d4af6 100644 --- a/src/template/Template.cc +++ b/src/template/Template.cc @@ -443,8 +443,9 @@ Attribute * Template::single_xml_att(const xmlNode * node) Attribute * attr = 0; xmlNode * child = node->children; - if( child != 0 && (child->type == XML_TEXT_NODE || - child->type == XML_CDATA_SECTION_NODE)) + if( child->next == 0 && child != 0 && + (child->type == XML_TEXT_NODE || + child->type == XML_CDATA_SECTION_NODE)) { attr = new SingleAttribute( reinterpret_cast(node->name), @@ -464,7 +465,12 @@ Attribute * Template::vector_xml_att(const xmlNode * node) xmlNode * child = node->children; xmlNode * grandchild = 0; - if(child != 0 && child->type == XML_ELEMENT_NODE) + while(child != 0 && child->type != XML_ELEMENT_NODE) + { + child = child->next; + } + + if(child != 0) { attr = new VectorAttribute( reinterpret_cast(node->name)); diff --git a/src/tm_mad/lvm/clone b/src/tm_mad/lvm/clone deleted file mode 100755 index 924b2b2998..0000000000 --- a/src/tm_mad/lvm/clone +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -SRC=$1 -DST=$2 -SIZE=$3 - -if [ -z "${ONE_LOCATION}" ]; then - TMCOMMON=/usr/lib/one/mads/tm_common.sh - LVMRC=/etc/one/tm_lvm/tm_lvmrc -else - TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh - LVMRC=$ONE_LOCATION/etc/tm_lvm/tm_lvmrc -fi - -. $TMCOMMON -. $LVMRC - -SRC_PATH=`arg_path $SRC` -DST_PATH=`arg_path $DST` - -SRC_HOST=`arg_host $SRC` -DST_HOST=`arg_host $DST` - -if [ -z $SIZE ] ; then - SIZE=$DEFAULT_LV_SIZE -fi - -LV_NAME=`get_lv_name $DST_PATH` - -log "$1 $2" -log "DST: $DST_PATH" - -DST_DIR=`dirname $DST_PATH` - -log "Creating directory $DST_DIR" -exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" - -case $SRC in -#------------------------------------------------------------------------------ -#Get the image from http repository and dump it to a new LV -#------------------------------------------------------------------------------ -http://*) - log "Creating LV $LV_NAME" - exec_and_log "$SSH $DST_HOST $SUDO $LVCREATE -L$SIZE -n $LV_NAME $VG_NAME" - exec_and_log "$SSH $DST_HOST ln -s /dev/$VG_NAME/$LV_NAME $DST_PATH" - - log "Dumping Image into /dev/$VG_NAME/$LV_NAME" - exec_and_log "eval $SSH $DST_HOST '$WGET $SRC -q -O- | $SUDO $DD of=/dev/$VG_NAME/$LV_NAME bs=64k'" - ;; - -#------------------------------------------------------------------------------ -#Make a snapshot from the given dev (already in DST_HOST) -#------------------------------------------------------------------------------ -*:/dev/*) - log "Cloning LV $LV_NAME" - exec_and_log "$SSH $DST_HOST $SUDO $LVCREATE -s -L$SIZE -n $LV_NAME $SRC_PATH" - exec_and_log "$SSH $DST_HOST ln -s /dev/$VG_NAME/$LV_NAME $DST_PATH" - ;; - -#------------------------------------------------------------------------------ -#Get the image from SRC_HOST and dump it to a new LV -#------------------------------------------------------------------------------ -*) - log "Creating LV $LV_NAME" - exec_and_log "$SSH $DST_HOST $SUDO $LVCREATE -L$SIZE -n $LV_NAME $VG_NAME" - exec_and_log "$SSH $DST_HOST ln -s /dev/$VG_NAME/$LV_NAME $DST_PATH" - - log "Dumping Image" - exec_and_log "eval cat $SRC_PATH | $SSH $DST_HOST $SUDO $DD of=/dev/$VG_NAME/$LV_NAME bs=64k" - ;; -esac diff --git a/src/tm_mad/lvm/context b/src/tm_mad/lvm/context deleted file mode 100755 index be99c283de..0000000000 --- a/src/tm_mad/lvm/context +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -while (( "$#" )); do - if [ "$#" == "1" ]; then - DST=$1 - else - SRC="$SRC $1" - fi - shift -done - - -if [ -z "${ONE_LOCATION}" ]; then - TMCOMMON=/usr/lib/one/mads/tm_common.sh -else - TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh -fi - -. $TMCOMMON - - -DST_PATH=`arg_path $DST` -DST_DIR=`dirname $DST_PATH` -DST_FILE=`basename $DST_PATH` -DST_HASH=`echo -n $DST | $MD5SUM | $AWK '{print $1}'` -if [ -z "$ONE_LOCATION" ]; then - TMP_DIR="/var/lib/one/$DST_HASH" -else - TMP_DIR="$ONE_LOCATION/var/$DST_HASH" -fi -ISO_DIR="$TMP_DIR/isofiles" - - -exec_and_log "mkdir -p $ISO_DIR" - -for f in $SRC; do - case $f in - http://*) - exec_and_log "$WGET -P $ISO_DIR $f" - ;; - - *) - exec_and_log "cp -R $f $ISO_DIR" \ - "Error copying $f to $ISO_DIR" - ;; - esac -done - -exec_and_log "$MKISOFS -o $TMP_DIR/$DST_FILE -J -R $ISO_DIR" -exec_and_log "$SCP $TMP_DIR/$DST_FILE $DST" -exec_and_log "rm -rf $TMP_DIR" diff --git a/src/tm_mad/lvm/delete b/src/tm_mad/lvm/delete deleted file mode 100755 index 9c2c09564a..0000000000 --- a/src/tm_mad/lvm/delete +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -SRC=$1 -DST=$2 - -if [ -z "${ONE_LOCATION}" ]; then - TMCOMMON=/usr/lib/one/mads/tm_common.sh - LVMRC=/etc/one/tm_lvm/tm_lvmrc -else - TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh - LVMRC=$ONE_LOCATION/etc/tm_lvm/tm_lvmrc -fi - -. $TMCOMMON -. $LVMRC - -SRC_PATH=`arg_path $SRC` -SRC_HOST=`arg_host $SRC` - -VID=`get_vid $SRC_PATH` - -log "Deleting remote LVs" -exec_and_log "$SSH $SRC_HOST $SUDO $LVREMOVE -f \$(echo $VG_NAME/\$($SUDO $LVS --noheadings $VG_NAME|$AWK '{print \$1}'|grep lv-one-$VID))" - -log "Deleting $SRC_PATH" -exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH" diff --git a/src/tm_mad/lvm/lvm.conf b/src/tm_mad/lvm/lvm.conf deleted file mode 100644 index 39076ac468..0000000000 --- a/src/tm_mad/lvm/lvm.conf +++ /dev/null @@ -1,38 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -# -------------------------------------------------------------------------- # - -# Volume Group to create logical volumes or snapshots in the cluster nodes # -VG_NAME= - -# Default size for logical volumes if not specified -DEFAULT_LV_SIZE="1G" - -# -------------------------------------------------------------------------- # -# Helper functions for the LVM plugin # -# -------------------------------------------------------------------------- # - -function get_vid { - echo $1 |$SED -e 's%^.*/([^/]*)/images.*$%\1%' -} - -function get_lv_name { - VID=`get_vid $1` - DISK=`echo $1|$AWK -F. '{printf $NF}'` - echo "lv-one-$VID-$DISK" -} - diff --git a/src/tm_mad/lvm/mkimage b/src/tm_mad/lvm/mkimage deleted file mode 100755 index a7396bc771..0000000000 --- a/src/tm_mad/lvm/mkimage +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -if [ -z "${ONE_LOCATION}" ]; then - TMCOMMON=/usr/lib/one/mads/tm_common.sh -else - TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh -fi - -. $TMCOMMON - -SIZE=$1 -FSTYPE=$2 -DST=$3 - -DST_PATH=`arg_path $DST` -DST_HOST=`arg_host $DST` -DST_DIR=`dirname $DST_PATH` - -MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE` - -exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" -exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" -exec_and_log "$SSH $DST_HOST $MKFS_CMD" -exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH" diff --git a/src/tm_mad/lvm/mkswap b/src/tm_mad/lvm/mkswap deleted file mode 100755 index e02ba100f9..0000000000 --- a/src/tm_mad/lvm/mkswap +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -SIZE=$1 -DST=$2 - -if [ -z "${ONE_LOCATION}" ]; then - TMCOMMON=/usr/lib/one/mads/tm_common.sh -else - TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh -fi - -. $TMCOMMON - -DST_PATH=`arg_path $DST` -DST_HOST=`arg_host $DST` - -DST_DIR=`dirname $DST_PATH` - -log "Creating ${SIZE}Mb image in $DST_PATH" -exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" -exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" - -log "Initializing swap space" -exec_and_log "$SSH $DST_HOST $MKSWAP $DST_PATH" - -exec_and_log "$SSH $DST_HOST chmod a+w $DST_PATH" - diff --git a/src/tm_mad/lvm/mv b/src/tm_mad/lvm/mv deleted file mode 100755 index 579f141d21..0000000000 --- a/src/tm_mad/lvm/mv +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -SRC=$1 -DST=$2 - -if [ -z "${ONE_LOCATION}" ]; then - TMCOMMON=/usr/lib/one/mads/tm_common.sh - LVMRC=/etc/one/tm_lvm/tm_lvmrc -else - TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh - LVMRC=$ONE_LOCATION/etc/tm_lvm/tm_lvmrc -fi - -. $TMCOMMON -. $LVMRC - -SRC_PATH=`arg_path $SRC` -DST_PATH=`arg_path $DST` - -SRC_HOST=`arg_host $SRC` -DST_HOST=`arg_host $DST` - -DST_DIR=`dirname $DST_PATH` - -VID=`get_vid $SRC_PATH` - -if [ -z $SIZE ] ; then - SIZE=$DEFAULT_LV_SIZE -fi - -# Check that we are not stopping, migrating or resuming -if echo `basename $SRC_PATH`|grep -vq '^disk'; then - log_error "This TM does not support stop, migrating or resuming." - exit 1 -fi - -if [ "$SRC_HOST" != "$HOSTNAME" ]; then - log "Dumping LV to disk image" - - echo "if [ -L "$SRC_PATH" ]; then - lv=\$(readlink $SRC_PATH) - rm $SRC_PATH - touch $SRC_PATH - $SUDO $DD if=\$lv of=$SRC_PATH bs=64k - else - exit 1 - fi" | $SSH $SRC_HOST "$BASH -s" - - [ "$?" != "0" ] && log_error "Error dumping LV to disk image" - - log "Deleting remote LVs" - exec_and_log "$SSH $SRC_HOST $SUDO $LVREMOVE -f \$(echo $VG_NAME/\$($SUDO $LVS --noheadings $VG_NAME|$AWK '{print \$1}'|grep lv-one-$VID))" -fi - -log "Moving $SRC_PATH" -exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" -exec_and_log "$SCP -r $SRC $DST" -exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH" - -if [ "$DST_HOST" != "$HOSTNAME" ]; then - log_error "This TM does not support resuming." -fi - diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index f25160dcf0..6b530500b2 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -170,7 +170,10 @@ int VirtualMachine::select(SqlDB * db) //-------------------------------------------------------------------------- try { - _log = new FileLog(nd.get_vm_log_filename(oid),Log::DEBUG); + Log::MessageType clevel; + + clevel = nd.get_debug_level(); + _log = new FileLog(nd.get_vm_log_filename(oid), clevel); } catch(exception &e) { diff --git a/src/vmm_mad/remotes/kvm/save b/src/vmm_mad/remotes/kvm/save index a63644ff71..110189dbbf 100755 --- a/src/vmm_mad/remotes/kvm/save +++ b/src/vmm_mad/remotes/kvm/save @@ -22,10 +22,16 @@ source $(dirname $0)/../../scripts_common.sh deploy_id=$1 file=$2 -if [ ! -f $file ]; then - touch $file - chmod 666 $file +if [ -f $file ]; then + log "Moving old checkpoint file $file" + epoch=`date +%s` + + exec_and_log "mv $file $file.$epoch" \ + "Could not move $file to $file.$epoch" fi +touch $file +chmod 666 $file + exec_and_log "virsh --connect $LIBVIRT_URI save $deploy_id $file" \ "Could not save $deploy_id to $file" diff --git a/src/vmm_mad/remotes/poll_xen_kvm.rb b/src/vmm_mad/remotes/poll_xen_kvm.rb index 12c13238ef..1486d1dfb4 100755 --- a/src/vmm_mad/remotes/poll_xen_kvm.rb +++ b/src/vmm_mad/remotes/poll_xen_kvm.rb @@ -172,7 +172,7 @@ private when *%w{running blocked shutdown dying idle} 'a' when 'paused' - 'p' + '-' when 'crashed' 'e' else @@ -242,7 +242,7 @@ module XEN when *%w{r b s d} 'a' when 'p' - 'p' + '-' when 'c' 'e' else diff --git a/src/vmm_mad/remotes/xen/cancel b/src/vmm_mad/remotes/xen/cancel index e6b1352976..0bf7e399d9 100755 --- a/src/vmm_mad/remotes/xen/cancel +++ b/src/vmm_mad/remotes/xen/cancel @@ -21,5 +21,17 @@ source $(dirname $0)/../../scripts_common.sh deploy_id=$1 +function gdm { + $XM_LIST | grep "$deploy_id " +} + exec_and_log "$XM_CANCEL $deploy_id" \ "Could not destroy $deploy_id" + +OUT=$(gdm) + +while [ -n "$OUT" ]; do + sleep 1 + OUT=$(gdm) +done + diff --git a/src/vmm_mad/remotes/xen/save b/src/vmm_mad/remotes/xen/save index d5b5511bd8..c168cc00c6 100755 --- a/src/vmm_mad/remotes/xen/save +++ b/src/vmm_mad/remotes/xen/save @@ -22,5 +22,13 @@ source $(dirname $0)/../../scripts_common.sh deploy_id=$1 file=$2 +if [ -f $file ]; then + log "Moving old checkpoint file $file" + epoch=`date +%s` + + exec_and_log "mv $file $file.$epoch" \ + "Could not move $file to $file.$epoch" +fi + exec_and_log "$XM_SAVE $deploy_id $file" \ "Could not save $deploy_id to $file"