From 34da9ece10a65f55e92cee2de4a3e57e14e7b556 Mon Sep 17 00:00:00 2001 From: John Dewey Date: Fri, 28 Jun 2013 17:47:54 -0700 Subject: [PATCH] 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`. Also, updated berkshelf to 2.x which handles dep resolution correctly. I run into problems getting berkshelf to lock to the new 0.3.0 openstack-common w/o updating berkshelf. Change-Id: Iaf39cee98589d8d1c4b90e610b94e5440ac51fd8 --- .gitignore | 1 - Berksfile.lock | 70 ++++++++++++++++++++++++++++++ Gemfile | 4 +- Gemfile.lock | 82 +++++++++++++++++++++-------------- README.md | 3 +- recipes/nova-common.rb | 6 +-- spec/libvirt-opensuse_spec.rb | 3 +- spec/nova-common_spec.rb | 20 +++++++++ spec/spec_helper.rb | 3 ++ 9 files changed, 149 insertions(+), 43 deletions(-) create mode 100644 Berksfile.lock diff --git a/.gitignore b/.gitignore index c6ba7b77..dcce5108 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ .bundle/ -Berksfile.lock diff --git a/Berksfile.lock b/Berksfile.lock new file mode 100644 index 00000000..be7a994d --- /dev/null +++ b/Berksfile.lock @@ -0,0 +1,70 @@ +{ + "sha": "c7d9e0b09c983a031e207c9a6205fb2c8f3313d8", + "sources": { + "openstack-compute": { + "path": "." + }, + "openstack-image": { + "locked_version": "7.0.0", + "git": "git://github.com/stackforge/cookbook-openstack-image.git", + "ref": "413c654a1f38ed016ba7ffa503f59ae6db7d6bb0" + }, + "openstack-identity": { + "locked_version": "7.0.0", + "git": "git://github.com/stackforge/cookbook-openstack-identity.git", + "ref": "ce3677c8dcb0e86ca2f07dcf8baff87de85cd004" + }, + "openstack-common": { + "locked_version": "0.3.0", + "git": "git://github.com/stackforge/cookbook-openstack-common.git", + "ref": "ae80d36e8f8d5705e01bb6c14238eccb5450a229" + }, + "sysctl": { + "locked_version": "0.2.0", + "git": "git://github.com/Fewbytes/sysctl-cookbook.git", + "ref": "65a96b45d489c904515d916aae6bc474da35f1ca" + }, + "apache2": { + "locked_version": "1.6.6" + }, + "database": { + "locked_version": "1.4.0" + }, + "mysql": { + "locked_version": "3.0.0" + }, + "openssl": { + "locked_version": "1.0.2" + }, + "build-essential": { + "locked_version": "1.4.0" + }, + "postgresql": { + "locked_version": "3.0.0" + }, + "apt": { + "locked_version": "1.10.0" + }, + "aws": { + "locked_version": "0.101.0" + }, + "xfs": { + "locked_version": "1.1.0" + }, + "rabbitmq": { + "locked_version": "2.1.0" + }, + "erlang": { + "locked_version": "1.3.0" + }, + "yum": { + "locked_version": "2.2.2" + }, + "selinux": { + "locked_version": "0.5.6" + }, + "python": { + "locked_version": "1.3.4" + } + } +} diff --git a/Gemfile b/Gemfile index 7de4657f..04ef97e4 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,8 @@ source "https://rubygems.org" gem "chef", "~> 11.4.4" gem "json", "<= 1.7.7" # chef 11 dependency -gem "berkshelf", "~> 1.4.5" -gem "chefspec", "~> 1.2.0" +gem "berkshelf", "~> 2.0.3" +gem "chefspec", "~> 1.3.0" gem "foodcritic" gem "strainer" gem "tailor" diff --git a/Gemfile.lock b/Gemfile.lock index 08e2917e..2d00f7d7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,33 +1,41 @@ GEM remote: https://rubygems.org/ specs: - activesupport (3.2.13) - i18n (= 0.6.1) - multi_json (~> 1.0) - addressable (2.3.4) + activesupport (4.0.0) + i18n (~> 0.6, >= 0.6.4) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + addressable (2.3.5) akami (1.2.0) gyoku (>= 0.4.0) nokogiri (>= 1.4.0) - berkshelf (1.4.5) + atomic (1.1.10) + berkshelf (2.0.5) activesupport (>= 3.2.0) - addressable + addressable (~> 2.3.4) + buff-shell_out (~> 0.1) celluloid (>= 0.14.0) chozo (>= 0.6.1) faraday (>= 0.8.5) hashie (>= 2.0.2) - json (>= 1.5.0) - minitar - mixlib-config (~> 1.1) - mixlib-shellout (~> 1.1) - multi_json (~> 1.5) - retryable - ridley (~> 0.12.4) - solve (>= 0.4.2) + minitar (~> 0.5.4) + rbzip2 (~> 0.2.0) + retryable (~> 1.3.3) + ridley (~> 1.2.1) + solve (>= 0.5.0) thor (~> 0.18.0) - yajl-ruby + buff-extensions (0.5.0) + buff-ruby_engine (0.1.0) + buff-shell_out (0.1.0) + buff-ruby_engine (~> 0.1.0) builder (3.2.2) celluloid (0.14.1) timers (>= 1.0.0) + celluloid-io (0.14.1) + celluloid (>= 0.14.1) + nio4r (>= 0.4.5) chef (11.4.4) erubis highline (>= 1.6.9) @@ -42,7 +50,7 @@ GEM ohai (>= 0.6.0) rest-client (>= 1.0.4, < 1.7.0) yajl-ruby (~> 1.1) - chefspec (1.2.0) + chefspec (1.3.1) chef (>= 10.0) erubis fauxhai (>= 0.1.1, < 2.0) @@ -62,7 +70,7 @@ GEM httparty net-ssh ohai - ffi (1.8.1) + ffi (1.9.0) foodcritic (2.1.0) erubis gherkin (~> 2.11.7) @@ -84,7 +92,7 @@ GEM httpclient (2.2.0.2) httpi (0.9.7) rack - i18n (0.6.1) + i18n (0.6.4) ipaddress (0.8.0) json (1.7.7) little-plugger (1.1.3) @@ -93,7 +101,7 @@ GEM little-plugger (>= 1.1.3) mime-types (1.23) minitar (0.5.4) - minitest (4.7.4) + minitest (4.7.5) minitest-chef-handler (1.0.1) chef ci_reporter @@ -104,7 +112,7 @@ GEM mixlib-config (1.1.2) mixlib-log (1.6.0) mixlib-shellout (1.1.0) - multi_json (1.7.6) + multi_json (1.7.7) multi_xml (0.5.4) multipart-post (1.2.0) net-http-persistent (2.8) @@ -114,7 +122,8 @@ GEM net-ssh-multi (1.1) net-ssh (>= 2.1.4) net-ssh-gateway (>= 0.99.0) - nokogiri (1.5.9) + nio4r (0.4.6) + nokogiri (1.5.10) nori (1.1.5) ohai (6.16.0) ipaddress @@ -127,24 +136,26 @@ GEM polyglot (0.3.3) rack (1.5.2) rak (1.4) + rbzip2 (0.2.0) rest-client (1.6.7) mime-types (>= 1.16) retryable (1.3.3) - ridley (0.12.4) + ridley (1.2.3) addressable + buff-extensions (~> 0.3) + buff-shell_out (~> 0.1) celluloid (~> 0.14.0) - chozo (>= 0.6.0) + celluloid-io (~> 0.14.0) erubis faraday (>= 0.8.4) hashie (>= 2.0.2) + json (>= 1.7.7) mixlib-authentication (>= 1.3.0) - mixlib-config (>= 1.1.0) - mixlib-log (>= 1.3.0) - mixlib-shellout (>= 1.1.0) net-http-persistent (>= 2.8) net-ssh retryable solve (>= 0.4.4) + varia_model (~> 0.1) winrm (~> 1.1.0) rspec (2.13.0) rspec-core (~> 2.13.0) @@ -163,10 +174,9 @@ GEM nokogiri (>= 1.4.0) nori (~> 1.0) wasabi (~> 1.0) - solve (0.4.4) - json - strainer (2.1.0) - berkshelf (~> 1.3) + solve (0.6.0) + strainer (3.0.3) + berkshelf (~> 2.0) systemu (2.5.2) tailor (1.2.1) log_switch (>= 0.3.0) @@ -176,12 +186,18 @@ GEM tins (~> 0.8) text-table (1.2.3) thor (0.18.1) + thread_safe (0.1.0) + atomic timers (1.1.0) - tins (0.8.0) + tins (0.8.2) treetop (1.4.14) polyglot polyglot (>= 0.3.1) + tzinfo (0.3.37) uuidtools (2.1.4) + varia_model (0.1.0) + buff-extensions (~> 0.1) + hashie (>= 2.0.2) wasabi (1.0.0) nokogiri (>= 1.4.0) winrm (1.1.2) @@ -198,9 +214,9 @@ PLATFORMS ruby DEPENDENCIES - berkshelf (~> 1.4.5) + berkshelf (~> 2.0.3) chef (~> 11.4.4) - chefspec (~> 1.2.0) + chefspec (~> 1.3.0) foodcritic json (<= 1.7.7) strainer diff --git a/README.md b/README.md index 55660160..4aa0924a 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,7 @@ http://nova.openstack.org Requirements ============ -* Chef 0.10.0 or higher required (for Chef environment use). -* [Network Addr](https://gist.github.com/jtimberman/1040543) Ohai plugin. +Chef 0.10.0 or higher required (for Chef environment use). Cookbooks --------- diff --git a/recipes/nova-common.rb b/recipes/nova-common.rb index 9ace7784..0b9b04ab 100644 --- a/recipes/nova-common.rb +++ b/recipes/nova-common.rb @@ -103,9 +103,9 @@ Chef::Log.debug("openstack-compute::nova-common:compute_api_endpoint|#{::URI.dec Chef::Log.debug("openstack-compute::nova-common:ec2_public_endpoint|#{ec2_public_endpoint.to_s}") Chef::Log.debug("openstack-compute::nova-common:image_endpoint|#{image_endpoint.to_s}") -vnc_bind_ip = node["network"]["ipaddress_#{node["openstack"]["compute"]["libvirt"]["bind_interface"]}"] -xvpvnc_proxy_ip = node["network"]["ipaddress_#{node["openstack"]["compute"]["xvpvnc_proxy"]["bind_interface"]}"] -novnc_proxy_ip = node["network"]["ipaddress_#{node["openstack"]["compute"]["novnc_proxy"]["bind_interface"]}"] +vnc_bind_ip = address_for node["openstack"]["compute"]["libvirt"]["bind_interface"] +xvpvnc_proxy_ip = address_for node["openstack"]["compute"]["xvpvnc_proxy"]["bind_interface"] +novnc_proxy_ip = address_for node["openstack"]["compute"]["novnc_proxy"]["bind_interface"] template "/etc/nova/nova.conf" do source "nova.conf.erb" diff --git a/spec/libvirt-opensuse_spec.rb b/spec/libvirt-opensuse_spec.rb index f4b87b07..59c5ecb6 100644 --- a/spec/libvirt-opensuse_spec.rb +++ b/spec/libvirt-opensuse_spec.rb @@ -10,8 +10,7 @@ describe "openstack-compute::libvirt" do # This is stubbed b/c systems without '/boot/grub/menul.lst`, # fail to pass tests. This can be removed if a check verifies # the files existence prior to File#open. - file = double File, :lines => StringIO.new("") - ::File.stub(:open) { |&block| block.yield file } + ::File.stub(:open).and_call_original end describe "suse" do diff --git a/spec/nova-common_spec.rb b/spec/nova-common_spec.rb index bfab8cce..1656ce59 100644 --- a/spec/nova-common_spec.rb +++ b/spec/nova-common_spec.rb @@ -77,6 +77,26 @@ describe "openstack-compute::nova-common" do expect(sprintf("%o", @file.mode)).to eq "644" end + it "has vncserver_listen" do + expect(@chef_run).to create_file_with_content "/etc/nova/nova.conf", + "vncserver_listen=127.0.1.1" + end + + it "has vncserver_proxyclient_address" do + expect(@chef_run).to create_file_with_content "/etc/nova/nova.conf", + "vncserver_proxyclient_address=127.0.1.1" + end + + it "has xvpvncproxy_host" do + expect(@chef_run).to create_file_with_content "/etc/nova/nova.conf", + "xvpvncproxy_host=127.0.1.1" + end + + it "has novncproxy_host" do + expect(@chef_run).to create_file_with_content "/etc/nova/nova.conf", + "novncproxy_host=127.0.1.1" + end + it "has correct force_dhcp_release value" do expect(@chef_run).to create_file_with_content "/etc/nova/nova.conf", "force_dhcp_release=true" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7eb9affa..bb676c39 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,6 +18,9 @@ require "chefspec" } def compute_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' }