mcollective-client 2.0.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mcollective-client might be problematic. Click here for more details.

Files changed (140) hide show
  1. data/lib/mcollective.rb +32 -23
  2. data/lib/mcollective/agent.rb +5 -0
  3. data/lib/mcollective/agents.rb +5 -16
  4. data/lib/mcollective/aggregate.rb +61 -0
  5. data/lib/mcollective/aggregate/base.rb +40 -0
  6. data/lib/mcollective/aggregate/result.rb +9 -0
  7. data/lib/mcollective/aggregate/result/base.rb +25 -0
  8. data/lib/mcollective/aggregate/result/collection_result.rb +19 -0
  9. data/lib/mcollective/aggregate/result/numeric_result.rb +13 -0
  10. data/lib/mcollective/application.rb +7 -4
  11. data/lib/mcollective/applications.rb +3 -14
  12. data/lib/mcollective/cache.rb +145 -0
  13. data/lib/mcollective/client.rb +10 -87
  14. data/lib/mcollective/config.rb +22 -8
  15. data/lib/mcollective/data.rb +87 -0
  16. data/lib/mcollective/data/base.rb +67 -0
  17. data/lib/mcollective/data/result.rb +40 -0
  18. data/lib/mcollective/ddl.rb +113 -0
  19. data/lib/mcollective/ddl/agentddl.rb +185 -0
  20. data/lib/mcollective/ddl/base.rb +220 -0
  21. data/lib/mcollective/ddl/dataddl.rb +56 -0
  22. data/lib/mcollective/ddl/discoveryddl.rb +52 -0
  23. data/lib/mcollective/ddl/validatorddl.rb +6 -0
  24. data/lib/mcollective/discovery.rb +143 -0
  25. data/lib/mcollective/generators.rb +7 -0
  26. data/lib/mcollective/generators/agent_generator.rb +51 -0
  27. data/lib/mcollective/generators/base.rb +46 -0
  28. data/lib/mcollective/generators/data_generator.rb +51 -0
  29. data/lib/mcollective/generators/templates/action_snippet.erb +13 -0
  30. data/lib/mcollective/generators/templates/data_input_snippet.erb +7 -0
  31. data/lib/mcollective/generators/templates/ddl.erb +8 -0
  32. data/lib/mcollective/generators/templates/plugin.erb +7 -0
  33. data/lib/mcollective/logger/console_logger.rb +15 -15
  34. data/lib/mcollective/matcher.rb +167 -0
  35. data/lib/mcollective/matcher/parser.rb +60 -25
  36. data/lib/mcollective/matcher/scanner.rb +156 -78
  37. data/lib/mcollective/message.rb +47 -6
  38. data/lib/mcollective/monkey_patches.rb +17 -0
  39. data/lib/mcollective/optionparser.rb +18 -1
  40. data/lib/mcollective/pluginmanager.rb +3 -3
  41. data/lib/mcollective/pluginpackager.rb +10 -3
  42. data/lib/mcollective/pluginpackager/agent_definition.rb +28 -20
  43. data/lib/mcollective/pluginpackager/standard_definition.rb +11 -9
  44. data/lib/mcollective/registration/base.rb +3 -1
  45. data/lib/mcollective/rpc.rb +18 -24
  46. data/lib/mcollective/rpc/agent.rb +37 -113
  47. data/lib/mcollective/rpc/client.rb +186 -64
  48. data/lib/mcollective/rpc/helpers.rb +42 -80
  49. data/lib/mcollective/rpc/progress.rb +3 -3
  50. data/lib/mcollective/rpc/reply.rb +37 -13
  51. data/lib/mcollective/rpc/request.rb +17 -6
  52. data/lib/mcollective/rpc/result.rb +9 -5
  53. data/lib/mcollective/rpc/stats.rb +71 -24
  54. data/lib/mcollective/security/base.rb +41 -34
  55. data/lib/mcollective/shell.rb +1 -1
  56. data/lib/mcollective/ssl.rb +34 -0
  57. data/lib/mcollective/util.rb +194 -23
  58. data/lib/mcollective/validator.rb +80 -0
  59. data/spec/fixtures/util/1.in +10 -0
  60. data/spec/fixtures/util/1.out +10 -0
  61. data/spec/fixtures/util/2.in +1 -0
  62. data/spec/fixtures/util/2.out +1 -0
  63. data/spec/fixtures/util/3.in +1 -0
  64. data/spec/fixtures/util/3.out +2 -0
  65. data/spec/fixtures/util/4.in +5 -0
  66. data/spec/fixtures/util/4.out +9 -0
  67. data/spec/spec.opts +1 -1
  68. data/spec/spec_helper.rb +2 -0
  69. data/spec/unit/agents_spec.rb +34 -19
  70. data/spec/unit/aggregate/base_spec.rb +57 -0
  71. data/spec/unit/aggregate/result/base_spec.rb +28 -0
  72. data/spec/unit/aggregate/result/collection_result_spec.rb +18 -0
  73. data/spec/unit/aggregate/result/numeric_result_spec.rb +22 -0
  74. data/spec/unit/aggregate_spec.rb +110 -0
  75. data/spec/unit/application_spec.rb +8 -3
  76. data/spec/unit/applications_spec.rb +2 -2
  77. data/spec/unit/cache_spec.rb +115 -0
  78. data/spec/unit/client_spec.rb +78 -0
  79. data/spec/unit/config_spec.rb +32 -34
  80. data/spec/unit/data/base_spec.rb +90 -0
  81. data/spec/unit/data/result_spec.rb +64 -0
  82. data/spec/unit/data_spec.rb +158 -0
  83. data/spec/unit/ddl/agentddl_spec.rb +217 -0
  84. data/spec/unit/{rpc/ddl_spec.rb → ddl/base_spec.rb} +238 -224
  85. data/spec/unit/ddl/dataddl_spec.rb +65 -0
  86. data/spec/unit/ddl/discoveryddl_spec.rb +58 -0
  87. data/spec/unit/ddl_spec.rb +84 -0
  88. data/spec/unit/discovery_spec.rb +196 -0
  89. data/spec/unit/facts/base_spec.rb +1 -1
  90. data/spec/unit/generators/agent_generator_spec.rb +72 -0
  91. data/spec/unit/generators/base_spec.rb +83 -0
  92. data/spec/unit/generators/data_generator_spec.rb +37 -0
  93. data/spec/unit/generators/snippets/agent_ddl +19 -0
  94. data/spec/unit/generators/snippets/data_ddl +20 -0
  95. data/spec/unit/logger/console_logger_spec.rb +76 -0
  96. data/spec/unit/logger/syslog_logger_spec.rb +2 -2
  97. data/spec/unit/matcher/parser_spec.rb +27 -10
  98. data/spec/unit/matcher/scanner_spec.rb +108 -5
  99. data/spec/unit/matcher_spec.rb +260 -0
  100. data/spec/unit/message_spec.rb +35 -13
  101. data/spec/unit/optionparser_spec.rb +2 -2
  102. data/spec/unit/pluginpackager/agent_definition_spec.rb +59 -42
  103. data/spec/unit/pluginpackager/standard_definition_spec.rb +10 -8
  104. data/spec/unit/pluginpackager_spec.rb +131 -0
  105. data/spec/unit/plugins/mcollective/aggregate/average_spec.rb +45 -0
  106. data/spec/unit/plugins/mcollective/aggregate/sum_spec.rb +31 -0
  107. data/spec/unit/plugins/mcollective/aggregate/summary_spec.rb +45 -0
  108. data/spec/unit/plugins/mcollective/connector/activemq_spec.rb +1 -1
  109. data/spec/unit/plugins/mcollective/connector/rabbitmq_spec.rb +478 -0
  110. data/spec/unit/plugins/mcollective/connector/stomp_spec.rb +2 -0
  111. data/spec/unit/plugins/mcollective/data/agent_data_spec.rb +43 -0
  112. data/spec/unit/plugins/mcollective/data/fstat_data_spec.rb +135 -0
  113. data/spec/unit/plugins/mcollective/discovery/flatfile_spec.rb +48 -0
  114. data/spec/unit/plugins/mcollective/discovery/mc_spec.rb +40 -0
  115. data/spec/unit/plugins/mcollective/packagers/debpackage_packager_spec.rb +41 -15
  116. data/spec/unit/plugins/mcollective/packagers/ospackage_spec.rb +1 -1
  117. data/spec/unit/plugins/mcollective/packagers/rpmpackage_packager_spec.rb +22 -38
  118. data/spec/unit/plugins/mcollective/validator/array_validator_spec.rb +19 -0
  119. data/spec/unit/plugins/mcollective/validator/ipv4address_validator_spec.rb +19 -0
  120. data/spec/unit/plugins/mcollective/validator/ipv6address_validator_spec.rb +19 -0
  121. data/spec/unit/plugins/mcollective/validator/length_validator_spec.rb +19 -0
  122. data/spec/unit/plugins/mcollective/validator/regex_validator_spec.rb +19 -0
  123. data/spec/unit/plugins/mcollective/validator/shellsafe_validator_spec.rb +21 -0
  124. data/spec/unit/plugins/mcollective/validator/typecheck_validator_spec.rb +23 -0
  125. data/spec/unit/registration/base_spec.rb +1 -1
  126. data/spec/unit/rpc/actionrunner_spec.rb +2 -2
  127. data/spec/unit/rpc/agent_spec.rb +41 -65
  128. data/spec/unit/rpc/client_spec.rb +430 -134
  129. data/spec/unit/rpc/reply_spec.rb +31 -1
  130. data/spec/unit/rpc/request_spec.rb +33 -12
  131. data/spec/unit/rpc/result_spec.rb +7 -0
  132. data/spec/unit/rpc/stats_spec.rb +14 -14
  133. data/spec/unit/rpc_spec.rb +16 -0
  134. data/spec/unit/security/base_spec.rb +8 -8
  135. data/spec/unit/ssl_spec.rb +20 -2
  136. data/spec/unit/string_spec.rb +15 -0
  137. data/spec/unit/util_spec.rb +141 -21
  138. data/spec/unit/validator_spec.rb +67 -0
  139. metadata +145 -7
  140. data/lib/mcollective/rpc/ddl.rb +0 -258
@@ -19,6 +19,7 @@ module MCollective
19
19
  # options[:options] - the normal client options hash
20
20
  # options[:ttl] - the maximum amount of seconds this message can be valid for
21
21
  # options[:expected_msgid] - in the case of replies this is the msgid it is expecting in the replies
22
+ # options[:requestid] - specific request id to use else one will be generated
22
23
  def initialize(payload, message, options = {})
23
24
  options = {:base64 => false,
24
25
  :agent => nil,
@@ -29,11 +30,12 @@ module MCollective
29
30
  :options => {},
30
31
  :ttl => 60,
31
32
  :expected_msgid => nil,
33
+ :requestid => nil,
32
34
  :collective => nil}.merge(options)
33
35
 
34
36
  @payload = payload
35
37
  @message = message
36
- @requestid = nil
38
+ @requestid = options[:requestid]
37
39
  @discovered_hosts = nil
38
40
  @reply_to = nil
39
41
 
@@ -72,15 +74,21 @@ module MCollective
72
74
  # this is to force a workflow that doesnt not yield in a mistake when someone might assume
73
75
  # direct_addressing is enabled when its not.
74
76
  def type=(type)
77
+ raise "Unknown message type #{type}" unless VALIDTYPES.include?(type)
78
+
75
79
  if type == :direct_request
76
80
  raise "Direct requests is not enabled using the direct_addressing config option" unless Config.instance.direct_addressing
77
81
 
78
82
  unless @discovered_hosts && !@discovered_hosts.empty?
79
83
  raise "Can only set type to :direct_request if discovered_hosts have been set"
80
84
  end
81
- end
82
85
 
83
- raise "Unknown message type #{type}" unless VALIDTYPES.include?(type)
86
+ # clear out the filter, custom discovery sources might interpret the filters
87
+ # different than the remote mcollectived and in directed mode really the only
88
+ # filter that matters is the agent filter
89
+ @filter = Util.empty_filter
90
+ @filter["agent"] << @agent
91
+ end
84
92
 
85
93
  @type = type
86
94
  end
@@ -131,13 +139,43 @@ module MCollective
131
139
  @requestid = request.payload[:requestid]
132
140
  @payload = PluginManager["security_plugin"].encodereply(agent, payload, requestid, request.payload[:callerid])
133
141
  when :request, :direct_request
134
- @requestid = create_reqid
142
+ validate_compount_filter(@filter["compound"]) unless @filter["compound"].empty?
143
+
144
+ @requestid = create_reqid unless @requestid
135
145
  @payload = PluginManager["security_plugin"].encoderequest(Config.instance.identity, payload, requestid, filter, agent, collective, ttl)
136
146
  else
137
147
  raise "Cannot encode #{type} messages"
138
148
  end
139
149
  end
140
150
 
151
+ def validate_compount_filter(compound_filter)
152
+ compound_filter.each do |filter|
153
+ filter.each do |statement|
154
+ if statement["fstatement"]
155
+ functionname = statement["fstatement"]["name"]
156
+ pluginname = Data.pluginname(functionname)
157
+ value = statement["fstatement"]["value"]
158
+
159
+ begin
160
+ ddl = DDL.new(pluginname, :data)
161
+ rescue
162
+ raise DDLValidationError, "Could not find DDL for data plugin #{pluginname}, cannot use #{functionname}() in discovery"
163
+ end
164
+
165
+ # parses numbers and booleans entered as strings into proper
166
+ # types of data so that DDL validation will pass
167
+ statement["fstatement"]["params"] = Data.ddl_transform_input(ddl, statement["fstatement"]["params"])
168
+
169
+ Data.ddl_validate(ddl, statement["fstatement"]["params"])
170
+
171
+ unless value && Data.ddl_has_output?(ddl, value)
172
+ raise DDLValidationError, "#{functionname}() does not return a #{value} value"
173
+ end
174
+ end
175
+ end
176
+ end
177
+ end
178
+
141
179
  def decode!
142
180
  raise "Cannot decode message type #{type}" unless [:request, :reply].include?(type)
143
181
 
@@ -183,7 +221,7 @@ module MCollective
183
221
  # send it as is.
184
222
  if @discovered_hosts && Config.instance.direct_addressing
185
223
  if @discovered_hosts.size <= Config.instance.direct_addressing_threshold
186
- @type = :direct_request
224
+ self.type = :direct_request
187
225
  Log.debug("Handling #{requestid} as a direct request")
188
226
  end
189
227
 
@@ -195,7 +233,10 @@ module MCollective
195
233
  end
196
234
 
197
235
  def create_reqid
198
- Digest::MD5.hexdigest("#{Config.instance.identity}-#{Time.now.to_f}-#{agent}-#{collective}")
236
+ # we gsub out the -s so that the format of the id does not
237
+ # change from previous versions, these should just be more
238
+ # unique than previous ones
239
+ SSL.uuid.gsub("-", "")
199
240
  end
200
241
  end
201
242
  end
@@ -1,3 +1,11 @@
1
+ # start_with? was introduced in 1.8.7, we need to support
2
+ # 1.8.5 and 1.8.6
3
+ class String
4
+ def start_with?(str)
5
+ return self[0 .. (str.length-1)] == str
6
+ end unless method_defined?("start_with?")
7
+ end
8
+
1
9
  # Make arrays of Symbols sortable
2
10
  class Symbol
3
11
  include Comparable
@@ -51,6 +59,15 @@ class Array
51
59
  end unless method_defined?(:in_groups_of)
52
60
  end
53
61
 
62
+ class String
63
+ def bytes(&block)
64
+ # This should not be necessary, really ...
65
+ require 'enumerator'
66
+ return to_enum(:each_byte) unless block_given?
67
+ each_byte(&block)
68
+ end unless method_defined?(:bytes)
69
+ end
70
+
54
71
  class Dir
55
72
  def self.mktmpdir(prefix_suffix=nil, tmpdir=nil)
56
73
  case prefix_suffix
@@ -86,7 +86,7 @@ module MCollective
86
86
  end
87
87
 
88
88
  @parser.on('-S', '--select FILTER', 'Compound filter combining facts and classes') do |f|
89
- @options[:filter]["compound"] << MCollective::Matcher::Parser.new(f).execution_stack
89
+ @options[:filter]["compound"] << Matcher.create_compound_callstack(f)
90
90
  end
91
91
 
92
92
  @parser.on('-F', '--wf', '--with-fact fact=val', 'Match hosts with a certain fact') do |f|
@@ -152,6 +152,23 @@ module MCollective
152
152
  @parser.on('--reply-to TARGET', 'Set a custom target for replies') do |v|
153
153
  @options[:reply_to] = v
154
154
  end
155
+
156
+ @parser.on('--dm', '--disc-method METHOD', 'Which discovery method to use') do |v|
157
+ raise "Discovery method is already set by a competing option" if @options[:discovery_method] && @options[:discovery_method] != v
158
+ @options[:discovery_method] = v
159
+ end
160
+
161
+ @parser.on('--do', '--disc-option OPTION', 'Options to pass to the discovery method') do |a|
162
+ @options[:discovery_options] << a
163
+ end
164
+
165
+ @parser.on("--nodes FILE", "List of nodes to address") do |v|
166
+ raise "Cannot mix --disc-method, --disc-option and --nodes" if @options[:discovery_method] || @options[:discovery_options].size > 0
167
+ raise "Cannot read the discovery file #{v}" unless File.readable?(v)
168
+
169
+ @options[:discovery_method] = "flatfile"
170
+ @options[:discovery_options] = v
171
+ end
155
172
  end
156
173
 
157
174
  private
@@ -60,7 +60,7 @@ module MCollective
60
60
 
61
61
  # Provides a list of plugins we know about
62
62
  def self.pluginlist
63
- @plugins.keys
63
+ @plugins.keys.sort
64
64
  end
65
65
 
66
66
  # deletes all registered plugins
@@ -119,7 +119,7 @@ module MCollective
119
119
  plugins = []
120
120
 
121
121
  Config.instance.libdir.each do |libdir|
122
- plugdir = File.join([libdir, "mcollective", type])
122
+ plugdir = File.join([libdir, "mcollective", type.to_s])
123
123
  next unless File.directory?(plugdir)
124
124
 
125
125
  Dir.new(plugdir).grep(/#{extension}$/).map do |plugin|
@@ -174,7 +174,7 @@ module MCollective
174
174
 
175
175
  # Grep's over the plugin list and returns the list found
176
176
  def self.grep(regex)
177
- @plugins.keys.grep regex
177
+ @plugins.keys.grep(regex)
178
178
  end
179
179
  end
180
180
  end
@@ -15,9 +15,16 @@ module MCollective
15
15
 
16
16
  # Fetch and return metadata from plugin DDL
17
17
  def self.get_metadata(path, type)
18
- ddl = MCollective::RPC::DDL.new("package", false)
19
- ddl.instance_eval File.read(Dir.glob(File.join(path, type, "*.ddl")).first)
20
- ddl.meta
18
+ ddl = DDL.new("package", type.to_sym, false)
19
+
20
+ begin
21
+ ddl_file = File.read(Dir.glob(File.join(path, type, "*.ddl")).first)
22
+ rescue Exception
23
+ raise "failed to load ddl file in plugin directory : #{File.join(path, type)}"
24
+ end
25
+ ddl.instance_eval ddl_file
26
+
27
+ return ddl.meta, ddl.requirements[:mcollective]
21
28
  end
22
29
 
23
30
  # Checks if a directory is present and not empty
@@ -3,9 +3,9 @@ module MCollective
3
3
  # MCollective Agent Plugin package
4
4
  class AgentDefinition
5
5
  attr_accessor :path, :packagedata, :metadata, :target_path, :vendor, :iteration, :preinstall
6
- attr_accessor :plugintype, :dependencies, :postinstall, :mcserver, :mcclient, :mccommon
6
+ attr_accessor :plugintype, :dependencies, :postinstall, :mcname, :mcversion
7
7
 
8
- def initialize(path, name, vendor, preinstall, postinstall, iteration, dependencies, mcodependency, plugintype)
8
+ def initialize(path, name, vendor, preinstall, postinstall, iteration, dependencies, mcdependency, plugintype)
9
9
  @plugintype = plugintype
10
10
  @path = path
11
11
  @packagedata = {}
@@ -13,12 +13,13 @@ module MCollective
13
13
  @preinstall = preinstall
14
14
  @postinstall = postinstall
15
15
  @vendor = vendor || "Puppet Labs"
16
- @mcserver = mcodependency[:server] || "mcollective"
17
- @mcclient = mcodependency[:client] || "mcollective-client"
18
- @mccommon = mcodependency[:common] || "mcollective-common"
19
16
  @dependencies = dependencies || []
20
17
  @target_path = File.expand_path(@path)
21
- @metadata = PluginPackager.get_metadata(@path, "agent")
18
+ @metadata, mcversion = PluginPackager.get_metadata(@path, "agent")
19
+ @mcname = mcdependency[:mcname] || "mcollective"
20
+ @mcversion = mcdependency[:mcversion] || mcversion
21
+ @dependencies << {:name => "#{@mcname}-common", :version => @mcversion}
22
+
22
23
  @metadata[:name] = (name || @metadata[:name]).downcase.gsub(" ", "-")
23
24
  identify_packages
24
25
  end
@@ -36,7 +37,7 @@ module MCollective
36
37
  # Obtain Agent package files and dependencies.
37
38
  def agent
38
39
  agent = {:files => [],
39
- :dependencies => @dependencies.clone << @mcserver,
40
+ :dependencies => @dependencies.clone,
40
41
  :description => "Agent plugin for #{@metadata[:name]}"}
41
42
 
42
43
  agentdir = File.join(@path, "agent")
@@ -44,43 +45,50 @@ module MCollective
44
45
  if PluginPackager.check_dir_present agentdir
45
46
  ddls = Dir.glob(File.join(agentdir, "*.ddl"))
46
47
  agent[:files] = (Dir.glob(File.join(agentdir, "*")) - ddls)
47
- implementations = Dir.glob(File.join(@metadata[:name], "**"))
48
- agent[:files] += implementations unless implementations.empty?
49
48
  else
50
49
  return nil
51
50
  end
52
- agent[:dependencies] << "mcollective-#{@metadata[:name]}-common" if @packagedata[:common]
51
+ agent[:dependencies] << {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version]}
53
52
  agent
54
53
  end
55
54
 
56
55
  # Obtain client package files and dependencies.
57
56
  def client
58
57
  client = {:files => [],
59
- :dependencies => @dependencies.clone << @mcclient,
58
+ :dependencies => @dependencies.clone,
60
59
  :description => "Client plugin for #{@metadata[:name]}"}
61
60
 
62
61
  clientdir = File.join(@path, "application")
63
- bindir = File.join(@path, "bin")
64
- ddldir = File.join(@path, "agent")
62
+ aggregatedir = File.join(@path, "aggregate")
65
63
 
66
64
  client[:files] += Dir.glob(File.join(clientdir, "*")) if PluginPackager.check_dir_present clientdir
67
- client[:files] += Dir.glob(File.join(bindir,"*")) if PluginPackager.check_dir_present bindir
68
- client[:files] += Dir.glob(File.join(ddldir, "*.ddl")) if PluginPackager.check_dir_present ddldir
69
- client[:dependencies] << "mcollective-#{@metadata[:name]}-common" if @packagedata[:common]
65
+ client[:files] += Dir.glob(File.join(aggregatedir, "*")) if PluginPackager.check_dir_present aggregatedir
66
+ client[:dependencies] << {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version]}
70
67
  client[:files].empty? ? nil : client
71
68
  end
72
69
 
73
70
  # Obtain common package files and dependencies.
74
71
  def common
75
72
  common = {:files =>[],
76
- :dependencies => @dependencies.clone << @mccommon,
73
+ :dependencies => @dependencies.clone,
77
74
  :description => "Common libraries for #{@metadata[:name]}"}
78
75
 
79
- commondir = File.join(@path, "util")
80
- common[:files] += Dir.glob(File.join(commondir,"*")) if PluginPackager.check_dir_present commondir
76
+ datadir = File.join(@path, "data", "**")
77
+ utildir = File.join(@path, "util", "**", "**")
78
+ ddldir = File.join(@path, "agent", "*.ddl")
79
+ validatordir = File.join(@path, "validator", "**")
80
+
81
+ [datadir, utildir, validatordir, ddldir].each do |directory|
82
+ common[:files] += Dir.glob(directory)
83
+ end
84
+
85
+ # We fail if there is no ddl file present
86
+ if common[:files].grep(/^.*\.ddl$/).empty?
87
+ raise "cannot create package - No ddl file found in #{File.join(@path, "agent")}"
88
+ end
89
+
81
90
  common[:files].empty? ? nil : common
82
91
  end
83
-
84
92
  end
85
93
  end
86
94
  end
@@ -2,10 +2,9 @@ module MCollective
2
2
  module PluginPackager
3
3
  class StandardDefinition
4
4
  attr_accessor :path, :packagedata, :metadata, :target_path, :vendor, :iteration
5
- attr_accessor :plugintype, :preinstall, :postinstall, :dependencies, :mcserver
6
- attr_accessor :mccommon
5
+ attr_accessor :plugintype, :preinstall, :postinstall, :dependencies, :mcname, :mcversion
7
6
 
8
- def initialize(path, name, vendor, preinstall, postinstall, iteration, dependencies, mcodependency, plugintype)
7
+ def initialize(path, name, vendor, preinstall, postinstall, iteration, dependencies, mcdependency, plugintype)
9
8
  @plugintype = plugintype
10
9
  @path = path
11
10
  @packagedata = {}
@@ -14,10 +13,12 @@ module MCollective
14
13
  @postinstall = postinstall
15
14
  @vendor = vendor || "Puppet Labs"
16
15
  @dependencies = dependencies || []
17
- @mcserver = mcodependency[:server] || "mcollective"
18
- @mccommon = mcodependency[:common] || "mcollective-common"
19
16
  @target_path = File.expand_path(@path)
20
- @metadata = PluginPackager.get_metadata(@path, @plugintype)
17
+ @metadata, mcversion = PluginPackager.get_metadata(@path, @plugintype)
18
+
19
+ @mcname = mcdependency[:mcname] || "mcollective"
20
+ @mcversion = mcdependency[:mcversion] || mcversion
21
+ @dependencies << {:name => "#{mcname}-common", :version => @mcversion}
21
22
  @metadata[:name] = (name || @metadata[:name]).downcase.gsub(" ", "-")
22
23
  identify_packages
23
24
  end
@@ -33,7 +34,7 @@ module MCollective
33
34
  # Obtain standard plugin files and dependencies
34
35
  def plugin
35
36
  plugindata = {:files => [],
36
- :dependencies => @dependencies.clone << @mcserver,
37
+ :dependencies => @dependencies.clone,
37
38
  :description => "#{@name} #{@plugintype} plugin for the Marionette Collective."}
38
39
 
39
40
  plugindir = File.join(@path, @plugintype.to_s)
@@ -43,14 +44,15 @@ module MCollective
43
44
  return nil
44
45
  end
45
46
 
46
- plugindata[:dependencies] <<"mcollective-#{@metadata[:name]}-common" if @packagedata[:common]
47
+ plugindata[:dependencies] << {:name => "#{@mcname}-#{@metadata[:name]}-common",
48
+ :version => @metadata[:version]} if @packagedata[:common]
47
49
  plugindata
48
50
  end
49
51
 
50
52
  # Obtain list of common files
51
53
  def common
52
54
  common = {:files => [],
53
- :dependencies => @dependencies.clone << @mccommon,
55
+ :dependencies => @dependencies.clone,
54
56
  :description => "Common libraries for #{@name} connector plugin"}
55
57
 
56
58
  commondir = File.join(@path, "util")
@@ -38,7 +38,9 @@ module MCollective
38
38
  end
39
39
 
40
40
  def msg_filter
41
- {"agent" => "registration"}
41
+ filter = Util.empty_filter
42
+ filter["agent"] << "registration"
43
+ filter
42
44
  end
43
45
 
44
46
  def target_collective
@@ -5,17 +5,16 @@ module MCollective
5
5
  # an RPC metaphor, standard compliant agents will make it easier
6
6
  # to create generic clients like web interfaces etc
7
7
  module RPC
8
- autoload :Client, "mcollective/rpc/client"
8
+ autoload :ActionRunner, "mcollective/rpc/actionrunner"
9
9
  autoload :Agent, "mcollective/rpc/agent"
10
- autoload :Reply, "mcollective/rpc/reply"
11
- autoload :Request, "mcollective/rpc/request"
12
10
  autoload :Audit, "mcollective/rpc/audit"
11
+ autoload :Client, "mcollective/rpc/client"
12
+ autoload :Helpers, "mcollective/rpc/helpers"
13
13
  autoload :Progress, "mcollective/rpc/progress"
14
- autoload :Stats, "mcollective/rpc/stats"
15
- autoload :DDL, "mcollective/rpc/ddl"
14
+ autoload :Reply, "mcollective/rpc/reply"
15
+ autoload :Request, "mcollective/rpc/request"
16
16
  autoload :Result, "mcollective/rpc/result"
17
- autoload :Helpers, "mcollective/rpc/helpers"
18
- autoload :ActionRunner, "mcollective/rpc/actionrunner"
17
+ autoload :Stats, "mcollective/rpc/stats"
19
18
 
20
19
  # Creates a standard options hash, pass in a block to add extra headings etc
21
20
  # see Optionparser
@@ -115,18 +114,18 @@ module MCollective
115
114
  # If you've passed -v on the command line a detailed stat block
116
115
  # will be printed, else just a one liner.
117
116
  #
118
- # You can pass flags into it, at the moment only one flag is
119
- # supported:
117
+ # You can pass flags into it:
120
118
  #
121
- # printrpcstats :caption => "Foo"
119
+ # printrpcstats :caption => "Foo", :summarize => true
122
120
  #
123
121
  # This will use "Foo" as the caption to the stats in verbose
124
- # mode
122
+ # mode and print out any aggregate summary information if present
125
123
  def printrpcstats(flags={})
126
124
  return unless @options[:output_format] == :console
127
125
 
126
+ flags = {:summarize => false, :caption => "rpc stats"}.merge(flags)
127
+
128
128
  verbose = @options[:verbose] rescue verbose = false
129
- caption = flags[:caption] || "rpc stats"
130
129
 
131
130
  begin
132
131
  stats = @@stats
@@ -135,8 +134,7 @@ module MCollective
135
134
  return
136
135
  end
137
136
 
138
- puts
139
- puts stats.report(caption, verbose)
137
+ puts stats.report(flags[:caption], flags[:summarize], verbose)
140
138
  end
141
139
 
142
140
  # Prints the result of an RPC call.
@@ -150,8 +148,9 @@ module MCollective
150
148
  verbose = flags[:verbose] || verbose
151
149
  flatten = flags[:flatten] || false
152
150
  format = @options[:output_format]
151
+ forced_mode = @options[:force_display_mode] || false
153
152
 
154
- result_text = Helpers.rpcresults(result, {:verbose => verbose, :flatten => flatten, :format => format})
153
+ result_text = Helpers.rpcresults(result, {:verbose => verbose, :flatten => flatten, :format => format, :force_display_mode => forced_mode})
155
154
 
156
155
  if result.is_a?(Array) && format == :console
157
156
  puts "\n%s\n" % [ result_text ]
@@ -173,16 +172,11 @@ module MCollective
173
172
  end
174
173
  end
175
174
 
176
- # Factory for RPC::Request messages, only really here to make agents
177
- # a bit easier to understand
178
- def self.request(msg)
179
- RPC::Request.new(msg)
180
- end
175
+ def self.const_missing(const_name)
176
+ super unless const_name == :DDL
181
177
 
182
- # Factory for RPC::Reply messages, only really here to make agents
183
- # a bit easier to understand
184
- def self.reply
185
- RPC::Reply.new
178
+ Log.warn("MCollective::RPC::DDL is deprecatd, please use MCollective::DDL instead")
179
+ MCollective::DDL
186
180
  end
187
181
  end
188
182
  end