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.
- checksums.yaml +4 -4
- data/.git_revision +1 -1
- data/NEWS +10 -0
- data/bin/machinery +1 -1
- data/lib/analyze_changed_config_files_diffs_task.rb +6 -6
- data/lib/autoyast.rb +2 -2
- data/lib/build_task.rb +10 -7
- data/lib/cli.rb +1005 -801
- data/lib/compare_task.rb +11 -7
- data/lib/comparison.rb +2 -2
- data/lib/config_base.rb +1 -1
- data/lib/config_task.rb +1 -1
- data/lib/containerize_task.rb +3 -3
- data/lib/containerized_app.rb +1 -1
- data/lib/copy_task.rb +1 -1
- data/lib/current_user.rb +1 -1
- data/lib/deploy_task.rb +6 -4
- data/lib/diff_widget.rb +67 -63
- data/lib/docker_system.rb +12 -8
- data/lib/dpkg_database.rb +1 -1
- data/lib/element_filter.rb +7 -4
- data/lib/exceptions.rb +23 -5
- data/lib/export_task.rb +1 -1
- data/lib/exporter.rb +1 -1
- data/lib/file_diff.rb +1 -1
- data/lib/file_scope.rb +1 -1
- data/lib/file_validator.rb +7 -4
- data/lib/filter.rb +97 -93
- data/lib/filter_option_parser.rb +2 -2
- data/lib/hint.rb +64 -59
- data/lib/html.rb +1 -1
- data/lib/inspect_task.rb +12 -12
- data/lib/inspector.rb +3 -3
- data/lib/json_validation_error_cleaner.rb +1 -1
- data/lib/json_validator.rb +4 -4
- data/lib/kiwi_config.rb +8 -4
- data/lib/list_task.rb +10 -9
- data/lib/local_system.rb +11 -5
- data/lib/logged_cheetah.rb +1 -1
- data/lib/man_task.rb +10 -6
- data/lib/managed_files_database.rb +1 -1
- data/lib/manifest.rb +5 -5
- data/lib/migration.rb +16 -10
- data/lib/mountpoints.rb +1 -1
- data/lib/move_task.rb +1 -1
- data/lib/remote_system.rb +7 -7
- data/lib/remove_task.rb +1 -1
- data/lib/renderer.rb +177 -172
- data/lib/rpm.rb +4 -4
- data/lib/rpm_database.rb +1 -1
- data/lib/scope.rb +2 -2
- data/lib/scope_file_access_archive.rb +1 -1
- data/lib/scope_file_access_flat.rb +1 -1
- data/lib/scope_file_store.rb +1 -1
- data/lib/serve_html_task.rb +6 -2
- data/lib/server.rb +19 -12
- data/lib/show_task.rb +10 -6
- data/lib/static_html.rb +1 -1
- data/lib/system.rb +10 -10
- data/lib/system_description.rb +14 -13
- data/lib/system_description_memory_store.rb +1 -1
- data/lib/system_description_store.rb +9 -9
- data/lib/tarball.rb +8 -2
- data/lib/upgrade_format_task.rb +11 -6
- data/lib/validate_task.rb +2 -2
- data/lib/version.rb +1 -1
- data/lib/workload_mapper.rb +2 -2
- data/lib/workload_mapper_dsl.rb +1 -1
- data/lib/zypper.rb +40 -17
- data/machinery-helper/machinery_helper.go +35 -16
- data/machinery-helper/version.go +1 -1
- data/man/generated/machinery.1.gz +0 -0
- data/manual/site/sitemap.xml +24 -24
- data/plugins/changed_config_files/changed_config_files_inspector.rb +59 -56
- data/plugins/changed_config_files/changed_config_files_model.rb +23 -21
- data/plugins/changed_config_files/changed_config_files_renderer.rb +56 -52
- data/plugins/changed_managed_files/changed_managed_files_inspector.rb +52 -50
- data/plugins/changed_managed_files/changed_managed_files_model.rb +23 -21
- data/plugins/changed_managed_files/changed_managed_files_renderer.rb +43 -39
- data/plugins/environment/environment_inspector.rb +25 -23
- data/plugins/environment/environment_model.rb +5 -3
- data/plugins/groups/groups_inspector.rb +30 -28
- data/plugins/groups/groups_model.rb +18 -17
- data/plugins/groups/groups_renderer.rb +29 -25
- data/plugins/os/os_inspector.rb +120 -118
- data/plugins/os/os_model.rb +139 -134
- data/plugins/os/os_renderer.rb +13 -9
- data/plugins/packages/packages_inspector.rb +99 -86
- data/plugins/packages/packages_model.rb +35 -34
- data/plugins/packages/packages_renderer.rb +47 -39
- data/plugins/patterns/patterns_inspector.rb +70 -68
- data/plugins/patterns/patterns_model.rb +19 -18
- data/plugins/patterns/patterns_renderer.rb +36 -32
- data/plugins/repositories/repositories_inspector.rb +162 -156
- data/plugins/repositories/repositories_model.rb +50 -49
- data/plugins/repositories/repositories_renderer.rb +48 -44
- data/plugins/repositories/schema/system-description-repositories.schema-v10.json +0 -1
- data/plugins/services/services_inspector.rb +187 -176
- data/plugins/services/services_model.rb +37 -36
- data/plugins/services/services_renderer.rb +28 -24
- data/plugins/unmanaged_files/unmanaged_files_inspector.rb +102 -99
- data/plugins/unmanaged_files/unmanaged_files_model.rb +64 -56
- data/plugins/unmanaged_files/unmanaged_files_renderer.rb +44 -40
- data/plugins/users/users_inspector.rb +67 -65
- data/plugins/users/users_model.rb +37 -36
- data/plugins/users/users_renderer.rb +31 -27
- data/schema/migrations/migrate1to2.rb +1 -1
- data/schema/migrations/migrate2to3.rb +1 -1
- data/schema/migrations/migrate3to4.rb +1 -1
- data/schema/migrations/migrate4to5.rb +1 -1
- data/schema/migrations/migrate5to6.rb +1 -1
- data/schema/migrations/migrate6to7.rb +1 -1
- data/schema/migrations/migrate7to8.rb +1 -1
- data/schema/migrations/migrate8to9.rb +1 -1
- data/schema/migrations/migrate9to10.rb +1 -1
- 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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
)
|
52
|
-
|
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
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
-
|
73
|
-
end
|
49
|
+
private
|
74
50
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
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
|
-
|
90
|
-
|
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
|
-
|
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
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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
|
-
|
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
|
-
|
137
|
-
|
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
|
-
|
140
|
-
|
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
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
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
|
-
|
178
|
-
|
179
|
-
|
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
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
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
|
-
|
197
|
-
|
198
|
-
|
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
|
-
|
201
|
-
end
|
202
|
-
|
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
|
-
|
21
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
class ZyppRepository < Repository
|
26
|
+
class << self
|
27
|
+
def key
|
28
|
+
"alias"
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
class YumRepository < Repository
|
38
|
+
class << self
|
39
|
+
def key
|
40
|
+
"alias"
|
41
|
+
end
|
42
42
|
|
43
|
-
|
44
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
class AptRepository < Repository
|
50
|
+
class << self
|
51
|
+
def key
|
52
|
+
"url"
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
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
|
-
|
61
|
+
class RepositoriesScope < Machinery::Array
|
62
|
+
include Machinery::Scope
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|