bosh_openstack_cpi 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/cloud/openstack/cloud.rb +311 -197
- data/lib/cloud/openstack/dynamic_network.rb +4 -2
- data/lib/cloud/openstack/helpers.rb +43 -13
- data/lib/cloud/openstack/network.rb +1 -1
- data/lib/cloud/openstack/network_configurator.rb +23 -15
- data/lib/cloud/openstack/registry_client.rb +29 -11
- data/lib/cloud/openstack/version.rb +1 -1
- data/lib/cloud/openstack/vip_network.rb +19 -20
- data/spec/assets/sample_config.yml +14 -0
- data/spec/integration/cpi_test.rb +119 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/unit/attach_disk_spec.rb +37 -21
- data/spec/unit/configure_networks_spec.rb +49 -26
- data/spec/unit/create_disk_spec.rb +17 -17
- data/spec/unit/create_stemcell_spec.rb +78 -20
- data/spec/unit/create_vm_spec.rb +80 -16
- data/spec/unit/delete_disk_spec.rb +5 -3
- data/spec/unit/delete_stemcell_spec.rb +18 -11
- data/spec/unit/delete_vm_spec.rb +1 -2
- data/spec/unit/detach_disk_spec.rb +23 -12
- data/spec/unit/helpers_spec.rb +46 -6
- data/spec/unit/network_configurator_spec.rb +8 -8
- data/spec/unit/reboot_vm_spec.rb +2 -4
- data/spec/unit/validate_deployment_spec.rb +2 -1
- metadata +9 -5
data/spec/unit/create_vm_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Bosh::OpenStackCloud::Cloud, "create_vm" do
|
|
26
26
|
|
27
27
|
def openstack_params(unique_name, user_data, security_groups=[])
|
28
28
|
{
|
29
|
-
:name=>"vm-#{unique_name}",
|
29
|
+
:name => "vm-#{unique_name}",
|
30
30
|
:image_ref => "sc-id",
|
31
31
|
:flavor_ref => "f-test",
|
32
32
|
:key_name => "test_key",
|
@@ -53,10 +53,13 @@ describe Bosh::OpenStackCloud::Cloud, "create_vm" do
|
|
53
53
|
server = double("server", :id => "i-test", :name => "i-test")
|
54
54
|
image = double("image", :id => "sc-id", :name => "sc-id")
|
55
55
|
flavor = double("flavor", :id => "f-test", :name => "m1.tiny")
|
56
|
-
address = double("address", :id => "a-test", :ip => "10.0.0.1",
|
56
|
+
address = double("address", :id => "a-test", :ip => "10.0.0.1",
|
57
|
+
:instance_id => "i-test")
|
57
58
|
|
58
59
|
cloud = mock_cloud do |openstack|
|
59
|
-
openstack.servers.should_receive(:create).
|
60
|
+
openstack.servers.should_receive(:create).
|
61
|
+
with(openstack_params(unique_name, user_data, %w[default])).
|
62
|
+
and_return(server)
|
60
63
|
openstack.images.should_receive(:find).and_return(image)
|
61
64
|
openstack.flavors.should_receive(:find).and_return(flavor)
|
62
65
|
openstack.addresses.should_receive(:each).and_yield(address)
|
@@ -64,10 +67,10 @@ describe Bosh::OpenStackCloud::Cloud, "create_vm" do
|
|
64
67
|
|
65
68
|
cloud.should_receive(:generate_unique_name).and_return(unique_name)
|
66
69
|
address.should_receive(:server=).with(nil)
|
67
|
-
|
68
|
-
cloud.should_receive(:wait_resource).with(server, :build, :active, :state)
|
70
|
+
cloud.should_receive(:wait_resource).with(server, :active, :state)
|
69
71
|
|
70
|
-
@registry.should_receive(:update_settings).
|
72
|
+
@registry.should_receive(:update_settings).
|
73
|
+
with("i-test", agent_settings(unique_name))
|
71
74
|
|
72
75
|
vm_id = cloud.create_vm("agent-id", "sc-id",
|
73
76
|
resource_pool_spec,
|
@@ -86,26 +89,29 @@ describe Bosh::OpenStackCloud::Cloud, "create_vm" do
|
|
86
89
|
"name" => "vm-#{unique_name}"
|
87
90
|
}
|
88
91
|
}
|
89
|
-
security_groups = %w[foo
|
92
|
+
security_groups = %w[bar foo]
|
90
93
|
network_spec = dynamic_network_spec
|
91
94
|
network_spec["cloud_properties"] = { "security_groups" => security_groups }
|
92
95
|
server = double("server", :id => "i-test", :name => "i-test")
|
93
96
|
image = double("image", :id => "sc-id", :name => "sc-id")
|
94
97
|
flavor = double("flavor", :id => "f-test", :name => "m1.tiny")
|
95
|
-
address = double("address", :id => "a-test", :ip => "10.0.0.1",
|
98
|
+
address = double("address", :id => "a-test", :ip => "10.0.0.1",
|
99
|
+
:instance_id => nil)
|
96
100
|
|
97
101
|
cloud = mock_cloud do |openstack|
|
98
|
-
openstack.servers.should_receive(:create).
|
102
|
+
openstack.servers.should_receive(:create).
|
103
|
+
with(openstack_params(unique_name, user_data, security_groups)).
|
104
|
+
and_return(server)
|
99
105
|
openstack.images.should_receive(:find).and_return(image)
|
100
106
|
openstack.flavors.should_receive(:find).and_return(flavor)
|
101
107
|
openstack.addresses.should_receive(:each).and_yield(address)
|
102
108
|
end
|
103
109
|
|
104
110
|
cloud.should_receive(:generate_unique_name).and_return(unique_name)
|
105
|
-
|
106
|
-
cloud.should_receive(:wait_resource).with(server, :build, :active, :state)
|
111
|
+
cloud.should_receive(:wait_resource).with(server, :active, :state)
|
107
112
|
|
108
|
-
@registry.should_receive(:update_settings).
|
113
|
+
@registry.should_receive(:update_settings).
|
114
|
+
with("i-test", agent_settings(unique_name, network_spec))
|
109
115
|
|
110
116
|
vm_id = cloud.create_vm("agent-id", "sc-id",
|
111
117
|
resource_pool_spec,
|
@@ -118,19 +124,19 @@ describe Bosh::OpenStackCloud::Cloud, "create_vm" do
|
|
118
124
|
server = double("server", :id => "i-test", :name => "i-test")
|
119
125
|
image = double("image", :id => "sc-id", :name => "sc-id")
|
120
126
|
flavor = double("flavor", :id => "f-test", :name => "m1.tiny")
|
121
|
-
address = double("address", :id => "a-test", :ip => "10.0.0.1",
|
127
|
+
address = double("address", :id => "a-test", :ip => "10.0.0.1",
|
128
|
+
:instance_id => "i-test")
|
122
129
|
|
123
130
|
cloud = mock_cloud do |openstack|
|
124
131
|
openstack.servers.should_receive(:create).and_return(server)
|
125
132
|
openstack.images.should_receive(:find).and_return(image)
|
126
133
|
openstack.flavors.should_receive(:find).and_return(flavor)
|
127
|
-
openstack.addresses.should_receive(:
|
134
|
+
openstack.addresses.should_receive(:find).and_return(address)
|
128
135
|
end
|
129
136
|
|
130
137
|
address.should_receive(:server=).with(nil)
|
131
138
|
address.should_receive(:server=).with(server)
|
132
|
-
|
133
|
-
cloud.should_receive(:wait_resource).with(server, :build, :active, :state)
|
139
|
+
cloud.should_receive(:wait_resource).with(server, :active, :state)
|
134
140
|
|
135
141
|
@registry.should_receive(:update_settings)
|
136
142
|
|
@@ -139,4 +145,62 @@ describe Bosh::OpenStackCloud::Cloud, "create_vm" do
|
|
139
145
|
combined_network_spec)
|
140
146
|
end
|
141
147
|
|
148
|
+
def volume(zone)
|
149
|
+
vol = double("volume")
|
150
|
+
vol.stub(:availability_zone).and_return(zone)
|
151
|
+
vol
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "#select_availability_zone" do
|
155
|
+
it "should return nil when all values are nil" do
|
156
|
+
cloud = mock_cloud
|
157
|
+
cloud.select_availability_zone(nil, nil).should == nil
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should select the resource pool availability_zone when disks are nil" do
|
161
|
+
cloud = mock_cloud
|
162
|
+
cloud.select_availability_zone(nil, "foobar-1a").should == "foobar-1a"
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should select the zone from a list of disks" do
|
166
|
+
cloud = mock_cloud do |openstack|
|
167
|
+
openstack.volumes.stub(:get).and_return(volume("foo"), volume("foo"))
|
168
|
+
end
|
169
|
+
cloud.select_availability_zone(%w[cid1 cid2], nil).should == "foo"
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should select the zone from a list of disks and a default" do
|
173
|
+
cloud = mock_cloud do |openstack|
|
174
|
+
openstack.volumes.stub(:get).and_return(volume("foo"), volume("foo"))
|
175
|
+
end
|
176
|
+
cloud.select_availability_zone(%w[cid1 cid2], "foo").should == "foo"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe "#ensure_same_availability_zone" do
|
181
|
+
it "should raise an error when the zones differ" do
|
182
|
+
cloud = mock_cloud
|
183
|
+
expect {
|
184
|
+
cloud.ensure_same_availability_zone([volume("foo"), volume("bar")],
|
185
|
+
nil)
|
186
|
+
}.to raise_error Bosh::Clouds::CloudError
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should raise an error when the zones differ" do
|
190
|
+
cloud = mock_cloud
|
191
|
+
expect {
|
192
|
+
cloud.ensure_same_availability_zone([volume("foo"), volume("bar")],
|
193
|
+
"foo")
|
194
|
+
}.to raise_error Bosh::Clouds::CloudError
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should raise an error when the zones differ" do
|
198
|
+
cloud = mock_cloud
|
199
|
+
expect {
|
200
|
+
cloud.ensure_same_availability_zone([volume("foo"), volume("foo")],
|
201
|
+
"bar")
|
202
|
+
}.to raise_error Bosh::Clouds::CloudError
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
142
206
|
end
|
@@ -8,12 +8,13 @@ describe Bosh::OpenStackCloud::Cloud do
|
|
8
8
|
volume = double("volume", :id => "v-foobar")
|
9
9
|
|
10
10
|
cloud = mock_cloud do |openstack|
|
11
|
-
openstack.volumes.should_receive(:get).
|
11
|
+
openstack.volumes.should_receive(:get).
|
12
|
+
with("v-foobar").and_return(volume)
|
12
13
|
end
|
13
14
|
|
14
15
|
volume.should_receive(:status).and_return(:available)
|
15
16
|
volume.should_receive(:destroy).and_return(true)
|
16
|
-
cloud.should_receive(:wait_resource).with(volume, :
|
17
|
+
cloud.should_receive(:wait_resource).with(volume, :deleted, :status, true)
|
17
18
|
|
18
19
|
cloud.delete_disk("v-foobar")
|
19
20
|
end
|
@@ -29,7 +30,8 @@ describe Bosh::OpenStackCloud::Cloud do
|
|
29
30
|
|
30
31
|
expect {
|
31
32
|
cloud.delete_disk("v-foobar")
|
32
|
-
}.to raise_error(Bosh::Clouds::CloudError,
|
33
|
+
}.to raise_error(Bosh::Clouds::CloudError,
|
34
|
+
"Cannot delete volume `v-foobar', state is busy")
|
33
35
|
end
|
34
36
|
|
35
37
|
end
|
@@ -4,7 +4,7 @@ require File.expand_path("../../spec_helper", __FILE__)
|
|
4
4
|
|
5
5
|
describe Bosh::OpenStackCloud::Cloud do
|
6
6
|
|
7
|
-
it "
|
7
|
+
it "deletes stemcell (only image)" do
|
8
8
|
image = double("image", :id => "i-foo", :name => "i-foo",
|
9
9
|
:properties => {})
|
10
10
|
|
@@ -17,11 +17,14 @@ describe Bosh::OpenStackCloud::Cloud do
|
|
17
17
|
cloud.delete_stemcell("i-foo")
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
20
|
+
it "deletes stemcell (image, kernel and ramdisk)" do
|
21
21
|
image = double("image", :id => "i-foo", :name => "i-foo",
|
22
|
-
:properties => {"kernel_id" => "k-id",
|
23
|
-
|
24
|
-
|
22
|
+
:properties => {"kernel_id" => "k-id",
|
23
|
+
"ramdisk_id" => "r-id"})
|
24
|
+
kernel = double("image", :id => "k-id",
|
25
|
+
:properties => {"stemcell" => "i-foo"})
|
26
|
+
ramdisk = double("image", :id => "r-id",
|
27
|
+
:properties => {"stemcell" => "i-foo"})
|
25
28
|
|
26
29
|
cloud = mock_glance do |glance|
|
27
30
|
glance.images.stub(:find_by_id).with("i-foo").and_return(image)
|
@@ -36,9 +39,10 @@ describe Bosh::OpenStackCloud::Cloud do
|
|
36
39
|
cloud.delete_stemcell("i-foo")
|
37
40
|
end
|
38
41
|
|
39
|
-
it "
|
42
|
+
it "deletes stemcell (kernel and ramdisk not uploaded by the CPI)" do
|
40
43
|
image = double("image", :id => "i-foo", :name => "i-foo",
|
41
|
-
:properties => {"kernel_id" => "k-id",
|
44
|
+
:properties => {"kernel_id" => "k-id",
|
45
|
+
"ramdisk_id" => "r-id"})
|
42
46
|
kernel = double("image", :id => "k-id", :properties => {})
|
43
47
|
ramdisk = double("image", :id => "r-id", :properties => {})
|
44
48
|
|
@@ -53,11 +57,14 @@ describe Bosh::OpenStackCloud::Cloud do
|
|
53
57
|
cloud.delete_stemcell("i-foo")
|
54
58
|
end
|
55
59
|
|
56
|
-
it "
|
60
|
+
it "deletes stemcell (kernel and ramdisk that do not belong to stemcell)" do
|
57
61
|
image = double("image", :id => "i-foo", :name => "i-foo",
|
58
|
-
:properties => {"kernel_id" => "k-id",
|
59
|
-
|
60
|
-
|
62
|
+
:properties => {"kernel_id" => "k-id",
|
63
|
+
"ramdisk_id" => "r-id"})
|
64
|
+
kernel = double("image", :id => "k-id",
|
65
|
+
:properties => {"stemcell" => "i-bar"})
|
66
|
+
ramdisk = double("image", :id => "r-id",
|
67
|
+
:properties => {"stemcell" => "i-bar"})
|
61
68
|
|
62
69
|
cloud = mock_glance do |glance|
|
63
70
|
glance.images.stub(:find_by_id).with("i-foo").and_return(image)
|
data/spec/unit/delete_vm_spec.rb
CHANGED
@@ -15,9 +15,8 @@ describe Bosh::OpenStackCloud::Cloud do
|
|
15
15
|
openstack.servers.should_receive(:get).with("i-foobar").and_return(server)
|
16
16
|
end
|
17
17
|
|
18
|
-
server.should_receive(:state).and_return(:active)
|
19
18
|
server.should_receive(:destroy).and_return(true)
|
20
|
-
cloud.should_receive(:wait_resource).with(server, :
|
19
|
+
cloud.should_receive(:wait_resource).with(server, :terminated, :state, true)
|
21
20
|
|
22
21
|
@registry.should_receive(:delete_settings).with("i-foobar")
|
23
22
|
|
@@ -11,17 +11,21 @@ describe Bosh::OpenStackCloud::Cloud do
|
|
11
11
|
it "detaches an OpenStack volume from a server" do
|
12
12
|
server = double("server", :id => "i-test", :name => "i-test")
|
13
13
|
volume = double("volume", :id => "v-foobar")
|
14
|
-
volume_attachments = double("body", :body => {"volumeAttachments" =>
|
14
|
+
volume_attachments = double("body", :body => {"volumeAttachments" =>
|
15
|
+
[{"volumeId" => "v-foobar"},
|
16
|
+
{"volumeId" => "v-barfoo"}]})
|
15
17
|
|
16
18
|
cloud = mock_cloud do |openstack|
|
17
|
-
openstack.servers.should_receive(:get).
|
18
|
-
|
19
|
-
openstack.should_receive(:
|
19
|
+
openstack.servers.should_receive(:get).
|
20
|
+
with("i-test").and_return(server)
|
21
|
+
openstack.volumes.should_receive(:get).
|
22
|
+
with("v-foobar").and_return(volume)
|
23
|
+
openstack.should_receive(:get_server_volumes).
|
24
|
+
and_return(volume_attachments)
|
20
25
|
end
|
21
26
|
|
22
|
-
volume.should_receive(:status).and_return(:"in-use")
|
23
27
|
volume.should_receive(:detach).with(server.id, "v-foobar").and_return(true)
|
24
|
-
cloud.should_receive(:wait_resource).with(volume, :
|
28
|
+
cloud.should_receive(:wait_resource).with(volume, :available)
|
25
29
|
|
26
30
|
old_settings = {
|
27
31
|
"foo" => "bar",
|
@@ -42,8 +46,10 @@ describe Bosh::OpenStackCloud::Cloud do
|
|
42
46
|
}
|
43
47
|
}
|
44
48
|
|
45
|
-
@registry.should_receive(:read_settings).
|
46
|
-
|
49
|
+
@registry.should_receive(:read_settings).
|
50
|
+
with("i-test").and_return(old_settings)
|
51
|
+
@registry.should_receive(:update_settings).
|
52
|
+
with("i-test", new_settings)
|
47
53
|
|
48
54
|
cloud.detach_disk("i-test", "v-foobar")
|
49
55
|
end
|
@@ -51,12 +57,17 @@ describe Bosh::OpenStackCloud::Cloud do
|
|
51
57
|
it "raises an error when volume is not attached to a server" do
|
52
58
|
server = double("server", :id => "i-test", :name => "i-test")
|
53
59
|
volume = double("volume", :id => "v-barfoo")
|
54
|
-
volume_attachments = double("body",
|
60
|
+
volume_attachments = double("body",
|
61
|
+
:body => {"volumeAttachments" =>
|
62
|
+
[{"volumeId" => "v-foobar"}]})
|
55
63
|
|
56
64
|
cloud = mock_cloud do |openstack|
|
57
|
-
openstack.servers.should_receive(:get).
|
58
|
-
|
59
|
-
openstack.should_receive(:
|
65
|
+
openstack.servers.should_receive(:get).
|
66
|
+
with("i-test").and_return(server)
|
67
|
+
openstack.volumes.should_receive(:get).
|
68
|
+
with("v-barfoo").and_return(volume)
|
69
|
+
openstack.should_receive(:get_server_volumes).
|
70
|
+
and_return(volume_attachments)
|
60
71
|
end
|
61
72
|
|
62
73
|
expect {
|
data/spec/unit/helpers_spec.rb
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
require File.expand_path("../../spec_helper", __FILE__)
|
4
4
|
|
5
5
|
describe Bosh::OpenStackCloud::Helpers do
|
6
|
+
before(:each) do
|
7
|
+
Bosh::Clouds::Config.stub(:task_checkpoint)
|
8
|
+
end
|
9
|
+
|
6
10
|
it "should time out" do
|
7
11
|
cloud = mock_cloud
|
8
12
|
|
@@ -12,9 +16,9 @@ describe Bosh::OpenStackCloud::Helpers do
|
|
12
16
|
resource.stub(:status).and_return(:start)
|
13
17
|
cloud.stub(:sleep)
|
14
18
|
|
15
|
-
|
16
|
-
cloud.wait_resource(resource, :
|
17
|
-
}.
|
19
|
+
expect {
|
20
|
+
cloud.wait_resource(resource, :stop, :status, false, 0.1)
|
21
|
+
}.to raise_error Bosh::Clouds::CloudError, /Timed out/
|
18
22
|
end
|
19
23
|
|
20
24
|
it "should not time out" do
|
@@ -26,9 +30,45 @@ describe Bosh::OpenStackCloud::Helpers do
|
|
26
30
|
resource.stub(:status).and_return(:start, :stop)
|
27
31
|
cloud.stub(:sleep)
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
cloud.wait_resource(resource, :stop, :status, false, 0.1)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should raise Bosh::Clouds::CloudError if state is error" do
|
37
|
+
cloud = mock_cloud
|
38
|
+
|
39
|
+
resource = double("resource")
|
40
|
+
resource.stub(:id).and_return("foobar")
|
41
|
+
resource.stub(:reload).and_return(cloud)
|
42
|
+
resource.stub(:status).and_return(:error)
|
43
|
+
cloud.stub(:sleep)
|
44
|
+
|
45
|
+
expect {
|
46
|
+
cloud.wait_resource(resource, :stop, :status, false, 0.1)
|
47
|
+
}.to raise_error Bosh::Clouds::CloudError, /state is error/
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should raise Bosh::Clouds::CloudError if resource not found" do
|
51
|
+
cloud = mock_cloud
|
52
|
+
|
53
|
+
resource = double("resource")
|
54
|
+
resource.stub(:id).and_return("foobar")
|
55
|
+
resource.stub(:reload).and_return(nil)
|
56
|
+
cloud.stub(:sleep)
|
57
|
+
|
58
|
+
expect {
|
59
|
+
cloud.wait_resource(resource, :deleted, :status, false, 0.1)
|
60
|
+
}.to raise_error Bosh::Clouds::CloudError, /Resource not found/
|
32
61
|
end
|
33
62
|
|
63
|
+
it "should not raise and exception if resource not found" do
|
64
|
+
cloud = mock_cloud
|
65
|
+
|
66
|
+
resource = double("resource")
|
67
|
+
resource.stub(:id).and_return("foobar")
|
68
|
+
resource.stub(:reload).and_return(nil)
|
69
|
+
resource.stub(:status).and_return(:deleted)
|
70
|
+
cloud.stub(:sleep)
|
71
|
+
|
72
|
+
cloud.wait_resource(resource, :deleted, :status, true, 0.1)
|
73
|
+
end
|
34
74
|
end
|
@@ -11,13 +11,13 @@ describe Bosh::OpenStackCloud::NetworkConfigurator do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should raise an error if the spec isn't a hash" do
|
14
|
-
|
14
|
+
expect {
|
15
15
|
Bosh::OpenStackCloud::NetworkConfigurator.new("foo")
|
16
|
-
}.
|
16
|
+
}.to raise_error ArgumentError
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "security groups" do
|
20
|
-
it "should
|
20
|
+
it "should be extracted from both dynamic and vip network" do
|
21
21
|
spec = {}
|
22
22
|
spec["network_a"] = dynamic_network_spec
|
23
23
|
set_security_groups(spec["network_a"], %w[foo])
|
@@ -25,12 +25,12 @@ describe Bosh::OpenStackCloud::NetworkConfigurator do
|
|
25
25
|
set_security_groups(spec["network_b"], %w[bar])
|
26
26
|
|
27
27
|
nc = Bosh::OpenStackCloud::NetworkConfigurator.new(spec)
|
28
|
-
nc.security_groups(nil).should == %w[foo]
|
28
|
+
nc.security_groups(nil).should == %w[bar foo]
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should return the default groups if none are extracted" do
|
32
32
|
spec = {}
|
33
|
-
spec["network_a"] =
|
33
|
+
spec["network_a"] = {"type" => "dynamic"}
|
34
34
|
|
35
35
|
nc = Bosh::OpenStackCloud::NetworkConfigurator.new(spec)
|
36
36
|
nc.security_groups(%w[foo]).should == %w[foo]
|
@@ -38,7 +38,7 @@ describe Bosh::OpenStackCloud::NetworkConfigurator do
|
|
38
38
|
|
39
39
|
it "should return an empty list if no default group is set" do
|
40
40
|
spec = {}
|
41
|
-
spec["network_a"] =
|
41
|
+
spec["network_a"] = {"type" => "dynamic"}
|
42
42
|
|
43
43
|
nc = Bosh::OpenStackCloud::NetworkConfigurator.new(spec)
|
44
44
|
nc.security_groups(nil).should == []
|
@@ -49,9 +49,9 @@ describe Bosh::OpenStackCloud::NetworkConfigurator do
|
|
49
49
|
spec["network_a"] = dynamic_network_spec
|
50
50
|
set_security_groups(spec["network_a"], "foo")
|
51
51
|
|
52
|
-
|
52
|
+
expect {
|
53
53
|
Bosh::OpenStackCloud::NetworkConfigurator.new(spec)
|
54
|
-
}.
|
54
|
+
}.to raise_error ArgumentError, "security groups must be an Array"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
data/spec/unit/reboot_vm_spec.rb
CHANGED
@@ -19,15 +19,13 @@ describe Bosh::OpenStackCloud::Cloud do
|
|
19
19
|
|
20
20
|
it "soft reboots an OpenStack server" do
|
21
21
|
@server.should_receive(:reboot)
|
22
|
-
@
|
23
|
-
@cloud.should_receive(:wait_resource).with(@server, :reboot, :active, :state)
|
22
|
+
@cloud.should_receive(:wait_resource).with(@server, :active, :state)
|
24
23
|
@cloud.send(:soft_reboot, @server)
|
25
24
|
end
|
26
25
|
|
27
26
|
it "hard reboots an OpenStack server" do
|
28
27
|
@server.should_receive(:reboot)
|
29
|
-
@
|
30
|
-
@cloud.should_receive(:wait_resource).with(@server, :reboot, :active, :state)
|
28
|
+
@cloud.should_receive(:wait_resource).with(@server, :active, :state)
|
31
29
|
@cloud.send(:hard_reboot, @server)
|
32
30
|
end
|
33
31
|
|