diff --git a/src/im_mad/remotes/vmware.d/vmware.rb b/src/im_mad/remotes/vmware.d/vmware.rb index 5552818cf3..8ee8853b00 100755 --- a/src/im_mad/remotes/vmware.d/vmware.rb +++ b/src/im_mad/remotes/vmware.d/vmware.rb @@ -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\)') diff --git a/src/mad/ruby/vmwarelib.rb b/src/mad/ruby/vmwarelib.rb index d2b58e25c7..164f76c042 100644 --- a/src/mad/ruby/vmwarelib.rb +++ b/src/mad/ruby/vmwarelib.rb @@ -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 # # ######################################################################## # diff --git a/src/vmm_mad/remotes/vmware/cancel b/src/vmm_mad/remotes/vmware/cancel index aa01113c91..8ca9d3dc59 100755 --- a/src/vmm_mad/remotes/vmware/cancel +++ b/src/vmm_mad/remotes/vmware/cancel @@ -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 diff --git a/src/vmm_mad/remotes/vmware/deploy b/src/vmm_mad/remotes/vmware/deploy index aae48e318c..8b923be19b 100755 --- a/src/vmm_mad/remotes/vmware/deploy +++ b/src/vmm_mad/remotes/vmware/deploy @@ -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