mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Merge branch 'feature-1020' of git.opennebula.org:one into feature-1020
This commit is contained in:
commit
af95964ffa
@ -30,6 +30,7 @@ $: << RUBY_LIB_LOCATION
|
||||
|
||||
require 'OpenNebula'
|
||||
include OpenNebula
|
||||
require 'vmwarelib'
|
||||
|
||||
begin
|
||||
client = Client.new()
|
||||
@ -40,29 +41,24 @@ end
|
||||
|
||||
def add_info(name, value)
|
||||
value = "0" if value.nil? or value.to_s.empty?
|
||||
@result_str << "#{name}=#{value} "
|
||||
result_str << "#{name}=#{value} "
|
||||
end
|
||||
|
||||
def print_info
|
||||
puts @result_str
|
||||
puts result_str
|
||||
end
|
||||
|
||||
@result_str = ""
|
||||
result_str = ""
|
||||
|
||||
@host = ARGV[2]
|
||||
host = ARGV[2]
|
||||
|
||||
if !@host
|
||||
exit -1
|
||||
end
|
||||
|
||||
load ETC_LOCATION + "/vmwarerc"
|
||||
vmware_drv = VMWareDriver.new(host)
|
||||
|
||||
if USERNAME.class!=String || PASSWORD.class!=String
|
||||
warn "Bad ESX credentials, aborting"
|
||||
exit -1
|
||||
end
|
||||
|
||||
data = perform_action("virsh -c #{LIBVIRT_URI} --readonly nodeinfo")
|
||||
data = vmware_drv.poll_hypervisor
|
||||
|
||||
data.split(/\n/).each{|line|
|
||||
if line.match('^CPU\(s\)')
|
||||
|
@ -89,7 +89,7 @@ class VmWareDriver
|
||||
end
|
||||
|
||||
# Undefine the VM
|
||||
exit undefine_domain(deploy_id)
|
||||
undefine_domain(deploy_id)
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
@ -217,6 +217,20 @@ class VmWareDriver
|
||||
undefine_domain(deploy_id)
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Poll a VMware hypervisor #
|
||||
# ------------------------------------------------------------------------ #
|
||||
def poll_hypervisor
|
||||
# Destroy the VM
|
||||
rc, info = perform_action("virsh -c #{@uri} --readonly nodeinfo")
|
||||
|
||||
if rc == false
|
||||
exit info
|
||||
end
|
||||
|
||||
return info
|
||||
end
|
||||
|
||||
# ######################################################################## #
|
||||
# DRIVER HELPER FUNCTIONS #
|
||||
# ######################################################################## #
|
||||
|
@ -42,7 +42,7 @@ REPO_NAME="images"
|
||||
RELATIVE_SRC_PATH="../../$REPO_NAME/$VM_FOLDER_NAME"
|
||||
|
||||
log "Creating directory $DST_PATH"
|
||||
exec_and_log "rm -rf $DST_PATH"
|
||||
exec_and_log "rm -rf $DST"
|
||||
exec_and_log "mkdir -p $DST_PATH"
|
||||
exec_and_log "chmod a+w $DST_PATH"
|
||||
|
||||
@ -56,5 +56,8 @@ for file in `find $RELATIVE_SRC_PATH/* -type f`; do
|
||||
exec_and_log "ln -sf ../$file $DST_PATH/$file_name"
|
||||
done
|
||||
|
||||
# Put the symlink mark for tm_mv
|
||||
exec_and_log "ln -sf $RELATIVE_SRC_PATH $DST_PATH/.disk"
|
||||
|
||||
|
||||
|
||||
|
@ -41,9 +41,11 @@ SRC_PATH=`fix_dir_slashes "$SRC_PATH"`
|
||||
|
||||
if [ "$SRC_PATH" = "$DST_PATH" ]; then
|
||||
log "Will not move, source and destination are equal"
|
||||
elif [ -f "$SRC_PATH/.disk" ]; then # This link was set in tm_ln.sh
|
||||
exec_and_log "mv $SRC_PATH/.disk $DST_PATH"
|
||||
elif echo $SRC_PATH | grep -q 'disk\.[0-9]\+$'; then
|
||||
log "Moving $SRC_PATH"
|
||||
exec_and_log "mv $SRC_PATH $DST_PATH"
|
||||
log "Moving $SRC_PATH"
|
||||
exec_and_log "mv $SRC_PATH $DST_PATH"
|
||||
elif [ -d $SRC_PATH ]; then
|
||||
log "Will not move, is not saving image"
|
||||
else
|
||||
|
@ -18,6 +18,28 @@
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'vmwarelib'
|
||||
|
||||
dfile = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
vmware_drv = VMWareDriver.new(host)
|
||||
|
||||
puts vmware_drv.deploy(dfile)
|
||||
|
||||
exit 0
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
ETC_LOCATION="/etc/one" if !defined?(ETC_LOCATION)
|
||||
else
|
||||
|
@ -16,12 +16,12 @@
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"]
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
Loading…
x
Reference in New Issue
Block a user