bosh_cli 0.19.6 → 1.0.rc1

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.
Files changed (64) hide show
  1. data/bin/bosh +3 -0
  2. data/lib/cli.rb +15 -5
  3. data/lib/cli/{commands/base.rb → base_command.rb} +38 -44
  4. data/lib/cli/command_discovery.rb +40 -0
  5. data/lib/cli/command_handler.rb +135 -0
  6. data/lib/cli/commands/biff.rb +16 -12
  7. data/lib/cli/commands/blob_management.rb +10 -3
  8. data/lib/cli/commands/cloudcheck.rb +13 -11
  9. data/lib/cli/commands/complete.rb +29 -0
  10. data/lib/cli/commands/deployment.rb +137 -28
  11. data/lib/cli/commands/help.rb +96 -0
  12. data/lib/cli/commands/job.rb +4 -1
  13. data/lib/cli/commands/job_management.rb +36 -23
  14. data/lib/cli/commands/job_rename.rb +11 -12
  15. data/lib/cli/commands/log_management.rb +28 -32
  16. data/lib/cli/commands/maintenance.rb +6 -1
  17. data/lib/cli/commands/misc.rb +129 -87
  18. data/lib/cli/commands/package.rb +6 -65
  19. data/lib/cli/commands/property_management.rb +20 -8
  20. data/lib/cli/commands/release.rb +211 -206
  21. data/lib/cli/commands/ssh.rb +178 -188
  22. data/lib/cli/commands/stemcell.rb +114 -51
  23. data/lib/cli/commands/task.rb +74 -56
  24. data/lib/cli/commands/user.rb +6 -3
  25. data/lib/cli/commands/vms.rb +17 -15
  26. data/lib/cli/config.rb +27 -1
  27. data/lib/cli/core_ext.rb +27 -1
  28. data/lib/cli/deployment_helper.rb +47 -0
  29. data/lib/cli/director.rb +18 -9
  30. data/lib/cli/errors.rb +6 -0
  31. data/lib/cli/job_builder.rb +75 -23
  32. data/lib/cli/job_property_collection.rb +87 -0
  33. data/lib/cli/job_property_validator.rb +130 -0
  34. data/lib/cli/package_builder.rb +32 -5
  35. data/lib/cli/release.rb +2 -0
  36. data/lib/cli/release_builder.rb +9 -13
  37. data/lib/cli/release_compiler.rb +5 -34
  38. data/lib/cli/release_tarball.rb +4 -19
  39. data/lib/cli/runner.rb +118 -694
  40. data/lib/cli/version.rb +1 -1
  41. data/spec/assets/config/swift-hp/config/final.yml +6 -0
  42. data/spec/assets/config/swift-hp/config/private.yml +7 -0
  43. data/spec/assets/config/swift-rackspace/config/final.yml +6 -0
  44. data/spec/assets/config/swift-rackspace/config/private.yml +6 -0
  45. data/spec/spec_helper.rb +0 -5
  46. data/spec/unit/base_command_spec.rb +32 -37
  47. data/spec/unit/biff_spec.rb +11 -10
  48. data/spec/unit/cli_commands_spec.rb +96 -88
  49. data/spec/unit/core_ext_spec.rb +1 -1
  50. data/spec/unit/deployment_manifest_spec.rb +36 -0
  51. data/spec/unit/director_spec.rb +17 -3
  52. data/spec/unit/job_builder_spec.rb +2 -2
  53. data/spec/unit/job_property_collection_spec.rb +111 -0
  54. data/spec/unit/job_property_validator_spec.rb +7 -0
  55. data/spec/unit/job_rename_spec.rb +7 -6
  56. data/spec/unit/package_builder_spec.rb +2 -2
  57. data/spec/unit/release_builder_spec.rb +33 -0
  58. data/spec/unit/release_spec.rb +54 -0
  59. data/spec/unit/release_tarball_spec.rb +2 -7
  60. data/spec/unit/runner_spec.rb +1 -151
  61. data/spec/unit/ssh_spec.rb +15 -9
  62. metadata +41 -12
  63. data/lib/cli/command_definition.rb +0 -52
  64. data/lib/cli/templates/help_message.erb +0 -80
data/lib/cli/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bosh
4
4
  module Cli
5
- VERSION = "0.19.6"
5
+ VERSION = "1.0.rc1"
6
6
  end
7
7
  end
@@ -0,0 +1,6 @@
1
+ ---
2
+ blobstore:
3
+ provider: swift
4
+ options:
5
+ container_name: test
6
+ swift_provider: hp
@@ -0,0 +1,7 @@
1
+ ---
2
+ blobstore:
3
+ swift:
4
+ hp:
5
+ hp_account_id: foo
6
+ hp_secret_key: bar
7
+ hp_tenant_id: foo
@@ -0,0 +1,6 @@
1
+ ---
2
+ blobstore:
3
+ provider: swift
4
+ options:
5
+ container_name: test
6
+ swift_provider: rackspace
@@ -0,0 +1,6 @@
1
+ ---
2
+ blobstore:
3
+ swift:
4
+ rackspace:
5
+ rackspace_username: foo
6
+ rackspace_api_key: bar
data/spec/spec_helper.rb CHANGED
@@ -9,11 +9,6 @@ def spec_asset(filename)
9
9
  File.expand_path(File.join(File.dirname(__FILE__), "assets", filename))
10
10
  end
11
11
 
12
- tmpdir = Dir.mktmpdir
13
- ENV["TMPDIR"] = tmpdir
14
- FileUtils.mkdir_p(tmpdir)
15
- at_exit { FileUtils.rm_rf(tmpdir) }
16
-
17
12
  RSpec.configure do |c|
18
13
  c.before(:each) do
19
14
  Bosh::Cli::Config.interactive = false
@@ -5,35 +5,38 @@ require "spec_helper"
5
5
  describe Bosh::Cli::Command::Base do
6
6
 
7
7
  before :each do
8
- @config = File.join(Dir.mktmpdir, "bosh_config")
8
+ @runner = mock(Bosh::Cli::Runner)
9
+ @config_file = File.join(Dir.mktmpdir, "bosh_config")
9
10
  @cache_dir = Dir.mktmpdir
10
11
  end
11
12
 
12
13
  def add_config(object)
13
- File.open(@config, "w") do |f|
14
+ File.open(@config_file, "w") do |f|
14
15
  f.write(YAML.dump(object))
15
16
  end
16
17
  end
17
18
 
18
- def make_command(options = {})
19
- Bosh::Cli::Command::Base.new({:config => @config,
20
- :cache_dir => @cache_dir}.merge(options))
19
+ def make
20
+ cmd = Bosh::Cli::Command::Base.new(@runner)
21
+ cmd.add_option(:config, @config_file)
22
+ cmd
21
23
  end
22
24
 
23
25
  it "can access configuration and respects options" do
24
26
  add_config("target" => "localhost:8080", "deployment" => "test")
25
27
 
26
- cmd = make_command(:verbose => true, :dry_run => true)
27
- cmd.verbose?.should be_true
28
- cmd.dry_run?.should be_true
28
+ cmd = make
29
+ cmd.config.should be_a(Bosh::Cli::Config)
30
+
29
31
  cmd.target.should == "http://localhost:8080"
30
32
  cmd.deployment.should == "test"
31
- cmd.username.should == nil
32
- cmd.password.should == nil
33
+ cmd.username.should be_nil
34
+ cmd.password.should be_nil
33
35
  end
34
36
 
35
- it "looks up target, deployment and credentials in a right order" do
36
- cmd = make_command
37
+ it "looks up target, deployment and credentials in the right order" do
38
+ cmd = make
39
+
37
40
  cmd.username.should be_nil
38
41
  cmd.password.should be_nil
39
42
  old_user = ENV["BOSH_USER"]
@@ -44,7 +47,10 @@ describe Bosh::Cli::Command::Base do
44
47
  ENV["BOSH_PASSWORD"] = "bar"
45
48
  cmd.username.should == "foo"
46
49
  cmd.password.should == "bar"
47
- other_cmd = make_command(:username => "new", :password => "baz")
50
+ other_cmd = make
51
+ other_cmd.add_option(:username, "new")
52
+ other_cmd.add_option(:password, "baz")
53
+
48
54
  other_cmd.username.should == "new"
49
55
  other_cmd.password.should == "baz"
50
56
  ensure
@@ -53,7 +59,10 @@ describe Bosh::Cli::Command::Base do
53
59
  end
54
60
 
55
61
  add_config("target" => "localhost:8080", "deployment" => "test")
56
- cmd2 = make_command(:target => "foo", :deployment => "bar")
62
+
63
+ cmd2 = make
64
+ cmd2.add_option(:target, "foo")
65
+ cmd2.add_option(:deployment, "bar")
57
66
  cmd2.target.should == "http://foo:25555"
58
67
  cmd2.deployment.should == "bar"
59
68
  end
@@ -61,32 +70,18 @@ describe Bosh::Cli::Command::Base do
61
70
  it "instantiates director when needed" do
62
71
  add_config("target" => "localhost:8080", "deployment" => "test")
63
72
 
64
- cmd = make_command
73
+ cmd = make
74
+ cmd.director.should be_kind_of(Bosh::Cli::Director)
65
75
  cmd.director.director_uri.should == "http://localhost:8080"
66
76
  end
67
77
 
68
- it "can evaluate other commands" do
69
- cmd = make_command
70
- new_cmd = mock(Object)
71
-
72
- Bosh::Cli::Command::Misc.should_receive(:new).and_return(new_cmd)
73
- new_cmd.should_receive(:status).with(:arg1, :arg2)
74
-
75
- cmd.run("misc", "status", :arg1, :arg2)
76
- end
77
-
78
- it "can redirect to other commands " +
79
- "(effectively exiting after running them)" do
80
- cmd = make_command
81
- new_cmd = mock(Object)
82
-
83
- Bosh::Cli::Command::Misc.should_receive(:new).and_return(new_cmd)
84
- new_cmd.should_receive(:status).with(:arg1, :arg2)
85
-
86
- lambda {
87
- cmd.redirect("misc", "status", :arg1, :arg2)
88
- }.should raise_error(Bosh::Cli::GracefulExit,
89
- "redirected to misc status arg1 arg2")
78
+ it "has logged_in? helper" do
79
+ cmd = make
80
+ cmd.logged_in?.should be_false
81
+ cmd.add_option(:username, "foo")
82
+ cmd.logged_in?.should be_false
83
+ cmd.add_option(:password, "bar")
84
+ cmd.logged_in?.should be_true
90
85
  end
91
86
 
92
87
  end
@@ -19,7 +19,10 @@ describe Bosh::Cli::Command::Biff do
19
19
  @biff.stub!(:deployment).and_return(config_file)
20
20
  lambda {
21
21
  @biff.biff(template_file)
22
- }.should raise_error(Bosh::Cli::CliExit, "IP range '2..9' is not within the bounds of network 'default', which only has 1 IPs.")
22
+ }.should raise_error(
23
+ Bosh::Cli::CliError,
24
+ "IP range '2..9' is not within " +
25
+ "the bounds of network 'default', which only has 1 IPs.")
23
26
  end
24
27
 
25
28
  it "throws an error when there is more than one subnet for default" do
@@ -28,7 +31,7 @@ describe Bosh::Cli::Command::Biff do
28
31
  @biff.stub!(:deployment).and_return(config_file)
29
32
  lambda {
30
33
  @biff.biff(template_file)
31
- }.should raise_error(Bosh::Cli::CliExit, "Biff doesn't know how to deal " +
34
+ }.should raise_error(Bosh::Cli::CliError, "Biff doesn't know how to deal " +
32
35
  "with anything other than one subnet in default")
33
36
  end
34
37
 
@@ -38,7 +41,7 @@ describe Bosh::Cli::Command::Biff do
38
41
  @biff.stub!(:deployment).and_return(config_file)
39
42
  lambda {
40
43
  @biff.biff(template_file)
41
- }.should raise_error(Bosh::Cli::CliExit, "Biff only supports " +
44
+ }.should raise_error(Bosh::Cli::CliError, "Biff only supports " +
42
45
  "configurations where the gateway is the first IP (e.g. 172.31.196.1).")
43
46
  end
44
47
 
@@ -48,7 +51,7 @@ describe Bosh::Cli::Command::Biff do
48
51
  @biff.stub!(:deployment).and_return(config_file)
49
52
  lambda {
50
53
  @biff.biff(template_file)
51
- }.should raise_error(Bosh::Cli::CliExit, "Biff requires each network to " +
54
+ }.should raise_error(Bosh::Cli::CliError, "Biff requires each network to " +
52
55
  "have range and dns entries.")
53
56
  end
54
57
 
@@ -58,7 +61,7 @@ describe Bosh::Cli::Command::Biff do
58
61
  @biff.stub!(:deployment).and_return(config_file)
59
62
  lambda {
60
63
  @biff.biff(template_file)
61
- }.should raise_error(Bosh::Cli::CliExit, "You must have subnets in default")
64
+ }.should raise_error(Bosh::Cli::CliError, "You must have subnets in default")
62
65
  end
63
66
 
64
67
  it "outputs the required yaml when the input does not contain it" do
@@ -76,11 +79,9 @@ describe Bosh::Cli::Command::Biff do
76
79
  # can come back in any order.
77
80
  @biff.should_receive(:say).with(/Add this to '':/).once
78
81
 
79
- #@biff.should_receive(:say).once
80
-
81
- @biff.should_receive(:say).with("There were 1 errors.").once
82
-
83
- @biff.biff(template_file)
82
+ lambda {
83
+ @biff.biff(template_file)
84
+ }.should raise_error Bosh::Cli::CliError, "There were 1 errors."
84
85
  end
85
86
 
86
87
  it "correctly generates a file and reports when there are no differences" do
@@ -5,49 +5,46 @@ require "spec_helper"
5
5
  describe Bosh::Cli::Command::Base do
6
6
 
7
7
  before :each do
8
- @config = File.join(Dir.mktmpdir, "bosh_config")
9
- @cache = File.join(Dir.mktmpdir, "bosh_cache")
10
- @opts = { :config => @config, :cache_dir => @cache }
8
+ tmpdir = Dir.mktmpdir
9
+ @config = File.join(tmpdir, "bosh_config")
10
+ @cache = File.join(tmpdir, "bosh_cache")
11
+ @director = mock(Bosh::Cli::Director)
12
+ Bosh::Cli::Director.stub!(:new).and_return(@director)
13
+ @director.stub!(:get_status).and_return("name" => "ZB")
11
14
  end
12
15
 
13
16
  describe Bosh::Cli::Command::Misc do
14
17
 
15
18
  before :each do
16
- @cmd = Bosh::Cli::Command::Misc.new(@opts)
17
- @cmd.stub!(:interactive?).and_return(false)
19
+ @cmd = Bosh::Cli::Command::Misc.new
20
+ @cmd.add_option(:config, @config)
21
+ @cmd.add_option(:cache_dir, @cache)
22
+ @cmd.add_option(:non_interactive, true)
18
23
  end
19
24
 
20
25
  it "sets the target" do
21
- @cmd.target.should == nil
26
+ @cmd.target.should be_nil
22
27
  @cmd.set_target("http://example.com:232")
23
28
  @cmd.target.should == "http://example.com:232"
24
29
  end
25
30
 
26
31
  it "normalizes target" do
27
- @cmd.target.should == nil
32
+ @cmd.target.should be_nil
28
33
  @cmd.set_target("test")
29
34
  @cmd.target.should == "http://test:25555"
30
35
  end
31
36
 
32
- it "respects director checks option when setting target" do
33
- @cmd.options[:director_checks] = true
37
+ it "handles director errors when setting target" do
38
+ @director.should_receive(:get_status).and_raise(Bosh::Cli::DirectorError)
34
39
 
35
40
  lambda {
36
- mock_director = mock(Object)
37
- mock_director.stub!(:get_status).and_raise(Bosh::Cli::DirectorError)
38
- Bosh::Cli::Director.should_receive(:new).
39
- with("http://test:25555").and_return(mock_director)
40
41
  @cmd.set_target("test")
41
- }.should raise_error(Bosh::Cli::CliExit,
42
- "Cannot talk to director at `http://test:25555', " +
43
- "please set correct target")
42
+ }.should raise_error(Bosh::Cli::CliError, /cannot talk to director/i)
44
43
 
45
- @cmd.target.should == nil
44
+ @cmd.target.should be_nil
45
+ end
46
46
 
47
- mock_director = mock(Bosh::Cli::Director)
48
- mock_director.stub!(:get_status).and_return("name" => "ZB")
49
- Bosh::Cli::Director.should_receive(:new).
50
- with("http://test:25555").and_return(mock_director)
47
+ it "sets target" do
51
48
  @cmd.set_target("test")
52
49
  @cmd.target.should == "http://test:25555"
53
50
  end
@@ -66,6 +63,9 @@ describe Bosh::Cli::Command::Base do
66
63
  end
67
64
 
68
65
  it "logs user in" do
66
+ @director.should_receive(:authenticated?).and_return(true)
67
+ @director.should_receive(:user=).with("user")
68
+ @director.should_receive(:password=).with("pass")
69
69
  @cmd.set_target("test")
70
70
  @cmd.login("user", "pass")
71
71
  @cmd.logged_in?.should be_true
@@ -75,26 +75,22 @@ describe Bosh::Cli::Command::Base do
75
75
 
76
76
  it "logs user out" do
77
77
  @cmd.set_target("test")
78
+ @director.should_receive(:authenticated?).and_return(true)
79
+ @director.should_receive(:user=).with("user")
80
+ @director.should_receive(:password=).with("pass")
78
81
  @cmd.login("user", "pass")
79
82
  @cmd.logout
80
83
  @cmd.logged_in?.should be_false
81
84
  end
82
85
 
83
86
  it "respects director checks option when logging in" do
84
- @cmd.options[:director_checks] = true
85
-
86
- mock_director = mock(Object)
87
- mock_director.stub(:get_status).
88
- and_return({ "user" => "user", "name" => "ZB" })
89
- mock_director.stub(:authenticated?).and_return(true)
87
+ @director.stub!(:get_status).
88
+ and_return({ "user" => "user", "name" => "ZB" })
89
+ @director.stub(:authenticated?).and_return(true)
90
90
 
91
- Bosh::Cli::Director.should_receive(:new).
92
- with("http://test:25555").and_return(mock_director)
93
91
  @cmd.set_target("test")
94
-
95
- Bosh::Cli::Director.should_receive(:new).
96
- with("http://test:25555", "user", "pass").and_return(mock_director)
97
-
92
+ @director.should_receive(:user=).with("user")
93
+ @director.should_receive(:password=).with("pass")
98
94
  @cmd.login("user", "pass")
99
95
  @cmd.logged_in?.should be_true
100
96
  @cmd.username.should == "user"
@@ -104,37 +100,48 @@ describe Bosh::Cli::Command::Base do
104
100
 
105
101
  describe Bosh::Cli::Command::Stemcell do
106
102
  before :each do
107
- @cmd = Bosh::Cli::Command::Stemcell.new(@opts)
108
- end
103
+ @director = mock(Bosh::Cli::Director)
104
+ @director.stub(:list_stemcells).
105
+ and_return([{ "name" => "foo", "version" => "123" }])
106
+ @director.should_receive(:list_stemcells)
109
107
 
110
- it "allows deleting the stemcell" do
111
- mock_director = mock(Bosh::Cli::Director)
112
- mock_director.should_receive(:delete_stemcell).with("foo", "123")
108
+ @cmd = Bosh::Cli::Command::Stemcell.new
109
+ @cmd.add_option(:non_interactive, true)
113
110
 
114
- @cmd.stub!(:interactive?).and_return(false)
115
111
  @cmd.stub!(:target).and_return("test")
116
112
  @cmd.stub!(:username).and_return("user")
117
113
  @cmd.stub!(:password).and_return("pass")
118
- @cmd.stub!(:director).and_return(mock_director)
114
+ @cmd.stub!(:director).and_return(@director)
115
+ end
116
+
117
+ it "allows deleting the stemcell" do
118
+ @director.should_receive(:delete_stemcell).with("foo", "123")
119
119
  @cmd.delete("foo", "123")
120
120
  end
121
121
 
122
122
  it "needs confirmation to delete stemcell" do
123
- mock_director = mock(Bosh::Cli::Director)
124
- mock_director.should_not_receive(:delete_stemcell)
123
+ @cmd.remove_option(:non_interactive)
124
+ @director.should_not_receive(:delete_stemcell)
125
125
 
126
- @cmd.stub!(:target).and_return("test")
127
- @cmd.stub!(:username).and_return("user")
128
- @cmd.stub!(:password).and_return("pass")
129
- @cmd.stub!(:director).and_return(mock_director)
130
126
  @cmd.stub!(:ask).and_return("")
131
127
  @cmd.delete("foo", "123")
132
128
  end
129
+
130
+ it "raises error when deleting if stemcell does not exist" do
131
+ @director.should_not_receive(:delete_stemcell)
132
+
133
+ @cmd.add_option(:non_interactive, true)
134
+ lambda {
135
+ @cmd.delete("foo", "111")
136
+ }.should raise_error(Bosh::Cli::CliError,
137
+ "Stemcell `foo/111' does not exist")
138
+ end
133
139
  end
134
140
 
135
141
  describe Bosh::Cli::Command::Deployment do
136
142
  before :each do
137
- @cmd = Bosh::Cli::Command::Deployment.new(@opts)
143
+ @cmd = Bosh::Cli::Command::Deployment.new
144
+ @cmd.add_option(:non_interactive, true)
138
145
  end
139
146
 
140
147
  it "allows deleting the deployment" do
@@ -154,6 +161,7 @@ describe Bosh::Cli::Command::Base do
154
161
  mock_director = mock(Bosh::Cli::Director)
155
162
  mock_director.should_not_receive(:delete_deployment)
156
163
 
164
+ @cmd.remove_option(:non_interactive)
157
165
  @cmd.stub!(:target).and_return("test")
158
166
  @cmd.stub!(:username).and_return("user")
159
167
  @cmd.stub!(:password).and_return("pass")
@@ -165,56 +173,51 @@ describe Bosh::Cli::Command::Base do
165
173
 
166
174
  describe Bosh::Cli::Command::Release do
167
175
  before :each do
168
- @cmd = Bosh::Cli::Command::Release.new(@opts)
176
+ @director = mock(Bosh::Cli::Director)
177
+
178
+ @cmd = Bosh::Cli::Command::Release.new
179
+ @cmd.add_option(:non_interactive, true)
180
+
169
181
  @cmd.stub!(:target).and_return("test")
170
182
  @cmd.stub!(:username).and_return("user")
171
183
  @cmd.stub!(:password).and_return("pass")
184
+ @cmd.stub!(:director).and_return(@director)
172
185
  end
173
186
 
174
187
  it "allows deleting the release (non-force)" do
175
- mock_director = mock(Bosh::Cli::Director)
176
- mock_director.should_receive(:delete_release).
188
+ @director.should_receive(:delete_release).
177
189
  with("foo", :force => false, :version => nil)
178
190
 
179
- @cmd.stub!(:interactive?).and_return(false)
180
- @cmd.stub!(:director).and_return(mock_director)
181
191
  @cmd.delete("foo")
182
192
  end
183
193
 
184
- it "allows deleting the release (non-force)" do
185
- mock_director = mock(Bosh::Cli::Director)
186
- mock_director.should_receive(:delete_release).
194
+ it "allows deleting the release (force)" do
195
+ @director.should_receive(:delete_release).
187
196
  with("foo", :force => true, :version => nil)
188
197
 
189
- @cmd.stub!(:ask).and_return("yes")
190
- @cmd.stub!(:director).and_return(mock_director)
191
- @cmd.delete("foo", "--force")
198
+ @cmd.add_option(:force, true)
199
+ @cmd.delete("foo")
192
200
  end
193
201
 
194
202
  it "allows deleting a particular release version (non-force)" do
195
- mock_director = mock(Bosh::Cli::Director)
196
- mock_director.should_receive(:delete_release).
203
+ @director.should_receive(:delete_release).
197
204
  with("foo", :force => false, :version => "42")
198
205
 
199
- @cmd.stub!(:ask).and_return("yes")
200
- @cmd.stub!(:director).and_return(mock_director)
201
206
  @cmd.delete("foo", "42")
202
207
  end
203
208
 
204
- it "allows deleting a particular release version (non-force)" do
205
- mock_director = mock(Bosh::Cli::Director)
206
- mock_director.should_receive(:delete_release).
209
+ it "allows deleting a particular release version (force)" do
210
+ @director.should_receive(:delete_release).
207
211
  with("foo", :force => true, :version => "42")
208
212
 
209
- @cmd.stub!(:ask).and_return("yes")
210
- @cmd.stub!(:director).and_return(mock_director)
211
- @cmd.delete("foo", "42", "--force")
213
+ @cmd.add_option(:force, true)
214
+ @cmd.delete("foo", "42")
212
215
  end
213
216
 
214
217
  it "requires confirmation on deleting release" do
215
- mock_director = mock(Bosh::Cli::Director)
216
- mock_director.should_not_receive(:delete_release)
217
- @cmd.stub!(:director).and_return(mock_director)
218
+ @director.should_not_receive(:delete_release)
219
+ @cmd.remove_option(:non_interactive)
220
+
218
221
  @cmd.stub!(:ask).and_return("")
219
222
  @cmd.delete("foo")
220
223
  end
@@ -225,10 +228,11 @@ describe Bosh::Cli::Command::Base do
225
228
  before :each do
226
229
  @manifest_path = spec_asset("deployment.MF")
227
230
  @manifest_yaml = YAML.dump({ "name" => "foo" })
228
- @cmd = Bosh::Cli::Command::JobManagement.new(@opts)
231
+
232
+ @cmd = Bosh::Cli::Command::JobManagement.new
233
+ @cmd.add_option(:non_interactive, true)
229
234
  @cmd.stub!(:prepare_deployment_manifest).
230
- with(:yaml => true).and_return(@manifest_yaml)
231
- @cmd.stub!(:interactive?).and_return(false)
235
+ with(:yaml => true).and_return(@manifest_yaml)
232
236
  @cmd.stub!(:deployment).and_return(@manifest_path)
233
237
  @cmd.stub!(:target).and_return("test.com")
234
238
  @cmd.stub!(:target_name).and_return("dev2")
@@ -240,76 +244,80 @@ describe Bosh::Cli::Command::Base do
240
244
 
241
245
  it "allows starting jobs" do
242
246
  @director.should_receive(:change_job_state).
243
- with("foo", @manifest_yaml, "dea", nil, "started")
247
+ with("foo", @manifest_yaml, "dea", nil, "started")
244
248
  @cmd.start_job("dea")
245
249
  end
246
250
 
247
251
  it "allows starting job instances" do
248
252
  @director.should_receive(:change_job_state).
249
- with("foo", @manifest_yaml, "dea", 3, "started")
253
+ with("foo", @manifest_yaml, "dea", 3, "started")
250
254
  @cmd.start_job("dea", 3)
251
255
  end
252
256
 
253
257
  it "allows stopping jobs" do
254
258
  @director.should_receive(:change_job_state).
255
- with("foo", @manifest_yaml, "dea", nil, "stopped")
259
+ with("foo", @manifest_yaml, "dea", nil, "stopped")
256
260
  @cmd.stop_job("dea")
257
261
  end
258
262
 
259
263
  it "allows stopping job instances" do
260
264
  @director.should_receive(:change_job_state).
261
- with("foo", @manifest_yaml, "dea", 3, "stopped")
265
+ with("foo", @manifest_yaml, "dea", 3, "stopped")
262
266
  @cmd.stop_job("dea", 3)
263
267
  end
264
268
 
265
269
  it "allows restarting jobs" do
266
270
  @director.should_receive(:change_job_state).
267
- with("foo", @manifest_yaml, "dea", nil, "restart")
271
+ with("foo", @manifest_yaml, "dea", nil, "restart")
268
272
  @cmd.restart_job("dea")
269
273
  end
270
274
 
271
275
  it "allows restart job instances" do
272
276
  @director.should_receive(:change_job_state).
273
- with("foo", @manifest_yaml, "dea", 3, "restart")
277
+ with("foo", @manifest_yaml, "dea", 3, "restart")
274
278
  @cmd.restart_job("dea", 3)
275
279
  end
276
280
 
277
281
  it "allows recreating jobs" do
278
282
  @director.should_receive(:change_job_state).
279
- with("foo", @manifest_yaml, "dea", nil, "recreate")
283
+ with("foo", @manifest_yaml, "dea", nil, "recreate")
280
284
  @cmd.recreate_job("dea")
281
285
  end
282
286
 
283
287
  it "allows recreating job instances" do
284
288
  @director.should_receive(:change_job_state).
285
- with("foo", @manifest_yaml, "dea", 3, "recreate")
289
+ with("foo", @manifest_yaml, "dea", 3, "recreate")
286
290
  @cmd.recreate_job("dea", 3)
287
291
  end
288
292
 
289
293
  it "allows hard stop" do
290
294
  @director.should_receive(:change_job_state).
291
- with("foo", @manifest_yaml, "dea", 3, "detached")
292
- @cmd.stop_job("dea", 3, "--hard")
295
+ with("foo", @manifest_yaml, "dea", 3, "detached")
296
+ @cmd.add_option(:hard, true)
297
+ @cmd.stop_job("dea", 3)
293
298
  end
294
299
 
295
300
  it "allows soft stop (= regular stop)" do
296
301
  @director.should_receive(:change_job_state).
297
- with("foo", @manifest_yaml, "dea", 3, "stopped")
298
- @cmd.stop_job("dea", 3, "--soft")
302
+ with("foo", @manifest_yaml, "dea", 3, "stopped")
303
+ @cmd.add_option(:soft, true)
304
+ @cmd.stop_job("dea", 3)
299
305
  end
300
306
 
301
307
  end
302
308
 
303
309
  describe Bosh::Cli::Command::BlobManagement do
304
310
  before :each do
305
- @cmd = Bosh::Cli::Command::BlobManagement.new(@opts)
311
+ @cmd = Bosh::Cli::Command::BlobManagement.new
312
+ @cmd.add_option(:non_interactive, true)
313
+
306
314
  @blob_manager = mock("blob manager")
307
315
  @release = mock("release")
308
316
 
309
317
  @cmd.should_receive(:check_if_release_dir)
310
318
  Bosh::Cli::Release.stub!(:new).and_return(@release)
311
319
  Bosh::Cli::BlobManager.stub!(:new).with(@release).
312
- and_return(@blob_manager)
320
+ and_return(@blob_manager)
313
321
  end
314
322
 
315
323
  it "prints blobs status" do