bosh_cli 1.3169.0 → 1.3173.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d65f21821f357b177b60604495cada9fb19a905
4
- data.tar.gz: 99512cfe481d7e21af42ce996f8482ea2bf92a02
3
+ metadata.gz: fd4840a33d85038708d6c6bcb0a70ef609d8fe84
4
+ data.tar.gz: 9f528fe9ed3e09e5e697ccfa01876766125defd1
5
5
  SHA512:
6
- metadata.gz: 79b1646f801c050e15450a7530d137be0cb12500989d52f61eeafc6012914e7067c0158ceaa9997a55b4011ee1ef4ccaa040d05a85dd790d85ef1578ab338c55
7
- data.tar.gz: e285d74c20c709d25f43b57cd5f574212fffb629c058a93f1fa2c8ba721929172dd932fc56d4739a4e97c70c0fb943329a045236ffe2b93ac34ec6e53f5a3f1b
6
+ metadata.gz: 36106183c74c6d0e0ce882b745e78c7189d36fee761986fd70d967c81b88f9d55090904951835c87b9a0ebd436786d1378a5fd1f53bdeb0cd254ef4e08dc0ae4
7
+ data.tar.gz: f78e770441f282e4ee0726f5697b0a880406cf7877d6a828e0907e4c07a8320f655ca9e4663d571a94e0d3bcb68412197b0c69249f447b749de2fee0eeb2107c
@@ -554,6 +554,34 @@ module Bosh
554
554
  path
555
555
  end
556
556
 
557
+ def restore_db(filename)
558
+ upload_without_track('/restore', filename, { content_type: 'application/x-compressed' })
559
+ end
560
+
561
+ def check_director_restart(poll_interval, timeout)
562
+ current_time = start_time = Time.now()
563
+
564
+ #step 1, wait until director is stopped
565
+ while current_time.to_i - start_time.to_i <= timeout do
566
+ status, body = get_json_with_status('/info')
567
+ break if status != 200
568
+
569
+ sleep(poll_interval)
570
+ current_time = Time.now()
571
+ end
572
+
573
+ #step 2, wait until director is started
574
+ while current_time.to_i - start_time.to_i <= timeout do
575
+ status, body = get_json_with_status('/info')
576
+ return true if status == 200
577
+
578
+ sleep(poll_interval)
579
+ current_time = Time.now()
580
+ end
581
+
582
+ return false
583
+ end
584
+
557
585
  def list_locks
558
586
  get_json('/locks')
559
587
  end
@@ -602,6 +630,14 @@ module Bosh
602
630
  file.stop_progress_bar if file
603
631
  end
604
632
 
633
+ def upload_without_track(uri, filename, options = {})
634
+ file = FileWithProgressBar.open(filename, 'r')
635
+ status, _ = post(uri, options[:content_type], file, {}, options)
636
+ status
637
+ ensure
638
+ file.stop_progress_bar if file
639
+ end
640
+
605
641
  def get_cloud_config
606
642
  _, cloud_configs = get_json_with_status('/cloud_configs?limit=1')
607
643
  latest = cloud_configs.first
@@ -0,0 +1,40 @@
1
+ module Bosh::Cli::Command
2
+ class Restore < Base
3
+ usage 'restore'
4
+ desc 'Restore BOSH director database'
5
+ def restore(path)
6
+ auth_required
7
+ show_current_state
8
+
9
+ nl
10
+ say("You are going to restore the director's database.".make_red)
11
+ nl
12
+ say('THIS IS A VERY DESTRUCTIVE OPERATION WHICH WILL DROP CURRENT DATABASE.'.make_red)
13
+ nl
14
+ say('IT CANNOT BE UNDONE!'.make_red)
15
+ nl
16
+
17
+ unless confirmed?
18
+ say('Canceled restoring database'.make_green)
19
+ return
20
+ end
21
+
22
+ err("The file `#{path}' does not exist.".make_red) unless File.exists?(path)
23
+ err("The file `#{path}' is not readable.".make_red) unless File.readable?(path)
24
+
25
+ nl
26
+ status = director.restore_db(path)
27
+ err("Failed to restore the database, the status is `#{status}'") unless status == 202
28
+ nl
29
+ say('Starting restore of BOSH director.')
30
+
31
+ result = director.check_director_restart(5, 600)
32
+
33
+ unless result
34
+ err('Restore database timed out.')
35
+ else
36
+ say('Restore done!'.make_green)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Cli
3
- VERSION = '1.3169.0'
3
+ VERSION = '1.3173.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3169.0
4
+ version: 1.3173.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-31 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_common
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3169.0
19
+ version: 1.3173.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3169.0
26
+ version: 1.3173.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bosh-template
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3169.0
33
+ version: 1.3173.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.3169.0
40
+ version: 1.3173.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cf-uaa-lib
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.3169.0
131
+ version: 1.3173.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.3169.0
138
+ version: 1.3173.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: net-ssh
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -382,6 +382,7 @@ files:
382
382
  - lib/cli/commands/release/reset_release.rb
383
383
  - lib/cli/commands/release/upload_release.rb
384
384
  - lib/cli/commands/release/verify_release.rb
385
+ - lib/cli/commands/restore.rb
385
386
  - lib/cli/commands/snapshot.rb
386
387
  - lib/cli/commands/ssh.rb
387
388
  - lib/cli/commands/stemcell.rb