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
data/lib/export_task.rb
CHANGED
data/lib/exporter.rb
CHANGED
data/lib/file_diff.rb
CHANGED
@@ -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 FileDiff
|
18
|
+
class Machinery::FileDiff
|
19
19
|
def self.diff(description1, description2, scope, path)
|
20
20
|
return nil if !description1.scope_extracted?(scope) || !description2.scope_extracted?(scope)
|
21
21
|
|
data/lib/file_scope.rb
CHANGED
@@ -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 FileScope < Machinery::Array
|
18
|
+
class Machinery::FileScope < Machinery::Array
|
19
19
|
def compare_with(other)
|
20
20
|
only_self, only_other, changed, common = super(other)
|
21
21
|
|
data/lib/file_validator.rb
CHANGED
@@ -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 FileValidator
|
18
|
+
class Machinery::FileValidator
|
19
19
|
def initialize(json_hash, base_path)
|
20
20
|
@json_hash = json_hash
|
21
21
|
@base_path = base_path
|
@@ -39,7 +39,10 @@ class FileValidator
|
|
39
39
|
next unless scope_extracted?(scope)
|
40
40
|
|
41
41
|
expected_files = expected_files(scope)
|
42
|
-
file_errors = validate_scope(
|
42
|
+
file_errors = validate_scope(
|
43
|
+
Machinery::ScopeFileStore.new(@base_path, scope.to_s),
|
44
|
+
expected_files
|
45
|
+
)
|
43
46
|
|
44
47
|
errors << "Scope '#{scope}':\n" + file_errors.join("\n") unless file_errors.empty?
|
45
48
|
end
|
@@ -58,7 +61,7 @@ class FileValidator
|
|
58
61
|
|
59
62
|
def scope_extracted?(scope)
|
60
63
|
if @format_version == 1
|
61
|
-
@json_hash[scope] && ScopeFileStore.new(@base_path, scope.to_s).path
|
64
|
+
@json_hash[scope] && Machinery::ScopeFileStore.new(@base_path, scope.to_s).path
|
62
65
|
elsif @format_version < 6
|
63
66
|
@json_hash[scope] && @json_hash[scope]["extracted"]
|
64
67
|
else
|
@@ -92,7 +95,7 @@ class FileValidator
|
|
92
95
|
end.map { |file| file["name"] }
|
93
96
|
end
|
94
97
|
|
95
|
-
store_base_path = ScopeFileStore.new(@base_path, scope.to_s).path
|
98
|
+
store_base_path = Machinery::ScopeFileStore.new(@base_path, scope.to_s).path
|
96
99
|
expected_files.map { |file| File.join(store_base_path, file) }
|
97
100
|
end
|
98
101
|
|
data/lib/filter.rb
CHANGED
@@ -43,129 +43,133 @@
|
|
43
43
|
#
|
44
44
|
# More details about how the filter work can be found at
|
45
45
|
# https://github.com/SUSE/machinery/blob/master/docs/Filtering-Design.md
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
46
|
+
module Machinery
|
47
|
+
class Filter
|
48
|
+
attr_accessor :element_filters
|
49
|
+
|
50
|
+
OPERATOR_EQUALS = "=".freeze
|
51
|
+
OPERATOR_EQUALS_NOT = "!=".freeze
|
52
|
+
|
53
|
+
def self.parse_filter_definitions(filter_definitions)
|
54
|
+
element_filters = {}
|
55
|
+
Array(filter_definitions).each do |definition|
|
56
|
+
path, operator, matcher_definition = definition.scan(/([a-zA-Z_\/]+)(.*=)(.*)/)[0]
|
57
|
+
|
58
|
+
raise Machinery::Errors::InvalidFilter.new(
|
59
|
+
"Invalid filter: '#{definition}'"
|
60
|
+
) unless operator
|
61
|
+
element_filters[path] ||= ElementFilter.new(path)
|
62
|
+
if matcher_definition.index(",")
|
63
|
+
matchers = matcher_definition.split(/(?<!\\),/)
|
64
|
+
matchers.map! { |matcher| matcher.gsub("\\,", ",") } # Unescape escaped commas
|
65
|
+
|
66
|
+
element_filters[path].add_matchers(operator, [matchers])
|
67
|
+
else
|
68
|
+
element_filters[path].add_matchers(operator, matcher_definition)
|
69
|
+
end
|
66
70
|
end
|
67
|
-
end
|
68
71
|
|
69
|
-
|
70
|
-
|
72
|
+
element_filters
|
73
|
+
end
|
71
74
|
|
72
|
-
|
73
|
-
|
75
|
+
def self.from_default_definition(command)
|
76
|
+
filter = Filter.new
|
74
77
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
default_filters_file = File.join(Machinery::ROOT, "filters", "default_filters.json")
|
79
|
+
if File.exist?(default_filters_file)
|
80
|
+
default_filters = JSON.parse(File.read(default_filters_file))
|
81
|
+
if default_filters[command]
|
82
|
+
default_filters[command].each do |definition|
|
83
|
+
filter.add_element_filter_from_definition(definition)
|
84
|
+
end
|
81
85
|
end
|
82
86
|
end
|
83
|
-
end
|
84
87
|
|
85
|
-
|
86
|
-
|
88
|
+
filter
|
89
|
+
end
|
87
90
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
+
def initialize(definitions = [])
|
92
|
+
@element_filters = Filter.parse_filter_definitions(definitions)
|
93
|
+
end
|
91
94
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
+
def add_element_filter_from_definition(filter_definition)
|
96
|
+
add_element_filters(Filter.parse_filter_definitions(filter_definition).values)
|
97
|
+
end
|
95
98
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
99
|
+
def add_element_filters(element_filters)
|
100
|
+
Array(element_filters).each do |element_filter|
|
101
|
+
path = element_filter.path
|
102
|
+
@element_filters[path] ||= ElementFilter.new(path)
|
100
103
|
|
101
|
-
|
102
|
-
|
104
|
+
element_filter.matchers.each do |operator, matchers|
|
105
|
+
@element_filters[path].add_matchers(operator, matchers)
|
106
|
+
end
|
103
107
|
end
|
104
108
|
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def element_filter_for(path)
|
108
|
-
element_filters[path]
|
109
|
-
end
|
110
109
|
|
111
|
-
|
112
|
-
|
113
|
-
element_filter.filters_scope?(scope)
|
110
|
+
def element_filter_for(path)
|
111
|
+
element_filters[path]
|
114
112
|
end
|
115
|
-
end
|
116
113
|
|
117
|
-
|
118
|
-
|
119
|
-
|
114
|
+
def element_filters_for_scope(scope)
|
115
|
+
@element_filters.values.select do |element_filter|
|
116
|
+
element_filter.filters_scope?(scope)
|
117
|
+
end
|
120
118
|
end
|
121
119
|
|
122
|
-
|
123
|
-
|
120
|
+
def set_element_filters_for_scope(scope, element_filters)
|
121
|
+
@element_filters.reject! do |_path, element_filter|
|
122
|
+
element_filter.filters_scope?(scope)
|
123
|
+
end
|
124
|
+
|
125
|
+
add_element_filters(element_filters)
|
126
|
+
end
|
124
127
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
128
|
+
def to_array
|
129
|
+
@element_filters.flat_map do |path, element_filter|
|
130
|
+
element_filter.matchers.flat_map do |operator, matchers|
|
131
|
+
matchers.map do |matcher|
|
132
|
+
"#{path}#{operator}#{Array(matcher).join(",")}"
|
133
|
+
end
|
130
134
|
end
|
131
135
|
end
|
132
136
|
end
|
133
|
-
end
|
134
137
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
+
def matches?(path, value)
|
139
|
+
filter = element_filter_for(path)
|
140
|
+
return false unless filter
|
138
141
|
|
139
|
-
|
140
|
-
|
142
|
+
filter.matches?(value)
|
143
|
+
end
|
141
144
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
145
|
+
def apply!(system_description)
|
146
|
+
element_filters.each do |path, element_filter|
|
147
|
+
steps = path.split("/").reject(&:empty?)
|
148
|
+
target = steps.pop
|
149
|
+
|
150
|
+
pointer = system_description
|
151
|
+
container = nil
|
152
|
+
steps.each do |step|
|
153
|
+
break unless pointer
|
154
|
+
pointer = pointer[step]
|
155
|
+
container ||= pointer if pointer.is_a?(Machinery::Array)
|
156
|
+
end
|
154
157
|
|
155
|
-
|
158
|
+
next unless pointer
|
156
159
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
+
begin
|
161
|
+
pointer.delete_if do |element|
|
162
|
+
element_filter.matches?(element[target])
|
163
|
+
end
|
164
|
+
rescue Machinery::Errors::ElementFilterTypeMismatch => e
|
165
|
+
Machinery::Ui.warn("Warning: Filter '#{e.failed_matcher}' tries to match an array, " \
|
166
|
+
"but the according element is not an array.")
|
160
167
|
end
|
161
|
-
rescue Machinery::Errors::ElementFilterTypeMismatch => e
|
162
|
-
Machinery::Ui.warn("Warning: Filter '#{e.failed_matcher}' tries to match an array, " \
|
163
|
-
"but the according element is not an array.")
|
164
168
|
end
|
165
169
|
end
|
166
|
-
end
|
167
170
|
|
168
|
-
|
169
|
-
|
171
|
+
def empty?
|
172
|
+
element_filters.empty?
|
173
|
+
end
|
170
174
|
end
|
171
175
|
end
|
data/lib/filter_option_parser.rb
CHANGED
@@ -17,10 +17,10 @@
|
|
17
17
|
|
18
18
|
# This class takes care of transforming the user-provided filter options into
|
19
19
|
# actual Filter objects.
|
20
|
-
class FilterOptionParser
|
20
|
+
class Machinery::FilterOptionParser
|
21
21
|
class <<self
|
22
22
|
def parse(command, options)
|
23
|
-
filter = Filter.from_default_definition(command)
|
23
|
+
filter = Machinery::Filter.from_default_definition(command)
|
24
24
|
|
25
25
|
definitions = skip_files_definitions(options.delete("skip-files"))
|
26
26
|
definitions += exclude_definitions(options["exclude"])
|
data/lib/hint.rb
CHANGED
@@ -15,78 +15,83 @@
|
|
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
|
20
|
-
|
21
|
-
|
18
|
+
module Machinery
|
19
|
+
class Ui
|
20
|
+
class Hint
|
21
|
+
class << self
|
22
|
+
def print(method, options = {})
|
23
|
+
return unless Machinery::Config.new.hints
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
Machinery::Ui.puts to_string(method, options)
|
26
|
+
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
def to_string(method, options = {})
|
29
|
+
return "" unless Machinery::Config.new.hints
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
"\nHint: #{send(method, options)}\n"
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
def program_name
|
35
|
+
if which_machinery == $PROGRAM_NAME
|
36
|
+
"machinery"
|
37
|
+
else
|
38
|
+
$PROGRAM_NAME
|
39
|
+
end
|
40
|
+
end
|
39
41
|
|
40
|
-
|
42
|
+
private
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def which_machinery
|
45
|
+
`which machinery 2>/dev/null`.chomp
|
46
|
+
rescue Errno::EPIPE => e
|
47
|
+
Machinery.logger.debug "Command `which machinery 2>/dev/null` crashed. " \
|
48
|
+
"Error was #{e.class}: #{e}"
|
49
|
+
end
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
def get_started(_options)
|
52
|
+
"You can get started by inspecting a system. Run:\n'#{program_name} inspect HOSTNAME'\n" \
|
53
|
+
"To inspect a system as a user with sudo rights instead of root run:\n" \
|
54
|
+
"'#{program_name} inspect --remote-user USER HOSTNAME'"
|
55
|
+
end
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
def upgrade_format_force(options)
|
58
|
+
"To force an upgrade of system descriptions run:\n" \
|
59
|
+
"#{program_name} upgrade-format --force #{options[:name]}"
|
60
|
+
end
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
def show_data(options)
|
63
|
+
"To show the data of the system you just inspected "\
|
64
|
+
"run:\n#{program_name} show #{options[:name]}"
|
65
|
+
end
|
63
66
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
67
|
+
def show_analyze_data(options)
|
68
|
+
"To show the config file diffs you just created run:\n" \
|
69
|
+
"#{program_name} show --scope changed-config-files --show-diffs #{options[:name]}"
|
70
|
+
end
|
68
71
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
72
|
+
def do_complete_inspection(options)
|
73
|
+
if options[:host]
|
74
|
+
"To do a full inspection containing all scopes and to extract files run:\n" \
|
75
|
+
"#{program_name} inspect #{options[:host]} --name #{options[:name]} --extract-files"
|
76
|
+
elsif options[:docker_container]
|
77
|
+
"To do a full inspection containing all scopes and to extract files run:\n" \
|
78
|
+
"#{program_name} inspect-container #{options[:docker_container]} " \
|
79
|
+
"--name #{options[:name]} --extract-files"
|
80
|
+
end
|
81
|
+
end
|
79
82
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
83
|
+
def upgrade_system_description(_options)
|
84
|
+
"To upgrade all system descriptions run:\n" \
|
85
|
+
"#{program_name} upgrade-format --all"
|
86
|
+
end
|
84
87
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
def share_html_contents(options)
|
89
|
+
dir = options[:directory] || ""
|
90
|
+
index_file = File.join(dir, "index.html")
|
91
|
+
assets_dir = File.join(dir, "assets/")
|
92
|
+
"Share the file: '#{index_file}' and the directory: '#{assets_dir}' as needed."
|
93
|
+
end
|
94
|
+
end
|
90
95
|
end
|
91
96
|
end
|
92
97
|
end
|