1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

im-collectd: onehost sync allows specific hosts or cluster to update

This commit is contained in:
Jaime Melis 2013-10-15 18:47:15 +02:00
parent 97f63c3659
commit 74edd8b23d
2 changed files with 17 additions and 4 deletions

View File

@ -158,7 +158,9 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
NUM_THREADS = 15
def sync
def sync(host_ids, options)
cluster_id = options[:cluster]
# Get remote_dir (implies oneadmin group)
rc = OpenNebula::System.new(@client).get_configuration
return -1, rc.message if OpenNebula.is_error?(rc)
@ -187,7 +189,14 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
# Assign hosts to threads
i = 0
hs_threads = Array.new
pool.each do |host|
if host_ids
next if !host_ids.include?(host['ID'].to_i)
elsif cluster_id
next if host['CLUSTER_ID'].to_i != cluster_id
end
hs_threads[i % NUM_THREADS] ||= []
hs_threads[i % NUM_THREADS] << host['NAME']
i+=1

View File

@ -74,6 +74,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
}
CREAT_OPTIONS = [ IM, VMM, VNET, OneClusterHelper::CLUSTER ]
SYNC_OPTIONS = [ OneClusterHelper::CLUSTER ]
########################################################################
# Formatters for arguments
@ -166,11 +167,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
sync_desc = <<-EOT.unindent
Synchronizes probes in /var/lib/one/remotes ($ONE_LOCATION/var/remotes
in self-contained installations) with Hosts.
The copy is performed the next time the Host is monitored
Examples:
onehost sync
onehost sync -c myCluster
onehost sync host01,host02,host03
EOT
command :sync, sync_desc do
helper.sync
command :sync, sync_desc, [:range,:hostid_list, nil], :options=>SYNC_OPTIONS do
helper.sync(args[0],options)
end
list_desc = <<-EOT.unindent