knife-ec-backup 1.1.6 → 1.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1fa04532a43b013c1d7e6f535f6245959c34b88
4
- data.tar.gz: 219c74741df411d3072e0927259337972ce69b7e
3
+ metadata.gz: 54d12c87f2f93b3140357b7206d01274571f8adb
4
+ data.tar.gz: b597018c25f2c2c8da15bbcee036e423c42a26db
5
5
  SHA512:
6
- metadata.gz: c85f85e6984ee20d7d87471ff5926df00ae82b834dd8a31242d0ac11e8e44b3bc174090c45676230a2d1005b78e87221223fda79d89e655e7394ede761d829c1
7
- data.tar.gz: e2c99033987ecf7e5040c529a0f509b17efc5141d889962537eca3160a3927347d11bf468b4183c9edb52111141a2ee529ce0c6aab755594351a369b2c347f2a
6
+ metadata.gz: be56f4584a4e166ead2daa956dbfd2659d572433a33520aba295aa26677acc5c22301b57898c3eb545b26bf7a722a673b3e3b245a7da5222ecfa5704c3e9cf45
7
+ data.tar.gz: 7c272d46ba92aa91d269dcde62adb146a1a1d4a8ec79ec45ca31acf20e6aa811e835a6103af85fbc1488973d6cf0447425f88b929488c27d68f4f5b3e9648d99
@@ -238,11 +238,15 @@ class Chef
238
238
  # Upload the admins group and billing-admins acls
239
239
  puts "Restoring the org admin data"
240
240
  chef_fs_config = ::ChefFS::Config.new
241
- %w(/groups/admins.json /groups/billing-admins.json /acls/groups/billing-admins.json).each do |name|
242
- pattern = ::ChefFS::FilePattern.new(name)
243
- if ::ChefFS::FileSystem.copy_to(pattern, chef_fs_config.local_fs, chef_fs_config.chef_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
244
- @error = true
245
- end
241
+
242
+ # Restore users w/o clients (which don't exist yet)
243
+ ['admins', 'billing-admins'].each do |group|
244
+ restore_group(chef_fs_config, group, :clients => false)
245
+ end
246
+
247
+ pattern = ::ChefFS::FilePattern.new('/acls/groups/billing-admins.json')
248
+ if ::ChefFS::FileSystem.copy_to(pattern, chef_fs_config.local_fs, chef_fs_config.chef_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
249
+ @error = true
246
250
  end
247
251
 
248
252
  # Figure out who the admin is so we can spoof him and retrieve his stuff
@@ -270,6 +274,10 @@ class Chef
270
274
  (top_level_paths + group_paths + group_acl_paths + acl_paths).each do |path|
271
275
  ::ChefFS::FileSystem.copy_to(::ChefFS::FilePattern.new(path), chef_fs_config.local_fs, chef_fs_config.chef_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
272
276
  end
277
+ # restore clients to groups
278
+ ['admins', 'billing-admins'].each do |group|
279
+ restore_group(chef_fs_config, group, :users => false)
280
+ end
273
281
  ensure
274
282
  CONFIG_VARS.each do |key|
275
283
  Chef::Config[key.to_sym] = old_config[key]
@@ -277,6 +285,33 @@ class Chef
277
285
  end
278
286
  end
279
287
 
288
+ def restore_group(chef_fs_config, group_name, includes = {:users => true, :clients => true})
289
+ includes[:users] = true unless includes.key? :users
290
+ includes[:clients] = true unless includes.key? :clients
291
+
292
+ group = ::ChefFS::FileSystem.resolve_path(
293
+ chef_fs_config.chef_fs,
294
+ "/groups/#{group_name}.json"
295
+ )
296
+
297
+ members_json = ::ChefFS::FileSystem.resolve_path(
298
+ chef_fs_config.local_fs,
299
+ "/groups/#{group_name}.json"
300
+ ).read
301
+
302
+ members = JSON.parse(members_json).select do |member|
303
+ if includes[:users] and includes[:clients]
304
+ member
305
+ elsif includes[:users]
306
+ member == 'users'
307
+ elsif includes[:clients]
308
+ member == 'clients'
309
+ end
310
+ end
311
+
312
+ group.write(members.to_json)
313
+ end
314
+
280
315
  def parallelize(entries, options = {}, &block)
281
316
  ::ChefFS::Parallelizer.parallelize(entries, options, &block)
282
317
  end
@@ -1,3 +1,3 @@
1
1
  module KnifeECBackup
2
- VERSION = '1.1.6'
2
+ VERSION = '1.1.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-ec-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-30 00:00:00.000000000 Z
11
+ date: 2014-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec