diff --git a/README.md b/README.md index 342e52f..0db0ca7 100644 --- a/README.md +++ b/README.md @@ -52,16 +52,15 @@ Recipes ## openstack-dashboard::horizon - Sets up the packages needed to run the Horizon dashboard and its dependencies. - Will be included from the `server` recipe. + Includes openstack-dashboard::apache2-server recipe. ## openstack-dashboard::apache2-server - Installs the Apache webserver and sets up an `mod_wsgi` container to run the - Horizon dashboard. Will be included from the `server` recipe. + Horizon dashboard. -## openstack-dashboard::server -- Sets up the Horizon dashboard and a webserver of type - `['openstack']['dashboard']['server_type']` to run it, default type is - 'apache2'. +## openstack-dashboard::neutron-lbaas-dashboard +- Installs the python neutron-lbaas-dashboard package. Includes + openstack-dashboard::horizon recipe at the beginning. License and Author diff --git a/attributes/default.rb b/attributes/default.rb index 07a32a4..46de695 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -37,7 +37,6 @@ default['openstack']['bind_service']['dashboard_https']['port'] = '443' # ******************************************************************************** -default['openstack']['dashboard']['server_type'] = 'apache2' default['openstack']['dashboard']['debug'] = false # Don't cache html pages. @@ -236,3 +235,5 @@ default['openstack']['dashboard']['neutron']['enable_lb'] = false # 'varable2': 'value2', # } default['openstack']['dashboard']['misc_local_settings'] = nil +# version of python neutron-lbaas-dashboard package to install +default['openstack']['dashboard']['lbaas']['version'] = '1.0.0' diff --git a/metadata.rb b/metadata.rb index d0f6f0c..0d7936d 100644 --- a/metadata.rb +++ b/metadata.rb @@ -15,3 +15,4 @@ end depends 'apache2', '~> 3.2' depends 'openstack-common', '>= 14.0.0' depends 'openstack-identity', '>= 14.0.0' +depends 'poise-python', '~> 1.5.1' diff --git a/recipes/horizon.rb b/recipes/horizon.rb index 8846eb6..7a31b62 100644 --- a/recipes/horizon.rb +++ b/recipes/horizon.rb @@ -41,9 +41,9 @@ https_bind = node['openstack']['bind_service']['dashboard_https'] https_bind_address = bind_address https_bind horizon_host = if node['openstack']['dashboard']['use_ssl'] - http_bind_address - else https_bind_address + else + http_bind_address end db_pass = get_password 'db', 'horizon' @@ -65,6 +65,7 @@ if node['openstack']['dashboard']['session_backend'] == 'memcached' end end +django_path = node['openstack']['dashboard']['django_path'] memcached = memcached_servers template node['openstack']['dashboard']['local_settings_path'] do @@ -83,12 +84,12 @@ template node['openstack']['dashboard']['local_settings_path'] do host: horizon_host ) - notifies :restart, "service[#{node['openstack']['dashboard']['server_type']}]", :delayed + notifies :restart, 'service[apache2]', :delayed end execute 'openstack-dashboard syncdb' do - cwd node['openstack']['dashboard']['django_path'] - environment 'PYTHONPATH' => "/etc/openstack-dashboard:#{node['openstack']['dashboard']['django_path']}:$PYTHONPATH" + cwd django_path + environment 'PYTHONPATH' => "/etc/openstack-dashboard:#{django_path}:$PYTHONPATH" command 'python manage.py syncdb --noinput' action :run only_if do @@ -113,6 +114,13 @@ package 'openstack-dashboard-ubuntu-theme' do only_if { platform_family?('debian') } end -# TODO(shep) -# Horizon has a forced dependency on there being a volume service endpoint in your keystone catalog -# https://answers.launchpad.net/horizon/+question/189551 +# resource can be triggered from other recipes (e.g. in +# recipe/neutron-lbaas-dashboard.rb) +execute 'openstack-dashboard collectstatic' do + cwd django_path + environment 'PYTHONPATH' => "/etc/openstack-dashboard:#{django_path}:$PYTHONPATH" + command 'python manage.py collectstatic --noinput' + action :nothing +end + +include_recipe 'openstack-dashboard::apache2-server' diff --git a/recipes/neutron-lbaas-dashboard.rb b/recipes/neutron-lbaas-dashboard.rb new file mode 100644 index 0000000..2e9bb31 --- /dev/null +++ b/recipes/neutron-lbaas-dashboard.rb @@ -0,0 +1,34 @@ +# 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' + +python_runtime '2' + +django_path = node['openstack']['dashboard']['django_path'] + +python_package 'neutron-lbaas-dashboard' do + version node['openstack']['dashboard']['lbaas']['version'] + notifies :run, 'execute[openstack-dashboard collectstatic]' +end + +remote_file "#{django_path}/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py" do + source 'https://raw.githubusercontent.com/openstack/neutron-lbaas-dashboard/stable/mitaka/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py' + owner 'root' + mode 00644 + notifies :run, 'execute[openstack-dashboard collectstatic]' +end diff --git a/recipes/server.rb b/recipes/server.rb deleted file mode 100644 index 307c373..0000000 --- a/recipes/server.rb +++ /dev/null @@ -1,26 +0,0 @@ -# encoding: UTF-8 -# -# Cookbook Name:: openstack-dashboard -# Recipe:: server -# -# Copyright 2012, Rackspace US, Inc. -# Copyright 2012-2013, AT&T Services, Inc. -# Copyright 2013-2014, IBM, Corp. -# Copyright 2014, SUSE Linux, GmbH. -# Copyright 2014, x-ion GmbH. -# -# 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' -include_recipe "openstack-dashboard::#{node['openstack']['dashboard']['server_type']}-server" diff --git a/spec/horizon-redhat_spec.rb b/spec/horizon-redhat_spec.rb index 2b20836..d244f5e 100644 --- a/spec/horizon-redhat_spec.rb +++ b/spec/horizon-redhat_spec.rb @@ -6,7 +6,7 @@ describe 'openstack-dashboard::horizon' do let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } let(:node) { runner.node } let(:chef_run) do - runner.converge('openstack-dashboard::server') + runner.converge(described_recipe) end include_context 'dashboard_stubs' diff --git a/spec/horizon_spec.rb b/spec/horizon_spec.rb index 22e82bd..c902a24 100644 --- a/spec/horizon_spec.rb +++ b/spec/horizon_spec.rb @@ -6,12 +6,12 @@ describe 'openstack-dashboard::horizon' do let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } let(:node) { runner.node } let(:chef_run) do - runner.converge('openstack-dashboard::server') + runner.converge(described_recipe) end let(:chef_run_session_sql) do node.set['openstack']['dashboard']['session_backend'] = 'sql' - runner.converge('openstack-dashboard::server') + runner.converge(described_recipe) end include_context 'non_redhat_stubs' diff --git a/spec/neutron-lbaas-dashboard_spec.rb b/spec/neutron-lbaas-dashboard_spec.rb new file mode 100644 index 0000000..b6a8a2f --- /dev/null +++ b/spec/neutron-lbaas-dashboard_spec.rb @@ -0,0 +1,42 @@ +# encoding: UTF-8 +require_relative 'spec_helper' + +describe 'openstack-dashboard::neutron-lbaas-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-lbaas-dashboard') + end + + it do + expect(chef_run).to create_remote_file( + '/usr/share/openstack-dashboard/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py' + ).with( + mode: 00644, + owner: 'root', + source: 'https://raw.githubusercontent.com/openstack/neutron-lbaas-dashboard/stable/mitaka/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py' + ) + end + + it do + expect(chef_run.remote_file('/usr/share/openstack-dashboard/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py')) + .to notify('execute[openstack-dashboard collectstatic]') + end + end +end diff --git a/spec/server_spec.rb b/spec/server_spec.rb deleted file mode 100644 index be7344f..0000000 --- a/spec/server_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -# encoding: UTF-8 -require_relative 'spec_helper' - -describe 'openstack-dashboard::server' 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 'installs the horizon dashboard' do - expect(chef_run).to include_recipe('openstack-dashboard::horizon') - end - - it 'by default installs the apache2 webserver' do - expect(chef_run).to include_recipe('openstack-dashboard::apache2-server') - end -end