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
data/lib/mountpoints.rb CHANGED
@@ -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
data/lib/object.rb CHANGED
@@ -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
@@ -20,15 +20,15 @@ module Machinery
20
20
  class << self
21
21
  def has_property(name, options)
22
22
  @property_classes ||= {}
23
- @property_classes[name.to_sym] = options[:class]
23
+ @property_classes[name.to_s] = options[:class]
24
24
  end
25
25
 
26
26
  def object_hash_from_json(json)
27
27
  return nil unless json
28
28
 
29
29
  entries = json.map do |key, value|
30
- value_converted = if @property_classes && @property_classes[key.to_sym]
31
- @property_classes[key.to_sym].from_json(value)
30
+ value_converted = if @property_classes && @property_classes[key.to_s]
31
+ @property_classes[key.to_s].from_json(value)
32
32
  else
33
33
  case value
34
34
  when ::Array
@@ -59,7 +59,7 @@ module Machinery
59
59
 
60
60
  def set_attributes(attrs)
61
61
  @attributes = attrs.inject({}) do |attributes, (key, value)|
62
- key = key.to_sym if key.respond_to?(:to_sym)
62
+ key = key.to_s if key.is_a?(Symbol)
63
63
 
64
64
  attributes[key] = value
65
65
  attributes
@@ -80,11 +80,11 @@ module Machinery
80
80
  end
81
81
 
82
82
  def [](key)
83
- @attributes[key.to_sym]
83
+ @attributes[key.to_s]
84
84
  end
85
85
 
86
86
  def []=(key, value)
87
- @attributes[key.to_sym] = value
87
+ @attributes[key.to_s] = value
88
88
  end
89
89
 
90
90
  def empty?
@@ -96,15 +96,14 @@ module Machinery
96
96
  if args.size != 1
97
97
  raise ArgumentError, "wrong number of arguments (#{args.size} for 1)"
98
98
  end
99
-
100
- @attributes[name.to_s[0..-2].to_sym] = args.first
99
+ @attributes[name.to_s[0..-2].to_s] = args.first
101
100
  else
102
- if @attributes.has_key?(name)
101
+ if @attributes.has_key?(name.to_s)
103
102
  if !args.empty?
104
103
  raise ArgumentError, "wrong number of arguments (#{args.size} for 0)"
105
104
  end
106
105
 
107
- @attributes[name]
106
+ @attributes[name.to_s]
108
107
  else
109
108
  nil
110
109
  end
data/lib/remote_system.rb CHANGED
@@ -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
data/lib/remove_task.rb CHANGED
@@ -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
@@ -16,28 +16,33 @@
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
18
  class RemoveTask
19
- def remove(store, name, options = {})
20
- if !options[:all] && !store.list.include?(name)
21
- raise Machinery::Errors::SystemDescriptionNotFound.new(
22
- "System description \"#{name}\" does not exist."
23
- )
24
- end
25
-
19
+ def remove(store, names, options = {})
26
20
  if options[:all]
27
21
  removed_descriptions = store.list
28
22
  removed_descriptions.each do |name|
29
23
  store.remove(name)
30
24
  end
31
- else
32
- store.remove(name)
33
- end
34
25
 
35
- if options[:verbose]
36
- if options[:all]
26
+ if options[:verbose]
37
27
  Machinery::Ui.puts "Removed #{removed_descriptions.length} system descriptions successfully."
28
+ end
29
+ end
30
+
31
+ errors = []
32
+
33
+ Array(names).each do |name|
34
+ if !store.list.include?(name)
35
+ errors.push("System description \"#{name}\" does not exist.")
38
36
  else
39
- Machinery::Ui.puts "System description \"#{name}\" successfully removed."
37
+ store.remove(name)
38
+ if options[:verbose]
39
+ Machinery::Ui.puts "System description \"#{name}\" successfully removed."
40
+ end
40
41
  end
41
42
  end
43
+
44
+ if !errors.empty?
45
+ raise Machinery::Errors::SystemDescriptionNotFound.new(errors.join("\n"))
46
+ end
42
47
  end
43
48
  end
data/lib/renderer.rb CHANGED
@@ -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
@@ -148,16 +148,17 @@ class Renderer
148
148
  @stack = []
149
149
  missing_descriptions = Array.new
150
150
 
151
- @buffer += "# #{display_name}\n"
152
-
153
- if !description1[scope]
151
+ if !description1[scope]
154
152
  missing_descriptions << description1.name
155
153
  end
156
154
  if !description2[scope]
157
155
  missing_descriptions << description2.name
158
156
  end
159
157
 
160
- indent { puts "Unable to compare, no data in '#{missing_descriptions.join("', '")}'" }
158
+ if missing_descriptions.count == 1
159
+ @buffer += "# #{display_name}\n"
160
+ indent { puts "Unable to compare, no data in '#{missing_descriptions.join("', '")}'" }
161
+ end
161
162
  @buffer += "\n" unless @buffer.empty? || @buffer.end_with?("\n\n")
162
163
 
163
164
  @buffer
@@ -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
data/lib/rpm.rb CHANGED
@@ -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
data/lib/scope_mixin.rb CHANGED
@@ -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
data/lib/show_task.rb CHANGED
@@ -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
data/lib/system.rb CHANGED
@@ -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
@@ -55,7 +55,7 @@ class System
55
55
  out = File.open(archive, "w")
56
56
  begin
57
57
  run_command(
58
- "tar", "--directory=/", "--create", "--gzip", "--null", "--files-from=-",
58
+ "tar", "--create", "--gzip", "--null", "--files-from=-",
59
59
  *exclude.flat_map { |f| ["--exclude", f]},
60
60
  :stdout => out,
61
61
  :stdin => filelist
@@ -78,4 +78,11 @@ class System
78
78
 
79
79
  run_command("bash", "-c", script, *args)
80
80
  end
81
+
82
+ def has_command?(command)
83
+ run_command("bash", "-c", "type -P #{command}", stdout: :capture)
84
+ true
85
+ rescue Cheetah::ExecutionFailed
86
+ false
87
+ end
81
88
  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
@@ -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 = 2
29
+ CURRENT_FORMAT_VERSION = 3
30
30
  EXTRACTABLE_SCOPES = [
31
31
  "changed_managed_files",
32
32
  "config_files",
@@ -41,13 +41,17 @@ class SystemDescription < Machinery::Object
41
41
  # Load the system description with the given name
42
42
  #
43
43
  # If there are file validation errors the call fails with an exception
44
- def load!(name, store)
44
+ def load!(name, store, options = {})
45
45
  manifest = Manifest.load(name, store.manifest_path(name))
46
- manifest.validate
46
+ manifest.validate!
47
47
 
48
48
  description = from_hash(name, store, manifest.to_hash)
49
- description.validate_compatibility
50
- description.validate_file_data
49
+ description.validate_file_data!
50
+
51
+ if !options[:skip_format_compatibility]
52
+ description.validate_format_compatibility
53
+ end
54
+
51
55
  description
52
56
  end
53
57
 
@@ -55,18 +59,15 @@ class SystemDescription < Machinery::Object
55
59
  #
56
60
  # If there are file validation errors these are put out as warnings but the
57
61
  # loading of the system description succeeds.
58
- def load(name, store)
62
+ def load(name, store, options = {})
59
63
  manifest = Manifest.load(name, store.manifest_path(name))
60
- manifest.validate
64
+ manifest.validate if !options[:skip_validation]
61
65
 
62
66
  description = from_hash(name, store, manifest.to_hash)
63
- description.validate_compatibility
64
- begin
65
- description.validate_file_data
66
- rescue Machinery::Errors::SystemDescriptionValidationFailed => e
67
- Machinery::Ui.warn("Warning: File validation errors:")
68
- Machinery::Ui.warn(e.to_s)
69
- end
67
+ description.validate_file_data if !options[:skip_validation]
68
+
69
+ description.validate_format_compatibility if !options[:skip_format_compatibility]
70
+
70
71
  description
71
72
  end
72
73
 
@@ -133,12 +134,26 @@ class SystemDescription < Machinery::Object
133
134
  format_version == SystemDescription::CURRENT_FORMAT_VERSION
134
135
  end
135
136
 
136
- def validate_compatibility
137
+ def validate_format_compatibility
137
138
  if !compatible?
138
139
  raise Machinery::Errors::SystemDescriptionIncompatible.new(self.name)
139
140
  end
140
141
  end
141
142
 
143
+ def validate_analysis_compatibility
144
+ if !os.can_be_analyzed?
145
+ raise Machinery::Errors::AnalysisFailed.new("Analysis of operating " +
146
+ "system '#{os.display_name}' is not supported.")
147
+ end
148
+ end
149
+
150
+ def validate_export_compatibility
151
+ if !os.can_be_exported?
152
+ raise Machinery::Errors::ExportFailed.new("Export of operating " +
153
+ "system '#{os.display_name}' is not supported.")
154
+ end
155
+ end
156
+
142
157
  def to_hash
143
158
  meta = {}
144
159
  meta["format_version"] = self.format_version if self.format_version
@@ -200,50 +215,25 @@ class SystemDescription < Machinery::Object
200
215
  ScopeFileStore.new(description_path, store_name)
201
216
  end
202
217
 
203
- def missing_files(scope, file_list)
204
- file_list.map! { |file| File.join(scope_file_store(scope).path, file) }
205
-
206
- file_list.select { |file| !File.exists?(file) }
207
- end
208
-
209
- def additional_files(scope, file_list)
210
- file_store = scope_file_store(scope)
211
- file_list.map! { |file| File.join(file_store.path, file) }
212
- files = file_store.list_content
213
-
214
- files - file_list
218
+ def validate_file_data
219
+ errors = FileValidator.new(to_hash, description_path).validate
220
+ if !errors.empty?
221
+ Machinery::Ui.warn("Warning: File validation errors:")
222
+ Machinery::Ui.warn("Error validating description '#{@name}'\n\n")
223
+ Machinery::Ui.warn(errors)
224
+ end
215
225
  end
216
226
 
217
- def validate_file_data
218
- SystemDescriptionValidator.new(self).validate_file_data
227
+ def validate_file_data!
228
+ errors = FileValidator.new(to_hash, description_path).validate
229
+ if !errors.empty?
230
+ e = Machinery::Errors::SystemDescriptionValidationFailed.new(errors)
231
+ e.header = "Error validating description '#{@name}'"
232
+ raise e
233
+ end
219
234
  end
220
235
 
221
236
  def description_path
222
237
  @store.description_path(name)
223
238
  end
224
-
225
- # Filestore handling
226
- def initialize_file_store(store_name)
227
- @store.initialize_file_store(self.name, store_name)
228
- end
229
-
230
- def file_store(store_name)
231
- @store.file_store(self.name, store_name)
232
- end
233
-
234
- def remove_file_store(store_name)
235
- @store.remove_file_store(self.name, store_name)
236
- end
237
-
238
- def rename_file_store(old_name, new_name)
239
- @store.rename_file_store(self.name, old_name, new_name)
240
- end
241
-
242
- def list_file_store_content(store_name)
243
- @store.list_file_store_content(self.name, store_name)
244
- end
245
-
246
- def create_file_store_sub_dir(store_name, sub_dir)
247
- @store.create_file_store_sub_dir(self.name, store_name, sub_dir)
248
- end
249
239
  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
@@ -67,28 +67,16 @@ class SystemDescriptionStore
67
67
  def copy(from, to)
68
68
  SystemDescription.validate_name(from)
69
69
  SystemDescription.validate_name(to)
70
- if !list.include?(from)
71
- raise Machinery::Errors::SystemDescriptionNotFound.new(
72
- "System description \"#{from}\" does not exist."
73
- )
74
- end
75
70
 
76
- if list.include?(to)
77
- raise Machinery::Errors::SystemDescriptionError.new(
78
- "A System description with the name \"#{to}\" does already exist."
79
- )
80
- end
71
+ validate_existence_of_description(from)
72
+ validate_nonexistence_of_description(to)
81
73
 
82
74
  FileUtils.cp_r(description_path(from), description_path(to))
83
75
  end
84
76
 
85
77
  def backup(description_name)
86
78
  SystemDescription.validate_name(description_name)
87
- if !list.include?(description_name)
88
- raise Machinery::Errors::SystemDescriptionNotFound.new(
89
- "System description \"#{description_name}\" does not exist."
90
- )
91
- end
79
+ validate_existence_of_description(description_name)
92
80
 
93
81
  backup_name = get_backup_name(description_name)
94
82
 
@@ -99,55 +87,22 @@ class SystemDescriptionStore
99
87
  def rename(from, to)
100
88
  SystemDescription.validate_name(from)
101
89
  SystemDescription.validate_name(to)
102
- if !list.include?(from)
103
- raise Machinery::Errors::SystemDescriptionNotFound.new(
104
- "System description \"#{from}\" does not exist."
105
- )
106
- end
107
90
 
108
- if list.include?(to)
109
- raise Machinery::Errors::SystemDescriptionError.new(
110
- "A System description with the name \"#{to}\" does already exist."
111
- )
112
- end
91
+ validate_existence_of_description(from)
92
+ validate_nonexistence_of_description(to)
113
93
 
114
94
  FileUtils.mv(description_path(from), description_path(to))
115
95
  end
116
96
 
117
- def initialize_file_store(description_name, store_name)
118
- file_store = ScopeFileStore.new(description_path(description_name),
119
- store_name)
120
- file_store.create
121
- end
97
+ def swap(description_name_1, description_name_2)
98
+ validate_existence_of_description(description_name_1)
99
+ validate_existence_of_description(description_name_2)
122
100
 
123
- def file_store(description_name, store_name)
124
- file_store = ScopeFileStore.new(description_path(description_name),
125
- store_name)
126
- file_store.path
127
- end
101
+ tmp_description_name = "#{description_name_1}-#{Time.now.to_i}-#{rand(1000)}"
128
102
 
129
- def remove_file_store(description_name, store_name)
130
- file_store = ScopeFileStore.new(description_path(description_name),
131
- store_name)
132
- file_store.remove
133
- end
134
-
135
- def rename_file_store(description_name, store_old, store_new)
136
- file_store = ScopeFileStore.new(description_path(description_name),
137
- store_old)
138
- file_store.rename(store_new)
139
- end
140
-
141
- def create_file_store_sub_dir(description_name, store_name, sub_dir)
142
- file_store = ScopeFileStore.new(description_path(description_name),
143
- store_name)
144
- file_store.create_sub_directory(sub_dir)
145
- end
146
-
147
- def list_file_store_content(description_name, store_name)
148
- file_store = ScopeFileStore.new(description_path(description_name),
149
- store_name)
150
- file_store.list_content
103
+ FileUtils.mv(description_path(description_name_1), description_path(tmp_description_name))
104
+ FileUtils.mv(description_path(description_name_2), description_path(description_name_1))
105
+ FileUtils.mv(description_path(tmp_description_name), description_path(description_name_2))
151
106
  end
152
107
 
153
108
  def directory_for(name)
@@ -175,4 +130,20 @@ class SystemDescriptionStore
175
130
 
176
131
  backup_name
177
132
  end
133
+
134
+ def validate_existence_of_description(description_name)
135
+ if !list.include?(description_name)
136
+ raise Machinery::Errors::SystemDescriptionNotFound.new(
137
+ "System description \"#{description_name}\" does not exist."
138
+ )
139
+ end
140
+ end
141
+
142
+ def validate_nonexistence_of_description(description_name)
143
+ if list.include?(description_name)
144
+ raise Machinery::Errors::SystemDescriptionError.new(
145
+ "A System description with the name \"#{description_name}\" does already exist."
146
+ )
147
+ end
148
+ end
178
149
  end