machinery-tool 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS +20 -0
  3. data/export_helpers/containerize_readme.md +28 -11
  4. data/html/comparison.html.haml +3 -3
  5. data/lib/build_task.rb +8 -6
  6. data/lib/cli.rb +69 -17
  7. data/lib/compare_task.rb +1 -1
  8. data/lib/config_base.rb +1 -1
  9. data/lib/config_task.rb +4 -1
  10. data/lib/containerize_task.rb +15 -1
  11. data/lib/containerized_app.rb +27 -0
  12. data/lib/hint.rb +18 -6
  13. data/lib/html.rb +17 -0
  14. data/lib/inspect_task.rb +6 -0
  15. data/lib/inspector.rb +2 -1
  16. data/lib/kiwi_config.rb +14 -1
  17. data/lib/logged_cheetah.rb +1 -20
  18. data/lib/machinery.rb +1 -0
  19. data/lib/remote_system.rb +2 -1
  20. data/lib/scope.rb +22 -2
  21. data/lib/serve_html_task.rb +1 -1
  22. data/lib/show_task.rb +1 -1
  23. data/lib/system.rb +6 -0
  24. data/lib/system_description.rb +4 -3
  25. data/lib/version.rb +1 -1
  26. data/lib/workload_mapper.rb +1 -0
  27. data/man/generated/machinery.1.gz +0 -0
  28. data/man/generated/machinery.1.html +16 -4
  29. data/plugins/changed_managed_files/schema/system-description-changed-managed-files.schema-v5.json +126 -0
  30. data/plugins/config_files/schema/system-description-config-files.schema-v5.json +126 -0
  31. data/plugins/environment/environment.md +1 -0
  32. data/plugins/environment/environment_inspector.rb +50 -0
  33. data/plugins/environment/environment_model.rb +22 -0
  34. data/plugins/environment/schema/system-description-environment.schema-v5.json +13 -0
  35. data/plugins/groups/schema/system-description-groups.schema-v5.json +30 -0
  36. data/plugins/os/os_model.rb +4 -0
  37. data/plugins/os/schema/system-description-os.schema-v5.json +21 -0
  38. data/plugins/packages/schema/system-description-packages.schema-v5.json +34 -0
  39. data/plugins/patterns/schema/system-description-patterns.schema-v5.json +24 -0
  40. data/plugins/repositories/schema/system-description-repositories.schema-v5.json +45 -0
  41. data/plugins/services/schema/system-description-services.schema-v5.json +30 -0
  42. data/plugins/unmanaged_files/schema/system-description-unmanaged-files.schema-v5.json +144 -0
  43. data/plugins/unmanaged_files/unmanaged_files_inspector.rb +45 -23
  44. data/plugins/users/schema/system-description-users.schema-v5.json +61 -0
  45. data/schema/migrations/migrate4to5.rb +28 -0
  46. data/schema/system-description-global.schema-v5.json +43 -0
  47. data/workload_mapper/docker-registry/clue.rb +14 -0
  48. data/workload_mapper/docker-registry/compose-template.yml +5 -0
  49. data/workload_mapper/docker-registry/container/Dockerfile +12 -0
  50. data/workload_mapper/mariadb/clue.rb +5 -0
  51. data/workload_mapper/mariadb/compose-template.yml +9 -0
  52. data/workload_mapper/mariadb/container/Dockerfile +13 -0
  53. data/workload_mapper/mariadb/container/scripts/config_mariadb.sh +49 -0
  54. data/workload_mapper/mariadb/container/scripts/start.sh +11 -0
  55. data/workload_mapper/rails/clue.rb +16 -0
  56. data/workload_mapper/rails/compose-template.yml +5 -0
  57. data/workload_mapper/rails/config/config/database.yml +7 -0
  58. data/workload_mapper/rails/container/Dockerfile +48 -0
  59. data/workload_mapper/rails/container/apache2/httpd.conf.local +5 -0
  60. data/workload_mapper/rails/container/apache2/listen.conf +1 -0
  61. data/workload_mapper/rails/container/apache2/rails_app_vhost.conf +13 -0
  62. data/workload_mapper/rails/container/apache2/sysconfig_apache2 +280 -0
  63. data/workload_mapper/rails/setup/setup.rb.erb +72 -0
  64. metadata +248 -214
data/lib/hint.rb CHANGED
@@ -29,34 +29,46 @@ class Hint
29
29
  "\nHint: #{send(method, options)}\n"
30
30
  end
31
31
 
32
+ def program_name
33
+ if which_machinery == $PROGRAM_NAME
34
+ "machinery"
35
+ else
36
+ $PROGRAM_NAME
37
+ end
38
+ end
39
+
32
40
  private
33
41
 
42
+ def which_machinery
43
+ `which machinery 2>/dev/null`.chomp
44
+ end
45
+
34
46
  def get_started(_options)
35
- "You can get started by inspecting a system. Run:\n#{$0} inspect HOSTNAME"
47
+ "You can get started by inspecting a system. Run:\n#{program_name} inspect HOSTNAME"
36
48
  end
37
49
 
38
50
  def upgrade_format_force(options)
39
51
  "To force an upgrade of system descriptions run:\n" \
40
- "#{$0} upgrade-format --force #{options[:name]}"
52
+ "#{program_name} upgrade-format --force #{options[:name]}"
41
53
  end
42
54
 
43
55
  def show_data(options)
44
- "To show the data of the system you just inspected run:\n#{$0} show #{options[:name]}"
56
+ "To show the data of the system you just inspected run:\n#{program_name} show #{options[:name]}"
45
57
  end
46
58
 
47
59
  def show_analyze_data(options)
48
60
  "To show the config file diffs you just created run:\n" \
49
- "#{$0} show --scope config-files --show-diffs #{options[:name]}"
61
+ "#{program_name} show --scope config-files --show-diffs #{options[:name]}"
50
62
  end
51
63
 
52
64
  def do_complete_inspection(options)
53
65
  "To do a full inspection containing all scopes and to extract files run:\n" \
54
- "#{$0} inspect #{options[:host]} --name #{options[:name]} --extract-files"
66
+ "#{program_name} inspect #{options[:host]} --name #{options[:name]} --extract-files"
55
67
  end
56
68
 
57
69
  def upgrade_system_description(_options)
58
70
  "To upgrade all system descriptions run:\n" \
59
- "#{$0} upgrade-format --all"
71
+ "#{program_name} upgrade-format --all"
60
72
  end
61
73
 
62
74
  def share_html_contents(options)
data/lib/html.rb CHANGED
@@ -43,6 +43,23 @@ EOF
43
43
  servefailed_error = <<-EOF.chomp
44
44
  Port #{Server.settings.port} is already in use.
45
45
  Stop the already running server on port #{Server.settings.port} or specify a new port by using --port option.
46
+ EOF
47
+ raise Machinery::Errors::ServeFailed, servefailed_error
48
+ rescue SocketError => e
49
+ servefailed_error = <<-EOF.chomp
50
+ Cannot start server on #{opts[:ip]}:#{Server.settings.port}.
51
+ ERROR: #{e.message}
52
+ EOF
53
+ raise Machinery::Errors::ServeFailed, servefailed_error
54
+ rescue Errno::EADDRNOTAVAIL
55
+ servefailed_error = <<-EOF.chomp
56
+ The IP-Address #{opts[:ip]} is not available. Please choose a different IP-Address.
57
+ EOF
58
+ raise Machinery::Errors::ServeFailed, servefailed_error
59
+ rescue Errno::EACCES => e
60
+ servefailed_error = <<-EOF.chomp
61
+ You are not allowed to start the server on port #{Server.settings.port}. You need root privileges for ports between 2 and 1023!
62
+ ERROR: #{e.message}
46
63
  EOF
47
64
  raise Machinery::Errors::ServeFailed, servefailed_error
48
65
  end
data/lib/inspect_task.rb CHANGED
@@ -70,6 +70,7 @@ class InspectTask
70
70
  else
71
71
  host = system.host
72
72
  end
73
+ set_system_locale(system, description)
73
74
 
74
75
  failed_inspections = {}
75
76
 
@@ -102,4 +103,9 @@ class InspectTask
102
103
 
103
104
  return description, failed_inspections
104
105
  end
106
+
107
+ def set_system_locale(system, description)
108
+ Inspector.for("environment").new(system, description).inspect
109
+ system.locale = description.environment.locale
110
+ end
105
111
  end
data/lib/inspector.rb CHANGED
@@ -67,9 +67,10 @@ class Inspector
67
67
  def sort_scopes(scope_list)
68
68
  scope_priority = {}
69
69
 
70
+ visible_scopes = Machinery::Scope.visible_scopes.map(&:scope_name)
70
71
  scope_list.each do |scope|
71
72
  inspector = self.for(scope)
72
- next if !inspector
73
+ next if !inspector || !visible_scopes.include?(scope)
73
74
 
74
75
  scope_priority[inspector.priority] = scope
75
76
  end
data/lib/kiwi_config.rb CHANGED
@@ -30,7 +30,7 @@ class KiwiConfig < Exporter
30
30
  "os"
31
31
  )
32
32
  check_existance_of_extracted_files
33
-
33
+ check_repositories
34
34
  generate_config
35
35
  end
36
36
 
@@ -159,6 +159,19 @@ EOF
159
159
  end
160
160
  end
161
161
 
162
+ def check_repositories
163
+ if @system_description.repositories.empty?
164
+ raise(
165
+ Machinery::Errors::MissingRequirement.new(
166
+ "The scope 'repositories' of the system description doesn't contain a" \
167
+ " repository, which is necesarry for kiwi." \
168
+ " Please make sure that there is at least one accessible repository" \
169
+ " with all the required packages."
170
+ )
171
+ )
172
+ end
173
+ end
174
+
162
175
  def generate_config
163
176
  @sh = <<EOF
164
177
  test -f /.kconfig && . /.kconfig
@@ -18,28 +18,9 @@
18
18
  class LoggedCheetah
19
19
  class << self
20
20
  def run(*args)
21
- run_overloaded(*args, {})
22
- end
23
-
24
- def run_with_c(*args)
25
- run_overloaded(*args, with_c_locale: true)
26
- end
27
-
28
- private
29
-
30
- def run_overloaded(*args, options)
31
21
  command = args.select { |e| e.is_a?(String) }.join(" ")
32
22
  Machinery.logger.info("Running '#{command}'")
33
-
34
- if options[:with_c_locale]
35
- with_c_locale do
36
- Cheetah.run(*args)
37
- end
38
- else
39
- with_utf8_locale do
40
- Cheetah.run(*args)
41
- end
42
- end
23
+ Cheetah.run(*args)
43
24
  end
44
25
  end
45
26
  end
data/lib/machinery.rb CHANGED
@@ -106,6 +106,7 @@ require_relative "machinery_helper"
106
106
  require_relative "workload_mapper"
107
107
  require_relative "containerize_task"
108
108
  require_relative "workload_mapper_dsl"
109
+ require_relative "containerized_app"
109
110
 
110
111
  Dir[File.join(Machinery::ROOT, "plugins", "**", "*.rb")].each { |f| require(f) }
111
112
 
data/lib/remote_system.rb CHANGED
@@ -74,7 +74,8 @@ class RemoteSystem < System
74
74
 
75
75
  sudo = ["sudo", "-n"] if options[:privileged] && remote_user != "root"
76
76
  cmds = [
77
- "ssh", "#{remote_user}@#{host}", sudo, "LC_ALL=en_US.utf8", *piped_args, options
77
+ "ssh", "#{remote_user}@#{host}", "-o", "LogLevel=ERROR", sudo, "LC_ALL=#{locale}",
78
+ *piped_args, options
78
79
  ].compact.flatten
79
80
  cheetah_class.run(*cmds)
80
81
  rescue Cheetah::ExecutionFailed => e
data/lib/scope.rb CHANGED
@@ -18,6 +18,8 @@
18
18
  module Machinery
19
19
  module Scope
20
20
  def self.included(mod)
21
+ mod.extend(ClassMethods)
22
+
21
23
  @scopes ||= []
22
24
  @scopes.push(mod)
23
25
  end
@@ -26,6 +28,10 @@ module Machinery
26
28
  @scopes
27
29
  end
28
30
 
31
+ def self.visible_scopes
32
+ all_scopes.reject(&:hidden?)
33
+ end
34
+
29
35
  def self.for(scope_name, json, scope_file_store)
30
36
  all_scopes.each do |scope|
31
37
  if scope.new.scope_name == scope_name
@@ -40,6 +46,21 @@ module Machinery
40
46
  nil
41
47
  end
42
48
 
49
+ module ClassMethods
50
+ def hidden?
51
+ @hidden || false
52
+ end
53
+
54
+ def hidden_scope
55
+ @hidden = true
56
+ end
57
+
58
+ def scope_name
59
+ scope = name.match(/^(.*)Scope$/)[1]
60
+ scope.gsub(/([^A-Z])([A-Z])/, "\\1_\\2").downcase
61
+ end
62
+ end
63
+
43
64
  attr_accessor :meta
44
65
  attr_accessor :scope_file_store
45
66
 
@@ -51,8 +72,7 @@ module Machinery
51
72
  end
52
73
 
53
74
  def scope_name
54
- scope = self.class.name.match(/^(.*)Scope$/)[1]
55
- scope.gsub(/([^A-Z])([A-Z])/, "\\1_\\2").downcase
75
+ self.class.scope_name
56
76
  end
57
77
 
58
78
  def is_extractable?
@@ -21,7 +21,7 @@ class ServeHtmlTask
21
21
 
22
22
  Machinery::Ui.use_pager = false
23
23
  Machinery::Ui.puts <<EOF
24
- The description is now available at #{url}
24
+ Trying to start a web server for the description on #{url}
25
25
 
26
26
  The web server can be closed with Ctrl+C.
27
27
  EOF
data/lib/show_task.rb CHANGED
@@ -36,7 +36,7 @@ class ShowTask
36
36
 
37
37
  Machinery::Ui.use_pager = false
38
38
  Machinery::Ui.puts <<EOF
39
- There is a web server running, serving the description on #{url}.
39
+ Trying to start a web server for serving the description on #{url}.
40
40
 
41
41
  The server can be closed with Ctrl+C.
42
42
  EOF
data/lib/system.rb CHANGED
@@ -30,6 +30,8 @@ class System
30
30
  abstract_method :inject_file
31
31
  abstract_method :remove_file
32
32
 
33
+ attr_writer :locale
34
+
33
35
  def self.for(host, remote_user = "root")
34
36
  if host && host != "localhost"
35
37
  RemoteSystem.new(host, remote_user)
@@ -96,4 +98,8 @@ class System
96
98
  def arch
97
99
  run_command("uname", "-m", stdout: :capture).chomp
98
100
  end
101
+
102
+ def locale
103
+ @locale || "C"
104
+ end
99
105
  end
@@ -26,7 +26,7 @@
26
26
  # The sub directories storing the data for specific scopes are handled by the
27
27
  # ScopeFileStore class.
28
28
  class SystemDescription < Machinery::Object
29
- CURRENT_FORMAT_VERSION = 4
29
+ CURRENT_FORMAT_VERSION = 5
30
30
  EXTRACTABLE_SCOPES = [
31
31
  "changed_managed_files",
32
32
  "config_files",
@@ -218,11 +218,12 @@ class SystemDescription < Machinery::Object
218
218
  end
219
219
 
220
220
  def assert_scopes(*scopes)
221
- missing = scopes.select { |scope| !self[scope] || self[scope].empty? }
221
+ missing = scopes.select { |scope| !self[scope] }
222
222
 
223
223
  unless missing.empty?
224
224
  raise Machinery::Errors::SystemDescriptionError.new(
225
- "The system description misses the following section(s): #{missing.join(", ")}."
225
+ "The system description misses the following" \
226
+ " #{Machinery.pluralize(missing.size, "scope")} : #{missing.join(", ")}."
226
227
  )
227
228
  end
228
229
  end
data/lib/version.rb CHANGED
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Machinery
19
19
 
20
- VERSION = "1.12.0"
20
+ VERSION = "1.13.0"
21
21
 
22
22
  end
@@ -26,6 +26,7 @@ class WorkloadMapper
26
26
  compose_services = compose_services(workloads)
27
27
  linked_services = link_compose_services(compose_services)
28
28
  File.write(File.join(path, "docker-compose.yml"), linked_services.to_yaml)
29
+ linked_services
29
30
  end
30
31
 
31
32
  def link_compose_services(services)
Binary file
@@ -1014,8 +1014,14 @@ IP address and the port can be configured using the according options.</p>
1014
1014
  <h3 id="OPTIONS">OPTIONS</h3>
1015
1015
 
1016
1016
  <dl>
1017
- <dt><code>-p PORT</code>, <code>--port=PORT</code> (optional)</dt><dd><p>Specify the port on which the web server will serve the system description: Default: 7585</p></dd>
1018
- <dt><code>-i IP</code>, <code>--ip=IP</code> (optional)</dt><dd><p>Specify the IP address on which the web server will be made available. Default: 127.0.0.1</p></dd>
1017
+ <dt><code>-p PORT</code>, <code>--port=PORT</code> (optional)</dt><dd><p>Specify the port on which the web server will serve the system description: Default: 7585</p>
1018
+
1019
+ <p>Ports can be selected in a range between 2-65535. Ports between 2 and 1023 can only be
1020
+ chosen when <code>machinery</code> will be executed as <code>root</code> user.</p></dd>
1021
+ <dt><code>-i IP</code>, <code>--ip=IP</code> (optional)</dt><dd><p>Specify the IP address on which the web server will be made available. Default: 127.0.0.1</p>
1022
+
1023
+ <p>It's only possible to use an IP address (or hostnames resolving to an IP address) which
1024
+ is assigned to a network interface on the local machine.</p></dd>
1019
1025
  </dl>
1020
1026
 
1021
1027
 
@@ -1067,8 +1073,14 @@ See the <a href="#Scopes" data-bare-link="true">Scope section</a> for more infor
1067
1073
  for more information).</p></dd>
1068
1074
  <dt><code>--html</code> (optional)</dt><dd><p>Run a web server and open the system description in HTML format in your web browser using the
1069
1075
  <code>xdg-open</code> command.</p></dd>
1070
- <dt><code>-p PORT</code>, <code>--port=PORT</code> (optional)</dt><dd><p>Specify the port on which the web server will serve the system description: Default: 7585</p></dd>
1071
- <dt><code>-i IP</code>, <code>--ip=IP</code> (optional)</dt><dd><p>Specify the IP address on which the web server will be made available. Default: 127.0.0.1</p></dd>
1076
+ <dt><code>-p PORT</code>, <code>--port=PORT</code> (optional)</dt><dd><p>Specify the port on which the web server will serve the system description: Default: 7585</p>
1077
+
1078
+ <p>Ports can be selected in a range between 2-65535. Ports between 2 and 1023 can only be
1079
+ chosen when <code>machinery</code> will be executed as <code>root</code> user.</p></dd>
1080
+ <dt><code>-i IP</code>, <code>--ip=IP</code> (optional)</dt><dd><p>Specify the IP address on which the web server will be made available. Default: 127.0.0.1</p>
1081
+
1082
+ <p>It's only possible to use an IP address (or hostnames resolving to an IP address) which
1083
+ is assigned to a network interface on the local machine.</p></dd>
1072
1084
  <dt><code>--verbose</code> (optional)</dt><dd><p>Display the filters which were applied before showing the system description.</p></dd>
1073
1085
  </dl>
1074
1086
 
@@ -0,0 +1,126 @@
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/link_changed_modified" },
46
+ { "$ref": "#/definitions/file_changed_deleted" }
47
+ ]
48
+ },
49
+ "file_changed_modified": {
50
+ "required": ["changes", "mode", "user", "group", "type"],
51
+ "properties": {
52
+ "changes": {
53
+ "type": "array",
54
+ "items": {
55
+ "enum": ["size", "mode", "md5", "device_number", "link_path", "user", "group", "time", "capabilities", "replaced", "other_rpm_changes"]
56
+ },
57
+ "minItems": 1
58
+ },
59
+ "mode": {
60
+ "type": "string",
61
+ "pattern": "^[0-7]{3,4}$"
62
+ },
63
+ "user": {
64
+ "type": "string",
65
+ "minLength": 1
66
+ },
67
+ "group": {
68
+ "type": "string",
69
+ "minLength": 1
70
+ },
71
+ "type": {
72
+ "enum": ["file", "dir"]
73
+ }
74
+ }
75
+ },
76
+ "link_changed_modified": {
77
+ "required": ["target", "changes", "mode", "user", "group", "type"],
78
+ "properties": {
79
+ "changes": {
80
+ "type": "array",
81
+ "items": {
82
+ "enum": ["size", "mode", "md5", "device_number", "link_path", "user", "group", "time", "capabilities", "replaced", "other_rpm_changes"]
83
+ },
84
+ "minItems": 1
85
+ },
86
+ "mode": {
87
+ "type": "string",
88
+ "pattern": "^[0-7]{3,4}$"
89
+ },
90
+ "user": {
91
+ "type": "string",
92
+ "minLength": 1
93
+ },
94
+ "group": {
95
+ "type": "string",
96
+ "minLength": 1
97
+ },
98
+ "type": {
99
+ "enum": ["link"]
100
+ },
101
+ "target": {
102
+ "type": "string"
103
+ }
104
+ }
105
+ },
106
+ "file_changed_deleted": {
107
+ "required": ["changes"],
108
+ "properties": {
109
+ "changes": {
110
+ "enum": [["deleted"]]
111
+ }
112
+ }
113
+ },
114
+ "file_error": {
115
+ "required": ["status", "error_message"],
116
+ "properties": {
117
+ "status": {
118
+ "enum": ["error"]
119
+ },
120
+ "error_message": {
121
+ "type": "string"
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }