diff --git a/attributes/default.rb b/attributes/default.rb index 568d0db..04f21d5 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -96,6 +96,14 @@ default['openstack']['dashboard']['db_python_packages'] = { # library. default['openstack']['dashboard']['hash_algorithm'] = 'md5' +# ----------------------------- Nuage Networks Horizon Customization ------- + +# Enable Nuage Networks Horizon Extensions +default['openstack']['dashboard']['nuage']['customization_module']['enabled'] = false +default['openstack']['dashboard']['nuage']['customization_module']['name'] = 'nuage_horizon.customization' + +# -------------------------------------------------------------------------- + case node['platform_family'] when 'rhel' default['openstack']['dashboard']['horizon_user'] = 'apache' @@ -111,9 +119,12 @@ when 'rhel' default['openstack']['dashboard']['platform'] = { 'horizon_packages' => ['openstack-dashboard'], 'memcache_python_packages' => ['python-memcached'], + 'nuage_horizon_packages' => ['nuage-openstack-horizon'], 'package_overrides' => '' } default['openstack']['dashboard']['apache']['sites-path'] = "#{node['apache']['dir']}/sites-available/openstack-dashboard.conf" + default['openstack']['dashboard']['nuage']['customization_module']['static_path'] = '/usr/lib/python2.7/site-packages/nuage_horizon/static/' + default['openstack']['dashboard']['nuage']['customization_module']['path'] = '/usr/lib/python2.7/site-packages/nuage_horizon' when 'suse' default['openstack']['dashboard']['horizon_user'] = 'wwwrun' default['openstack']['dashboard']['horizon_group'] = 'www' @@ -127,9 +138,12 @@ when 'suse' default['openstack']['dashboard']['platform'] = { 'horizon_packages' => ['openstack-dashboard'], 'memcache_python_packages' => ['python-python-memcached'], + 'nuage_horizon_packages' => ['nuage-openstack-horizon'], 'package_overrides' => '' } default['openstack']['dashboard']['apache']['sites-path'] = "#{node['apache']['dir']}/conf.d/openstack-dashboard.conf" + default['openstack']['dashboard']['nuage']['customization_module']['static_path'] = '/usr/lib/python2.7/site-packages/nuage_horizon/static/' + default['openstack']['dashboard']['nuage']['customization_module']['path'] = '/usr/lib/python2.7/site-packages/nuage_horizon' when 'debian' default['openstack']['dashboard']['horizon_user'] = 'horizon' default['openstack']['dashboard']['horizon_group'] = 'horizon' @@ -142,10 +156,13 @@ when 'debian' default['openstack']['dashboard']['login_redirect_url'] = nil default['openstack']['dashboard']['platform'] = { 'memcache_python_packages' => ['python-memcache'], - 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'" + 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'", + 'nuage_horizon_packages' => ['nuage-openstack-horizon'] } default['openstack']['dashboard']['platform']['horizon_packages'] = ['node-less', 'openstack-dashboard'] default['openstack']['dashboard']['apache']['sites-path'] = "#{node['apache']['dir']}/sites-available/openstack-dashboard.conf" + default['openstack']['dashboard']['nuage']['customization_module']['static_path'] = '/usr/lib/python2.7/dist-packages/nuage_horizon/static/' + default['openstack']['dashboard']['nuage']['customization_module']['path'] = '/usr/lib/python2.7/dist-packages/nuage_horizon' end default['openstack']['dashboard']['dash_path'] = "#{node['openstack']['dashboard']['django_path']}/openstack_dashboard" diff --git a/metadata.rb b/metadata.rb index 2d2cf64..d694c53 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ maintainer_email 'opscode-chef-openstack@googlegroups.com' license 'Apache 2.0' description 'Installs/Configures the OpenStack Dashboard (Horizon)' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '11.0.0' +version '11.1.0' recipe 'openstack-dashboard::horizon', 'Sets up the Horizon dashboard.' recipe 'openstack-dashboard::apache2-server', 'Sets up an Apache `mod_wsgi` container to run the dashboard.' diff --git a/recipes/horizon.rb b/recipes/horizon.rb index c0efddf..0c080fc 100644 --- a/recipes/horizon.rb +++ b/recipes/horizon.rb @@ -48,6 +48,12 @@ python_packages += Array(node['openstack']['dashboard']['db_python_packages'][db end end +if node['openstack']['dashboard']['nuage']['customization_module']['enabled'] + platform_options['nuage_horizon_packages'].each do |pkg| + package pkg + end +end + if node['openstack']['dashboard']['session_backend'] == 'memcached' platform_options['memcache_python_packages'].each do |pkg| package pkg diff --git a/spec/horizon-redhat_spec.rb b/spec/horizon-redhat_spec.rb index 153b2f5..133b8c8 100644 --- a/spec/horizon-redhat_spec.rb +++ b/spec/horizon-redhat_spec.rb @@ -24,6 +24,11 @@ describe 'openstack-dashboard::horizon' do end end + it 'installs nuage packages if dashboard nuage customization module is enabled' do + node.set['openstack']['dashboard']['nuage']['customization_module']['enabled'] = true + expect(chef_run).to install_package('nuage-openstack-horizon') + end + describe 'local_settings' do let(:file) { chef_run.template('/etc/openstack-dashboard/local_settings') } diff --git a/spec/horizon-suse_spec.rb b/spec/horizon-suse_spec.rb index 239a12a..9f06600 100644 --- a/spec/horizon-suse_spec.rb +++ b/spec/horizon-suse_spec.rb @@ -20,6 +20,11 @@ describe 'openstack-dashboard::horizon' do end end + it 'installs nuage packages if dashboard nuage customization module is enabled' do + node.set['openstack']['dashboard']['nuage']['customization_module']['enabled'] = true + expect(chef_run).to install_package('nuage-openstack-horizon') + end + describe 'local_settings.py' do let(:file) { chef_run.template('/srv/www/openstack-dashboard/openstack_dashboard/local/local_settings.py') } diff --git a/spec/horizon_spec.rb b/spec/horizon_spec.rb index 2821787..a7b2903 100644 --- a/spec/horizon_spec.rb +++ b/spec/horizon_spec.rb @@ -23,6 +23,11 @@ describe 'openstack-dashboard::horizon' do expect(chef_run).to upgrade_package('python-mysqldb') end + it 'installs nuage packages if dashboard nuage customazation module is enabled' do + node.set['openstack']['dashboard']['nuage']['customization_module']['enabled'] = true + expect(chef_run).to install_package('nuage-openstack-horizon') + end + describe 'local_settings.py' do let(:file) { chef_run.template('/etc/openstack-dashboard/local_settings.py') } diff --git a/templates/default/dash-site.erb b/templates/default/dash-site.erb index d7af730..c0df5a9 100644 --- a/templates/default/dash-site.erb +++ b/templates/default/dash-site.erb @@ -34,6 +34,9 @@ NameVirtualHost <%= @https_bind_address %>:<%= @https_bind_port %> WSGIProcessGroup dashboard DocumentRoot <%= node["openstack"]["dashboard"]["dash_path"] %>/.blackhole/ + <% if node["openstack"]["dashboard"]["nuage"]["customization_module"]["enabled"] %> + Alias /static/nuage <%= node["openstack"]["dashboard"]["nuage"]["customization_module"]["static_path"] %> + <% end %> Alias /static <%= node["openstack"]["dashboard"]["static_path"] %> @@ -63,6 +66,19 @@ NameVirtualHost <%= @https_bind_address %>:<%= @https_bind_port %> <% end -%> + <% if node["openstack"]["dashboard"]["nuage"]["customization_module"]["enabled"] %> + > + Options FollowSymLinks + AllowOverride None + <% if node['apache']['version'] == '2.4' -%> + Require all granted + <% else -%> + Order allow,deny + allow from all + <% end -%> + + <% end %> + <% if node["openstack"]["dashboard"]["use_ssl"] -%> SSLEngine on SSLCertificateFile <%= @ssl_cert_file %> diff --git a/templates/default/local_settings.py.erb b/templates/default/local_settings.py.erb index 9c94530..967a130 100644 --- a/templates/default/local_settings.py.erb +++ b/templates/default/local_settings.py.erb @@ -77,6 +77,9 @@ HORIZON_CONFIG = { 'fade_duration': 1500, 'types': ['alert-success', 'alert-info'] }, + <% if node["openstack"]["dashboard"]["nuage"]["customization_module"]["enabled"] %> + 'customization_module': "<%= node["openstack"]["dashboard"]["nuage"]["customization_module"]["name"] %>", + <% end %> 'help_url': "<%= node["openstack"]["dashboard"]["help_url"] %>", 'exceptions': {'recoverable': exceptions.RECOVERABLE, 'not_found': exceptions.NOT_FOUND,