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.
- data/bin/bosh +3 -0
- data/lib/cli.rb +15 -5
- data/lib/cli/{commands/base.rb → base_command.rb} +38 -44
- data/lib/cli/command_discovery.rb +40 -0
- data/lib/cli/command_handler.rb +135 -0
- data/lib/cli/commands/biff.rb +16 -12
- data/lib/cli/commands/blob_management.rb +10 -3
- data/lib/cli/commands/cloudcheck.rb +13 -11
- data/lib/cli/commands/complete.rb +29 -0
- data/lib/cli/commands/deployment.rb +137 -28
- data/lib/cli/commands/help.rb +96 -0
- data/lib/cli/commands/job.rb +4 -1
- data/lib/cli/commands/job_management.rb +36 -23
- data/lib/cli/commands/job_rename.rb +11 -12
- data/lib/cli/commands/log_management.rb +28 -32
- data/lib/cli/commands/maintenance.rb +6 -1
- data/lib/cli/commands/misc.rb +129 -87
- data/lib/cli/commands/package.rb +6 -65
- data/lib/cli/commands/property_management.rb +20 -8
- data/lib/cli/commands/release.rb +211 -206
- data/lib/cli/commands/ssh.rb +178 -188
- data/lib/cli/commands/stemcell.rb +114 -51
- data/lib/cli/commands/task.rb +74 -56
- data/lib/cli/commands/user.rb +6 -3
- data/lib/cli/commands/vms.rb +17 -15
- data/lib/cli/config.rb +27 -1
- data/lib/cli/core_ext.rb +27 -1
- data/lib/cli/deployment_helper.rb +47 -0
- data/lib/cli/director.rb +18 -9
- data/lib/cli/errors.rb +6 -0
- data/lib/cli/job_builder.rb +75 -23
- data/lib/cli/job_property_collection.rb +87 -0
- data/lib/cli/job_property_validator.rb +130 -0
- data/lib/cli/package_builder.rb +32 -5
- data/lib/cli/release.rb +2 -0
- data/lib/cli/release_builder.rb +9 -13
- data/lib/cli/release_compiler.rb +5 -34
- data/lib/cli/release_tarball.rb +4 -19
- data/lib/cli/runner.rb +118 -694
- data/lib/cli/version.rb +1 -1
- data/spec/assets/config/swift-hp/config/final.yml +6 -0
- data/spec/assets/config/swift-hp/config/private.yml +7 -0
- data/spec/assets/config/swift-rackspace/config/final.yml +6 -0
- data/spec/assets/config/swift-rackspace/config/private.yml +6 -0
- data/spec/spec_helper.rb +0 -5
- data/spec/unit/base_command_spec.rb +32 -37
- data/spec/unit/biff_spec.rb +11 -10
- data/spec/unit/cli_commands_spec.rb +96 -88
- data/spec/unit/core_ext_spec.rb +1 -1
- data/spec/unit/deployment_manifest_spec.rb +36 -0
- data/spec/unit/director_spec.rb +17 -3
- data/spec/unit/job_builder_spec.rb +2 -2
- data/spec/unit/job_property_collection_spec.rb +111 -0
- data/spec/unit/job_property_validator_spec.rb +7 -0
- data/spec/unit/job_rename_spec.rb +7 -6
- data/spec/unit/package_builder_spec.rb +2 -2
- data/spec/unit/release_builder_spec.rb +33 -0
- data/spec/unit/release_spec.rb +54 -0
- data/spec/unit/release_tarball_spec.rb +2 -7
- data/spec/unit/runner_spec.rb +1 -151
- data/spec/unit/ssh_spec.rb +15 -9
- metadata +41 -12
- data/lib/cli/command_definition.rb +0 -52
- data/lib/cli/templates/help_message.erb +0 -80
data/lib/cli/version.rb
CHANGED
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
|
-
@
|
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(@
|
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
|
19
|
-
Bosh::Cli::Command::Base.new(
|
20
|
-
|
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 =
|
27
|
-
cmd.
|
28
|
-
|
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
|
32
|
-
cmd.password.should
|
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
|
36
|
-
cmd =
|
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 =
|
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
|
-
|
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 =
|
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 "
|
69
|
-
cmd
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|
data/spec/unit/biff_spec.rb
CHANGED
@@ -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(
|
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::
|
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::
|
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::
|
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::
|
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
|
-
|
80
|
-
|
81
|
-
|
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
|
-
|
9
|
-
@
|
10
|
-
@
|
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
|
17
|
-
@cmd.
|
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
|
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
|
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 "
|
33
|
-
@
|
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::
|
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
|
44
|
+
@cmd.target.should be_nil
|
45
|
+
end
|
46
46
|
|
47
|
-
|
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
|
-
@
|
85
|
-
|
86
|
-
|
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
|
-
|
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
|
-
@
|
108
|
-
|
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
|
-
|
111
|
-
|
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(
|
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
|
-
|
124
|
-
|
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
|
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
|
-
@
|
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
|
-
|
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 (
|
185
|
-
|
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.
|
190
|
-
@cmd.
|
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
|
-
|
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 (
|
205
|
-
|
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.
|
210
|
-
@cmd.
|
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
|
-
|
216
|
-
|
217
|
-
|
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
|
-
|
231
|
+
|
232
|
+
@cmd = Bosh::Cli::Command::JobManagement.new
|
233
|
+
@cmd.add_option(:non_interactive, true)
|
229
234
|
@cmd.stub!(:prepare_deployment_manifest).
|
230
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
292
|
-
@cmd.
|
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
|
-
|
298
|
-
@cmd.
|
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
|
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
|
-
|
320
|
+
and_return(@blob_manager)
|
313
321
|
end
|
314
322
|
|
315
323
|
it "prints blobs status" do
|