machinery-tool 1.2.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS +16 -0
  3. data/bin/machinery +1 -1
  4. data/export_helpers/merge_users_and_groups.pl.erb +1 -1
  5. data/export_helpers/unmanaged_files_autoyast_excludes +10 -0
  6. data/export_helpers/{unmanaged_files_build_excludes → unmanaged_files_kiwi_excludes} +1 -0
  7. data/helpers/changed_managed_files.sh +1 -1
  8. data/helpers/yum_repositories.py +37 -0
  9. data/html/assets/machinery.js +76 -57
  10. data/html/assets/reset.png +0 -0
  11. data/html/index.html.haml +6 -2
  12. data/lib/analyze_config_file_diffs_task.rb +5 -4
  13. data/lib/array.rb +1 -1
  14. data/lib/autoyast.rb +16 -8
  15. data/lib/build_task.rb +2 -1
  16. data/lib/changed_rpm_files_helper.rb +1 -1
  17. data/lib/cli.rb +13 -9
  18. data/lib/compare_task.rb +1 -1
  19. data/lib/config.rb +1 -1
  20. data/lib/config_base.rb +1 -1
  21. data/lib/config_task.rb +1 -1
  22. data/lib/constants.rb +1 -1
  23. data/lib/copy_task.rb +1 -1
  24. data/lib/current_user.rb +1 -1
  25. data/lib/deploy_task.rb +4 -1
  26. data/lib/exceptions.rb +5 -2
  27. data/lib/export_task.rb +8 -2
  28. data/lib/exporter.rb +1 -1
  29. data/lib/file_validator.rb +107 -0
  30. data/lib/generate_html_task.rb +1 -1
  31. data/lib/helper.rb +18 -1
  32. data/lib/hint.rb +1 -1
  33. data/lib/html.rb +8 -3
  34. data/lib/inspect_task.rb +3 -4
  35. data/lib/inspector.rb +1 -1
  36. data/lib/json_validation_error_cleaner.rb +78 -0
  37. data/lib/json_validator.rb +86 -0
  38. data/lib/kiwi_config.rb +6 -4
  39. data/lib/list_task.rb +33 -39
  40. data/lib/local_system.rb +20 -27
  41. data/lib/logged_cheetah.rb +1 -1
  42. data/lib/machinery.rb +5 -2
  43. data/lib/machinery_logger.rb +1 -1
  44. data/lib/manifest.rb +16 -5
  45. data/lib/migration.rb +40 -10
  46. data/lib/mountpoints.rb +1 -1
  47. data/lib/object.rb +10 -11
  48. data/lib/remote_system.rb +1 -1
  49. data/lib/remove_task.rb +19 -14
  50. data/lib/renderer.rb +6 -5
  51. data/lib/renderer_helper.rb +1 -1
  52. data/lib/rpm.rb +1 -1
  53. data/lib/scope_file_store.rb +1 -1
  54. data/lib/scope_mixin.rb +1 -1
  55. data/lib/show_task.rb +1 -1
  56. data/lib/system.rb +9 -2
  57. data/lib/system_description.rb +45 -55
  58. data/lib/system_description_memory_store.rb +1 -1
  59. data/lib/system_description_store.rb +29 -58
  60. data/lib/tarball.rb +18 -12
  61. data/lib/ui.rb +1 -1
  62. data/lib/upgrade_format_task.rb +12 -11
  63. data/lib/validate_task.rb +5 -2
  64. data/lib/version.rb +2 -2
  65. data/lib/zypper.rb +15 -11
  66. data/man/generated/machinery.1.gz +0 -0
  67. data/man/generated/machinery.1.html +20 -10
  68. data/plugins/inspect/changed_managed_files_inspector.rb +1 -1
  69. data/plugins/inspect/config_files_inspector.rb +1 -1
  70. data/plugins/inspect/groups_inspector.rb +1 -1
  71. data/plugins/inspect/os_inspector.rb +19 -1
  72. data/plugins/inspect/packages_inspector.rb +1 -1
  73. data/plugins/inspect/patterns_inspector.rb +14 -30
  74. data/plugins/inspect/repositories_inspector.rb +137 -77
  75. data/plugins/inspect/services_inspector.rb +42 -19
  76. data/plugins/inspect/unmanaged_files_inspector.rb +1 -1
  77. data/plugins/inspect/users_inspector.rb +1 -1
  78. data/plugins/model/changed_managed_files_model.rb +1 -1
  79. data/plugins/model/config_files_model.rb +1 -1
  80. data/plugins/model/file_scope.rb +2 -2
  81. data/plugins/model/groups_model.rb +1 -1
  82. data/plugins/model/os_model.rb +60 -8
  83. data/plugins/model/packages_model.rb +1 -1
  84. data/plugins/model/patterns_model.rb +1 -1
  85. data/plugins/model/repositories_model.rb +1 -1
  86. data/plugins/model/services_model.rb +1 -1
  87. data/plugins/model/unmanaged_files_model.rb +1 -1
  88. data/plugins/model/users_model.rb +1 -1
  89. data/plugins/schema/v3/system-description-changed-managed-files.schema.json +92 -0
  90. data/plugins/schema/v3/system-description-config-files.schema.json +92 -0
  91. data/plugins/schema/v3/system-description-groups.schema.json +30 -0
  92. data/plugins/schema/v3/system-description-os.schema.json +21 -0
  93. data/plugins/schema/v3/system-description-packages.schema.json +34 -0
  94. data/plugins/schema/v3/system-description-patterns.schema.json +24 -0
  95. data/plugins/schema/v3/system-description-repositories.schema.json +45 -0
  96. data/plugins/schema/v3/system-description-services.schema.json +30 -0
  97. data/plugins/schema/v3/system-description-unmanaged-files.schema.json +138 -0
  98. data/plugins/schema/v3/system-description-users.schema.json +61 -0
  99. data/plugins/show/changed_managed_files_renderer.rb +1 -1
  100. data/plugins/show/config_files_renderer.rb +2 -2
  101. data/plugins/show/groups_renderer.rb +1 -1
  102. data/plugins/show/os_renderer.rb +1 -1
  103. data/plugins/show/packages_renderer.rb +1 -1
  104. data/plugins/show/patterns_renderer.rb +1 -1
  105. data/plugins/show/repositories_renderer.rb +8 -3
  106. data/plugins/show/services_renderer.rb +1 -1
  107. data/plugins/show/unmanaged_files_renderer.rb +1 -1
  108. data/plugins/show/users_renderer.rb +1 -1
  109. data/schema/migrations/migrate1to2.rb +1 -1
  110. data/schema/migrations/migrate2to3.rb +42 -0
  111. data/schema/v3/system-description-global.schema.json +31 -0
  112. metadata +147 -130
  113. data/lib/system_description_validator.rb +0 -216
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -17,15 +17,15 @@
17
17
 
18
18
  class ServicesInspector < Inspector
19
19
  def inspect(system, description, options = {})
20
- if has_systemd(system)
20
+ if system.has_command?("systemctl")
21
21
  result = ServicesScope.new(
22
22
  init_system: "systemd",
23
- services: inspect_systemd_services(system)
23
+ services: inspect_systemd_services(system)
24
24
  )
25
25
  else
26
26
  result = ServicesScope.new(
27
27
  init_system: "sysvinit",
28
- services: inspect_sysvinit_services(system)
28
+ services: inspect_sysvinit_services(system)
29
29
  )
30
30
  end
31
31
 
@@ -35,13 +35,6 @@ class ServicesInspector < Inspector
35
35
 
36
36
  private
37
37
 
38
- def has_systemd(system)
39
- system.run_command("systemctl", "--version")
40
- true
41
- rescue Cheetah::ExecutionFailed
42
- false
43
- end
44
-
45
38
  def inspect_systemd_services(system)
46
39
  output = system.run_command(
47
40
  "systemctl",
@@ -54,35 +47,65 @@ class ServicesInspector < Inspector
54
47
  # separator and a summary (e.g. "197 unit files listed"). We also filter
55
48
  # templates.
56
49
  lines = output.lines[1..-3].reject { |l| l =~ /@/ }
57
-
58
- @summary = "Found #{lines.size} services."
59
-
60
50
  services = lines.map do |line|
61
51
  name, state = line.split(/\s+/)
62
52
 
63
53
  Service.new(name: name, state: state)
64
54
  end
65
55
 
56
+ @summary = "Found #{services.size} services."
66
57
  ServiceList.new(services.sort_by(&:name))
67
58
  end
68
59
 
69
60
  def inspect_sysvinit_services(system)
70
- system.check_requirement("chkconfig", "--help")
61
+ # Red Hat's chkconfig behaves differently than SUSE's: It takes different
62
+ # command line arguments and has a different output format. We determine
63
+ # if it's Red Hat by calling 'chkconfig --version'. On SUSE it exits with
64
+ # an error, on Red Hat it doesn't.
65
+ #
66
+ begin
67
+ system.run_command("chkconfig", "--version")
68
+ services = parse_redhat_chkconfig(system)
69
+ rescue
70
+ services = parse_suse_chkconfig(system)
71
+ end
71
72
 
73
+ @summary = "Found #{services.size} services."
74
+ ServiceList.new(services.sort_by(&:name))
75
+ end
76
+
77
+ def parse_suse_chkconfig(system)
78
+ system.check_requirement("chkconfig", "--help")
72
79
  output = system.run_command(
73
80
  "chkconfig",
74
81
  "--allservices",
75
82
  :stdout => :capture
76
83
  )
77
84
 
78
- @summary = "Found #{output.lines.size} services."
79
-
80
85
  services = output.lines.map do |line|
81
86
  name, state = line.split(/\s+/)
82
-
83
87
  Service.new(name: name, state: state)
84
88
  end
89
+ end
85
90
 
86
- ServiceList.new(services.sort_by(&:name))
91
+ def parse_redhat_chkconfig(system)
92
+ system.check_requirement("chkconfig", "--version")
93
+ system.check_requirement("runlevel")
94
+ _, runlevel = system.run_command(
95
+ "runlevel",
96
+ stdout: :capture
97
+ ).split(" ")
98
+
99
+ output = system.run_command(
100
+ "chkconfig", "--list",
101
+ stdout: :capture
102
+ )
103
+
104
+ services = output.lines.map do |line|
105
+ state = []
106
+ name, state[0], state[1], state[2], state[3], state[4], state[5], state[6] = line.split(/\s+/)
107
+ Service.new(name: name, state: state[runlevel.to_i].split(":")[1])
108
+ end
109
+ services
87
110
  end
88
111
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -35,7 +35,7 @@ class FileScope < Machinery::Object
35
35
  private
36
36
 
37
37
  def validate_attributes(other)
38
- expected_attributes = [:extracted, :files]
38
+ expected_attributes = ["extracted", "files"]
39
39
  actual_attributes = (attributes.keys + other.attributes.keys).uniq.sort
40
40
 
41
41
  if actual_attributes != expected_attributes
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -19,7 +19,9 @@ class Os < Machinery::Object
19
19
  include Machinery::ScopeMixin
20
20
 
21
21
  def self.descendants
22
- ObjectSpace.each_object(::Class).select { |klass| klass < self }
22
+ @descendants ||= ObjectSpace.each_object(::Class).select do |klass|
23
+ klass < self && klass.descendants.empty?
24
+ end
23
25
  end
24
26
 
25
27
  def self.for(os_name)
@@ -31,7 +33,7 @@ class Os < Machinery::Object
31
33
  end
32
34
  end
33
35
  os = OsUnknown.new
34
- os.name = "Unknown: #{os_name}"
36
+ os.name = os_name
35
37
  os
36
38
  end
37
39
 
@@ -66,7 +68,15 @@ class Os < Machinery::Object
66
68
  end
67
69
 
68
70
  def can_build?(os)
69
- self.class.buildable_systems.include?(os.class)
71
+ self.class.buildable_systems.include?(os.class) && os.architecture == "x86_64"
72
+ end
73
+
74
+ def can_be_analyzed?
75
+ false
76
+ end
77
+
78
+ def can_be_exported?
79
+ false
70
80
  end
71
81
 
72
82
  def module_required_by_package(package)
@@ -76,6 +86,10 @@ class Os < Machinery::Object
76
86
  def canonical_name
77
87
  self.class.canonical_name
78
88
  end
89
+
90
+ def display_name
91
+ "#{name} #{version} (#{architecture})"
92
+ end
79
93
  end
80
94
 
81
95
  class OsUnknown < Os
@@ -88,7 +102,17 @@ class OsUnknown < Os
88
102
  end
89
103
  end
90
104
 
91
- class OsSles11 < Os
105
+ class OsSuse < Os
106
+ def can_be_analyzed?
107
+ true
108
+ end
109
+
110
+ def can_be_exported?
111
+ true
112
+ end
113
+ end
114
+
115
+ class OsSles11 < OsSuse
92
116
  def self.canonical_name
93
117
  "SUSE Linux Enterprise Server 11"
94
118
  end
@@ -96,9 +120,15 @@ class OsSles11 < Os
96
120
  def self.can_run_machinery?
97
121
  false
98
122
  end
123
+
124
+ def display_name
125
+ version =~ /11 (.*)/
126
+ sp = $1
127
+ "#{name} #{sp} (#{architecture})"
128
+ end
99
129
  end
100
130
 
101
- class OsSles12 < Os
131
+ class OsSles12 < OsSuse
102
132
  def self.canonical_name
103
133
  "SUSE Linux Enterprise Server 12"
104
134
  end
@@ -110,9 +140,21 @@ class OsSles12 < Os
110
140
  def self.module_dependencies
111
141
  { "python-glanceclient" => "Public Cloud Module" }
112
142
  end
143
+
144
+ def display_name
145
+ "#{name} (#{architecture})"
146
+ end
113
147
  end
114
148
 
115
- class OsOpenSuse13_1 < Os
149
+ class OsOpenSuse < OsSuse
150
+ def display_name
151
+ name =~ /(.*) \(.*\)/
152
+ name_and_version_without_codename = $1
153
+ "#{name_and_version_without_codename} (#{architecture})"
154
+ end
155
+ end
156
+
157
+ class OsOpenSuse13_1 < OsOpenSuse
116
158
  def self.canonical_name
117
159
  "openSUSE 13.1 (Bottle)"
118
160
  end
@@ -122,7 +164,7 @@ class OsOpenSuse13_1 < Os
122
164
  end
123
165
  end
124
166
 
125
- class OsOpenSuse13_2 < Os
167
+ class OsOpenSuse13_2 < OsOpenSuse
126
168
  def self.canonical_name
127
169
  "openSUSE 13.2 (Harlequin)"
128
170
  end
@@ -131,3 +173,13 @@ class OsOpenSuse13_2 < Os
131
173
  [OsSles11, OsOpenSuse13_1, OsOpenSuse13_2]
132
174
  end
133
175
  end
176
+
177
+ class Rhel < Os
178
+ def self.canonical_name
179
+ "Red Hat Enterprise Linux Server"
180
+ end
181
+
182
+ def self.can_run_machinery?
183
+ false
184
+ end
185
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2014 SUSE LLC
1
+ # Copyright (c) 2013-2015 SUSE LLC
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or
4
4
  # modify it under the terms of version 3 of the GNU General Public License as
@@ -0,0 +1,92 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+
4
+ "type": "object",
5
+ "required": ["extracted", "files"],
6
+ "properties": {
7
+ "extracted": {
8
+ "type": "boolean"
9
+ },
10
+ "files": {
11
+ "type": "array",
12
+ "items" : {
13
+ "type": "object",
14
+ "required": ["name", "package_name", "package_version"],
15
+ "properties": {
16
+ "name": {
17
+ "type": "string"
18
+ },
19
+ "package_name": {
20
+ "type": "string",
21
+ "minLength": 1
22
+ },
23
+ "package_version": {
24
+ "type": "string",
25
+ "minLength": 1
26
+ }
27
+ },
28
+ "oneOf": [
29
+ { "$ref": "#/definitions/file_changed" },
30
+ { "$ref": "#/definitions/file_error" }
31
+ ]
32
+ }
33
+ }
34
+ },
35
+ "definitions": {
36
+ "file_changed": {
37
+ "required": ["status"],
38
+ "properties": {
39
+ "status": {
40
+ "enum": ["changed"]
41
+ }
42
+ },
43
+ "oneOf": [
44
+ { "$ref": "#/definitions/file_changed_modified" },
45
+ { "$ref": "#/definitions/file_changed_deleted" }
46
+ ]
47
+ },
48
+ "file_changed_modified": {
49
+ "required": ["changes", "mode", "user", "group"],
50
+ "properties": {
51
+ "changes": {
52
+ "type": "array",
53
+ "items": {
54
+ "enum": ["mode", "md5", "group", "user", "replaced"]
55
+ },
56
+ "minItems": 1
57
+ },
58
+ "mode": {
59
+ "type": "string",
60
+ "pattern": "^[0-7]{3,4}$"
61
+ },
62
+ "user": {
63
+ "type": "string",
64
+ "minLength": 1
65
+ },
66
+ "group": {
67
+ "type": "string",
68
+ "minLength": 1
69
+ }
70
+ }
71
+ },
72
+ "file_changed_deleted": {
73
+ "required": ["changes"],
74
+ "properties": {
75
+ "changes": {
76
+ "enum": [["deleted"]]
77
+ }
78
+ }
79
+ },
80
+ "file_error": {
81
+ "required": ["status", "error_message"],
82
+ "properties": {
83
+ "status": {
84
+ "enum": ["error"]
85
+ },
86
+ "error_message": {
87
+ "type": "string"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,92 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+
4
+ "type": "object",
5
+ "required": ["extracted", "files"],
6
+ "properties": {
7
+ "extracted": {
8
+ "type": "boolean"
9
+ },
10
+ "files": {
11
+ "type": "array",
12
+ "items" : {
13
+ "type": "object",
14
+ "required": ["name", "package_name", "package_version"],
15
+ "properties": {
16
+ "name": {
17
+ "type": "string"
18
+ },
19
+ "package_name": {
20
+ "type": "string",
21
+ "minLength": 1
22
+ },
23
+ "package_version": {
24
+ "type": "string",
25
+ "minLength": 1
26
+ }
27
+ },
28
+ "oneOf": [
29
+ { "$ref": "#/definitions/file_changed" },
30
+ { "$ref": "#/definitions/file_error" }
31
+ ]
32
+ }
33
+ }
34
+ },
35
+ "definitions": {
36
+ "file_changed": {
37
+ "required": ["status"],
38
+ "properties": {
39
+ "status": {
40
+ "enum": ["changed"]
41
+ }
42
+ },
43
+ "oneOf": [
44
+ { "$ref": "#/definitions/file_changed_modified" },
45
+ { "$ref": "#/definitions/file_changed_deleted" }
46
+ ]
47
+ },
48
+ "file_changed_modified": {
49
+ "required": ["changes", "mode", "user", "group"],
50
+ "properties": {
51
+ "changes": {
52
+ "type": "array",
53
+ "items": {
54
+ "enum": ["mode", "md5", "group", "user", "replaced"]
55
+ },
56
+ "minItems": 1
57
+ },
58
+ "mode": {
59
+ "type": "string",
60
+ "pattern": "^[0-7]{3,4}$"
61
+ },
62
+ "user": {
63
+ "type": "string",
64
+ "minLength": 1
65
+ },
66
+ "group": {
67
+ "type": "string",
68
+ "minLength": 1
69
+ }
70
+ }
71
+ },
72
+ "file_changed_deleted": {
73
+ "required": ["changes"],
74
+ "properties": {
75
+ "changes": {
76
+ "enum": [["deleted"]]
77
+ }
78
+ }
79
+ },
80
+ "file_error": {
81
+ "required": ["status", "error_message"],
82
+ "properties": {
83
+ "status": {
84
+ "enum": ["error"]
85
+ },
86
+ "error_message": {
87
+ "type": "string"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }