choria-mcorpc-support 2.20.6 → 2.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29d095eecde9726e77979a330ff4ed2a27ac7912
4
- data.tar.gz: a6aa7aa304f84aa576e711e40184d492c245295e
3
+ metadata.gz: d5151bca988c13512d1ee9cb12fb125b05fa0d23
4
+ data.tar.gz: cb3874403af146e42bb62dfbc757214793304ff0
5
5
  SHA512:
6
- metadata.gz: da30c83fef47986f8acb747d284ace2ecc736cfd9f7045b938c51684c801837080b346dbcdde7ca27a692e00181bb4b616af1d172457312217d26bd0d113bc92
7
- data.tar.gz: ad9ca3e3fc6e99bad8eafd7a97764519d0e490644d9b80c39933b020d26c1f307ba4891e34d63bf8d79ac207533981dfa6a2a1bc201a99bb9ce9c4798747758c
6
+ metadata.gz: bfa78420e316f4b13d985e51564716877c9e85a3b0b7eaabd79c7c29758f7c4d155ad203c5698bcce744c5a9c9ed1ab49a573970c60840468ca08887c98e22bb
7
+ data.tar.gz: 61a065d3f880a3943ee0ea389730aabc8c4da5b790c26c8014df4b4861579448050c75c2119195e0d53cda089846b65405f6e3ab497a2215d5d7ef14a4ef9a2c
@@ -54,7 +54,7 @@ module MCollective
54
54
  require "mcollective/util"
55
55
  require "mcollective/validator"
56
56
 
57
- VERSION = "2.20.6".freeze
57
+ VERSION = "2.22.0".freeze
58
58
 
59
59
  def self.version
60
60
  VERSION
@@ -12,6 +12,8 @@ class MCollective::Application::Facts<MCollective::Application
12
12
  def show_single_fact_report(fact, facts, verbose=false)
13
13
  puts("Report for fact: #{fact}\n\n")
14
14
 
15
+ facts = stringify_facts_hash(facts)
16
+
15
17
  field_size = MCollective::Util.field_size(facts.keys)
16
18
  facts.keys.sort.each do |k|
17
19
  printf(" %-#{field_size}s found %d times\n", k, facts[k].size)
@@ -28,6 +30,12 @@ class MCollective::Application::Facts<MCollective::Application
28
30
  end
29
31
  end
30
32
 
33
+ def stringify_facts_hash(facts)
34
+ res = Hash.new([])
35
+ facts.each { |k, v| res[k.to_s] += v }
36
+ res
37
+ end
38
+
31
39
  def main
32
40
  rpcutil = rpcclient("rpcutil")
33
41
  rpcutil.progress = false
@@ -10,7 +10,7 @@ module MCollective
10
10
 
11
11
  begin
12
12
  load_application(appname)
13
- rescue Exception # rubocop:disable Lint/RescueException
13
+ rescue Exception => e # rubocop:disable Lint/RescueException
14
14
  e.backtrace.first << Util.colorize(:red, " <----")
15
15
  STDERR.puts "Application '%s' failed to load:" % appname
16
16
  STDERR.puts
@@ -98,6 +98,7 @@ module MCollective
98
98
 
99
99
  # avoid option parsers own internal version handling that sux
100
100
  parser.on("-v", "--verbose")
101
+ parser.on("--version")
101
102
 
102
103
  if original_extra_opts
103
104
  begin
@@ -37,7 +37,7 @@ module MCollective
37
37
  # aggregate summary(:value)
38
38
  # end
39
39
  # end
40
- class AgentDDL<Base
40
+ class AgentDDL < Base
41
41
  def initialize(plugin, plugintype=:agent, loadddl=true)
42
42
  @process_aggregate_functions = nil
43
43
 
@@ -65,18 +65,18 @@ module MCollective
65
65
  def summarize(&block)
66
66
  unless @config.mode == :server
67
67
  @process_aggregate_functions = true
68
- block.call
68
+ yield
69
69
  @process_aggregate_functions = nil
70
70
  end
71
71
  end
72
72
 
73
73
  # Sets the aggregate array for the given action
74
- def aggregate(function, format = {:format => nil})
74
+ def aggregate(function, format={:format => nil})
75
75
  raise(DDLValidationError, "Formats supplied to aggregation functions should be a hash") unless format.is_a?(Hash)
76
76
  raise(DDLValidationError, "Formats supplied to aggregation functions must have a :format key") unless format.keys.include?(:format)
77
77
  raise(DDLValidationError, "Functions supplied to aggregate should be a hash") unless function.is_a?(Hash)
78
78
 
79
- unless (function.keys.include?(:args)) && function[:args]
79
+ unless function.keys.include?(:args) && function[:args]
80
80
  raise DDLValidationError, "aggregate method for action '%s' missing a function parameter" % entities[@current_entity][:action]
81
81
  end
82
82
 
@@ -133,7 +133,7 @@ module MCollective
133
133
  # we set @current_entity so the input block can know what its talking
134
134
  # to, this is probably an epic hack, need to improve.
135
135
  @current_entity = name
136
- block.call if block_given?
136
+ yield if block_given?
137
137
  @current_entity = nil
138
138
  end
139
139
 
@@ -141,11 +141,13 @@ module MCollective
141
141
  # with args as a hash. This will only be active if the @process_aggregate_functions
142
142
  # is set to true which only happens in the #summarize block
143
143
  def method_missing(name, *args, &block)
144
- unless @process_aggregate_functions || is_function?(name)
145
- raise NoMethodError, "undefined local variable or method `#{name}'", caller
146
- end
144
+ super unless @process_aggregate_functions || is_function?(name)
145
+
146
+ {:function => name, :args => args}
147
+ end
147
148
 
148
- return {:function => name, :args => args}
149
+ def respond_to_missing?(method, *)
150
+ @process_aggregate_functions || is_function?(name) || super
149
151
  end
150
152
 
151
153
  # Checks if a method name matches a aggregate plugin.
@@ -169,7 +171,7 @@ module MCollective
169
171
 
170
172
  return unless input
171
173
 
172
- input.keys.each do |key|
174
+ input.each_key do |key|
173
175
  if key.is_a?(Symbol) && arguments.include?(key.to_s) && !input.include?(key.to_s)
174
176
  compat_arg = key.to_s
175
177
  else
@@ -228,7 +230,7 @@ module MCollective
228
230
  input = action_interface(action)[:input] || {}
229
231
  compatible_args = symbolize_basic_input_arguments(input, arguments)
230
232
 
231
- input.keys.each do |key|
233
+ input.each_key do |key|
232
234
  unless input[key][:optional]
233
235
  unless compatible_args.include?(key)
234
236
  raise DDLValidationError, "Action #{action} needs a #{key} argument"
@@ -42,7 +42,7 @@ module MCollective
42
42
  # the config dir and if that does not exist, default to
43
43
  # /etc/mcollective
44
44
  def help(template=nil)
45
- template = template_for_plugintype unless template
45
+ template ||= template_for_plugintype
46
46
  template = Util.templatepath(template) unless Util.absolute_path?(template)
47
47
 
48
48
  template = File.read(template)
@@ -52,14 +52,15 @@ module MCollective
52
52
  unless template == "metadata-help.erb"
53
53
  metadata_template = Util.templatepath("metadata-help.erb")
54
54
  metadata_template = File.read(metadata_template)
55
- metastring = ERB.new(metadata_template, 0, '%')
55
+ metastring = ERB.new(metadata_template, 0, "%")
56
56
  metastring = metastring.result(binding)
57
57
  end
58
58
 
59
- erb = ERB.new(template, 0, '%')
59
+ erb = ERB.new(template, 0, "%")
60
60
  erb.result(binding)
61
61
  end
62
62
 
63
+ # rubocop:disable Lint/DuplicateMethods, Style/TrivialAccessors
63
64
  def usage(usage_text)
64
65
  @usage = usage_text
65
66
  end
@@ -67,13 +68,13 @@ module MCollective
67
68
  def template_for_plugintype
68
69
  case @plugintype
69
70
  when :agent
70
- return "rpc-help.erb"
71
+ "rpc-help.erb"
71
72
  else
72
- if File.exists?(Util.templatepath("#{@plugintype}-help.erb"))
73
- return "#{@plugintype}-help.erb"
73
+ if File.exist?(Util.templatepath("#{@plugintype}-help.erb"))
74
+ "#{@plugintype}-help.erb"
74
75
  else
75
76
  # Default help template gets loaded if plugintype-help does not exist.
76
- return "metadata-help.erb"
77
+ "metadata-help.erb"
77
78
  end
78
79
  end
79
80
  end
@@ -91,8 +92,8 @@ module MCollective
91
92
  end
92
93
 
93
94
  def findddlfile(ddlname=nil, ddltype=nil)
94
- ddlname = @pluginname unless ddlname
95
- ddltype = @plugintype unless ddltype
95
+ ddlname ||= @pluginname
96
+ ddltype ||= @plugintype
96
97
 
97
98
  @config.libdir.each do |libdir|
98
99
  ddlfile = File.join([libdir, "mcollective", ddltype.to_s, "#{ddlname}.ddl"])
@@ -148,7 +149,7 @@ module MCollective
148
149
 
149
150
  return true
150
151
  rescue => e
151
- raise DDLValidationError, "Cannot validate input %s: %s" % [key, e.to_s]
152
+ raise DDLValidationError, "Cannot validate input %s: %s" % [key, e.to_s], e.backtrace
152
153
  end
153
154
 
154
155
  # Registers an input argument for a given action
@@ -170,17 +171,17 @@ module MCollective
170
171
  :optional => properties[:optional]}
171
172
 
172
173
  case properties[:type]
173
- when :string
174
- raise "Input type :string needs a :validation argument" unless properties.include?(:validation)
175
- raise "Input type :string needs a :maxlength argument" unless properties.include?(:maxlength)
174
+ when :string
175
+ raise "Input type :string needs a :validation argument" unless properties.include?(:validation)
176
+ raise "Input type :string needs a :maxlength argument" unless properties.include?(:maxlength)
176
177
 
177
- @entities[entity][:input][argument][:validation] = properties[:validation]
178
- @entities[entity][:input][argument][:maxlength] = properties[:maxlength]
178
+ @entities[entity][:input][argument][:validation] = properties[:validation]
179
+ @entities[entity][:input][argument][:maxlength] = properties[:maxlength]
179
180
 
180
- when :list
181
- raise "Input type :list needs a :list argument" unless properties.include?(:list)
181
+ when :list
182
+ raise "Input type :list needs a :list argument" unless properties.include?(:list)
182
183
 
183
- @entities[entity][:input][argument][:list] = properties[:list]
184
+ @entities[entity][:input][argument][:list] = properties[:list]
184
185
  end
185
186
  end
186
187
 
@@ -206,7 +207,7 @@ module MCollective
206
207
 
207
208
  valid_requirements = [:mcollective]
208
209
 
209
- requirement.keys.each do |key|
210
+ requirement.each_key do |key|
210
211
  unless valid_requirements.include?(key)
211
212
  raise "Requirement %s is not a valid requirement, only %s is supported" % [key, valid_requirements.join(", ")]
212
213
  end
@@ -27,17 +27,17 @@ module MCollective
27
27
  # :display_as => item.to_s.capitalize
28
28
  # end
29
29
  # end
30
- class DataDDL<Base
30
+ class DataDDL < Base
31
31
  def dataquery(input, &block)
32
32
  raise "Data queries need a :description" unless input.include?(:description)
33
33
  raise "Data queries can only have one definition" if @entities[:data]
34
34
 
35
- @entities[:data] = {:description => input[:description],
36
- :input => {},
37
- :output => {}}
35
+ @entities[:data] = {:description => input[:description],
36
+ :input => {},
37
+ :output => {}}
38
38
 
39
39
  @current_entity = :data
40
- block.call if block_given?
40
+ yield if block_given?
41
41
  @current_entity = nil
42
42
  end
43
43
 
@@ -13,7 +13,7 @@ module MCollective
13
13
  # discovery do
14
14
  # capabilities [:classes, :facts, :identity, :agents, :compound]
15
15
  # end
16
- class DiscoveryDDL<Base
16
+ class DiscoveryDDL < Base
17
17
  def discovery_interface
18
18
  @entities[:discovery]
19
19
  end
@@ -44,7 +44,7 @@ module MCollective
44
44
  @entities[:discovery] = {:capabilities => []}
45
45
 
46
46
  @current_entity = :discovery
47
- block.call if block_given?
47
+ yield if block_given?
48
48
  @current_entity = nil
49
49
  end
50
50
  end
@@ -1,6 +1,6 @@
1
1
  module MCollective
2
2
  module DDL
3
- class ValidatorDDL<Base
3
+ class ValidatorDDL < Base
4
4
  end
5
5
  end
6
6
  end
@@ -16,11 +16,13 @@ module MCollective
16
16
  @dependencies = configuration[:dependency] || []
17
17
  @target_path = File.expand_path(@path)
18
18
  @metadata, mcversion = PluginPackager.get_metadata(@path, "agent")
19
- @mcname = mcdependency[:mcname] || "mcollective"
19
+ @mcname = mcdependency[:mcname] || "mcollective"
20
20
  @mcversion = mcdependency[:mcversion] || mcversion
21
21
  @metadata[:version] = (configuration[:version] || @metadata[:version])
22
22
  @dependencies << {:name => "#{@mcname}-common", :version => @mcversion}
23
+ @agent_name = @metadata[:name].downcase
23
24
  @metadata[:name] = (configuration[:pluginname] || @metadata[:name]).downcase.gsub(/\s+|_/, "-")
25
+
24
26
  identify_packages
25
27
  end
26
28
 
@@ -38,27 +40,33 @@ module MCollective
38
40
  def agent
39
41
  agent = {
40
42
  :files => [],
43
+ :executable_files => [],
41
44
  :dependencies => @dependencies.clone,
42
45
  :description => "Agent plugin for #{@metadata[:name]}"
43
46
  }
44
47
 
45
48
  agentdir = File.join(@path, "agent")
46
49
 
47
- if (PluginPackager.check_dir_present(agentdir))
48
- ddls = Dir.glob(File.join(agentdir, "*.ddl"))
49
- agent[:files] = (Dir.glob(File.join(agentdir, "**", "**")) - ddls)
50
- else
51
- return nil
52
- end
50
+ return nil unless PluginPackager.check_dir_present(agentdir)
51
+
52
+ ddls = Dir.glob(File.join(agentdir, "*.{ddl,json}"))
53
+ agent[:files] = (Dir.glob(File.join(agentdir, "**", "**")) - ddls)
53
54
  agent[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :revision => @revision}
55
+
56
+ if @metadata[:provider] == "external"
57
+ agent[:executable_files] << File.join(agentdir, @agent_name)
58
+ end
59
+
54
60
  agent
55
61
  end
56
62
 
57
63
  # Obtain client package files and dependencies.
58
64
  def client
59
- client = {:files => [],
60
- :dependencies => @dependencies.clone,
61
- :description => "Client plugin for #{@metadata[:name]}"}
65
+ client = {
66
+ :files => [],
67
+ :dependencies => @dependencies.clone,
68
+ :description => "Client plugin for #{@metadata[:name]}"
69
+ }
62
70
 
63
71
  clientdir = File.join(@path, "application")
64
72
  aggregatedir = File.join(@path, "aggregate")
@@ -72,14 +80,14 @@ module MCollective
72
80
  # Obtain common package files and dependencies.
73
81
  def common
74
82
  common = {
75
- :files =>[],
83
+ :files => [],
76
84
  :dependencies => @dependencies.clone,
77
85
  :description => "Common libraries for #{@metadata[:name]}"
78
86
  }
79
87
 
80
88
  datadir = File.join(@path, "data", "**")
81
89
  utildir = File.join(@path, "util", "**", "**")
82
- ddldir = File.join(@path, "agent", "*.ddl")
90
+ ddldir = File.join(@path, "agent", "*.{ddl,json}")
83
91
  validatordir = File.join(@path, "validator", "**")
84
92
 
85
93
  [datadir, utildir, validatordir, ddldir].each do |directory|
@@ -88,9 +96,11 @@ module MCollective
88
96
 
89
97
  # We fail if there is no ddl file present
90
98
  if common[:files].grep(/^.*\.ddl$/).empty?
91
- raise "cannot create package - No ddl file found in #{File.join(@path, "agent")}"
99
+ raise "cannot create package - No ddl file found in #{File.join(@path, 'agent')}"
92
100
  end
93
101
 
102
+ common[:files].uniq!
103
+
94
104
  common[:files].empty? ? nil : common
95
105
  end
96
106
  end
@@ -3,11 +3,11 @@ require "yaml"
3
3
  module MCollective
4
4
  module PluginPackager
5
5
  class ForgePackager
6
- def initialize(plugin, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = nil, module_template = nil)
6
+ def initialize(plugin, pluginpath=nil, signature=nil, verbose=false, keep_artifacts=nil, module_template=nil)
7
7
  @plugin = plugin
8
8
  @verbose = verbose
9
9
  @keep_artifacts = keep_artifacts
10
- @module_template = module_template || File.join(File.dirname(__FILE__), 'templates', 'forge')
10
+ @module_template = module_template || File.join(File.dirname(__FILE__), "templates", "forge")
11
11
  end
12
12
 
13
13
  def which(cmd)
@@ -18,11 +18,11 @@ module MCollective
18
18
  return exe if File.executable?(exe) && !File.directory?(exe)
19
19
  end
20
20
  end
21
- return nil
21
+ nil
22
22
  end
23
23
 
24
24
  def create_packages
25
- assert_new_enough_puppet
25
+ assert_new_enough_pdk
26
26
  validate_environment
27
27
 
28
28
  begin
@@ -44,7 +44,7 @@ module MCollective
44
44
  ensure
45
45
  if @keep_artifacts
46
46
  puts("Keeping build artifacts")
47
- puts("Build artifacts saved in %s" % @tmpdir)
47
+ puts("Build artifacts saved in %s" % @tmpdir)
48
48
  else
49
49
  cleanup_tmpdirs
50
50
  end
@@ -81,7 +81,15 @@ module MCollective
81
81
  def filelist(type)
82
82
  @plugin.packagedata[type][:files].map do |file|
83
83
  file.gsub(/^\.\//, "") unless File.directory?(file)
84
- end.compact
84
+ end.compact.uniq
85
+ rescue
86
+ []
87
+ end
88
+
89
+ def executablelist(type)
90
+ @plugin.packagedata[type][:executable_files].map do |file|
91
+ file.gsub(/^\.\//, "") unless File.directory?(file)
92
+ end.compact.uniq
85
93
  rescue
86
94
  []
87
95
  end
@@ -100,11 +108,12 @@ module MCollective
100
108
  {
101
109
  hierakey(:config_name) => @plugin.metadata[:name].downcase,
102
110
  hierakey(:common_files) => filelist(:common),
111
+ hierakey(:executable_files) => executablelist(:agent),
103
112
  hierakey(:common_directories) => dirlist(:common),
104
113
  hierakey(:server_files) => filelist(:agent),
105
114
  hierakey(:server_directories) => dirlist(:agent),
106
115
  hierakey(:client_files) => filelist(:client),
107
- hierakey(:client_directories) => dirlist(:client),
116
+ hierakey(:client_directories) => dirlist(:client)
108
117
  }.merge(module_override_data)
109
118
  end
110
119
 
@@ -123,7 +132,7 @@ module MCollective
123
132
  end
124
133
 
125
134
  def copy_module_files
126
- @plugin.packagedata.each do |klass, data|
135
+ @plugin.packagedata.each_value do |data|
127
136
  data[:files].each do |file|
128
137
  clean_dest_file = file.gsub("./lib/mcollective", "")
129
138
  dest_dir = File.expand_path(File.join(@tmpdir, "files", "mcollective", File.dirname(clean_dest_file)))
@@ -142,13 +151,18 @@ module MCollective
142
151
  agent_name = File.basename(file, ".ddl")
143
152
  json_file = File.join(agent_dir, "%s.json" % agent_name)
144
153
 
154
+ if File.exist?(json_file)
155
+ Log.warn("JSON DDL %s already exist, not regenerating from the %s" % [json_file, agent_name])
156
+ next
157
+ end
158
+
145
159
  ddl = DDL.new(agent_name, :agent, false)
146
160
  ddl.instance_eval(File.read(file))
147
161
 
148
162
  data = {
149
163
  "$schema" => "https://choria.io/schemas/mcorpc/ddl/v1/agent.json",
150
164
  "metadata" => ddl.meta,
151
- "actions" => [],
165
+ "actions" => []
152
166
  }
153
167
 
154
168
  ddl.actions.sort.each do |action|
@@ -165,7 +179,7 @@ module MCollective
165
179
  end
166
180
 
167
181
  def render_templates
168
- templates = Dir.chdir(@module_template) do |path|
182
+ templates = Dir.chdir(@module_template) do |_path|
169
183
  Dir.glob("**/*.erb")
170
184
  end
171
185
 
@@ -177,69 +191,62 @@ module MCollective
177
191
  end
178
192
 
179
193
  def render_template(infile, outfile)
180
- begin
181
- erb = ERB.new(File.read(infile), nil, "-")
182
- File.open(outfile, "w") do |f|
183
- f.puts erb.result(binding)
184
- end
185
- rescue
186
- STDERR.puts("Could not render template %s to %s" % [infile, outfile])
187
- raise
194
+ erb = ERB.new(File.read(infile), nil, "-")
195
+ File.open(outfile, "w") do |f|
196
+ f.puts erb.result(binding)
188
197
  end
198
+ rescue
199
+ STDERR.puts("Could not render template %s to %s" % [infile, outfile])
200
+ raise
189
201
  end
190
202
 
191
203
  def validate_environment
192
204
  raise("Supplying a vendor is required, please use --vendor") if @plugin.vendor == "Puppet Labs"
193
- raise("Vendor names may not have a space in them, please specify a valid vendor using --vendor") if @plugin.vendor.match(" ")
205
+ raise("Vendor names may not have a space in them, please specify a valid vendor using --vendor") if @plugin.vendor.include?(" ")
194
206
  end
195
207
 
196
- def assert_new_enough_puppet
197
- puppet_bin = which("puppet")
198
- puppet_bin = "/opt/puppetlabs/bin/puppet" if !puppet_bin
199
- if !puppet_bin
200
- raise("Cannot build package. 'puppet' not found on path, and '/opt/puppetlabs/bin/puppet' is not present on the system.")
201
- end
208
+ def pdk_path
209
+ pdk_bin = which("pdk")
210
+ pdk_bin ||= "/opt/puppetlabs/pdk/bin/pdk"
202
211
 
203
- s = Shell.new("#{puppet_bin} --version")
212
+ pdk_bin
213
+ end
214
+
215
+ def assert_new_enough_pdk
216
+ s = Shell.new("#{pdk_path} --version")
204
217
  s.runcommand
205
218
  actual_version = s.stdout.chomp
206
- required_version = '4.5.1'
219
+ required_version = "1.12.0"
207
220
 
208
221
  if Util.versioncmp(actual_version, required_version) < 0
209
- raise("Cannot build package. puppet #{required_version} or greater required. We have #{actual_version}.")
222
+ raise("Cannot build package. pdk #{required_version} or greater required. We have #{actual_version}.")
210
223
  end
211
224
  end
212
225
 
213
226
  def run_build
214
- begin
215
- PluginPackager.execute_verbosely(@verbose) do
216
- Dir.chdir(@tmpdir) do
217
- PluginPackager.safe_system('pdk build --force')
218
- end
227
+ PluginPackager.execute_verbosely(@verbose) do
228
+ Dir.chdir(@tmpdir) do
229
+ PluginPackager.safe_system("#{pdk_path} build --force")
219
230
  end
220
- rescue
221
- STDERR.puts("Build process has failed")
222
- raise
223
231
  end
232
+ rescue
233
+ STDERR.puts("Build process has failed")
234
+ raise
224
235
  end
225
236
 
226
237
  def move_package
227
- begin
228
- package_file = File.join(@tmpdir, "pkg", module_file_name)
229
- FileUtils.cp(package_file, ".")
230
- rescue
231
- STDERR.puts("Could not copy package to working directory")
232
- raise
233
- end
238
+ package_file = File.join(@tmpdir, "pkg", module_file_name)
239
+ FileUtils.cp(package_file, ".")
240
+ rescue
241
+ STDERR.puts("Could not copy package to working directory")
242
+ raise
234
243
  end
235
244
 
236
245
  def cleanup_tmpdirs
237
- begin
238
- FileUtils.rm_r(@tmpdir) if File.directory?(@tmpdir)
239
- rescue
240
- STDERR.puts("Could not remove temporary build directory %s" % [@tmpdir])
241
- raise
242
- end
246
+ FileUtils.rm_r(@tmpdir) if File.directory?(@tmpdir)
247
+ rescue
248
+ STDERR.puts("Could not remove temporary build directory %s" % [@tmpdir])
249
+ raise
243
250
  end
244
251
  end
245
252
  end
@@ -6,6 +6,7 @@ class <%= module_name %> (
6
6
  Array[String] $server_directories = [],
7
7
  Array[String] $common_files = [],
8
8
  Array[String] $common_directories = [],
9
+ Array[String] $executable_files = [],
9
10
  Boolean $manage_gem_dependencies = true,
10
11
  Hash $gem_dependencies = {},
11
12
  Boolean $manage_package_dependencies = true,
@@ -26,6 +27,7 @@ class <%= module_name %> (
26
27
  client_files => $client_files,
27
28
  server_files => $server_files,
28
29
  common_files => $common_files,
30
+ executable_files => $executable_files,
29
31
  client_directories => $client_directories,
30
32
  server_directories => $server_directories,
31
33
  common_directories => $common_directories,
@@ -169,6 +169,7 @@ module MCollective
169
169
  else
170
170
  config_paths << "/etc/puppetlabs/mcollective/client.cfg"
171
171
  config_paths << "/etc/mcollective/client.cfg"
172
+ config_paths << "/usr/local/etc/mcollective/client.cfg"
172
173
  end
173
174
 
174
175
  config_paths
@@ -188,22 +189,25 @@ module MCollective
188
189
  config_paths << File.join(choria_windows_prefix, "etc", "client.conf")
189
190
  else
190
191
  config_paths << "/etc/choria/client.conf"
192
+ config_paths << "/usr/local/etc/choria/client.conf"
191
193
  end
192
194
 
193
195
  config_paths
194
196
  end
195
197
 
196
- # Picks the default user config file, pririties are first Choria ones then old MCollective ones
198
+ # Picks the default user config file, priorities are first Choria ones then old MCollective ones
197
199
  #
198
200
  # In roughly this order, first to exist is used:
199
201
  #
200
202
  # - ~/.choriarc
201
203
  # - APPData/ChoriaIO/choria/etc/client.conf on windows
202
- # - /etc/choria/client.conf on unix
204
+ # - /etc/choria/client.conf then
205
+ # - /usr/local/etc/choria/client.conf on unix
203
206
  # - ~/.mcollective
204
207
  # - APPData/PuppetLabs/mcollective/etc/client.cfg on windows
205
208
  # - /etc/puppetlabs/mcollective/client.cfg
206
209
  # - /etc/mcollective/client.cfg
210
+ # - /usr/local/etc/mcollective/client.cfg
207
211
  def self.config_file_for_user
208
212
  config_paths = choria_config_paths_for_user + mcollective_config_paths_for_user
209
213
  found = config_paths.find_index { |file| File.readable?(file) } || 0
@@ -57,7 +57,7 @@ module MCollective
57
57
  Validator.load_validators
58
58
 
59
59
  begin
60
- if [:integer, :boolean, :float, :number, :string].include?(validation)
60
+ if [:integer, :boolean, :float, :number, :string, :array, :hash].include?(validation)
61
61
  Validator.typecheck(validator, validation)
62
62
 
63
63
  else
@@ -76,7 +76,7 @@ module MCollective
76
76
  end
77
77
  end
78
78
  rescue => e
79
- raise ValidatorError, e.to_s
79
+ raise ValidatorError, e.to_s, e.backtrace
80
80
  end
81
81
  end
82
82
  end
@@ -2,7 +2,7 @@ module MCollective
2
2
  module Validator
3
3
  class ArrayValidator
4
4
  def self.validate(validator, array)
5
- raise ValidatorError, "value should be one of %s" % [ array.join(", ") ] unless array.include?(validator)
5
+ raise ValidatorError, "value should be one of %s" % [array.join(", ")] unless array.include?(validator)
6
6
  end
7
7
  end
8
8
  end
@@ -1,15 +1,13 @@
1
1
  module MCollective
2
2
  module Validator
3
3
  class Ipv4addressValidator
4
- require 'ipaddr'
4
+ require "ipaddr"
5
5
 
6
6
  def self.validate(validator)
7
- begin
8
- ip = IPAddr.new(validator)
9
- raise ValidatorError, "value should be an ipv4 adddress" unless ip.ipv4?
10
- rescue
11
- raise ValidatorError, "value should be an ipv4 address"
12
- end
7
+ ip = IPAddr.new(validator)
8
+ raise ValidatorError, "value should be an ipv4 adddress" unless ip.ipv4?
9
+ rescue
10
+ raise ValidatorError, "value should be an ipv4 address"
13
11
  end
14
12
  end
15
13
  end
@@ -1,15 +1,13 @@
1
1
  module MCollective
2
2
  module Validator
3
3
  class Ipv6addressValidator
4
- require 'ipaddr'
4
+ require "ipaddr"
5
5
 
6
6
  def self.validate(validator)
7
- begin
8
- ip = IPAddr.new(validator)
9
- raise ValidatorError, "value should be an ipv6 adddress" unless ip.ipv6?
10
- rescue
11
- raise ValidatorError, "value should be an ipv6 address"
12
- end
7
+ ip = IPAddr.new(validator)
8
+ raise ValidatorError, "value should be an ipv6 adddress" unless ip.ipv6?
9
+ rescue
10
+ raise ValidatorError, "value should be an ipv6 address"
13
11
  end
14
12
  end
15
13
  end
@@ -4,7 +4,7 @@ module MCollective
4
4
  def self.validate(validator)
5
5
  raise ValidatorError, "value should be a String" unless validator.is_a?(String)
6
6
 
7
- ['`', '$', ';', '|', '&&', '>', '<'].each do |chr|
7
+ ["`", "$", ";", "|", "&&", ">", "<"].each do |chr|
8
8
  raise ValidatorError, "value should not have #{chr} in it" if validator.match(Regexp.escape(chr))
9
9
  end
10
10
  end
@@ -2,25 +2,29 @@ module MCollective
2
2
  module Validator
3
3
  class TypecheckValidator
4
4
  def self.validate(validator, validation_type)
5
- raise ValidatorError, "value should be a #{validation_type.to_s}" unless check_type(validator, validation_type)
5
+ raise ValidatorError, "value should be a #{validation_type}" unless check_type(validator, validation_type)
6
6
  end
7
7
 
8
8
  def self.check_type(validator, validation_type)
9
9
  case validation_type
10
- when Class
11
- validator.is_a?(validation_type)
12
- when :integer
13
- validator.is_a?(Integer)
14
- when :float
15
- validator.is_a?(Float)
16
- when :number
17
- validator.is_a?(Numeric)
18
- when :string
19
- validator.is_a?(String)
20
- when :boolean
21
- [TrueClass, FalseClass].include?(validator.class)
22
- else
23
- false
10
+ when Class
11
+ validator.is_a?(validation_type)
12
+ when :integer
13
+ validator.is_a?(Integer)
14
+ when :float
15
+ validator.is_a?(Float)
16
+ when :number
17
+ validator.is_a?(Numeric)
18
+ when :string
19
+ validator.is_a?(String)
20
+ when :boolean
21
+ [TrueClass, FalseClass].include?(validator.class)
22
+ when :array
23
+ validator.is_a?(Array)
24
+ when :hash
25
+ validator.is_a?(Hash)
26
+ else
27
+ false
24
28
  end
25
29
  end
26
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: choria-mcorpc-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.20.6
4
+ version: 2.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - R.I.Pienaar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-19 00:00:00.000000000 Z
11
+ date: 2020-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.5.0
39
+ version: '0.6'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.5.0
46
+ version: '0.6'
47
47
  description: Libraries enabling Ruby support for the Choria Orchestration Server
48
48
  email: rip@devco.net
49
49
  executables: