From 1932da5165ea6af7acc8d0b58734af094144a3ef Mon Sep 17 00:00:00 2001 From: Vincent Janelle Date: Tue, 10 Dec 2024 16:11:05 -0800 Subject: [PATCH] (#202) pass federations properly down from choria playbooks --- lib/mcollective/ddl/discoveryddl.rb | 6 +++--- lib/mcollective/discovery/delegate.rb | 4 +--- lib/mcollective/discovery/external.ddl | 2 +- lib/mcollective/rpc.rb | 1 - lib/mcollective/util.rb | 2 +- lib/mcollective/util/choria.rb | 2 +- lib/mcollective/util/playbook/nodes/mcollective_nodes.rb | 1 + 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/mcollective/ddl/discoveryddl.rb b/lib/mcollective/ddl/discoveryddl.rb index 73cd28ab..8ea09f8b 100644 --- a/lib/mcollective/ddl/discoveryddl.rb +++ b/lib/mcollective/ddl/discoveryddl.rb @@ -11,7 +11,7 @@ module DDL # :timeout => 2 # # discovery do - # capabilities [:classes, :facts, :identity, :agents, :compound] + # capabilities [:classes, :facts, :identity, :agents, :compound, :federations] # end class DiscoveryDDL < Base def discovery_interface @@ -25,10 +25,10 @@ def capabilities(*caps) raise "Discovery plugin capabilities can't be empty" if caps.empty? caps.each do |cap| - if [:classes, :facts, :identity, :agents, :compound].include?(cap) + if [:classes, :facts, :identity, :agents, :compound, :federations].include?(cap) @entities[:discovery][:capabilities] << cap else - raise "%s is not a valid capability, valid capabilities are :classes, :facts, :identity, :agents and :compound" % cap + raise "%s is not a valid capability, valid capabilities are :classes, :facts, :identity, :agents, :compound, and :federations" % cap end end end diff --git a/lib/mcollective/discovery/delegate.rb b/lib/mcollective/discovery/delegate.rb index 6e09326a..dc3753d2 100644 --- a/lib/mcollective/discovery/delegate.rb +++ b/lib/mcollective/discovery/delegate.rb @@ -39,9 +39,7 @@ def self.discover(filter, timeout, limit, client) cmd << "-S" << c.first["expr"] end - unless @config.federations.empty? - cmd << "--federations" << @config.federations.join(",") - end + cmd << "--federations" << @config.federations.join(",") unless @config.federations.empty? client.options.fetch(:discovery_options, []).each do |opt| cmd << "--do" << opt diff --git a/lib/mcollective/discovery/external.ddl b/lib/mcollective/discovery/external.ddl index a9b2a70c..dc2a039d 100644 --- a/lib/mcollective/discovery/external.ddl +++ b/lib/mcollective/discovery/external.ddl @@ -7,7 +7,7 @@ metadata :name => "external", :timeout => 2 discovery do - capabilities [:classes, :facts, :identity, :agents, :compound] + capabilities [:classes, :facts, :identity, :agents, :compound, :federations] end diff --git a/lib/mcollective/rpc.rb b/lib/mcollective/rpc.rb index 36255d7f..fb98dc57 100644 --- a/lib/mcollective/rpc.rb +++ b/lib/mcollective/rpc.rb @@ -26,7 +26,6 @@ def rpcoptions Helpers.add_simplerpc_options(parser, opts) end - end # Wrapper to create clients, supposed to be used as diff --git a/lib/mcollective/util.rb b/lib/mcollective/util.rb index f6a80a0a..f4e416b3 100644 --- a/lib/mcollective/util.rb +++ b/lib/mcollective/util.rb @@ -217,7 +217,7 @@ def self.default_options :discovery_method => nil, :discovery_options => Config.instance.default_discovery_options, :filter => empty_filter, - :federations => [] + :federations => Config.instance.federations } end diff --git a/lib/mcollective/util/choria.rb b/lib/mcollective/util/choria.rb index 1064a164..2865532a 100644 --- a/lib/mcollective/util/choria.rb +++ b/lib/mcollective/util/choria.rb @@ -97,7 +97,7 @@ def federated? # # @return [Array] def federation_collectives - if (@config.federations.length > 0) + if !@config.federations.empty? @config.federations elsif (override_networks = env_fetch("CHORIA_FED_COLLECTIVE", nil)) override_networks.split(",").map(&:strip).reject(&:empty?) diff --git a/lib/mcollective/util/playbook/nodes/mcollective_nodes.rb b/lib/mcollective/util/playbook/nodes/mcollective_nodes.rb index 3f0bb939..fbae609d 100644 --- a/lib/mcollective/util/playbook/nodes/mcollective_nodes.rb +++ b/lib/mcollective/util/playbook/nodes/mcollective_nodes.rb @@ -9,6 +9,7 @@ def initialize @facts = [] @classes = [] @identity = [] + @federations = [] @compound = nil end