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.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.git_revision +1 -1
  3. data/NEWS +10 -0
  4. data/bin/machinery +1 -1
  5. data/lib/analyze_changed_config_files_diffs_task.rb +6 -6
  6. data/lib/autoyast.rb +2 -2
  7. data/lib/build_task.rb +10 -7
  8. data/lib/cli.rb +1005 -801
  9. data/lib/compare_task.rb +11 -7
  10. data/lib/comparison.rb +2 -2
  11. data/lib/config_base.rb +1 -1
  12. data/lib/config_task.rb +1 -1
  13. data/lib/containerize_task.rb +3 -3
  14. data/lib/containerized_app.rb +1 -1
  15. data/lib/copy_task.rb +1 -1
  16. data/lib/current_user.rb +1 -1
  17. data/lib/deploy_task.rb +6 -4
  18. data/lib/diff_widget.rb +67 -63
  19. data/lib/docker_system.rb +12 -8
  20. data/lib/dpkg_database.rb +1 -1
  21. data/lib/element_filter.rb +7 -4
  22. data/lib/exceptions.rb +23 -5
  23. data/lib/export_task.rb +1 -1
  24. data/lib/exporter.rb +1 -1
  25. data/lib/file_diff.rb +1 -1
  26. data/lib/file_scope.rb +1 -1
  27. data/lib/file_validator.rb +7 -4
  28. data/lib/filter.rb +97 -93
  29. data/lib/filter_option_parser.rb +2 -2
  30. data/lib/hint.rb +64 -59
  31. data/lib/html.rb +1 -1
  32. data/lib/inspect_task.rb +12 -12
  33. data/lib/inspector.rb +3 -3
  34. data/lib/json_validation_error_cleaner.rb +1 -1
  35. data/lib/json_validator.rb +4 -4
  36. data/lib/kiwi_config.rb +8 -4
  37. data/lib/list_task.rb +10 -9
  38. data/lib/local_system.rb +11 -5
  39. data/lib/logged_cheetah.rb +1 -1
  40. data/lib/man_task.rb +10 -6
  41. data/lib/managed_files_database.rb +1 -1
  42. data/lib/manifest.rb +5 -5
  43. data/lib/migration.rb +16 -10
  44. data/lib/mountpoints.rb +1 -1
  45. data/lib/move_task.rb +1 -1
  46. data/lib/remote_system.rb +7 -7
  47. data/lib/remove_task.rb +1 -1
  48. data/lib/renderer.rb +177 -172
  49. data/lib/rpm.rb +4 -4
  50. data/lib/rpm_database.rb +1 -1
  51. data/lib/scope.rb +2 -2
  52. data/lib/scope_file_access_archive.rb +1 -1
  53. data/lib/scope_file_access_flat.rb +1 -1
  54. data/lib/scope_file_store.rb +1 -1
  55. data/lib/serve_html_task.rb +6 -2
  56. data/lib/server.rb +19 -12
  57. data/lib/show_task.rb +10 -6
  58. data/lib/static_html.rb +1 -1
  59. data/lib/system.rb +10 -10
  60. data/lib/system_description.rb +14 -13
  61. data/lib/system_description_memory_store.rb +1 -1
  62. data/lib/system_description_store.rb +9 -9
  63. data/lib/tarball.rb +8 -2
  64. data/lib/upgrade_format_task.rb +11 -6
  65. data/lib/validate_task.rb +2 -2
  66. data/lib/version.rb +1 -1
  67. data/lib/workload_mapper.rb +2 -2
  68. data/lib/workload_mapper_dsl.rb +1 -1
  69. data/lib/zypper.rb +40 -17
  70. data/machinery-helper/machinery_helper.go +35 -16
  71. data/machinery-helper/version.go +1 -1
  72. data/man/generated/machinery.1.gz +0 -0
  73. data/manual/site/sitemap.xml +24 -24
  74. data/plugins/changed_config_files/changed_config_files_inspector.rb +59 -56
  75. data/plugins/changed_config_files/changed_config_files_model.rb +23 -21
  76. data/plugins/changed_config_files/changed_config_files_renderer.rb +56 -52
  77. data/plugins/changed_managed_files/changed_managed_files_inspector.rb +52 -50
  78. data/plugins/changed_managed_files/changed_managed_files_model.rb +23 -21
  79. data/plugins/changed_managed_files/changed_managed_files_renderer.rb +43 -39
  80. data/plugins/environment/environment_inspector.rb +25 -23
  81. data/plugins/environment/environment_model.rb +5 -3
  82. data/plugins/groups/groups_inspector.rb +30 -28
  83. data/plugins/groups/groups_model.rb +18 -17
  84. data/plugins/groups/groups_renderer.rb +29 -25
  85. data/plugins/os/os_inspector.rb +120 -118
  86. data/plugins/os/os_model.rb +139 -134
  87. data/plugins/os/os_renderer.rb +13 -9
  88. data/plugins/packages/packages_inspector.rb +99 -86
  89. data/plugins/packages/packages_model.rb +35 -34
  90. data/plugins/packages/packages_renderer.rb +47 -39
  91. data/plugins/patterns/patterns_inspector.rb +70 -68
  92. data/plugins/patterns/patterns_model.rb +19 -18
  93. data/plugins/patterns/patterns_renderer.rb +36 -32
  94. data/plugins/repositories/repositories_inspector.rb +162 -156
  95. data/plugins/repositories/repositories_model.rb +50 -49
  96. data/plugins/repositories/repositories_renderer.rb +48 -44
  97. data/plugins/repositories/schema/system-description-repositories.schema-v10.json +0 -1
  98. data/plugins/services/services_inspector.rb +187 -176
  99. data/plugins/services/services_model.rb +37 -36
  100. data/plugins/services/services_renderer.rb +28 -24
  101. data/plugins/unmanaged_files/unmanaged_files_inspector.rb +102 -99
  102. data/plugins/unmanaged_files/unmanaged_files_model.rb +64 -56
  103. data/plugins/unmanaged_files/unmanaged_files_renderer.rb +44 -40
  104. data/plugins/users/users_inspector.rb +67 -65
  105. data/plugins/users/users_model.rb +37 -36
  106. data/plugins/users/users_renderer.rb +31 -27
  107. data/schema/migrations/migrate1to2.rb +1 -1
  108. data/schema/migrations/migrate2to3.rb +1 -1
  109. data/schema/migrations/migrate3to4.rb +1 -1
  110. data/schema/migrations/migrate4to5.rb +1 -1
  111. data/schema/migrations/migrate5to6.rb +1 -1
  112. data/schema/migrations/migrate6to7.rb +1 -1
  113. data/schema/migrations/migrate7to8.rb +1 -1
  114. data/schema/migrations/migrate8to9.rb +1 -1
  115. data/schema/migrations/migrate9to10.rb +1 -1
  116. metadata +2 -2
data/lib/html.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 Html
18
+ class Machinery::Html
19
19
  # Creates a new thread running a sinatra webserver which serves the local system descriptions
20
20
  # The Thread object is returned so that the caller can `.join` it until it's finished.
21
21
  def self.run_server(system_description_store, opts, &block)
data/lib/inspect_task.rb CHANGED
@@ -14,7 +14,7 @@
14
14
  #
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
- class InspectTask
17
+ class Machinery::InspectTask
18
18
  def inspect_system(store, system, name, current_user, scopes, filter, options = {})
19
19
  check_root(system, current_user)
20
20
 
@@ -48,7 +48,7 @@ class InspectTask
48
48
  return unless scopes
49
49
 
50
50
  scopes.each do |scope|
51
- renderer = Renderer.for(scope)
51
+ renderer = Machinery::Ui::Renderer.for(scope)
52
52
  next unless renderer
53
53
 
54
54
  output = renderer.render(description)
@@ -58,26 +58,26 @@ class InspectTask
58
58
 
59
59
  def build_description(store, name, system, scopes, filter, options)
60
60
  begin
61
- description = SystemDescription.load(name, store)
61
+ description = Machinery::SystemDescription.load(name, store)
62
62
  rescue Machinery::Errors::SystemDescriptionNotFound
63
- description = SystemDescription.new(name, store)
63
+ description = Machinery::SystemDescription.new(name, store)
64
64
  end
65
65
  timestring = Time.now.utc.iso8601
66
- if system.class == LocalSystem
67
- host = "localhost"
68
- elsif system.class == DockerSystem
69
- host = system.image
66
+ host = if system.class == Machinery::LocalSystem
67
+ "localhost"
68
+ elsif system.class == Machinery::DockerSystem
69
+ system.image
70
70
  else
71
- host = system.host
71
+ system.host
72
72
  end
73
73
  set_system_locale(system, description)
74
74
 
75
75
  failed_inspections = {}
76
76
 
77
- effective_filter = Filter.new(description.filter_definitions("inspect"))
77
+ effective_filter = Machinery::Filter.new(description.filter_definitions("inspect"))
78
78
 
79
79
  scopes.each do |scope|
80
- inspector = Inspector.for(scope).new(system, description)
80
+ inspector = Machinery::Inspector.for(scope).new(system, description)
81
81
  Machinery::Ui.puts "Inspecting #{Machinery::Ui.internal_scope_list_to_string(inspector.scope)}..."
82
82
 
83
83
  element_filters = filter.element_filters_for_scope(scope)
@@ -105,7 +105,7 @@ class InspectTask
105
105
  end
106
106
 
107
107
  def set_system_locale(system, description)
108
- Inspector.for("environment").new(system, description).inspect
108
+ Machinery::Inspector.for("environment").new(system, description).inspect
109
109
  system.locale = description.environment.locale
110
110
  end
111
111
  end
data/lib/inspector.rb CHANGED
@@ -31,7 +31,7 @@
31
31
  # the description. It returns a brief summary string of the inspection.
32
32
  #
33
33
  # The description object can also be used to store files in the description.
34
- class Inspector
34
+ class Machinery::Inspector
35
35
  abstract_method :inspect
36
36
  abstract_method :summary
37
37
 
@@ -53,7 +53,7 @@ class Inspector
53
53
  def for(scope)
54
54
  class_name = "#{scope.split("_").map(&:capitalize).join}Inspector"
55
55
 
56
- Object.const_get(class_name) if Object.const_defined?(class_name)
56
+ Machinery.const_get(class_name) if Machinery.const_defined?(class_name)
57
57
  end
58
58
 
59
59
  def all
@@ -83,7 +83,7 @@ class Inspector
83
83
  def scope
84
84
  # Return the un-camelcased name of the inspector,
85
85
  # e.g. "foo_bar" for "FooBarInspector"
86
- scope = self.name.match(/^(.*)Inspector$/)[1]
86
+ scope = name.match(/^Machinery::(.*)Inspector$/)[1]
87
87
  scope.gsub(/([^A-Z])([A-Z])/, "\\1_\\2").downcase
88
88
  end
89
89
  end
@@ -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 JsonValidationErrorCleaner
18
+ class Machinery::JsonValidationErrorCleaner
19
19
  class <<self
20
20
  def cleanup_error(message, scope)
21
21
  message = cleanup_json_path(message, scope)
@@ -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 JsonValidator
18
+ class Machinery::JsonValidator
19
19
  def initialize(json_hash)
20
20
  @json_hash = json_hash
21
21
 
@@ -53,11 +53,11 @@ class JsonValidator
53
53
  "In scope #{scope}: #{error}"
54
54
  end
55
55
  errors.map do |error|
56
- JsonValidationErrorCleaner.cleanup_error(error, scope)
56
+ Machinery::JsonValidationErrorCleaner.cleanup_error(error, scope)
57
57
  end
58
58
  end
59
59
 
60
- def global_schema(format_version = SystemDescription::CURRENT_FORMAT_VERSION)
60
+ def global_schema(format_version = Machinery::SystemDescription::CURRENT_FORMAT_VERSION)
61
61
  JSON.parse(File.read(File.join(
62
62
  Machinery::ROOT,
63
63
  "schema",
@@ -65,7 +65,7 @@ class JsonValidator
65
65
  )))
66
66
  end
67
67
 
68
- def scope_schemas(format_version = SystemDescription::CURRENT_FORMAT_VERSION)
68
+ def scope_schemas(format_version = Machinery::SystemDescription::CURRENT_FORMAT_VERSION)
69
69
  schema_path = File.join(
70
70
  Machinery::ROOT,
71
71
  "plugins",
data/lib/kiwi_config.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 KiwiConfig < Exporter
18
+ class Machinery::KiwiConfig < Machinery::Exporter
19
19
  attr_accessor :xml_text, :sh
20
20
  attr_accessor :name
21
21
 
@@ -57,6 +57,10 @@ class KiwiConfig < Exporter
57
57
 
58
58
  private
59
59
 
60
+ def repos_with_credentials?(repo)
61
+ repo.username && repo.password
62
+ end
63
+
60
64
  def optional_bootstrap_packages
61
65
  [
62
66
  "glibc-locale",
@@ -196,7 +200,7 @@ EOF
196
200
  end
197
201
 
198
202
  def check_exported_os
199
- unless @system_description.os.is_a?(OsSuse)
203
+ unless @system_description.os.is_a?(Machinery::OsSuse)
200
204
  raise Machinery::Errors::ExportFailed.new(
201
205
  "Export is not possible because the operating system " \
202
206
  "'#{@system_description.os.display_name}' is not supported."
@@ -293,7 +297,7 @@ EOF
293
297
  end
294
298
  end
295
299
 
296
- next if repo.url =~ /^https:\/\/nu.novell.com|^https:\/\/update.suse.com/
300
+ next if repos_with_credentials?(repo)
297
301
 
298
302
  @sh << "zypper -n ar --name='#{repo.name}' "
299
303
  @sh << "--type='#{repo.type}' " if repo.type
@@ -373,7 +377,7 @@ EOF
373
377
  end
374
378
 
375
379
  def enable_dhcp(output_location)
376
- if @system_description.os.is_a?(OsSles11)
380
+ if @system_description.os.is_a?(Machinery::OsSles11)
377
381
  write_dhcp_network_config(output_location, "eth0")
378
382
  else
379
383
  write_dhcp_network_config(output_location, "lan0")
data/lib/list_task.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 ListTask
18
+ class Machinery::ListTask
19
19
  def list(store, system_descriptions, options = {})
20
20
  if options[:html]
21
21
  list_html(store, options)
@@ -29,7 +29,7 @@ class ListTask
29
29
 
30
30
  descriptions.each do |name|
31
31
  begin
32
- system_description = SystemDescription.load(name, store, skip_validation: true)
32
+ system_description = Machinery::SystemDescription.load(name, store, skip_validation: true)
33
33
  rescue Machinery::Errors::SystemDescriptionIncompatible => e
34
34
  show_error("#{e}\n", options)
35
35
  next
@@ -39,8 +39,9 @@ class ListTask
39
39
  )
40
40
  next
41
41
  rescue Machinery::Errors::SystemDescriptionValidationFailed
42
- show_error("#{name}: This description is broken. Use " \
43
- "`#{Hint.program_name} validate #{name}` to see the error message.", options)
42
+ show_error("#{name}: This description is broken. Use "\
43
+ "`#{Machinery::Ui::Hint.program_name} validate "\
44
+ "#{name}` to see the error message.", options)
44
45
  next
45
46
  rescue Machinery::Errors::SystemDescriptionError
46
47
  show_error("#{name}: This description is broken.", options)
@@ -54,7 +55,7 @@ class ListTask
54
55
 
55
56
  system_description.scopes.each do |scope|
56
57
  entry = Machinery::Ui.internal_scope_list_to_string(scope)
57
- if SystemDescription::EXTRACTABLE_SCOPES.include?(scope)
58
+ if Machinery::SystemDescription::EXTRACTABLE_SCOPES.include?(scope)
58
59
  if system_description.scope_extracted?(scope)
59
60
  entry += " (extracted)"
60
61
  else
@@ -83,13 +84,13 @@ class ListTask
83
84
  end
84
85
  end
85
86
 
86
- Hint.print(:upgrade_system_description) if has_incompatible_version
87
+ Machinery::Ui::Hint.print(:upgrade_system_description) if has_incompatible_version
87
88
  end
88
89
  end
89
90
 
90
91
  def list_html(store, options)
91
92
  begin
92
- LocalSystem.validate_existence_of_command("xdg-open", "xdg-utils")
93
+ Machinery::LocalSystem.validate_existence_of_command("xdg-open", "xdg-utils")
93
94
 
94
95
  url = "http://#{options[:ip]}:#{options[:port]}/"
95
96
 
@@ -100,8 +101,8 @@ Trying to start a web server for serving the descriptions on #{url}.
100
101
  The server can be closed with Ctrl+C.
101
102
  EOF
102
103
 
103
- server = Html.run_server(store, port: options[:port], ip: options[:ip]) do
104
- LoggedCheetah.run("xdg-open", url)
104
+ server = Machinery::Html.run_server(store, port: options[:port], ip: options[:ip]) do
105
+ Machinery::LoggedCheetah.run("xdg-open", url)
105
106
  end
106
107
 
107
108
  server.join # Wait until the user cancelled the blocking webserver
data/lib/local_system.rb CHANGED
@@ -15,14 +15,20 @@
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 LocalSystem < System
18
+ class Machinery::LocalSystem < Machinery::System
19
19
  @@os = nil
20
20
 
21
21
  class << self
22
22
  def os
23
23
  unless @@os
24
- description = SystemDescription.new("localhost", SystemDescriptionMemoryStore.new)
25
- inspector = OsInspector.new(System.for("localhost"), description)
24
+ description = Machinery::SystemDescription.new(
25
+ "localhost",
26
+ Machinery::SystemDescriptionMemoryStore.new
27
+ )
28
+ inspector = Machinery::OsInspector.new(
29
+ Machinery::System.for("localhost"),
30
+ description
31
+ )
26
32
  inspector.inspect(nil)
27
33
  @@os = description.os
28
34
  end
@@ -102,7 +108,7 @@ You can install it by running `zypper install #{package}`.
102
108
  if args.last.is_a?(Hash) && args.last[:disable_logging]
103
109
  cheetah_class = Cheetah
104
110
  else
105
- cheetah_class = LoggedCheetah
111
+ cheetah_class = Machinery::LoggedCheetah
106
112
  end
107
113
 
108
114
  with_env(
@@ -118,7 +124,7 @@ You can install it by running `zypper install #{package}`.
118
124
  # the directory where to put the files.
119
125
  def retrieve_files(filelist, destination)
120
126
  begin
121
- LoggedCheetah.run(
127
+ Machinery::LoggedCheetah.run(
122
128
  "rsync",
123
129
  "--chmod=go-rwx",
124
130
  "--files-from=-",
@@ -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 LoggedCheetah
18
+ class Machinery::LoggedCheetah
19
19
  class << self
20
20
  def run(*args)
21
21
  command = args.select { |e| e.is_a?(String) }.join(" ")
data/lib/man_task.rb CHANGED
@@ -15,10 +15,10 @@
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 ManTask
18
+ class Machinery::ManTask
19
19
  def self.compile_documentation
20
20
  docs = "# Scopes\n\n"
21
- docs += Inspector.all_scopes.map do |scope|
21
+ docs += Machinery::Inspector.all_scopes.map do |scope|
22
22
  scope_doc = "* #{scope.tr("_", "-")}\n\n"
23
23
  scope_doc += YAML.load_file(
24
24
  File.join(Machinery::ROOT, "plugins/#{scope}/#{scope}.yml")
@@ -40,7 +40,7 @@ class ManTask
40
40
  end
41
41
 
42
42
  def man_system
43
- LocalSystem.validate_existence_of_package("man")
43
+ Machinery::LocalSystem.validate_existence_of_package("man")
44
44
  system("man", File.join(Machinery::ROOT, "man/generated/machinery.1.gz"))
45
45
  end
46
46
 
@@ -53,7 +53,7 @@ class ManTask
53
53
  return
54
54
  end
55
55
 
56
- LocalSystem.validate_existence_of_command("xdg-open", "xdg-utils")
56
+ Machinery::LocalSystem.validate_existence_of_command("xdg-open", "xdg-utils")
57
57
 
58
58
  url = "http://#{options[:ip]}:#{options[:port]}/site/docs/index.html"
59
59
 
@@ -64,8 +64,12 @@ Trying to start a web server for serving the documentation on #{url}.
64
64
  The server can be closed with Ctrl+C.
65
65
  EOF
66
66
 
67
- server = Html.run_server(SystemDescriptionStore.new, port: options[:port], ip: options[:ip]) do
68
- LoggedCheetah.run("xdg-open", url)
67
+ server = Machinery::Html.run_server(
68
+ Machinery::SystemDescriptionStore.new,
69
+ port: options[:port],
70
+ ip: options[:ip]
71
+ ) do
72
+ Machinery::LoggedCheetah.run("xdg-open", url)
69
73
  end
70
74
 
71
75
  server.join # Wait until the user cancelled the blocking webserver
@@ -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 ManagedFilesDatabase
18
+ class Machinery::ManagedFilesDatabase
19
19
  class ChangedFile < Machinery::Object
20
20
  attr_accessor :type
21
21
 
data/lib/manifest.rb CHANGED
@@ -18,7 +18,7 @@
18
18
  # The Manifest class takes care of handling the JSON representation of system
19
19
  # descriptions. It loads and parses the JSON into a hash and validates it against
20
20
  # the current schema.
21
- class Manifest
21
+ class Machinery::Manifest
22
22
  attr_accessor :name, :path, :json, :hash
23
23
 
24
24
  def self.load(name, path)
@@ -29,7 +29,7 @@ class Manifest
29
29
  end
30
30
 
31
31
  json = File.read(path)
32
- Manifest.new(name, json, path)
32
+ Machinery::Manifest.new(name, json, path)
33
33
  end
34
34
 
35
35
  def initialize(name, json, path = nil)
@@ -43,7 +43,7 @@ class Manifest
43
43
  def validate
44
44
  return unless compatible_json?
45
45
 
46
- errors = JsonValidator.new(@hash).validate
46
+ errors = Machinery::JsonValidator.new(@hash).validate
47
47
  unless errors.empty?
48
48
  Machinery::Ui.warn("Warning: System Description validation errors:")
49
49
  Machinery::Ui.warn(errors.join("\n"))
@@ -53,7 +53,7 @@ class Manifest
53
53
  def validate!
54
54
  return unless compatible_json?
55
55
 
56
- errors = JsonValidator.new(@hash).validate
56
+ errors = Machinery::JsonValidator.new(@hash).validate
57
57
  unless errors.empty?
58
58
  raise Machinery::Errors::SystemDescriptionValidationFailed.new(errors)
59
59
  end
@@ -96,6 +96,6 @@ class Manifest
96
96
 
97
97
  def compatible_json?
98
98
  @hash && @hash["meta"] && @hash["meta"]["format_version"] &&
99
- @hash["meta"]["format_version"] <= SystemDescription::CURRENT_FORMAT_VERSION
99
+ @hash["meta"]["format_version"] <= Machinery::SystemDescription::CURRENT_FORMAT_VERSION
100
100
  end
101
101
  end
data/lib/migration.rb CHANGED
@@ -43,7 +43,7 @@
43
43
  #
44
44
  # Simple example migration which adds a new attribute to the JSON:
45
45
  #
46
- # class Migrate1To2 < Migration
46
+ # class Machinery::Migrate1To2 < Machinery::Migration
47
47
  # desc <<-EOT
48
48
  # Add 'foo' element to the system description root.
49
49
  # EOT
@@ -53,7 +53,7 @@
53
53
  # @hash["changed_config_files"]["extracted"] = is_extracted
54
54
  # end
55
55
  # end
56
- class Migration
56
+ class Machinery::Migration
57
57
  MIGRATIONS_DIR= File.join(Machinery::ROOT, "schema/migrations")
58
58
 
59
59
  class << self
@@ -66,10 +66,16 @@ class Migration
66
66
  def migrate_description(store, description_name, options = {})
67
67
  load_migrations
68
68
 
69
- hash = Manifest.load(description_name, store.manifest_path(description_name)).to_hash
69
+ hash = Machinery::Manifest.load(
70
+ description_name,
71
+ store.manifest_path(description_name)
72
+ ).to_hash
70
73
 
71
- errors = JsonValidator.new(hash).validate
72
- errors += FileValidator.new(hash, store.description_path(description_name)).validate
74
+ errors = Machinery::JsonValidator.new(hash).validate
75
+ errors += Machinery::FileValidator.new(
76
+ hash,
77
+ store.description_path(description_name)
78
+ ).validate
73
79
  unless errors.empty?
74
80
  if options[:force]
75
81
  Machinery::Ui.warn("Warning: System Description validation errors:")
@@ -87,21 +93,21 @@ class Migration
87
93
  )
88
94
  end
89
95
 
90
- if current_version == SystemDescription::CURRENT_FORMAT_VERSION
96
+ if current_version == Machinery::SystemDescription::CURRENT_FORMAT_VERSION
91
97
  Machinery::Ui.puts "No upgrade necessary."
92
98
  return false
93
99
  end
94
100
 
95
101
  backup_description = store.backup(description_name)
96
102
  backup_path = store.description_path(backup_description)
97
- backup_hash = Manifest.load(
103
+ backup_hash = Machinery::Manifest.load(
98
104
  backup_description, store.manifest_path(backup_description)
99
105
  ).to_hash
100
106
 
101
- (current_version..SystemDescription::CURRENT_FORMAT_VERSION-1).each do |version|
107
+ (current_version..Machinery::SystemDescription::CURRENT_FORMAT_VERSION - 1).each do |version|
102
108
  next_version = version + 1
103
109
  begin
104
- klass = Object.const_get("Migrate#{version}To#{next_version}")
110
+ klass = Object.const_get("Machinery::Migrate#{version}To#{next_version}")
105
111
  rescue NameError
106
112
  return
107
113
  end
@@ -125,7 +131,7 @@ class Migration
125
131
  Machinery::Ui.puts "Saved backup to #{backup_path}"
126
132
  else
127
133
  begin
128
- SystemDescription.load!(backup_description, store)
134
+ Machinery::SystemDescription.load!(backup_description, store)
129
135
  store.remove(description_name)
130
136
  store.rename(backup_description, description_name)
131
137
  rescue Machinery::Errors::SystemDescriptionError