Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[openstack_cpi] Use new fog method to retrieve security groups

  • Loading branch information...
commit e142a529c638c0595cfdda3211e063fddba4f3dd 1 parent f00d32c
@frodenas frodenas authored
View
4 bosh_openstack_cpi/lib/cloud/openstack/cloud.rb
@@ -341,8 +341,8 @@ def configure_networks(server_id, network_spec)
server = with_openstack { @openstack.servers.get(server_id) }
cloud_error("Server `#{server_id}' not found") unless server
- sg = with_openstack { @openstack.list_security_groups(server_id).body["security_groups"] }
- actual = sg.collect { |s| s["name"] }.sort
+ sg = with_openstack { server.security_groups }
+ actual = sg.collect { |s| s.name }.sort
new = network_configurator.security_groups(@default_security_groups)
# If the security groups change, we need to recreate the VM
View
21 bosh_openstack_cpi/spec/unit/configure_networks_spec.rb
@@ -11,13 +11,12 @@
it "forces recreation when security groups differ" do
server = double("server", :id => "i-test", :name => "i-test")
- sec_grp = double("security_group",
- :body => {"security_groups" => [{"name"=> "newgroup" }]})
+ security_group = double("security_groups", :name => "newgroups")
+
+ server.should_receive(:security_groups).and_return([security_group])
cloud = mock_cloud do |openstack|
openstack.servers.should_receive(:get).with("i-test").and_return(server)
- openstack.should_receive(:list_security_groups).
- with("i-test").and_return(sec_grp)
end
expect {
@@ -29,14 +28,13 @@
server = double("server", :id => "i-test", :name => "i-test")
address = double("address", :id => "a-test", :ip => "10.0.0.1",
:instance_id => nil)
- sec_grp = double("security_group",
- :body => {"security_groups" => [{"name"=> "default" }]})
+ security_group = double("security_groups", :name => "default")
+
+ server.should_receive(:security_groups).and_return([security_group])
cloud = mock_cloud do |openstack|
openstack.servers.should_receive(:get).with("i-test").and_return(server)
openstack.addresses.should_receive(:find).and_return(address)
- openstack.should_receive(:list_security_groups).
- with("i-test").and_return(sec_grp)
end
address.should_receive(:server=).with(server)
@@ -55,14 +53,13 @@
server = double("server", :id => "i-test", :name => "i-test")
address = double("address", :id => "a-test", :ip => "10.0.0.1",
:instance_id => "i-test")
- sec_grp = double("security_group",
- :body => {"security_groups" => [{"name"=> "default" }]})
+ security_group = double("security_groups", :name => "default")
+
+ server.should_receive(:security_groups).and_return([security_group])
cloud = mock_cloud do |openstack|
openstack.servers.should_receive(:get).with("i-test").and_return(server)
openstack.addresses.should_receive(:each).and_yield(address)
- openstack.should_receive(:list_security_groups).
- with("i-test").and_return(sec_grp)
end
address.should_receive(:server=).with(nil)
Please sign in to comment.
Something went wrong with that request. Please try again.