Removed the use of non-standard ohai plugin

We now have a helper method `#address_for` to return the
IP of a given interface.  Switched out the ohai use
in favor of `#address_for`.

Change-Id: I773b20d2e663c1d04c49bfbd79c750da78da2ed1
This commit is contained in:
John Dewey
2013-06-28 12:28:32 -07:00
parent 9dec548bec
commit 413c654a1f
5 changed files with 33 additions and 6 deletions

View File

@@ -126,7 +126,7 @@ end
if node["openstack"]["image"]["api"]["bind_interface"].nil?
bind_address = api_endpoint.host
else
bind_address = node["network"]["ipaddress_#{node["openstack"]["image"]["api"]["bind_interface"]}"]
bind_address = address_for node["openstack"]["image"]["api"]["bind_interface"]
end
template "/etc/glance/glance-api.conf" do

View File

@@ -90,7 +90,7 @@ end
if node["openstack"]["image"]["registry"]["bind_interface"].nil?
bind_address = registry_endpoint.host
else
bind_address = node["network"]["ipaddress_#{node["openstack"]["image"]["registry"]["bind_interface"]}"]
bind_address = address_for node["openstack"]["image"]["registry"]["bind_interface"]
end
template "/etc/glance/glance-registry.conf" do

View File

@@ -6,6 +6,7 @@ describe "openstack-image::api" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["image"]["syslog"]["use"] = true
n.set["cpu"] = { 'total' => '1' }
end
@chef_run.converge "openstack-image::api"
end
@@ -64,8 +65,20 @@ describe "openstack-image::api" do
expect(sprintf("%o", @file.mode)).to eq "644"
end
it "template contents" do
pending "TODO: implement"
it "has bind host when bind_interface not specified" do
expect(@chef_run).to create_file_with_content @file.name,
"bind_host = 127.0.0.1"
end
it "has bind host when bind_interface specified" do
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["image"]["api"]["bind_interface"] = "lo"
n.set["cpu"] = { 'total' => '1' }
end
chef_run.converge "openstack-image::api"
expect(chef_run).to create_file_with_content @file.name,
"bind_host = 127.0.1.1"
end
it "notifies image-api restart" do

View File

@@ -76,8 +76,19 @@ describe "openstack-image::registry" do
expect(sprintf("%o", @file.mode)).to eq "644"
end
it "template contents" do
pending "TODO: implement"
it "has bind host when bind_interface not specified" do
expect(@chef_run).to create_file_with_content @file.name,
"bind_host = 127.0.0.1"
end
it "has bind host when bind_interface specified" do
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["image"]["registry"]["bind_interface"] = "lo"
end
chef_run.converge "openstack-image::registry"
expect(chef_run).to create_file_with_content @file.name,
"bind_host = 127.0.1.1"
end
it "notifies image-registry restart" do

View File

@@ -13,6 +13,9 @@ require "chefspec"
}
def image_stubs
::Chef::Recipe.any_instance.stub(:address_for).
with("lo").
and_return "127.0.1.1"
::Chef::Recipe.any_instance.stub(:config_by_role).
with("rabbitmq-server", "queue").and_return(
{'host' => 'rabbit-host', 'port' => 'rabbit-port'}