machinery-tool 1.22.1 → 1.22.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.git_revision +1 -1
  3. data/NEWS +10 -0
  4. data/bin/machinery +1 -1
  5. data/lib/analyze_changed_config_files_diffs_task.rb +6 -6
  6. data/lib/autoyast.rb +2 -2
  7. data/lib/build_task.rb +10 -7
  8. data/lib/cli.rb +1005 -801
  9. data/lib/compare_task.rb +11 -7
  10. data/lib/comparison.rb +2 -2
  11. data/lib/config_base.rb +1 -1
  12. data/lib/config_task.rb +1 -1
  13. data/lib/containerize_task.rb +3 -3
  14. data/lib/containerized_app.rb +1 -1
  15. data/lib/copy_task.rb +1 -1
  16. data/lib/current_user.rb +1 -1
  17. data/lib/deploy_task.rb +6 -4
  18. data/lib/diff_widget.rb +67 -63
  19. data/lib/docker_system.rb +12 -8
  20. data/lib/dpkg_database.rb +1 -1
  21. data/lib/element_filter.rb +7 -4
  22. data/lib/exceptions.rb +23 -5
  23. data/lib/export_task.rb +1 -1
  24. data/lib/exporter.rb +1 -1
  25. data/lib/file_diff.rb +1 -1
  26. data/lib/file_scope.rb +1 -1
  27. data/lib/file_validator.rb +7 -4
  28. data/lib/filter.rb +97 -93
  29. data/lib/filter_option_parser.rb +2 -2
  30. data/lib/hint.rb +64 -59
  31. data/lib/html.rb +1 -1
  32. data/lib/inspect_task.rb +12 -12
  33. data/lib/inspector.rb +3 -3
  34. data/lib/json_validation_error_cleaner.rb +1 -1
  35. data/lib/json_validator.rb +4 -4
  36. data/lib/kiwi_config.rb +8 -4
  37. data/lib/list_task.rb +10 -9
  38. data/lib/local_system.rb +11 -5
  39. data/lib/logged_cheetah.rb +1 -1
  40. data/lib/man_task.rb +10 -6
  41. data/lib/managed_files_database.rb +1 -1
  42. data/lib/manifest.rb +5 -5
  43. data/lib/migration.rb +16 -10
  44. data/lib/mountpoints.rb +1 -1
  45. data/lib/move_task.rb +1 -1
  46. data/lib/remote_system.rb +7 -7
  47. data/lib/remove_task.rb +1 -1
  48. data/lib/renderer.rb +177 -172
  49. data/lib/rpm.rb +4 -4
  50. data/lib/rpm_database.rb +1 -1
  51. data/lib/scope.rb +2 -2
  52. data/lib/scope_file_access_archive.rb +1 -1
  53. data/lib/scope_file_access_flat.rb +1 -1
  54. data/lib/scope_file_store.rb +1 -1
  55. data/lib/serve_html_task.rb +6 -2
  56. data/lib/server.rb +19 -12
  57. data/lib/show_task.rb +10 -6
  58. data/lib/static_html.rb +1 -1
  59. data/lib/system.rb +10 -10
  60. data/lib/system_description.rb +14 -13
  61. data/lib/system_description_memory_store.rb +1 -1
  62. data/lib/system_description_store.rb +9 -9
  63. data/lib/tarball.rb +8 -2
  64. data/lib/upgrade_format_task.rb +11 -6
  65. data/lib/validate_task.rb +2 -2
  66. data/lib/version.rb +1 -1
  67. data/lib/workload_mapper.rb +2 -2
  68. data/lib/workload_mapper_dsl.rb +1 -1
  69. data/lib/zypper.rb +40 -17
  70. data/machinery-helper/machinery_helper.go +35 -16
  71. data/machinery-helper/version.go +1 -1
  72. data/man/generated/machinery.1.gz +0 -0
  73. data/manual/site/sitemap.xml +24 -24
  74. data/plugins/changed_config_files/changed_config_files_inspector.rb +59 -56
  75. data/plugins/changed_config_files/changed_config_files_model.rb +23 -21
  76. data/plugins/changed_config_files/changed_config_files_renderer.rb +56 -52
  77. data/plugins/changed_managed_files/changed_managed_files_inspector.rb +52 -50
  78. data/plugins/changed_managed_files/changed_managed_files_model.rb +23 -21
  79. data/plugins/changed_managed_files/changed_managed_files_renderer.rb +43 -39
  80. data/plugins/environment/environment_inspector.rb +25 -23
  81. data/plugins/environment/environment_model.rb +5 -3
  82. data/plugins/groups/groups_inspector.rb +30 -28
  83. data/plugins/groups/groups_model.rb +18 -17
  84. data/plugins/groups/groups_renderer.rb +29 -25
  85. data/plugins/os/os_inspector.rb +120 -118
  86. data/plugins/os/os_model.rb +139 -134
  87. data/plugins/os/os_renderer.rb +13 -9
  88. data/plugins/packages/packages_inspector.rb +99 -86
  89. data/plugins/packages/packages_model.rb +35 -34
  90. data/plugins/packages/packages_renderer.rb +47 -39
  91. data/plugins/patterns/patterns_inspector.rb +70 -68
  92. data/plugins/patterns/patterns_model.rb +19 -18
  93. data/plugins/patterns/patterns_renderer.rb +36 -32
  94. data/plugins/repositories/repositories_inspector.rb +162 -156
  95. data/plugins/repositories/repositories_model.rb +50 -49
  96. data/plugins/repositories/repositories_renderer.rb +48 -44
  97. data/plugins/repositories/schema/system-description-repositories.schema-v10.json +0 -1
  98. data/plugins/services/services_inspector.rb +187 -176
  99. data/plugins/services/services_model.rb +37 -36
  100. data/plugins/services/services_renderer.rb +28 -24
  101. data/plugins/unmanaged_files/unmanaged_files_inspector.rb +102 -99
  102. data/plugins/unmanaged_files/unmanaged_files_model.rb +64 -56
  103. data/plugins/unmanaged_files/unmanaged_files_renderer.rb +44 -40
  104. data/plugins/users/users_inspector.rb +67 -65
  105. data/plugins/users/users_model.rb +37 -36
  106. data/plugins/users/users_renderer.rb +31 -27
  107. data/schema/migrations/migrate1to2.rb +1 -1
  108. data/schema/migrations/migrate2to3.rb +1 -1
  109. data/schema/migrations/migrate3to4.rb +1 -1
  110. data/schema/migrations/migrate4to5.rb +1 -1
  111. data/schema/migrations/migrate5to6.rb +1 -1
  112. data/schema/migrations/migrate6to7.rb +1 -1
  113. data/schema/migrations/migrate7to8.rb +1 -1
  114. data/schema/migrations/migrate8to9.rb +1 -1
  115. data/schema/migrations/migrate9to10.rb +1 -1
  116. metadata +2 -2
@@ -15,59 +15,63 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class UnmanagedFilesRenderer < Renderer
19
- def content(description)
20
- return unless description["unmanaged_files"]
18
+ module Machinery
19
+ class Ui
20
+ class UnmanagedFilesRenderer < Machinery::Ui::Renderer
21
+ def content(description)
22
+ return unless description["unmanaged_files"]
21
23
 
22
- list do
23
- file_status = description["unmanaged_files"].extracted
24
+ list do
25
+ file_status = description["unmanaged_files"].extracted
24
26
 
25
- if description["unmanaged_files"].elements.empty?
26
- puts "There are no unmanaged files."
27
- elsif !file_status.nil?
28
- puts "Files extracted: #{file_status ? "yes" : "no"}"
29
- end
27
+ if description["unmanaged_files"].elements.empty?
28
+ puts "There are no unmanaged files."
29
+ elsif !file_status.nil?
30
+ puts "Files extracted: #{file_status ? "yes" : "no"}"
31
+ end
30
32
 
31
- if description["unmanaged_files"]
32
- description["unmanaged_files"].each do |p|
33
- if description["unmanaged_files"].contains_metadata?
34
- item "#{p.name} (#{p.type})" do
35
- puts "User/Group: #{p.user}:#{p.group}" if p.user || p.group
36
- puts "Mode: #{p.mode}" if p.mode
37
- puts "Size: #{number_to_human_size(p.size)}" if p.size
38
- if p.files && p.dirs
39
- puts "Files: #{p.files}"
40
- puts "Directories: #{p.dirs}"
41
- end
42
- if p.file_objects
43
- puts "File Objects: #{p.file_objects}"
33
+ if description["unmanaged_files"]
34
+ description["unmanaged_files"].each do |p|
35
+ if description["unmanaged_files"].contains_metadata?
36
+ item "#{p.name} (#{p.type})" do
37
+ puts "User/Group: #{p.user}:#{p.group}" if p.user || p.group
38
+ puts "Mode: #{p.mode}" if p.mode
39
+ puts "Size: #{number_to_human_size(p.size)}" if p.size
40
+ if p.files && p.dirs
41
+ puts "Files: #{p.files}"
42
+ puts "Directories: #{p.dirs}"
43
+ end
44
+ if p.file_objects
45
+ puts "File Objects: #{p.file_objects}"
46
+ end
47
+ end
48
+ else
49
+ item "#{p.name} (#{p.type})"
44
50
  end
45
51
  end
46
- else
47
- item "#{p.name} (#{p.type})"
48
52
  end
49
53
  end
50
54
  end
51
- end
52
- end
53
55
 
54
- def display_name
55
- "Unmanaged Files"
56
- end
56
+ def display_name
57
+ "Unmanaged Files"
58
+ end
57
59
 
58
- def compare_content_changed(changed_elements)
59
- list do
60
- changed_elements.each do |one, two|
61
- changes = []
62
- relevant_attributes = (one.attributes.keys & two.attributes.keys)
60
+ def compare_content_changed(changed_elements)
61
+ list do
62
+ changed_elements.each do |one, two|
63
+ changes = []
64
+ relevant_attributes = (one.attributes.keys & two.attributes.keys)
63
65
 
64
- relevant_attributes.each do |attribute|
65
- if one[attribute] != two[attribute]
66
- changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
66
+ relevant_attributes.each do |attribute|
67
+ if one[attribute] != two[attribute]
68
+ changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
69
+ end
70
+ end
71
+
72
+ item "#{one.name} (#{changes.join(", ")})"
67
73
  end
68
74
  end
69
-
70
- item "#{one.name} (#{changes.join(", ")})"
71
75
  end
72
76
  end
73
77
  end
@@ -15,84 +15,86 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class UsersInspector < Inspector
19
- has_priority 50
18
+ module Machinery
19
+ class UsersInspector < Machinery::Inspector
20
+ has_priority 50
20
21
 
21
- def initialize(system, description)
22
- @system = system
23
- @description = description
24
- end
22
+ def initialize(system, description)
23
+ @system = system
24
+ @description = description
25
+ end
25
26
 
26
- def inspect(_filter, _options = {})
27
- passwd = @system.read_file("/etc/passwd")
28
- shadow = @system.read_file("/etc/shadow", privileged: true)
27
+ def inspect(_filter, _options = {})
28
+ passwd = @system.read_file("/etc/passwd")
29
+ shadow = @system.read_file("/etc/shadow", privileged: true)
29
30
 
30
- users = passwd ? parse_users(passwd, shadow) : []
31
+ users = passwd ? parse_users(passwd, shadow) : []
31
32
 
32
- @description.users = UsersScope.new(users.sort_by(&:name))
33
- end
33
+ @description.users = UsersScope.new(users.sort_by(&:name))
34
+ end
34
35
 
35
- def summary
36
- "Found #{Machinery.pluralize(@description.users.size, "%d user")}."
37
- end
36
+ def summary
37
+ "Found #{Machinery.pluralize(@description.users.size, "%d user")}."
38
+ end
38
39
 
39
- private
40
+ private
40
41
 
41
- def parse_users(passwd, shadow)
42
- passwd = Machinery.scrub(passwd)
43
- users = passwd.lines.map { |l| l.split(":").first }
42
+ def parse_users(passwd, shadow)
43
+ passwd = Machinery.scrub(passwd)
44
+ users = passwd.lines.map { |l| l.split(":").first }
44
45
 
45
- users.map do |user|
46
- attributes = passwd_attributes(passwd, user)
47
- attributes.merge!(shadow_attributes(shadow, user)) if shadow
46
+ users.map do |user|
47
+ attributes = passwd_attributes(passwd, user)
48
+ attributes.merge!(shadow_attributes(shadow, user)) if shadow
48
49
 
49
- User.new(attributes)
50
+ User.new(attributes)
51
+ end
50
52
  end
51
- end
52
53
 
53
- def passwd_attributes(passwd, user)
54
- line = passwd.lines.find { |l| l.start_with?("#{user}:") }
55
- user, passwd, uid, gid, comment, home, shell = line.split(":").map(&:chomp)
56
-
57
- # In case the inspected machine uses NIS, /etc/passwd will contain a
58
- # placeholder entry like this:
59
- #
60
- # +::::::
61
- #
62
- # We need to handle it correctly, which means setting non-string attributes
63
- # to nil.
64
- uid = Machinery::is_int?(uid) ? uid.to_i : nil
65
- gid = Machinery::is_int?(gid) ? gid.to_i : nil
66
-
67
- {
68
- name: user,
54
+ def passwd_attributes(passwd, user)
55
+ line = passwd.lines.find { |l| l.start_with?("#{user}:") }
56
+ user, passwd, uid, gid, comment, home, shell = line.split(":").map(&:chomp)
57
+
58
+ # In case the inspected machine uses NIS, /etc/passwd will contain a
59
+ # placeholder entry like this:
60
+ #
61
+ # +::::::
62
+ #
63
+ # We need to handle it correctly, which means setting non-string attributes
64
+ # to nil.
65
+ uid = Machinery.is_int?(uid) ? uid.to_i : nil
66
+ gid = Machinery.is_int?(gid) ? gid.to_i : nil
67
+
68
+ {
69
+ name: user,
69
70
  password: passwd,
70
- uid: uid,
71
- gid: gid,
72
- comment: comment,
73
- home: home,
74
- shell: shell
75
- }
76
- end
77
-
78
- def shadow_attributes(shadow, user)
79
- line = shadow.lines.find { |l| l.start_with?("#{user}:") }
80
- if line
81
- user, passwd, changed, min, max, warn, inactive, expire = line.split(":").map(&:chomp)
82
-
83
- result = {
84
- encrypted_password: passwd
71
+ uid: uid,
72
+ gid: gid,
73
+ comment: comment,
74
+ home: home,
75
+ shell: shell
85
76
  }
86
- result[:last_changed_date] = changed.to_i unless changed.empty?
87
- result[:min_days] = min.to_i unless min.empty?
88
- result[:max_days] = max.to_i unless max.empty?
89
- result[:warn_days] = warn.to_i unless warn.empty?
90
- result[:disable_days] = inactive.to_i unless inactive.empty?
91
- result[:disabled_date] = expire.to_i unless expire.empty?
92
-
93
- result
94
- else
95
- {}
77
+ end
78
+
79
+ def shadow_attributes(shadow, user)
80
+ line = shadow.lines.find { |l| l.start_with?("#{user}:") }
81
+ if line
82
+ user, passwd, changed, min, max, warn, inactive, expire = line.split(":").map(&:chomp)
83
+
84
+ result = {
85
+ encrypted_password: passwd
86
+ }
87
+ result[:last_changed_date] = changed.to_i unless changed.empty?
88
+ result[:min_days] = min.to_i unless min.empty?
89
+ result[:max_days] = max.to_i unless max.empty?
90
+ result[:warn_days] = warn.to_i unless warn.empty?
91
+ result[:disable_days] = inactive.to_i unless inactive.empty?
92
+ result[:disabled_date] = expire.to_i unless expire.empty?
93
+
94
+ result
95
+ else
96
+ {}
97
+ end
96
98
  end
97
99
  end
98
100
  end
@@ -15,50 +15,51 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
+ module Machinery
19
+ class User < Machinery::Object
20
+ IGNORED_ATTRIBUTES_IN_COMPARISON = [
21
+ "password",
22
+ "encrypted_password",
23
+ "last_changed_date",
24
+ "min_days",
25
+ "max_days",
26
+ "warn_days"
27
+ ].freeze
18
28
 
19
- class User < Machinery::Object
20
- IGNORED_ATTRIBUTES_IN_COMPARISON = [
21
- "password",
22
- "encrypted_password",
23
- "last_changed_date",
24
- "min_days",
25
- "max_days",
26
- "warn_days"
27
- ]
29
+ # User objects contain some information which is not relevant in the context of comparison (e.g.
30
+ # metadata like "last_changed_date"). In order to ignore these attributes during comparison we
31
+ # have to overwrite some methods.
32
+ def eql?(other)
33
+ relevant_attributes = (attributes.keys & other.attributes.keys) -
34
+ IGNORED_ATTRIBUTES_IN_COMPARISON
28
35
 
29
- # User objects contain some information which is not relevant in the context of comparison (e.g.
30
- # metadata like "last_changed_date"). In order to ignore these attributes during comparison we
31
- # have to overwrite some methods.
32
- def eql?(other)
33
- relevant_attributes = (attributes.keys & other.attributes.keys) -
34
- IGNORED_ATTRIBUTES_IN_COMPARISON
36
+ relevant_attributes.all? do |attribute|
37
+ self[attribute] == other[attribute]
38
+ end
39
+ end
35
40
 
36
- relevant_attributes.all? do |attribute|
37
- self[attribute] == other[attribute]
41
+ def hash
42
+ @attributes.reject { |k, _v| IGNORED_ATTRIBUTES_IN_COMPARISON.include?(k) }.hash
38
43
  end
39
44
  end
40
45
 
41
- def hash
42
- @attributes.reject { |k, _v| IGNORED_ATTRIBUTES_IN_COMPARISON.include?(k) }.hash
43
- end
44
- end
46
+ class UsersScope < Machinery::Array
47
+ include Machinery::Scope
45
48
 
46
- class UsersScope < Machinery::Array
47
- include Machinery::Scope
49
+ has_elements class: User
48
50
 
49
- has_elements class: User
51
+ def compare_with(other)
52
+ only_self = self - other
53
+ only_other = other - self
54
+ common = self & other
55
+ changed = Machinery::Scope.extract_changed_elements(only_self, only_other, :name)
50
56
 
51
- def compare_with(other)
52
- only_self = self - other
53
- only_other = other - self
54
- common = self & other
55
- changed = Machinery::Scope.extract_changed_elements(only_self, only_other, :name)
56
-
57
- [
58
- only_self,
59
- only_other,
60
- changed,
61
- common
62
- ].map { |e| (e && !e.empty?) ? e : nil }
57
+ [
58
+ only_self,
59
+ only_other,
60
+ changed,
61
+ common
62
+ ].map { |e| e && !e.empty? ? e : nil }
63
+ end
63
64
  end
64
65
  end
@@ -15,41 +15,45 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class UsersRenderer < Renderer
19
- def content(description)
20
- return unless description.users
18
+ module Machinery
19
+ class Ui
20
+ class UsersRenderer < Machinery::Ui::Renderer
21
+ def content(description)
22
+ return unless description.users
21
23
 
22
- if description.users.any? { |a| a[:comment] == "" || a[:uid].nil? || a[:gid].nil? }
23
- na_note("user info, user ID or group ID")
24
- end
24
+ if description.users.any? { |a| a[:comment] == "" || a[:uid].nil? || a[:gid].nil? }
25
+ na_note("user info, user ID or group ID")
26
+ end
25
27
 
26
- list do
27
- description.users.each do |user|
28
- info = user.comment.empty? ? "N/A" : user.comment
29
- uid = user.uid || "N/A"
30
- gid = user.gid || "N/A"
31
- item "#{user.name} (#{info}, uid: #{uid}, gid: #{gid}, shell: #{user.shell})"
28
+ list do
29
+ description.users.each do |user|
30
+ info = user.comment.empty? ? "N/A" : user.comment
31
+ uid = user.uid || "N/A"
32
+ gid = user.gid || "N/A"
33
+ item "#{user.name} (#{info}, uid: #{uid}, gid: #{gid}, shell: #{user.shell})"
34
+ end
35
+ end
32
36
  end
33
- end
34
- end
35
37
 
36
- def display_name
37
- "Users"
38
- end
38
+ def display_name
39
+ "Users"
40
+ end
39
41
 
40
- def compare_content_changed(changed_elements)
41
- list do
42
- changed_elements.each do |one, two|
43
- changes = []
44
- relevant_attributes = ["uid", "gid", "comment", "shell", "home"]
42
+ def compare_content_changed(changed_elements)
43
+ list do
44
+ changed_elements.each do |one, two|
45
+ changes = []
46
+ relevant_attributes = ["uid", "gid", "comment", "shell", "home"]
45
47
 
46
- relevant_attributes.each do |attribute|
47
- if one[attribute] != two[attribute]
48
- changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
48
+ relevant_attributes.each do |attribute|
49
+ if one[attribute] != two[attribute]
50
+ changes << "#{attribute}: #{one[attribute]} <> #{two[attribute]}"
51
+ end
52
+ end
53
+
54
+ item "#{one.name} (#{changes.join(", ")})"
49
55
  end
50
56
  end
51
-
52
- item "#{one.name} (#{changes.join(", ")})"
53
57
  end
54
58
  end
55
59
  end
@@ -15,7 +15,7 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class Migrate1To2 < Migration
18
+ class Machinery::Migrate1To2 < Machinery::Migration
19
19
  desc <<-EOT
20
20
  Schema version 2 introduces an "extracted" flag for the config_files,
21
21
  changed_managed_files and unmanaged_files scope, indicating whether the
@@ -15,7 +15,7 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class Migrate2To3 < Migration
18
+ class Machinery::Migrate2To3 < Machinery::Migration
19
19
  desc <<-EOT
20
20
  Schema version 3 stores the analyzed data under the directory
21
21
  "analyze" and config files diffs in the config_file_diffs
@@ -15,7 +15,7 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class Migrate3To4 < Migration
18
+ class Machinery::Migrate3To4 < Machinery::Migration
19
19
  desc <<-EOT
20
20
  Schema version 4 adds a "type" attribute to changed_managed_files and config_files
21
21
  in order to support other file types like links.
@@ -15,7 +15,7 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class Migrate4To5 < Migration
18
+ class Machinery::Migrate4To5 < Machinery::Migration
19
19
  desc <<-EOT
20
20
  Schema version 5 adds a "environment" scope which stores information about the inspected system.
21
21
  EOT