knife-ec-backup 0.9.2 → 0.9.3
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 +4 -4
- data/lib/chef/knife/ec_backup.rb +12 -4
- data/lib/chef/knife/opc_restore.rb +2 -2
- data/lib/knife_ec_backup/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c64485c8411324223a9453e39e68afbd7a834aa2
|
4
|
+
data.tar.gz: 904be6ea0754370384521c07d90578fa70ca4513
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 084f0ac8b43a0cd0139dd97c2a41e7840641bbca0589bba38a388845ca98857446c2f147e336a7943966804facf8949f27133b986e13480fbba8b314536a9970
|
7
|
+
data.tar.gz: 1e8489c6d5da29a0fd2bd6f8697cf78fe198905efbde6dfecd75ae4c586727552bcb2c969af634af376ddd3eac24fd13ba7e52a491fe399e4e91234ca2f92bda
|
data/lib/chef/knife/ec_backup.rb
CHANGED
@@ -21,16 +21,23 @@ class Chef
|
|
21
21
|
webui_key = name_args[1]
|
22
22
|
rest = Chef::REST.new(Chef::Config.chef_server_url)
|
23
23
|
if name_args.length >= 3
|
24
|
-
user_acl_rest = Chef::REST.new(name_args[
|
24
|
+
user_acl_rest = Chef::REST.new(name_args[2])
|
25
|
+
else
|
26
|
+
user_acl_rest = rest
|
25
27
|
end
|
28
|
+
|
26
29
|
# Grab users
|
30
|
+
puts "Grabbing users ..."
|
27
31
|
ensure_dir("#{dest_dir}/users")
|
32
|
+
ensure_dir("#{dest_dir}/user_acls")
|
28
33
|
|
29
|
-
puts "Grabbing users ..."
|
30
34
|
rest.get_rest('/users').each_pair do |name, url|
|
31
35
|
File.open("#{dest_dir}/users/#{name}.json", 'w') do |file|
|
32
36
|
file.write(rest.get_rest(url).to_json)
|
33
37
|
end
|
38
|
+
File.open("#{dest_dir}/user_acls/#{name}.json", 'w') do |file|
|
39
|
+
file.write(user_acl_rest.get_rest("users/#{name}/_acl").to_json)
|
40
|
+
end
|
34
41
|
end
|
35
42
|
|
36
43
|
# Download organizations
|
@@ -74,6 +81,7 @@ class Chef
|
|
74
81
|
Chef::Config.chef_server_url = "#{Chef::Config.chef_server_url}/organizations/#{name}"
|
75
82
|
|
76
83
|
# Figure out who the admin is so we can spoof him and retrieve his stuff
|
84
|
+
rest = Chef::REST.new(Chef::Config.chef_server_url)
|
77
85
|
admin_users = rest.get_rest('groups/admins')['users']
|
78
86
|
org_members = rest.get_rest('users').map { |user| user['user']['username'] }
|
79
87
|
admin_users.delete_if { |user| !org_members.include?(user) }
|
@@ -83,9 +91,9 @@ class Chef
|
|
83
91
|
|
84
92
|
# Do the download
|
85
93
|
ensure_dir(Chef::Config.chef_repo_path)
|
86
|
-
|
94
|
+
chef_fs_config ||= ::ChefFS::Config.new
|
87
95
|
root_pattern = ::ChefFS::FilePattern.new('/')
|
88
|
-
if ::ChefFS::FileSystem.copy_to(root_pattern,
|
96
|
+
if ::ChefFS::FileSystem.copy_to(root_pattern, chef_fs_config.chef_fs, chef_fs_config.local_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
|
89
97
|
@error = true
|
90
98
|
end
|
91
99
|
ensure
|