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,190 +15,196 @@
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 RepositoriesInspector < Inspector
19
- has_priority 40
20
- def initialize(system, description)
21
- @system = system
22
- @description = description
23
- end
24
-
25
- def inspect(_filter, _options = {})
26
- if system.has_command?("zypper")
27
- @description.repositories = inspect_zypp_repositories
28
- elsif system.has_command?("yum")
29
- @description.repositories = inspect_yum_repositories
30
- elsif system.has_command?("dpkg")
31
- @description.repositories = inspect_apt_repositories
32
- else
33
- raise Machinery::Errors::MissingRequirement.new(
34
- "Need either the binary 'zypper', 'yum' or 'apt' to be available on the inspected system."
35
- )
18
+ module Machinery
19
+ class RepositoriesInspector < Machinery::Inspector
20
+ has_priority 40
21
+ def initialize(system, description)
22
+ @system = system
23
+ @description = description
36
24
  end
37
- end
38
-
39
- def summary
40
- "Found " \
41
- "#{Machinery.pluralize(@description.repositories.size, "%d repository", "%d repositories")}."
42
- end
43
-
44
- private
45
25
 
46
- def inspect_zypp_repositories
47
- begin
48
- xml = system.run_command(
49
- "zypper", "--non-interactive", "--xmlout", "repos", "--details",
50
- stdout: :capture
51
- )
52
- details = system.run_command(
53
- "zypper", "--non-interactive", "repos", "--details", stdout: :capture
54
- ).split("\n").select { |l| l =~ /\A# +\| |\A *\d+ \| / }.
55
- map { |l| l.split("|").map(&:strip) }
56
- rescue Cheetah::ExecutionFailed => e
57
- if e.status.exitstatus == 6 # ZYPPER_EXIT_NO_REPOS
58
- details = []
26
+ def inspect(_filter, _options = {})
27
+ if system.has_command?("zypper")
28
+ @description.repositories = inspect_zypp_repositories
29
+ elsif system.has_command?("yum")
30
+ @description.repositories = inspect_yum_repositories
31
+ elsif system.has_command?("dpkg")
32
+ @description.repositories = inspect_apt_repositories
59
33
  else
60
- raise e
34
+ raise Machinery::Errors::MissingRequirement.new(
35
+ "Need either the binary 'zypper', 'yum' or 'apt' to be available on the inspected system."
36
+ )
61
37
  end
62
38
  end
63
39
 
64
- if details.empty?
65
- result = []
66
- else
67
- priorities = parse_priorities_from_details(details)
68
- credentials = get_credentials_from_system
69
- result = parse_repositories_from_xml(xml, priorities, credentials)
40
+ def summary
41
+ "Found " \
42
+ "#{Machinery.pluralize(
43
+ @description.repositories.size,
44
+ "%d repository",
45
+ "%d repositories"
46
+ )}."
70
47
  end
71
48
 
72
- RepositoriesScope.new(result, repository_system: "zypp")
73
- end
49
+ private
74
50
 
75
- def inspect_yum_repositories
76
- script = File.read(File.join(Machinery::ROOT, "inspect_helpers", "yum_repositories.py"))
77
- begin
78
- repositories = JSON.parse(system.run_command(
79
- "bash", "-c", "python", stdin: script, stdout: :capture
80
- ).split("\n").last).map { |element| YumRepository.new(element) }
81
- rescue JSON::ParserError
82
- raise Machinery::Errors::InspectionFailed.new("Extraction of YUM repositories failed.")
83
- rescue Cheetah::ExecutionFailed => e
84
- raise Machinery::Errors::InspectionFailed.new(
85
- "Extraction of YUM repositories failed:\n#{e.stderr}"
86
- )
87
- end
51
+ def inspect_zypp_repositories
52
+ begin
53
+ xml = system.run_command(
54
+ "zypper", "--non-interactive", "--xmlout", "repos", "--details",
55
+ stdout: :capture
56
+ )
57
+ details = system.run_command(
58
+ "zypper", "--non-interactive", "repos", "--details", stdout: :capture
59
+ ).split("\n").select { |l| l =~ /\A# +\| |\A *\d+ \| / }.
60
+ map { |l| l.split("|").map(&:strip) }
61
+ rescue Cheetah::ExecutionFailed => e
62
+ if e.status.exitstatus == 6 # ZYPPER_EXIT_NO_REPOS
63
+ details = []
64
+ else
65
+ raise e
66
+ end
67
+ end
88
68
 
89
- RepositoriesScope.new(repositories, repository_system: "yum")
90
- end
69
+ if details.empty?
70
+ result = []
71
+ else
72
+ priorities = parse_priorities_from_details(details)
73
+ credentials = get_credentials_from_system
74
+ result = parse_repositories_from_xml(xml, priorities, credentials)
75
+ end
91
76
 
92
- def inspect_apt_repositories
93
- content = system.read_file("/etc/apt/sources.list")
94
- begin
95
- content += "\n" + system.run_command(
96
- "bash", "-c", "cat /etc/apt/sources.list.d/*.list", stdout: :capture
97
- )
98
- rescue Cheetah::ExecutionFailed
77
+ RepositoriesScope.new(result, repository_system: "zypp")
99
78
  end
100
79
 
101
- RepositoriesScope.new(
102
- parse_apt_repositories(content), repository_system: "apt"
103
- )
104
- end
105
-
106
- def parse_apt_repositories(content)
107
- repositories = []
108
- content.each_line do |line|
109
- if line =~ /^\s*(deb|deb-src)\s+(cdrom:\[.+\]\/|\S+)\s+(\S+)(\s+\S[^#]*\S)?(\s*|\s*#.*)$/
110
- repositories << AptRepository.new(
111
- type: $1,
112
- url: $2,
113
- distribution: $3,
114
- components: $4 ? $4.strip.split(" ") : []
115
- )
116
- elsif line =~ /Types: deb/
117
- Machinery::Ui.warn(
118
- "Warning: An unsupported rfc822 style repository was found, which will be ignored."
80
+ def inspect_yum_repositories
81
+ script = File.read(File.join(Machinery::ROOT, "inspect_helpers", "yum_repositories.py"))
82
+ begin
83
+ repositories = JSON.parse(system.run_command(
84
+ "bash", "-c", "python", stdin: script, stdout: :capture
85
+ ).split("\n").last).map { |element| YumRepository.new(element) }
86
+ rescue JSON::ParserError
87
+ raise Machinery::Errors::InspectionFailed.new("Extraction of YUM repositories failed.")
88
+ rescue Cheetah::ExecutionFailed => e
89
+ raise Machinery::Errors::InspectionFailed.new(
90
+ "Extraction of YUM repositories failed:\n#{e.stderr}"
119
91
  )
120
92
  end
121
- end
122
- repositories.uniq
123
- end
124
-
125
- def parse_priorities_from_details(details)
126
- # parse and remove header
127
- idx_prio = details.first.index("Priority")
128
- idx_alias = details.first.index("Alias")
129
- details.shift
130
93
 
131
- prio = {}
132
- details.each do |entry|
133
- prio[entry[idx_alias]] = entry[idx_prio].to_i
94
+ RepositoriesScope.new(repositories, repository_system: "yum")
134
95
  end
135
96
 
136
- prio
137
- end
97
+ def inspect_apt_repositories
98
+ content = system.read_file("/etc/apt/sources.list")
99
+ begin
100
+ content += "\n" + system.run_command(
101
+ "bash", "-c", "cat /etc/apt/sources.list.d/*.list", stdout: :capture
102
+ )
103
+ rescue Cheetah::ExecutionFailed
104
+ end
138
105
 
139
- def get_credentials_from_system
140
- credentials = {}
141
- credential_dir = "/etc/zypp/credentials.d/"
142
- credential_files = @system.run_command(
143
- "bash", "-c",
144
- "test -d '#{credential_dir}' && ls -1 '#{credential_dir}' || echo ''",
145
- stdout: :capture
146
- )
147
- credential_files.split("\n").each do |f|
148
- content = @system.run_command(
149
- "cat", "/etc/zypp/credentials.d/#{f}", stdout: :capture, privileged: true
106
+ RepositoriesScope.new(
107
+ parse_apt_repositories(content), repository_system: "apt"
150
108
  )
151
- content.match(/username=(\w*)\npassword=(\w*)/)
152
- credentials[f] = {
153
- username: $1,
154
- password: $2
155
- }
156
109
  end
157
- credentials
158
- end
159
110
 
160
- def parse_repositories_from_xml(xml, priorities, credentials)
161
- reps = REXML::Document.new(xml).get_elements("/stream/repo-list/repo")
162
- result = reps.map do |rep|
163
- if rep.attributes["priority"]
164
- pri_value = rep.attributes["priority"].to_i
165
- else
166
- pri_value = priorities[rep.attributes["alias"]]
111
+ def parse_apt_repositories(content)
112
+ repositories = []
113
+ content.each_line do |line|
114
+ if line =~ /^\s*(deb|deb-src)\s+(cdrom:\[.+\]\/|\S+)\s+(\S+)(\s+\S[^#]*\S)?(\s*|\s*#.*)$/
115
+ repositories << AptRepository.new(
116
+ type: $1,
117
+ url: $2,
118
+ distribution: $3,
119
+ components: $4 ? $4.strip.split(" ") : []
120
+ )
121
+ elsif line =~ /Types: deb/
122
+ Machinery::Ui.warn(
123
+ "Warning: An unsupported rfc822 style repository was found, which will be ignored."
124
+ )
125
+ end
167
126
  end
127
+ repositories.uniq
128
+ end
168
129
 
169
- # NCC
170
- rep.elements["url"].first.to_s.match(/\?credentials=(\w*)/)
171
- cred_value = $1
172
- if cred_value && credentials[cred_value]
173
- username = credentials[cred_value][:username]
174
- password = credentials[cred_value][:password]
175
- end
130
+ def parse_priorities_from_details(details)
131
+ # parse and remove header
132
+ idx_prio = details.first.index("Priority")
133
+ idx_alias = details.first.index("Alias")
134
+ details.shift
176
135
 
177
- # SCC
178
- rep.elements["url"].first.to_s.match(/(https:\/\/updates.suse.com\/SUSE\/)/)
179
- scc_url = $1
180
- cred_value = "SCCcredentials"
181
- if scc_url && credentials[cred_value]
182
- username = credentials[cred_value][:username]
183
- password = credentials[cred_value][:password]
136
+ prio = {}
137
+ details.each do |entry|
138
+ prio[entry[idx_alias]] = entry[idx_prio].to_i
184
139
  end
185
140
 
186
- repository = ZyppRepository.new(
187
- alias: rep.attributes["alias"],
188
- name: rep.attributes["name"],
189
- type: rep.attributes["type"],
190
- url: rep.elements["url"].first.to_s,
191
- enabled: rep.attributes["enabled"] == "1",
192
- autorefresh: rep.attributes["autorefresh"] == "1",
193
- gpgcheck: rep.attributes["gpgcheck"] == "1",
194
- priority: pri_value
141
+ prio
142
+ end
143
+
144
+ def get_credentials_from_system
145
+ credentials = {}
146
+ credential_dir = "/etc/zypp/credentials.d/"
147
+ credential_files = @system.run_command(
148
+ "bash", "-c",
149
+ "test -d '#{credential_dir}' && ls -1 '#{credential_dir}' || echo ''",
150
+ stdout: :capture
195
151
  )
196
- if username && password
197
- repository[:username] = username
198
- repository[:password] = password
152
+ credential_files.split("\n").each do |f|
153
+ content = @system.run_command(
154
+ "cat", "/etc/zypp/credentials.d/#{f}", stdout: :capture, privileged: true
155
+ )
156
+ matches = content.match(/username=(\w*)\npassword=(\w*)/)
157
+ credentials[f] = {
158
+ username: matches[1],
159
+ password: matches[2]
160
+ }
199
161
  end
200
- repository
201
- end.sort_by(&:name)
202
- result
162
+ credentials
163
+ end
164
+
165
+ def parse_repositories_from_xml(xml, priorities, credentials)
166
+ reps = REXML::Document.new(xml).get_elements("/stream/repo-list/repo")
167
+ result = reps.map do |rep|
168
+ pri_value = if rep.attributes["priority"]
169
+ rep.attributes["priority"].to_i
170
+ else
171
+ priorities[rep.attributes["alias"]]
172
+ end
173
+
174
+ # NCC
175
+ rep.elements["url"].first.to_s.match(/\?credentials=(\w*)/)
176
+ cred_value = $1
177
+ if cred_value && credentials[cred_value]
178
+ username = credentials[cred_value][:username]
179
+ password = credentials[cred_value][:password]
180
+ end
181
+
182
+ # SCC
183
+ rep.elements["url"].first.to_s.match(/(https:\/\/updates.suse.com\/SUSE\/)/)
184
+ scc_url = $1
185
+ cred_value = "SCCcredentials"
186
+ if scc_url && credentials[cred_value]
187
+ username = credentials[cred_value][:username]
188
+ password = credentials[cred_value][:password]
189
+ end
190
+
191
+ repository = ZyppRepository.new(
192
+ alias: rep.attributes["alias"],
193
+ name: rep.attributes["name"],
194
+ type: rep.attributes["type"],
195
+ url: rep.elements["url"].first.to_s,
196
+ enabled: rep.attributes["enabled"] == "1",
197
+ autorefresh: rep.attributes["autorefresh"] == "1",
198
+ gpgcheck: rep.attributes["gpgcheck"] == "1",
199
+ priority: pri_value
200
+ )
201
+ if username && password
202
+ repository[:username] = username
203
+ repository[:password] = password
204
+ end
205
+ repository
206
+ end.sort_by(&:name)
207
+ result
208
+ end
203
209
  end
204
210
  end
@@ -15,72 +15,73 @@
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
-
19
- class Repository < Machinery::Object
20
- def external_medium?
21
- url.start_with?("cd://") || url.start_with?("dvd://") || url.start_with?("iso://")
18
+ module Machinery
19
+ class Repository < Machinery::Object
20
+ def external_medium?
21
+ url.start_with?("cd://", "dvd://", "iso://")
22
+ end
22
23
  end
23
- end
24
24
 
25
- class ZyppRepository < Repository
26
- class << self
27
- def key
28
- "alias"
29
- end
25
+ class ZyppRepository < Repository
26
+ class << self
27
+ def key
28
+ "alias"
29
+ end
30
30
 
31
- def attributes
32
- ["name", "url", "type", "enabled", "autorefresh", "gpgcheck", "priority", "gpgkey"]
31
+ def attributes
32
+ ["name", "url", "type", "enabled", "autorefresh", "gpgcheck", "priority", "gpgkey"]
33
+ end
33
34
  end
34
35
  end
35
- end
36
36
 
37
- class YumRepository < Repository
38
- class << self
39
- def key
40
- "alias"
41
- end
37
+ class YumRepository < Repository
38
+ class << self
39
+ def key
40
+ "alias"
41
+ end
42
42
 
43
- def attributes
44
- ["name", "url", "type", "enabled", "gpgcheck", "priority", "mirrorlist", "gpgkey"]
43
+ def attributes
44
+ ["name", "url", "type", "enabled", "gpgcheck", "priority", "mirrorlist", "gpgkey"]
45
+ end
45
46
  end
46
47
  end
47
- end
48
48
 
49
- class AptRepository < Repository
50
- class << self
51
- def key
52
- "url"
53
- end
49
+ class AptRepository < Repository
50
+ class << self
51
+ def key
52
+ "url"
53
+ end
54
54
 
55
- def attributes
56
- ["url", "type", "distribution", "components"]
55
+ def attributes
56
+ ["url", "type", "distribution", "components"]
57
+ end
57
58
  end
58
59
  end
59
- end
60
60
 
61
- class RepositoriesScope < Machinery::Array
62
- include Machinery::Scope
61
+ class RepositoriesScope < Machinery::Array
62
+ include Machinery::Scope
63
63
 
64
- has_attributes :repository_system
65
- has_elements class: ZyppRepository, if: { repository_system: "zypp" }
66
- has_elements class: YumRepository, if: { repository_system: "yum" }
67
- has_elements class: AptRepository, if: { repository_system: "apt" }
64
+ has_attributes :repository_system
65
+ has_elements class: ZyppRepository, if: { repository_system: "zypp" }
66
+ has_elements class: YumRepository, if: { repository_system: "yum" }
67
+ has_elements class: AptRepository, if: { repository_system: "apt" }
68
68
 
69
- def compare_with(other)
70
- if self.repository_system != other.repository_system
71
- [self, other, nil, nil]
72
- else
73
- only_self = self - other
74
- only_other = other - self
75
- changed = Machinery::Scope.extract_changed_elements(only_self, only_other, :alias)
76
- common = self & other
69
+ def compare_with(other)
70
+ if repository_system != other.repository_system
71
+ [self, other, nil, nil]
72
+ else
73
+ only_self = self - other
74
+ only_other = other - self
75
+ changed = Machinery::Scope.extract_changed_elements(only_self, only_other, :alias)
76
+ common = self & other
77
77
 
78
- [
79
- only_self,
80
- only_other,
81
- changed,
82
- common
83
- ].map { |e| (e && !e.empty?) ? e : nil }
78
+ [
79
+ only_self,
80
+ only_other,
81
+ changed,
82
+ common
83
+ ].map { |e| e && !e.empty? ? e : nil }
84
+ end
84
85
  end
85
86
  end
86
87
  end