Browse Source

Set sane defaults for linuxbridge_conf.ini

These defaults are based on upstream documentation [1] and should work in most
environments. In addition, add RHEL chefspec tests and also test the config file
contents.

Without a default config of any kind, the plugin_config recipe fails due to an
empty attribute.

[1] http://docs.openstack.org/mitaka/install-guide-rdo/neutron.html

Change-Id: I037e51f40db5f73c8b9a3f6289287e82fb73f8a6
Signed-off-by: Lance Albertson <lance@osuosl.org>
changes/88/321888/4
Lance Albertson 3 years ago
parent
commit
8e42ee27c0
3 changed files with 79 additions and 0 deletions
  1. 2
    0
      recipes/ml2_linuxbridge.rb
  2. 63
    0
      spec/ml2_linuxbridge-redhat_spec.rb
  3. 14
    0
      spec/ml2_linuxbridge_spec.rb

+ 2
- 0
recipes/ml2_linuxbridge.rb View File

@@ -40,6 +40,8 @@ node.default['openstack']['network']['plugins']['linuxbridge'].tap do |lb|
40 40
     '/etc/neutron/plugins/linuxbridge'
41 41
   lb['filename'] =
42 42
     'linuxbridge_conf.ini'
43
+  lb['conf']['securitygroup']['firewall_driver'] =
44
+    'neutron.agent.linux.iptables_firewall.IptablesFirewallDriver'
43 45
 end
44 46
 
45 47
 include_recipe 'openstack-network::plugin_config'

+ 63
- 0
spec/ml2_linuxbridge-redhat_spec.rb View File

@@ -0,0 +1,63 @@
1
+# pkg upgrade
2
+
3
+# service
4
+
5
+# Encoding: utf-8
6
+require_relative 'spec_helper'
7
+
8
+describe 'openstack-network::ml2_linuxbridge' do
9
+  describe 'redhat' do
10
+    let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
11
+    let(:node) { runner.node }
12
+    let(:chef_run) do
13
+      runner.converge(described_recipe)
14
+    end
15
+
16
+    include_context 'neutron-stubs'
17
+
18
+    before do
19
+      node.set['openstack']['network']['plugins']['linuxbridge']['path'] =
20
+        '/etc/neutron/plugins/linuxbridge'
21
+      node.set['openstack']['network']['plugins']['linuxbridge']['filename'] =
22
+        'linuxbridge_conf.ini'
23
+    end
24
+    it 'creates the /etc/neutron/plugins/linuxbridge agent directory' do
25
+      expect(chef_run).to create_directory('/etc/neutron/plugins/linuxbridge').with(
26
+        owner: 'neutron',
27
+        group: 'neutron',
28
+        mode: 0700
29
+      )
30
+    end
31
+    it do
32
+      expect(chef_run).to include_recipe('openstack-network::plugin_config')
33
+    end
34
+
35
+    describe '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini' do
36
+      let(:file) do
37
+        chef_run.template('/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini')
38
+      end
39
+      [
40
+        /^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/
41
+      ].each do |line|
42
+        it do
43
+          expect(chef_run).to render_config_file(file.name)
44
+            .with_section_content('securitygroup', line)
45
+        end
46
+      end
47
+    end
48
+
49
+    it do
50
+      %w(openstack-neutron-linuxbridge iproute).each do |pkg|
51
+        expect(chef_run).to upgrade_package(pkg)
52
+      end
53
+    end
54
+
55
+    it do
56
+      expect(chef_run).to enable_service('neutron-linuxbridge-agent')
57
+    end
58
+    it do
59
+      service = chef_run.service('neutron-linuxbridge-agent')
60
+      expect(service).to(subscribe_to('template[/etc/neutron/neutron.conf]').on(:restart).delayed) && subscribe_to('template[/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini]').on(:restart).delayed
61
+    end
62
+  end
63
+end

+ 14
- 0
spec/ml2_linuxbridge_spec.rb View File

@@ -33,6 +33,20 @@ describe 'openstack-network::ml2_linuxbridge' do
33 33
       expect(chef_run).to include_recipe('openstack-network::plugin_config')
34 34
     end
35 35
 
36
+    describe '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini' do
37
+      let(:file) do
38
+        chef_run.template('/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini')
39
+      end
40
+      [
41
+        /^firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver$/
42
+      ].each do |line|
43
+        it do
44
+          expect(chef_run).to render_config_file(file.name)
45
+            .with_section_content('securitygroup', line)
46
+        end
47
+      end
48
+    end
49
+
36 50
     it do
37 51
       %w(neutron-plugin-linuxbridge neutron-plugin-linuxbridge-agent).each do |pkg|
38 52
         expect(chef_run).to upgrade_package(pkg)

Loading…
Cancel
Save