From d8350b255176c601609aa49f397aec2e9c714694 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 13 Mar 2012 12:07:31 +0100 Subject: [PATCH 1/4] feature #1112: Improve debugging for one_tm.rb --- src/tm_mad/one_tm.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/tm_mad/one_tm.rb b/src/tm_mad/one_tm.rb index d8fc620987..0a9a70eff1 100755 --- a/src/tm_mad/one_tm.rb +++ b/src/tm_mad/one_tm.rb @@ -33,9 +33,9 @@ require 'OpenNebulaDriver' require 'CommandManager' require 'getoptlong' -# This class provides basic messaging and logging functionality to implement -# TransferManager Drivers. A TransferManager driver is a program (or a set of) -# that specialize the OpenNebula behavior to distribute disk images in a +# This class provides basic messaging and logging functionality to implement +# TransferManager Drivers. A TransferManager driver is a program (or a set of) +# that specialize the OpenNebula behavior to distribute disk images in a # specific datastore to the hosts class TransferManagerDriver < OpenNebulaDriver @@ -72,9 +72,9 @@ class TransferManagerDriver < OpenNebulaDriver script = parse_script(script_file) if script.nil? - send_message("TRANSFER", + send_message("TRANSFER", RESULT[:failure], - id, + id, "Transfer file '#{script_file}' does not exist") return end @@ -84,7 +84,7 @@ class TransferManagerDriver < OpenNebulaDriver if result == RESULT[:failure] send_message("TRANSFER", result, id, info) - return + return end } @@ -106,7 +106,7 @@ class TransferManagerDriver < OpenNebulaDriver stext.each_line {|line| next if line.match(/^\s*#/) # skip if the line is commented next if line.match(/^\s*$/) # skip if the line is empty - + command = line.split(" ") lines << command @@ -115,7 +115,7 @@ class TransferManagerDriver < OpenNebulaDriver return lines end - # Executes a single transfer action (command), as returned by the parse + # Executes a single transfer action (command), as returned by the parse # method # @param id [String] with the OpenNebula ID for the TRANSFER action # @param command [Array] @@ -131,10 +131,13 @@ class TransferManagerDriver < OpenNebulaDriver path = File.join(@local_scripts_path, tm, cmd) path << " " << args + rc = LocalCommand.run(path, log_method(id)) result, info = get_info_from_execution(rc) + PP.pp([path,result,info],STDERR) + return result, info end end From 6b86f36cad681b32e13e70021bb87a0a9bc60022 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 13 Mar 2012 12:07:53 +0100 Subject: [PATCH 2/4] feature #1112: tm_iscsi/clone not implemented --- src/tm_mad/iscsi/clone | 50 ++---------------------------------------- 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/src/tm_mad/iscsi/clone b/src/tm_mad/iscsi/clone index cf172ed818..322f2a511e 100755 --- a/src/tm_mad/iscsi/clone +++ b/src/tm_mad/iscsi/clone @@ -16,52 +16,6 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -# clone fe:SOURCE host:remote_system_ds/disk.i size -# - fe is the front-end hostname -# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk -# - host is the target host to deploy the VM -# - remote_system_ds is the path for the system datastore in the host +log_error "CLONE not supported for TM_ISCSI. Use persistent images" -SRC=$1 -DST=$2 - -if [ -z "${ONE_LOCATION}" ]; then - TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh -else - TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh -fi - -. $TMCOMMON - -#------------------------------------------------------------------------------- -# Set dst path and dir -#------------------------------------------------------------------------------- - -TARGET=`arg_path $SRC` -DST_PATH=`arg_path $DST` -DST_HOST=`arg_host $DST` -DST_DIR=`dirname $DST_PATH` - -IQN="$SRC" - -LV_NAME=`iqn_get_lv_name "$IQN"` -VG_NAME=`iqn_get_vg_name "$IQN"` -DEV="/dev/$VG_NAME/$LV_NAME" - -ssh_make_path "$DST_HOST" "$DST_DIR" - -#------------------------------------------------------------------------------- -# Copy files to the remote host -#------------------------------------------------------------------------------- -case $SRC in -http://*) - log "Downloading $SRC" - RMT_CMD="$WGET -O $DST_PATH $SRC" - ssh_exec_and_log "$DST_HOST" "$RMT_CMD" "Error downloading $SRC" - ;; - -*) - log "Cloning $SRC in $DST_PATH" - exec_and_log "$SCP $SRC $DST" "Error copying $SRC to $DST" - ;; -esac +exit 1 From dce32e135196cf05cd59bd1abec14cd987d63e57 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 13 Mar 2012 12:08:36 +0100 Subject: [PATCH 3/4] feature #1112: Include tm_iscsi files in install.sh --- install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install.sh b/install.sh index d5de5583f0..d49113c7f9 100755 --- a/install.sh +++ b/install.sh @@ -232,6 +232,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \ $VAR_LOCATION/remotes/tm/shared \ $VAR_LOCATION/remotes/tm/ssh \ $VAR_LOCATION/remotes/tm/vmware \ + $VAR_LOCATION/remotes/tm/iscsi \ $VAR_LOCATION/remotes/hooks \ $VAR_LOCATION/remotes/hooks/ft \ $VAR_LOCATION/remotes/datastore \ @@ -386,6 +387,7 @@ INSTALL_FILES=( TM_SHARED_FILES:$VAR_LOCATION/remotes/tm/shared TM_SSH_FILES:$VAR_LOCATION/remotes/tm/ssh 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/ @@ -805,6 +807,11 @@ TM_VMWARE_FILES="src/tm_mad/vmware/clone \ src/tm_mad/vmware/functions.sh \ src/tm_mad/vmware/context" +TM_ISCSI_FILES="src/tm_mad/iscsi/clone \ + src/tm_mad/iscsi/ln \ + src/tm_mad/iscsi/mv \ + src/tm_mad/iscsi/mvds \ + src/tm_mad/iscsi/delete" #------------------------------------------------------------------------------- # Datastore drivers, to be installed under $REMOTES_LOCATION/datastore # - FS based Image Repository, $REMOTES_LOCATION/datastore/fs From b304a6d896fc4e7f69a80daf1c6ace92f85fc06a Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 13 Mar 2012 16:00:55 +0100 Subject: [PATCH 4/4] feature #1112: Fix CLI option procs --- src/cli/command_parser.rb | 2 +- src/cli/one_helper.rb | 2 +- src/cli/one_helper/onecluster_helper.rb | 8 +++++++- src/cli/one_helper/onedatastore_helper.rb | 8 +++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/cli/command_parser.rb b/src/cli/command_parser.rb index fe3fc911ac..efe463d962 100755 --- a/src/cli/command_parser.rb +++ b/src/cli/command_parser.rb @@ -311,7 +311,7 @@ EOT opts.on(*args) do |o| if e[:proc] - @options[e[:name].to_sym]=e[:proc].call(o, @options) + e[:proc].call(o, @options) elsif e[:name]=="help" help exit diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index c9646e0809..16f08400f3 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -202,7 +202,7 @@ EOT result = names.split(',').collect { |name| if name.match(/^[0123456789]+$/) - name + name.to_i else rc = OneHelper.name_to_id(name, pool, poolname) diff --git a/src/cli/one_helper/onecluster_helper.rb b/src/cli/one_helper/onecluster_helper.rb index 4e837f9a29..40024d5b53 100644 --- a/src/cli/one_helper/onecluster_helper.rb +++ b/src/cli/one_helper/onecluster_helper.rb @@ -27,7 +27,13 @@ class OneClusterHelper < OpenNebulaHelper::OneHelper :proc => lambda { |o, options| ch = OneClusterHelper.new rc, cid = ch.to_id(o) - cid + if rc == 0 + options[:cluster] = cid + else + puts cid + puts "option cluster: Parsing error" + exit -1 + end } } diff --git a/src/cli/one_helper/onedatastore_helper.rb b/src/cli/one_helper/onedatastore_helper.rb index 4f524bbd71..b94ad60a3f 100644 --- a/src/cli/one_helper/onedatastore_helper.rb +++ b/src/cli/one_helper/onedatastore_helper.rb @@ -26,7 +26,13 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper :proc => lambda { |o, options| ch = OneDatastoreHelper.new rc, dsid = ch.to_id(o) - dsid + if rc == 0 + options[:datastore] = dsid + else + puts dsid + puts "option datastore: Parsing error" + exit -1 + end } }