mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
Signed-off-by: Carlos Herrera <cherrera@opennebula.io>
This commit is contained in:
parent
9c583bd3d2
commit
09beabdbbf
@ -1279,6 +1279,7 @@ IM_PROBES_LIB_FILES="\
|
||||
src/im_mad/remotes/lib/probe_db.rb \
|
||||
src/im_mad/remotes/lib/vcenter_monitor.rb \
|
||||
src/im_mad/remotes/lib/vcenter_cluster.rb \
|
||||
src/im_mad/remotes/lib/vcenter_monitor_vms.rb \
|
||||
src/im_mad/remotes/lib/monitord_client.rb \
|
||||
src/im_mad/remotes/lib/domain.rb \
|
||||
src/im_mad/remotes/lib/process_list.rb"
|
||||
|
@ -89,6 +89,7 @@ AllCops:
|
||||
- src/im_mad/remotes/az.d/poll
|
||||
- src/im_mad/remotes/lib/vcenter_cluster.rb
|
||||
- src/im_mad/remotes/lib/vcenter_monitor.rb
|
||||
- src/im_mad/remotes/lib/vcenter_monitor_vms.rb
|
||||
- src/vnm_mad/remotes/ovswitch/post
|
||||
- src/vnm_mad/remotes/ovswitch/clean
|
||||
- src/vnm_mad/remotes/ovswitch/pre
|
||||
|
@ -17,6 +17,7 @@
|
||||
require 'opennebula'
|
||||
require 'vcenter_driver'
|
||||
require 'logger'
|
||||
require 'open3'
|
||||
|
||||
def unindent(s)
|
||||
m = s.match(/^(\s*)/)
|
||||
@ -636,8 +637,9 @@ class Cluster
|
||||
# 'ones' : VMs in OpenNebula
|
||||
#---------------------------------------------------------------------------
|
||||
def vms_info(vm_type)
|
||||
str_info , _ltime = @cluster.monitor_vms(@host.id, vm_type)
|
||||
return str_info
|
||||
cmd = "#{File.dirname(__FILE__)}/vcenter_monitor_vms.rb #{@host.id} #{vm_type}"
|
||||
str_info, _stderr, _status = Open3.capture3(cmd)
|
||||
str_info
|
||||
end
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
64
src/im_mad/remotes/lib/vcenter_monitor_vms.rb
Normal file
64
src/im_mad/remotes/lib/vcenter_monitor_vms.rb
Normal file
@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION ||= ENV['ONE_LOCATION']
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
|
||||
GEMS_LOCATION ||= '/usr/share/one/gems'
|
||||
else
|
||||
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
|
||||
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
|
||||
end
|
||||
|
||||
if File.directory?(GEMS_LOCATION)
|
||||
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
||||
require 'rubygems'
|
||||
Gem.use_paths(File.realpath(GEMS_LOCATION))
|
||||
end
|
||||
|
||||
$LOAD_PATH << RUBY_LIB_LOCATION
|
||||
$LOAD_PATH << File.dirname(__FILE__)
|
||||
|
||||
require 'vcenter_driver'
|
||||
|
||||
CONFIG = VCenterConf.new
|
||||
|
||||
host_id = ARGV[0]
|
||||
vm_type = ARGV[1]
|
||||
|
||||
begin
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
|
||||
cluster = Cluster.new(host_id, vi_client)
|
||||
|
||||
str_info , _ltime = cluster.monitor_vms(@host.id, vm_type)
|
||||
|
||||
puts str_info
|
||||
rescue StandardError => e
|
||||
message = "Monitoring of VM #{vm_id} on vCenter cluster #{cluster_name} " \
|
||||
" failed due to \"#{e.message}\"."
|
||||
OpenNebula.log_error(message)
|
||||
if VCenterDriver::CONFIG[:debug_information]
|
||||
STDERR.puts "#{message} #{e.backtrace}"
|
||||
end
|
||||
|
||||
exit(-1)
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
end
|
Loading…
Reference in New Issue
Block a user