From 74edd8b23dbb178d0009190abb6a10d46de7b3b3 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 15 Oct 2013 18:47:15 +0200 Subject: [PATCH] im-collectd: onehost sync allows specific hosts or cluster to update --- src/cli/one_helper/onehost_helper.rb | 11 ++++++++++- src/cli/onehost | 10 +++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 0692a9c71d..a190e7bb31 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -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 diff --git a/src/cli/onehost b/src/cli/onehost index 8f218abef0..145f3bc616 100755 --- a/src/cli/onehost +++ b/src/cli/onehost @@ -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