machinery-tool 1.20.0 → 1.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.git_revision +1 -1
  3. data/NEWS +12 -0
  4. data/html/assets/bootstrap-modal.js +338 -0
  5. data/html/assets/compare/machinery.js +15 -0
  6. data/html/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
  7. data/html/assets/fonts/glyphicons-halflings-regular.woff +0 -0
  8. data/html/assets/machinery-base.css +5 -2
  9. data/html/assets/machinery-base.js +16 -1
  10. data/html/assets/machinery.css +41 -0
  11. data/html/assets/show/machinery.js +18 -0
  12. data/html/comparison.html.haml +25 -26
  13. data/html/homepage.html.haml +24 -0
  14. data/html/index.html.haml +35 -30
  15. data/html/partials/{landing_page/alert.html.haml → alert.html.haml} +0 -0
  16. data/html/partials/compare/changed_config_files.html.haml +1 -1
  17. data/html/partials/compare/changed_managed_files.html.haml +1 -1
  18. data/html/partials/compare/groups.html.haml +1 -1
  19. data/html/partials/compare/os.html.haml +1 -1
  20. data/html/partials/compare/packages.html.haml +1 -1
  21. data/html/partials/compare/pattern_list.html.haml +3 -0
  22. data/html/partials/compare/patterns.html.haml +1 -2
  23. data/html/partials/compare/repositories.html.haml +1 -1
  24. data/html/partials/compare/services.html.haml +1 -1
  25. data/html/partials/compare/unmanaged_file_list.html.haml +12 -4
  26. data/html/partials/compare/unmanaged_files.html.haml +1 -1
  27. data/html/partials/compare/users.html.haml +1 -1
  28. data/html/partials/description_selector.html.haml +57 -0
  29. data/html/partials/nav_bar.html.haml +34 -0
  30. data/html/partials/patterns.html.haml +4 -1
  31. data/html/partials/unmanaged_files.html.haml +11 -3
  32. data/lib/config_task.rb +8 -2
  33. data/lib/exceptions.rb +0 -1
  34. data/lib/server.rb +19 -2
  35. data/lib/system_description.rb +1 -1
  36. data/lib/version.rb +1 -1
  37. data/lib/zypper.rb +1 -1
  38. data/machinery-helper/machinery_helper.go +12 -4
  39. data/machinery-helper/machinery_helper_test.go +5 -1
  40. data/machinery-helper/version.go +1 -1
  41. data/man/generated/machinery.1.gz +0 -0
  42. data/manual/site/sitemap.xml +23 -23
  43. data/plugins/changed_config_files/schema/system-description-changed-config-files.schema-v10.json +160 -0
  44. data/plugins/changed_managed_files/schema/system-description-changed-managed-files.schema-v10.json +160 -0
  45. data/plugins/environment/schema/system-description-environment.schema-v10.json +17 -0
  46. data/plugins/groups/schema/system-description-groups.schema-v10.json +49 -0
  47. data/plugins/os/schema/system-description-os.schema-v10.json +21 -0
  48. data/plugins/packages/schema/system-description-packages.schema-v10.json +115 -0
  49. data/plugins/patterns/patterns_inspector.rb +2 -0
  50. data/plugins/patterns/patterns_model.rb +1 -0
  51. data/plugins/patterns/patterns_renderer.rb +4 -1
  52. data/plugins/patterns/schema/system-description-patterns.schema-v10.json +69 -0
  53. data/plugins/repositories/schema/system-description-repositories.schema-v10.json +165 -0
  54. data/plugins/services/schema/system-description-services.schema-v10.json +93 -0
  55. data/plugins/services/services_inspector.rb +40 -9
  56. data/plugins/unmanaged_files/schema/system-description-unmanaged-files.schema-v10.json +153 -0
  57. data/plugins/unmanaged_files/unmanaged_files_model.rb +8 -0
  58. data/plugins/unmanaged_files/unmanaged_files_renderer.rb +8 -2
  59. data/plugins/users/schema/system-description-users.schema-v10.json +86 -0
  60. data/schema/migrations/migrate9to10.rb +55 -0
  61. data/schema/system-description-global.schema-v10.json +43 -0
  62. metadata +23 -5
  63. data/html/landing_page.html.haml +0 -62
@@ -0,0 +1,165 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "type": "object",
4
+ "required": [
5
+ "_elements"
6
+ ],
7
+ "oneOf": [
8
+ {
9
+ "properties": {
10
+ "_attributes": {
11
+ "type": "object",
12
+ "required": [
13
+ "repository_system"
14
+ ],
15
+ "properties": {
16
+ "repository_system": {
17
+ "enum": ["zypp"]
18
+ }
19
+ }
20
+ },
21
+ "_elements": {
22
+ "type": "array",
23
+ "items": {
24
+ "type": "object",
25
+ "required": ["alias", "name", "url", "type", "enabled", "gpgcheck", "autorefresh", "priority"],
26
+ "properties": {
27
+ "alias": {
28
+ "type": "string",
29
+ "minLength": 1
30
+ },
31
+ "name": {
32
+ "type": "string",
33
+ "minLength": 1
34
+ },
35
+ "type": {
36
+ "enum": ["yast2", "rpm-md", "plaindir", null]
37
+ },
38
+ "url": {
39
+ "type": "string",
40
+ "format": "uri",
41
+ "minLength": 1
42
+ },
43
+ "enabled": {
44
+ "type": "boolean"
45
+ },
46
+ "autorefresh": {
47
+ "type": "boolean"
48
+ },
49
+ "gpgcheck": {
50
+ "type": "boolean"
51
+ },
52
+ "priority": {
53
+ "type": "integer",
54
+ "minimum": 1
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ },
61
+ {
62
+ "properties": {
63
+ "_attributes": {
64
+ "type": "object",
65
+ "required": [
66
+ "repository_system"
67
+ ],
68
+ "properties": {
69
+ "repository_system": {
70
+ "enum": ["yum"]
71
+ }
72
+ }
73
+ },
74
+ "_elements": {
75
+ "type": "array",
76
+ "items": {
77
+ "type": "object",
78
+ "required": ["alias", "name", "url", "type", "enabled", "gpgcheck", "gpgkey", "mirrorlist"],
79
+ "properties": {
80
+ "alias": {
81
+ "type": "string",
82
+ "minLength": 1
83
+ },
84
+ "mirrorlist": {
85
+ "type": "string"
86
+ },
87
+ "name": {
88
+ "type": "string",
89
+ "minLength": 1
90
+ },
91
+ "type": {
92
+ "enum": ["rpm-md", null]
93
+ },
94
+ "url": {
95
+ "type": "array",
96
+ "items": {
97
+ "type": "string",
98
+ "format": "url",
99
+ "minLength": 1
100
+ }
101
+ },
102
+ "enabled": {
103
+ "type": "boolean"
104
+ },
105
+ "gpgcheck": {
106
+ "type": "boolean"
107
+ },
108
+ "gpgkey": {
109
+ "type": "array",
110
+ "items": {
111
+ "type": "string",
112
+ "format": "url",
113
+ "minLength": 1
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ },
121
+ {
122
+ "properties": {
123
+ "_attributes": {
124
+ "type": "object",
125
+ "required": [
126
+ "repository_system"
127
+ ],
128
+ "properties": {
129
+ "repository_system": {
130
+ "enum": ["apt"]
131
+ }
132
+ }
133
+ },
134
+ "_elements": {
135
+ "type": "array",
136
+ "items": {
137
+ "type": "object",
138
+ "required": ["url", "type", "distribution", "components"],
139
+ "properties": {
140
+ "distribution": {
141
+ "type": "string",
142
+ "minLength": 1
143
+ },
144
+ "type": {
145
+ "enum": ["deb", "deb-src"]
146
+ },
147
+ "url": {
148
+ "type": "string",
149
+ "format": "uri",
150
+ "minLength": 1
151
+ },
152
+ "components": {
153
+ "type": "array",
154
+ "items": {
155
+ "type": "string",
156
+ "minLength": 1
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+ ]
165
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+
4
+ "type": "object",
5
+ "required": [
6
+ "_elements"
7
+ ],
8
+ "oneOf": [
9
+ {
10
+ "properties": {
11
+ "_attributes": {
12
+ "type": "object",
13
+ "required": [
14
+ "init_system"
15
+ ],
16
+ "properties": {
17
+ "init_system": {
18
+ "not": {
19
+ "enum": [
20
+ "upstart"
21
+ ]
22
+ },
23
+ "type": "string",
24
+ "minLength": 1
25
+ }
26
+ }
27
+ },
28
+ "_elements": {
29
+ "type": "array",
30
+ "items": {
31
+ "type": "object",
32
+ "required": [
33
+ "name",
34
+ "state"
35
+ ],
36
+ "properties": {
37
+ "name": {
38
+ "type": "string",
39
+ "minLength": 1
40
+ },
41
+ "state": {
42
+ "type": "string",
43
+ "minLength": 1
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ },
50
+ {
51
+ "properties": {
52
+ "_attributes": {
53
+ "type": "object",
54
+ "required": [
55
+ "init_system"
56
+ ],
57
+ "properties": {
58
+ "init_system": {
59
+ "enum": [
60
+ "upstart"
61
+ ]
62
+ }
63
+ }
64
+ },
65
+ "_elements": {
66
+ "type": "array",
67
+ "items": {
68
+ "type": "object",
69
+ "required": [
70
+ "name",
71
+ "state",
72
+ "legacy_sysv"
73
+ ],
74
+ "properties": {
75
+ "name": {
76
+ "type": "string",
77
+ "minLength": 1
78
+ },
79
+ "state": {
80
+ "type": "string",
81
+ "minLength": 1
82
+ },
83
+ "legacy_sysv": {
84
+ "type": "boolean"
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+ ]
92
+ }
93
+
@@ -51,7 +51,27 @@ class ServicesInspector < Inspector
51
51
  private
52
52
 
53
53
  def inspect_systemd_services
54
- output = @system.run_command(
54
+ services = list_unit_files.map do |line|
55
+ name, state = line.split(/\s+/)
56
+
57
+ Service.new(name: name, state: state)
58
+ end
59
+
60
+ list_unit_files(true).map { |line| line.split(/\s+/) }.each do |name, state|
61
+ prefix, suffix = name.split("@")
62
+
63
+ instances = list_units.select { |i| i =~ /#{prefix}@.+#{suffix}/ }.each do |instance|
64
+ services << Service.new(name: instance, state: unit_is_enabled?(instance))
65
+ end
66
+
67
+ services << Service.new(name: name, state: state) if instances.empty?
68
+ end
69
+
70
+ services.sort_by(&:name)
71
+ end
72
+
73
+ def list_unit_files(templates = false)
74
+ @unit_files ||= @system.run_command(
55
75
  "systemctl",
56
76
  "list-unit-files",
57
77
  "--type=service,socket",
@@ -59,16 +79,27 @@ class ServicesInspector < Inspector
59
79
  )
60
80
 
61
81
  # The first line contains a table header. The last two lines contain a
62
- # separator and a summary (e.g. "197 unit files listed"). We also filter
63
- # templates.
64
- lines = output.lines[1..-3].reject { |l| l =~ /@/ }
65
- services = lines.map do |line|
66
- name, state = line.split(/\s+/)
82
+ # separator and a summary (e.g. "197 unit files listed"). Files will be grouped by depending on
83
+ # weather they are templates or not.
84
+ @unit_files.lines[1..-3].group_by { |l| l.include?("@") }[templates]
85
+ end
67
86
 
68
- Service.new(name: name, state: state)
69
- end
87
+ def list_units
88
+ output = @system.run_command(
89
+ "systemctl",
90
+ "list-units",
91
+ "--all",
92
+ stdout: :capture
93
+ )
70
94
 
71
- services.sort_by(&:name)
95
+ output.lines[1..-8].map { |line| line.split.first }
96
+ end
97
+
98
+ def unit_is_enabled?(unit)
99
+ output = @system.run_command("systemctl", "is-enabled", unit, stdout: :capture)
100
+ return output.split("\n").first
101
+ rescue Cheetah::ExecutionFailed
102
+ return "disabled"
72
103
  end
73
104
 
74
105
  def inspect_sysvinit_services
@@ -0,0 +1,153 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+
4
+ "type": "object",
5
+ "required": [
6
+ "_elements"
7
+ ],
8
+ "properties": {
9
+ "_attributes": {
10
+ "type": "object",
11
+ "required": [
12
+ "extracted",
13
+ "has_metadata"
14
+ ],
15
+ "properties": {
16
+ "extracted": {
17
+ "type": "boolean"
18
+ },
19
+ "has_metadata": {
20
+ "type": "boolean"
21
+ }
22
+ }
23
+ },
24
+ "_elements": {
25
+ "type": "array",
26
+ "items": {
27
+ "anyOf": [
28
+ {
29
+ "$ref": "#/definitions/file"
30
+ },
31
+ {
32
+ "$ref": "#/definitions/file_remote_dir"
33
+ }
34
+ ]
35
+ }
36
+ }
37
+ },
38
+ "definitions": {
39
+ "file": {
40
+ "oneOf": [
41
+ {
42
+ "type": "object",
43
+ "required": ["name", "type", "user", "group"],
44
+ "properties": {
45
+ "name": {
46
+ "type": "string"
47
+ },
48
+ "type": {
49
+ "enum": ["file", "link", "dir", "remote_dir"]
50
+ },
51
+ "user": {
52
+ "type": "string",
53
+ "minLength": 1
54
+ },
55
+ "group": {
56
+ "type": "string",
57
+ "minLength": 1
58
+ }
59
+ },
60
+ "oneOf": [
61
+ { "$ref": "#/definitions/file_file" },
62
+ { "$ref": "#/definitions/file_dir" },
63
+ { "$ref": "#/definitions/file_link" }
64
+ ]
65
+ },
66
+ {
67
+ "$ref": "#/definitions/file_common"
68
+ }
69
+ ]
70
+ },
71
+ "file_common": {
72
+ "type": "object",
73
+ "required": ["name", "type"],
74
+ "properties": {
75
+ "name": {
76
+ "type": "string"
77
+ },
78
+ "type": {
79
+ "enum": ["file", "link", "dir", "remote_dir"]
80
+ }
81
+ }
82
+ },
83
+ "file_file": {
84
+ "required": ["type", "size", "mode"],
85
+ "properties": {
86
+ "type": {
87
+ "enum": ["file"]
88
+ },
89
+ "size": {
90
+ "type": "integer",
91
+ "minimum": 0
92
+ },
93
+ "mode": {
94
+ "type": "string",
95
+ "pattern": "^[0-7]{3,4}$"
96
+ }
97
+ }
98
+ },
99
+ "file_dir": {
100
+ "required": ["type", "size", "mode"],
101
+ "properties": {
102
+ "type": {
103
+ "enum": ["dir"]
104
+ },
105
+ "size": {
106
+ "type": "integer",
107
+ "minimum": 0
108
+ },
109
+ "mode": {
110
+ "type": "string",
111
+ "pattern": "^[0-4]?[0-7]{3}$"
112
+ }
113
+ },
114
+ "oneOf": [
115
+ {
116
+ "required": ["files", "dirs"],
117
+ "properties": {
118
+ "files": {
119
+ "type": "integer",
120
+ "minimum": 0
121
+ },
122
+ "dirs": {
123
+ "type": "integer",
124
+ "minimum": 0
125
+ }
126
+ }
127
+ },
128
+ {
129
+ "required": ["file_objects"],
130
+ "properties": {
131
+ "file_objects": {
132
+ "type": "integer",
133
+ "minimum": 0
134
+ }
135
+ }
136
+ }
137
+ ]
138
+ },
139
+ "file_link": {
140
+ "required": ["type"],
141
+ "properties": {
142
+ "type": {
143
+ "enum": ["link"]
144
+ }
145
+ }
146
+ },
147
+ "file_remote_dir": {
148
+ "allOf": [
149
+ { "$ref": "#/definitions/file_common" }
150
+ ]
151
+ }
152
+ }
153
+ }