knife-ec-backup 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/knife/ec_backup.rb +11 -0
- data/lib/chef/knife/ec_restore.rb +26 -1
- 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: 82f59d873c1202c42f7ddebd1e673b102f81fda2
|
4
|
+
data.tar.gz: f2826c7bb0ec69ae9ca0d40c1e455dadbc91e649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70ac26a02971b3b50184d9dd7d12c12233c0d7f33cd5097c366c9eef05ae3cc78845cd482cf28dbb3e8a477bc9142422f9894739a7caff7e59976ebc139f5447
|
7
|
+
data.tar.gz: cc3613d5eff4101a212c59f34f6a3ad736c0cce305501db4c41fc7dead3b0e11fb1912b564f15aecbb03a5aefdb5cfcb1ac9387271492ca17859f44bf00807c8
|
data/lib/chef/knife/ec_backup.rb
CHANGED
@@ -5,10 +5,21 @@ class Chef
|
|
5
5
|
class EcBackup < Chef::Knife
|
6
6
|
banner "knife ec backup"
|
7
7
|
|
8
|
+
option :concurrency,
|
9
|
+
:long => '--concurrency THREADS',
|
10
|
+
:description => 'Maximum number of simultaneous requests to send (default: 10)'
|
11
|
+
|
8
12
|
deps do
|
9
13
|
require 'chef_fs/config'
|
10
14
|
require 'chef_fs/file_system'
|
11
15
|
require 'chef_fs/file_pattern'
|
16
|
+
require 'chef_fs/parallelizer'
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure_chef
|
20
|
+
super
|
21
|
+
Chef::Config[:concurrency] = config[:concurrency].to_i if config[:concurrency]
|
22
|
+
::ChefFS::Parallelizer.threads = (Chef::Config[:concurrency] || 10) - 1
|
12
23
|
end
|
13
24
|
|
14
25
|
def run
|
@@ -5,6 +5,16 @@ class Chef
|
|
5
5
|
class EcRestore < Chef::Knife
|
6
6
|
banner "knife ec restore"
|
7
7
|
|
8
|
+
option :concurrency,
|
9
|
+
:long => '--concurrency THREADS',
|
10
|
+
:description => 'Maximum number of simultaneous requests to send (default: 10)'
|
11
|
+
|
12
|
+
option :overwrite_pivotal,
|
13
|
+
:long => '--overwrite-pivotal',
|
14
|
+
:boolean => true,
|
15
|
+
:default => false,
|
16
|
+
:description => "Whether to overwrite pivotal's key. Once this is done, future requests will fail until you fix the private key."
|
17
|
+
|
8
18
|
deps do
|
9
19
|
require 'chef/json_compat'
|
10
20
|
require 'chef_fs/config'
|
@@ -16,6 +26,12 @@ class Chef
|
|
16
26
|
require 'chef_fs/parallelizer'
|
17
27
|
end
|
18
28
|
|
29
|
+
def configure_chef
|
30
|
+
super
|
31
|
+
Chef::Config[:concurrency] = config[:concurrency].to_i if config[:concurrency]
|
32
|
+
::ChefFS::Parallelizer.threads = (Chef::Config[:concurrency] || 10) - 1
|
33
|
+
end
|
34
|
+
|
19
35
|
def run
|
20
36
|
if name_args.length == 0
|
21
37
|
ui.error("Must specify backup directory as argument.")
|
@@ -36,8 +52,15 @@ class Chef
|
|
36
52
|
Dir.foreach("#{dest_dir}/users") do |filename|
|
37
53
|
next if filename !~ /(.+)\.json/
|
38
54
|
name = $1
|
55
|
+
if name == 'pivotal' && !config[:overwrite_pivotal]
|
56
|
+
ui.warn("Skipping pivotal update. To overwrite pivotal, pass --overwrite-pivotal. Once pivotal is updated, you will need to modify #{Chef::Config.client_key} to be the corresponding private key.")
|
57
|
+
next
|
58
|
+
end
|
59
|
+
|
60
|
+
# Update user object
|
39
61
|
user = JSONCompat.from_json(IO.read("#{dest_dir}/users/#{name}.json"))
|
40
62
|
begin
|
63
|
+
# Supply password for new user
|
41
64
|
user_with_password = user.dup
|
42
65
|
user_with_password['password'] = SecureRandom.hex
|
43
66
|
rest.post_rest('users', user_with_password)
|
@@ -48,7 +71,9 @@ class Chef
|
|
48
71
|
raise
|
49
72
|
end
|
50
73
|
end
|
51
|
-
|
74
|
+
|
75
|
+
# Update user acl
|
76
|
+
# Doesn't work at present due to server
|
52
77
|
#user_acl = JSONCompat.from_json(IO.read("#{dest_dir}/user_acls/#{name}.json"))
|
53
78
|
#put_acl(user_acl_rest, "users/#{name}/_acl", user_acl)
|
54
79
|
end
|