diff --git a/attributes/default.rb b/attributes/default.rb index 5ad7804..8eb6ae7 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -215,6 +215,7 @@ default['openstack']['dashboard']['simple_ip_management'] = false default['openstack']['dashboard']['neutron']['enable_quotas'] = true default['openstack']['dashboard']['neutron']['enable_lb'] = false default['openstack']['dashboard']['neutron']['enable_vpn'] = false +default['openstack']['dashboard']['neutron']['enable_fwaas'] = false # Allow for misc sections to be added to the local_settings template # For example: { # 'CUSTOM_CONFIG_A' => { diff --git a/recipes/neutron-fwaas-dashboard.rb b/recipes/neutron-fwaas-dashboard.rb new file mode 100644 index 0000000..1c57263 --- /dev/null +++ b/recipes/neutron-fwaas-dashboard.rb @@ -0,0 +1,59 @@ +# encoding: UTF-8 +# +# Cookbook Name:: openstack-dashboard +# Recipe:: neutron-lbaas-dashboard +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe 'openstack-dashboard::horizon' + +django_path = node['openstack']['dashboard']['django_path'] +policy_file_path = node['openstack']['dashboard']['policy_files_path'] + +# use system python for fwaas dashboard +python_runtime '2' do + provider :system + version '2.7' +end + +python_package 'neutron-fwaas-dashboard' + +%w( + _7010_project_firewalls_common.py + _7011_project_firewalls_panel.py + _7012_project_firewalls_v2_panel.py +).each do |file| + remote_file "#{django_path}/openstack_dashboard/local/enabled/#{file}" do + source "https://raw.githubusercontent.com/openstack/neutron-fwaas-dashboard/stable/queens/neutron_fwaas_dashboard/enabled/#{file}" + owner 'root' + mode 0o0644 + notifies :run, 'execute[neutron-fwaas-dashboard compilemessages]' + notifies :run, 'execute[openstack-dashboard collectstatic]' + end +end + +remote_file "#{policy_file_path}/neutron-fwaas-policy.json" do + source 'https://raw.githubusercontent.com/openstack/neutron-fwaas-dashboard/stable/queens/etc/neutron-fwaas-policy.json' + owner 'root' + mode 0o0644 + notifies :run, 'execute[neutron-fwaas-dashboard compilemessages]' + notifies :run, 'execute[openstack-dashboard collectstatic]' + notifies :restart, 'service[apache2]', :delayed +end + +execute 'neutron-fwaas-dashboard compilemessages' do + cwd django_path + environment 'PYTHONPATH' => "/etc/openstack-dashboard:#{django_path}:$PYTHONPATH" + command 'python manage.py compilemessages' + action :nothing +end diff --git a/spec/neutron-fwaas-dashboard_spec.rb b/spec/neutron-fwaas-dashboard_spec.rb new file mode 100644 index 0000000..c01ed7b --- /dev/null +++ b/spec/neutron-fwaas-dashboard_spec.rb @@ -0,0 +1,66 @@ +# encoding: UTF-8 +require_relative 'spec_helper' + +describe 'openstack-dashboard::neutron-fwaas-dashboard' do + describe 'ubuntu' do + let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } + let(:node) { runner.node } + let(:chef_run) do + runner.converge(described_recipe) + end + + include_context 'non_redhat_stubs' + include_context 'dashboard_stubs' + + it do + expect(chef_run).to include_recipe('openstack-dashboard::horizon') + end + + it do + expect(chef_run).to install_python_runtime('2') + end + + it do + expect(chef_run).to install_python_package('neutron-fwaas-dashboard') + end + + %w( + _7010_project_firewalls_common.py + _7011_project_firewalls_panel.py + _7012_project_firewalls_v2_panel.py + ).each do |file| + it do + expect(chef_run).to create_remote_file( + "#{node['openstack']['dashboard']['django_path']}/openstack_dashboard/local/enabled/#{file}" + ).with( + mode: 0o0644, + owner: 'root', + source: "https://raw.githubusercontent.com/openstack/neutron-fwaas-dashboard/stable/queens/neutron_fwaas_dashboard/enabled/#{file}" + ) + end + + it do + expect(chef_run.remote_file("#{node['openstack']['dashboard']['django_path']}/openstack_dashboard/local/enabled/#{file}")) + .to notify('execute[openstack-dashboard collectstatic]').to(:run) + notify('execute[neutron-fwaas-dashboard compilemessages]').to(:run) + end + end + + it do + expect(chef_run).to create_remote_file( + "#{node['openstack']['dashboard']['policy_files_path']}/neutron-fwaas-policy.json" + ).with( + mode: 0o0644, + owner: 'root', + source: 'https://raw.githubusercontent.com/openstack/neutron-fwaas-dashboard/stable/queens/etc/neutron-fwaas-policy.json' + ) + end + + it do + expect(chef_run.remote_file("#{node['openstack']['dashboard']['policy_files_path']}/neutron-fwaas-policy.json")) + .to notify('execute[openstack-dashboard collectstatic]').to(:run) + notify('execute[neutron-fwaas-dashboard compilemessages]').to(:run) + notify('service[apache2]').to(:restart).delayed + end + end +end diff --git a/templates/default/local_settings.py.erb b/templates/default/local_settings.py.erb index 8d4f6b7..77a65d9 100644 --- a/templates/default/local_settings.py.erb +++ b/templates/default/local_settings.py.erb @@ -228,6 +228,7 @@ OPENSTACK_NEUTRON_NETWORK = { 'enable_lb': <%= node['openstack']['dashboard']['neutron']['enable_lb'].to_s.capitalize %>, 'enable_vpn': <%= node['openstack']['dashboard']['neutron']['enable_vpn'].to_s.capitalize %>, 'enable_quotas': <%= node['openstack']['dashboard']['neutron']['enable_quotas'] ? 'True' : 'False' %>, + 'enable_firewall': <%= node['openstack']['dashboard']['neutron']['enable_fwaas'].to_s.capitalize %>, # The profile_support option is used to detect if an external router can be # configured via the dashboard. When using specific plugins the # profile_support can be turned on if needed.