1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

feature 1020: Revamping IM for vmware

This commit is contained in:
Tino Vazquez 2011-12-22 18:21:24 +01:00
parent 4da7c9060f
commit 3cf891ff66
4 changed files with 47 additions and 15 deletions

View File

@ -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\)')

View File

@ -86,7 +86,7 @@ class VmWareDriver
end
# Undefine the VM
exit undefine_domain(deploy_id)
undefine_domain(deploy_id)
end
# ------------------------------------------------------------------------ #
@ -214,6 +214,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 #
# ######################################################################## #

View File

@ -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

View File

@ -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