kafo 1.0.4 → 1.0.5

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: d8d91c1c416307f1a338f208ff5eff030d1b848a
4
- data.tar.gz: c8b4d0291b2ab3afc351ebcd22e12b7326d96d3b
3
+ metadata.gz: cbf3ef253f9a74761e7ef0c3d46ea5bd1f614348
4
+ data.tar.gz: 543e582caf1cb8e46a994c3abb715d1164ab61a3
5
5
  SHA512:
6
- metadata.gz: 3ddd5d143247c1a437f6f6ea3afe287f9a53caed1b0a966aabd763184545706e34ac4428b2bff835893e8a6c62507deb8d9292f0ee5906a11e0a667ebb19de3d
7
- data.tar.gz: d07f78c6a86c1eb71617e127264bb39411ffd8f5077b9963725fd4c59d869f45b8a9edcd66ea8ddfda481b4d81967f84e675783dfe775602d06533ec6decd1fe
6
+ metadata.gz: c0ba6eaad2fc7396046fae8ca7ec19b6a4cdca1aa139a550f88cfd2303603f4b6e987c9ebef5198ab60d46873bb2a3dd288ec8961f944b9555c0a6e422ae278e
7
+ data.tar.gz: e4a91446ae30920ee6eec8893592821a881cfeefe88078aa798b1e3258a6cc13af5c06c47ca4831d153eb35321eea63a16b71a93bcaff84945391a306d8aaf10
data/README.md CHANGED
@@ -1093,6 +1093,19 @@ Other exit codes that can be returned:
1093
1093
 
1094
1094
  As of Puppet 3.2, performance data can be gathered during a puppet run by adding the `--profile` option. See [Tune Puppet for Performance with Profiler](https://puppetlabs.com/blog/tune-puppet-performance-profiler) for more information from the Puppet team. Users who wish to perform a Kafo run and gather this type of profiling data to analyze can pass the same option to their installer. The profiling data will then be present in the normal Kafo logs.
1095
1095
 
1096
+ ## Issue tracker
1097
+
1098
+ Issues are tracked in Redmine, see:
1099
+
1100
+ * [Open Kafo issues](http://projects.theforeman.org/projects/kafo/issues/)
1101
+ * [File new issue](http://projects.theforeman.org/projects/kafo/issues/new)
1102
+
1103
+ ## Related projects
1104
+
1105
+ * [kafo_module_lint](https://github.com/domcleal/kafo_module_lint) will lint Puppet modules to ensure data types are specified correctly etc.
1106
+ * [kafo_parsers](https://github.com/theforeman/kafo_parsers) parses Puppet manifests for class documentation and parameter data
1107
+ * [puppet-lint-param-docs](https://github.com/voxpupuli/puppet-lint-param-docs) will lint Puppet modules to ensure all parameters are documented
1108
+
1096
1109
  # License
1097
1110
 
1098
1111
  This project is licensed under the GPLv3+.
@@ -423,6 +423,7 @@ module Kafo
423
423
  '--reports=',
424
424
  "--hiera_config=#{hiera.config_path}",
425
425
  ]
426
+ options.push '--evaltrace' if @progress_bar
426
427
  options.push '--noop' if noop?
427
428
  options.push '--profile' if profile?
428
429
  begin
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require 'powerbar'
3
3
  require 'ansi/code'
4
+ require 'set'
4
5
 
5
6
  module Kafo
6
7
  # Progress bar base class
@@ -9,10 +10,16 @@ module Kafo
9
10
  # #finite_template and #infinite_template methods. Also you may find useful to
10
11
  # change more methods like #done_message or #print_error
11
12
  class ProgressBar
13
+ MONITOR_RESOURCE = %r{\w*MONITOR_RESOURCE ([^\]]+\])}
14
+ EVALTRACE_START = %r{/(.+\]): Starting to evaluate the resource}
15
+ EVALTRACE_END = %r{/(.+\]): Evaluated in [\d\.]+ seconds}
16
+ PREFETCH = %r{Prefetching .* resources for}
17
+
12
18
  def initialize
13
19
  @lines = 0
14
20
  @all_lines = 0
15
21
  @total = :unknown
22
+ @resources = Set.new
16
23
  @term_width = HighLine::SystemExtensions.terminal_size[0] || 0
17
24
  @bar = PowerBar.new
18
25
  @bar.settings.tty.infinite.template.main = infinite_template
@@ -23,15 +30,41 @@ module Kafo
23
30
  end
24
31
 
25
32
  def update(line)
26
- @total = $1.to_i if line =~ /\w*START (\d+)/
27
- @lines += 1 if line.include?('RESOURCE') && @lines < @total - 1
28
33
  @all_lines += 1
29
34
 
30
- # we print every 20th line during installation preparing otherwise we update every line
31
- if @all_lines % 20 == 0 || @total != :unknown
35
+ # we print every 20th line during installation preparing otherwise only update at EVALTRACE_START
36
+ update_bar = (@total == :unknown && @all_lines % 20 == 0)
37
+ force_update = false
38
+
39
+ if (line_monitor = MONITOR_RESOURCE.match(line))
40
+ @resources << line_monitor[1]
41
+ @total = (@total == :unknown ? 1 : @total + 1)
42
+ end
43
+
44
+ if (line_start = EVALTRACE_START.match(line))
45
+ if (known_resource = find_known_resource(line_start[1]))
46
+ line = known_resource
47
+ update_bar = true
48
+ force_update = true
49
+ end
50
+ end
51
+
52
+ if (line_end = EVALTRACE_END.match(line)) && @lines < @total
53
+ if (known_resource = find_known_resource(line_end[1]))
54
+ @resources.delete(known_resource) # ensure it's only counted once
55
+ @lines += 1
56
+ end
57
+ end
58
+
59
+ if PREFETCH =~ line
60
+ update_bar = true
61
+ force_update = true
62
+ end
63
+
64
+ if update_bar
32
65
  @bar.show({ :msg => format(line),
33
66
  :done => @lines,
34
- :total => @total })
67
+ :total => @total }, force_update)
35
68
  end
36
69
  end
37
70
 
@@ -69,6 +102,16 @@ module Kafo
69
102
  'Installing...'
70
103
  end
71
104
 
105
+ def find_known_resource(resource)
106
+ loop do
107
+ return resource if @resources.include?(resource)
108
+ # continue to remove prefixes from /Stage[main]/Example/File[/etc/foo] until a resource name is found
109
+ break unless resource.include?('/')
110
+ resource = resource.sub %r{.*?/}, ''
111
+ end
112
+ nil
113
+ end
114
+
72
115
  end
73
116
  end
74
117
 
@@ -138,12 +138,12 @@ module Kafo
138
138
 
139
139
  # custom module directory name
140
140
  def get_dir_name
141
- mapping[identifier].nil? ? name : mapping[identifier][:dir_name]
141
+ mapping[identifier].nil? ? default_dir_name : (mapping[identifier][:dir_name] || default_dir_name)
142
142
  end
143
143
 
144
144
  # custom manifest filename without .pp extension
145
145
  def get_manifest_name
146
- mapping[identifier].nil? ? 'init' : mapping[identifier][:manifest_name]
146
+ mapping[identifier].nil? ? default_manifest_name : (mapping[identifier][:manifest_name] || default_manifest_name)
147
147
  end
148
148
 
149
149
  def get_class_name
@@ -155,8 +155,7 @@ module Kafo
155
155
  end
156
156
 
157
157
  def get_params_name
158
- default = 'params'
159
- mapping[identifier].nil? ? default : (mapping[identifier][:params_name] || default)
158
+ mapping[identifier].nil? ? default_params_name : (mapping[identifier][:params_name] || default_params_name)
160
159
  end
161
160
 
162
161
  def get_params_class_name
@@ -167,10 +166,22 @@ module Kafo
167
166
  "#{dir_name}/manifests/#{manifest_name}.pp"
168
167
  end
169
168
 
169
+ def default_dir_name
170
+ identifier.split('::').first
171
+ end
172
+
170
173
  def default_params_path
171
174
  "#{dir_name}/manifests/#{get_params_name}.pp"
172
175
  end
173
176
 
177
+ def default_manifest_name
178
+ identifier.include?('::') ? identifier.split('::')[1..-1].join('/') : 'init'
179
+ end
180
+
181
+ def default_params_name
182
+ identifier.include?('::') ? (identifier.split('::')[1..-1] + ['params']).join('/') : 'params'
183
+ end
184
+
174
185
  def get_name
175
186
  identifier.gsub('::', '_')
176
187
  end
data/lib/kafo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
  module Kafo
3
3
  PARSER_CACHE_VERSION = 1
4
- VERSION = "1.0.4"
4
+ VERSION = "1.0.5"
5
5
  end
@@ -1,5 +1,3 @@
1
- require 'kafo_configure/lib/kafo/puppet/report_wrapper'
2
-
3
1
  module Puppet::Parser::Functions
4
2
  newfunction(:add_progress) do |args|
5
3
  loaded = false
@@ -16,7 +14,8 @@ module Puppet::Parser::Functions
16
14
  attr_accessor :in_main_catalog
17
15
 
18
16
  def is_interesting?(resource)
19
- ![:schedule, :class, :stage, :filebucket, :anchor, :'kafo_configure::yaml_to_class'].include?(resource.to_s.split('[')[0].downcase.to_sym)
17
+ return false if resource.class.name == :component # ignore defined types
18
+ ![:schedule, :class, :stage, :filebucket, :anchor, :concat_fragment].include?(resource.to_s.split('[')[0].downcase.to_sym)
20
19
  end
21
20
 
22
21
  def tracked_resources
@@ -26,24 +25,15 @@ module Puppet::Parser::Functions
26
25
  def evaluate_with_trigger(*args, &block)
27
26
  if catalog.version
28
27
  self.in_main_catalog = true
29
- ::Puppet.info "START #{tracked_resources.size}"
28
+ tracked_resources.each { |r| ::Puppet.info "MONITOR_RESOURCE #{r}" }
30
29
  end
31
30
  evaluate_without_trigger(*args, &block)
32
31
  self.in_main_catalog = false if catalog.version
33
32
  end
34
33
 
35
- def report_with_wrapper
36
- unless @report_wrapper
37
- @report_wrapper = Kafo::Puppet::ReportWrapper.new(self, report_without_wrapper)
38
- end
39
- @report_wrapper
40
- end
41
-
42
34
  if method_defined?(:evaluate) && method_defined?(:report)
43
35
  alias_method :evaluate_without_trigger, :evaluate
44
36
  alias_method :evaluate, :evaluate_with_trigger
45
- alias_method :report_without_wrapper, :report
46
- alias_method :report, :report_with_wrapper
47
37
  else
48
38
  ::Puppet.warning 'Unable to patch Puppet transactions for progress bar support, this version may not be supported'
49
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kafo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Hulan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-04 00:00:00.000000000 Z
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -261,7 +261,6 @@ files:
261
261
  - lib/kafo/validator.rb
262
262
  - lib/kafo/version.rb
263
263
  - lib/kafo/wizard.rb
264
- - modules/kafo_configure/lib/kafo/puppet/report_wrapper.rb
265
264
  - modules/kafo_configure/lib/puppet/parser/functions/add_progress.rb
266
265
  - modules/kafo_configure/lib/puppet/parser/functions/decrypt.rb
267
266
  - modules/kafo_configure/lib/puppet/parser/functions/dump_values.rb
@@ -1,39 +0,0 @@
1
- require 'set'
2
-
3
- module Kafo
4
- module Puppet
5
- class ReportWrapper
6
- attr_reader :transaction, :report
7
-
8
- def initialize(transaction, report)
9
- @transaction = transaction
10
- @report = report
11
- @supported = true
12
- @resources_seen = Set.new
13
- end
14
-
15
- # Needed to fool Puppet's logging framework
16
- def self.to_s
17
- "Puppet::Transaction::Report"
18
- end
19
-
20
- def add_resource_status(status, *args, &block)
21
- if @supported && report.respond_to?(:resource_statuses) && report.resource_statuses.is_a?(Hash)
22
- if transaction.in_main_catalog && report.resource_statuses[status.resource.to_s] && transaction.tracked_resources.include?(status.resource) && !@resources_seen.include?(status.resource)
23
- ::Puppet.info "RESOURCE #{status.resource}"
24
- @resources_seen << status.resource
25
- end
26
- report.add_resource_status(status, *args, &block)
27
- else
28
- ::Puppet.err "Your puppet env is not supported, report does not define resource_statuses"
29
- @supported = false
30
- end
31
- end
32
-
33
- def method_missing(method, *args, &block)
34
- report.send(method, *args, &block)
35
- end
36
- end
37
-
38
- end
39
- end