mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Merge branch 'master' into feature-1020
Conflicts: src/tm_mad/vmware/tm_ln.sh src/tm_mad/vmware/tm_mv.sh
This commit is contained in:
commit
fe20940e49
@ -90,6 +90,62 @@ class String
|
||||
end
|
||||
end
|
||||
|
||||
def good_gem_version?
|
||||
v=`gem --version`.strip
|
||||
version=Gem::Version.new(v)
|
||||
version>=Gem::Version.new('1.3.6')
|
||||
end
|
||||
|
||||
def install_rubygems
|
||||
if !good_gem_version?
|
||||
puts(<<-EOT.unindent())
|
||||
The rubygems version installed is too old to install some required
|
||||
libraries. We are about to update your rubygems version. If you
|
||||
want to do this by other means cancel this installation with
|
||||
CTRL+C now.
|
||||
|
||||
Press ENTER to continue...
|
||||
|
||||
EOT
|
||||
|
||||
STDIN.readline
|
||||
|
||||
`gem install rubygems-update --version '= 1.3.6'`
|
||||
|
||||
if $?.ecxitstatus!=0
|
||||
puts "Error updating rubygems"
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
update_rubygems_path=[
|
||||
'/usr/bin/update_rubygems',
|
||||
'/var/lib/gems/1.8/bin/update_rubygems',
|
||||
'/var/lib/gems/1.9/bin/update_rubygems'
|
||||
]
|
||||
|
||||
installed=false
|
||||
|
||||
update_rubygems_path.each do |path|
|
||||
if File.exist?(path)
|
||||
`#{path}`
|
||||
|
||||
if $?.exitstatus!=0
|
||||
puts "Error executing update_rubygems"
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
installed=true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if !installed
|
||||
puts "Could not find update_rubygems executable"
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def installed_gems
|
||||
text=`gem list --no-versions --no-details`
|
||||
if $?.exitstatus!=0
|
||||
@ -331,6 +387,7 @@ try_library :mkmf, <<-EOT.unindent
|
||||
* Install the ruby development package for your distro
|
||||
EOT
|
||||
|
||||
install_rubygems
|
||||
|
||||
command=''
|
||||
params=ARGV
|
||||
|
@ -51,9 +51,9 @@ exit(-1) if $?.exitstatus != 0
|
||||
top_text.gsub!(/^top.*^top.*?$/m, "") # Strip first top output
|
||||
|
||||
top_text.split(/\n/).each{|line|
|
||||
if line.match('^Cpu')
|
||||
if line.match('^%?Cpu')
|
||||
line[7..-1].split(",").each{|elemento|
|
||||
temp = elemento.strip.split("%")
|
||||
temp = elemento.strip.split(/[% ]/)
|
||||
if temp[1]=="id"
|
||||
idle = temp[0]
|
||||
$free_cpu = idle.to_f * $total_cpu.to_f / 100
|
||||
|
@ -21,7 +21,7 @@
|
||||
# as (FS)
|
||||
###############################################################################
|
||||
|
||||
# ------------ Set up the environment to source common tools ------------
|
||||
# ------------ Set up the environment to source common tools ------------
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
LIB_LOCATION=/usr/lib/one
|
||||
@ -32,37 +32,20 @@ fi
|
||||
. $LIB_LOCATION/sh/scripts_common.sh
|
||||
source $(dirname $0)/fsrc
|
||||
|
||||
# ------------ Create the image to the repository ------------
|
||||
# ------------ Create the image to the repository ------------
|
||||
|
||||
FSTYPE=$1
|
||||
SIZE=$2
|
||||
ID=$3
|
||||
|
||||
# Specific options for different FS
|
||||
case "$FSTYPE" in
|
||||
"ext2"|"ext3"|"ext4"|"ntfs")
|
||||
OPTS="-F"
|
||||
;;
|
||||
|
||||
"reiserfs")
|
||||
OPTS="-f -q"
|
||||
;;
|
||||
|
||||
"jfs")
|
||||
OPTS="-q"
|
||||
;;
|
||||
*)
|
||||
OPTS=""
|
||||
;;
|
||||
esac
|
||||
|
||||
DST=`generate_image_path`
|
||||
|
||||
MKFS_CMD=`mkfs_command $DST $FSTYPE`
|
||||
|
||||
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
|
||||
"Could not create image $DST"
|
||||
exec_and_log "$MKFS -t $FSTYPE $OPTS $DST" \
|
||||
exec_and_log "$MKFS_CMD" \
|
||||
"Unable to create filesystem $FSTYPE in $DST"
|
||||
|
||||
exec_and_log "chmod 0660 $DST"
|
||||
|
||||
# ---------------- Get the size of the image ------------
|
||||
|
@ -148,3 +148,30 @@ function timeout_exec_and_log
|
||||
exit $CMD_CODE
|
||||
fi
|
||||
}
|
||||
|
||||
# This function will return a command that upon execution will format a
|
||||
# filesystem with its proper parameters based on the filesystem type
|
||||
function mkfs_command {
|
||||
DST=$1
|
||||
FSTYPE=${2:-ext3}
|
||||
|
||||
# Specific options for different FS
|
||||
case "$FSTYPE" in
|
||||
"ext2"|"ext3"|"ext4"|"ntfs")
|
||||
OPTS="-F"
|
||||
;;
|
||||
|
||||
"reiserfs")
|
||||
OPTS="-f -q"
|
||||
;;
|
||||
|
||||
"jfs")
|
||||
OPTS="-q"
|
||||
;;
|
||||
*)
|
||||
OPTS=""
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "$MKFS -t $FSTYPE $OPTS $DST"
|
||||
}
|
||||
|
@ -32,7 +32,9 @@ 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 -t $FSTYPE -F $DST_PATH"
|
||||
exec_and_log "$SSH $DST_HOST $MKFS_CMD"
|
||||
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"
|
||||
|
@ -36,11 +36,13 @@ fix_dst_path
|
||||
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE`
|
||||
|
||||
exec_and_log "mkdir -p $DST_DIR" \
|
||||
"Error creating directory $DST_DIR"
|
||||
exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \
|
||||
"Could not create image $DST_PATH"
|
||||
exec_and_log "$MKFS -t $FSTYPE -F $DST_PATH" \
|
||||
exec_and_log "$MKFS_CMD" \
|
||||
"Unable to create filesystem $FSTYPE in $DST_PATH"
|
||||
exec_and_log "chmod a+rw $DST_PATH"
|
||||
|
||||
|
@ -32,10 +32,12 @@ 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" \
|
||||
"Error creating directory $DST_DIR"
|
||||
exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \
|
||||
"Could not create image $DST_PATH"
|
||||
exec_and_log "$SSH $DST_HOST $MKFS -t $FSTYPE -F $DST_PATH" \
|
||||
exec_and_log "$SSH $DST_HOST $MKFS_CMD" \
|
||||
"Unable to create filesystem $FSTYPE in $DST_PATH"
|
||||
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"
|
||||
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"
|
||||
|
@ -52,3 +52,4 @@ done
|
||||
|
||||
#Mark this disk persistent with a symlink for tm_mv and repo mv
|
||||
exec_and_log "ln -sf ${REL_SRC_PATH#../../} $DST_PATH/.disk"
|
||||
|
||||
|
@ -43,9 +43,9 @@ SRC_PATH=`fix_dir_slashes "$SRC_PATH"`
|
||||
if [ "$SRC_PATH" = "$DST_PATH" ]; then
|
||||
log "Will not move, source and destination are equal"
|
||||
elif [ -L "$SRC_PATH/.disk" ]; then
|
||||
exec_and_log "mv $SRC_PATH/.disk $DST_PATH"
|
||||
exec_and_log "mv $SRC_PATH/.disk $DST_PATH"
|
||||
elif [ "`is_disk $SRC_PATH`" = "0" ] ; then
|
||||
log "Moving $SRC_PATH"
|
||||
log "Moving $SRC_PATH"
|
||||
exec_and_log "mv $SRC_PATH $DST_PATH"
|
||||
elif [ -d $SRC_PATH ]; then
|
||||
log "Will not move, it is not saving a VM disk image"
|
||||
|
Loading…
x
Reference in New Issue
Block a user