Client and dashboard class implementation
Change-Id: Ie16be0d3707611279f0e782b33827de180143f14
This commit is contained in:
parent
b46a7b34c0
commit
6beefeabd0
23
manifests/client.pp
Normal file
23
manifests/client.pp
Normal file
@ -0,0 +1,23 @@
|
||||
# == Class: murano::client
|
||||
#
|
||||
# murano client package
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (Optional) Ensure state for package
|
||||
# Defaults to 'present'
|
||||
#
|
||||
class murano::client(
|
||||
$package_ensure = 'present',
|
||||
) {
|
||||
|
||||
include ::murano::params
|
||||
|
||||
package { 'python-muranoclient':
|
||||
ensure => $package_ensure,
|
||||
name => $::murano::params::pythonclient_package_name,
|
||||
tag => ['openstack', 'murano-packages'],
|
||||
}
|
||||
|
||||
}
|
115
manifests/dashboard.pp
Normal file
115
manifests/dashboard.pp
Normal file
@ -0,0 +1,115 @@
|
||||
# == Class: murano::dashboard
|
||||
#
|
||||
# murano dashboard package
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (Optional) Ensure state for package
|
||||
# Defaults to 'present'
|
||||
#
|
||||
# [*api_url*]
|
||||
# (Optional) API url for murano-dashboard
|
||||
# Defaults to 'http://127.0.0.1:8082'
|
||||
#
|
||||
# [*repo_url*]
|
||||
# (Optional) Application repository URL for murano-dashboard
|
||||
# Defaults to 'undef'
|
||||
#
|
||||
# [*collect_static_script*]
|
||||
# (Optional) Path to horizon manage utility
|
||||
# Defaults to '/usr/share/openstack-dashboard/manage.py'
|
||||
#
|
||||
# [*metadata_dir*]
|
||||
# (Optional) Directory to store murano dashboard metadata cache
|
||||
# Defaults to '/var/cache/muranodashboard-cache'
|
||||
#
|
||||
# [*max_file_size*]
|
||||
# (Optional) Maximum allowed filesize to upload
|
||||
# Defaults to '5'
|
||||
#
|
||||
# [*dashboard_debug_level*]
|
||||
# (Optional) Murano dashboard logging level
|
||||
# Defaults to 'DEBUG'
|
||||
#
|
||||
# [*client_debug_level*]
|
||||
# (Optional) Murano client logging level
|
||||
# Defaults to 'ERROR'
|
||||
#
|
||||
class murano::dashboard(
|
||||
$package_ensure = 'present',
|
||||
$api_url = 'http://127.0.0.1:8082',
|
||||
$repo_url = undef,
|
||||
$collect_static_script = '/usr/share/openstack-dashboard/manage.py',
|
||||
$metadata_dir = '/var/cache/muranodashboard-cache',
|
||||
$max_file_size = '5',
|
||||
$dashboard_debug_level = 'DEBUG',
|
||||
$client_debug_level = 'ERROR',
|
||||
) {
|
||||
|
||||
include ::murano::params
|
||||
|
||||
package { 'murano-dashboard':
|
||||
ensure => $package_ensure,
|
||||
name => $::murano::params::dashboard_package_name,
|
||||
tag => ['openstack', 'murano-packages'],
|
||||
}
|
||||
|
||||
concat { $::murano::params::local_settings_path: }
|
||||
|
||||
concat::fragment { 'original_config':
|
||||
target => $::murano::params::local_settings_path,
|
||||
source => $::murano::params::local_settings_path,
|
||||
order => 1,
|
||||
}
|
||||
|
||||
concat::fragment { 'murano_dashboard_section':
|
||||
target => $::murano::params::local_settings_path,
|
||||
content => template('murano/local_settings.py.erb'),
|
||||
order => 2,
|
||||
}
|
||||
|
||||
exec { 'clean_horizon_config':
|
||||
command => "sed -e '/^## MURANO_CONFIG_BEGIN/,/^## MURANO_CONFIG_END ##/ d' -i ${::murano::params::local_settings_path}",
|
||||
onlyif => "grep '^## MURANO_CONFIG_BEGIN' ${::murano::params::local_settings_path}",
|
||||
path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ],
|
||||
}
|
||||
|
||||
exec { 'django_collectstatic':
|
||||
command => "${collect_static_script} collectstatic --noinput --clear",
|
||||
environment => [
|
||||
"APACHE_USER=${::apache::params::user}",
|
||||
"APACHE_GROUP=${::apache::params::group}",
|
||||
],
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
exec { 'django_compressstatic':
|
||||
command => "${collect_static_script} compress --force",
|
||||
environment => [
|
||||
"APACHE_USER=${::apache::params::user}",
|
||||
"APACHE_GROUP=${::apache::params::group}",
|
||||
],
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
exec { 'django_syncdb':
|
||||
command => "${collect_static_script} syncdb --noinput",
|
||||
environment => [
|
||||
"APACHE_USER=${::apache::params::user}",
|
||||
"APACHE_GROUP=${::apache::params::group}",
|
||||
],
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
Package['murano-dashboard'] ->
|
||||
Exec['clean_horizon_config'] ->
|
||||
Concat[$::murano::params::local_settings_path] ->
|
||||
Service <| title == 'httpd' |>
|
||||
|
||||
Package['murano-dashboard'] ~>
|
||||
Exec['django_collectstatic'] ~>
|
||||
Exec['django_compressstatic'] ~>
|
||||
Exec['django_syncdb'] ~>
|
||||
Service <| title == 'httpd' |>
|
||||
}
|
22
spec/classes/murano_client_spec.rb
Normal file
22
spec/classes/murano_client_spec.rb
Normal file
@ -0,0 +1,22 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'murano::client' do
|
||||
|
||||
shared_examples_for 'murano-client' do
|
||||
it { is_expected.to contain_class('murano::client') }
|
||||
it { is_expected.to contain_package('python-muranoclient').with(
|
||||
:name => 'python-muranoclient',
|
||||
)}
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'murano-client'
|
||||
end
|
||||
end
|
116
spec/classes/murano_dashboard_spec.rb
Normal file
116
spec/classes/murano_dashboard_spec.rb
Normal file
@ -0,0 +1,116 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'murano::dashboard' do
|
||||
|
||||
let :facts do {
|
||||
:osfamily => 'Debian',
|
||||
} end
|
||||
|
||||
shared_examples_for 'with default class parameters' do
|
||||
it { is_expected.to contain_package('murano-dashboard').with({
|
||||
:ensure => 'present',
|
||||
:name => 'python-murano-dashboard',
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_concat('/etc/openstack-dashboard/local_settings.py')}
|
||||
it { is_expected.to contain_concat__fragment('original_config').with({
|
||||
:target => '/etc/openstack-dashboard/local_settings.py',
|
||||
:source => '/etc/openstack-dashboard/local_settings.py',
|
||||
:order => 1,
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with({
|
||||
:target => '/etc/openstack-dashboard/local_settings.py',
|
||||
:order => 2,
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/MURANO_API_URL = 'http:\/\/127.0.0.1:8082'/)}
|
||||
it { is_expected.to_not contain_concat__fragment('murano_dashboard_section').with_content(/MURANO_REPO_URL = /)}
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/MAX_FILE_SIZE_MB = '5'/)}
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/METADATA_CACHE_DIR = '\/var\/cache\/muranodashboard-cache'/)}
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/LOGGING\['loggers'\]\['muranodashboard'\] = \{'handlers': \['syslog'\], 'level': 'DEBUG'\}/)}
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/LOGGING\['loggers'\]\['muranoclient'\] = \{'handlers': \['syslog'\], 'level': 'ERROR'\}/)}
|
||||
|
||||
it { is_expected.to contain_exec('clean_horizon_config').with({
|
||||
:command => 'sed -e \'/^## MURANO_CONFIG_BEGIN/,/^## MURANO_CONFIG_END ##/ d\' -i /etc/openstack-dashboard/local_settings.py',
|
||||
:onlyif => 'grep \'^## MURANO_CONFIG_BEGIN\' /etc/openstack-dashboard/local_settings.py',
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_exec('django_collectstatic').with({
|
||||
:command => '/usr/share/openstack-dashboard/manage.py collectstatic --noinput --clear'
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_exec('django_compressstatic').with({
|
||||
:command => '/usr/share/openstack-dashboard/manage.py compress --force'
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_exec('django_syncdb').with({
|
||||
:command => '/usr/share/openstack-dashboard/manage.py syncdb --noinput'
|
||||
})}
|
||||
end
|
||||
|
||||
shared_examples_for 'with parameters override' do
|
||||
let :params do {
|
||||
:api_url => 'http://127.0.0.1:8083',
|
||||
:repo_url => 'http://storage.apps.openstack.com',
|
||||
:collect_static_script => '/bin/openstack-dashboard/manage.py',
|
||||
:metadata_dir => '/tmp/muranodashboard-cache',
|
||||
:max_file_size => '5',
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_package('murano-dashboard').with({
|
||||
:ensure => 'present',
|
||||
:name => 'python-murano-dashboard',
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_concat('/etc/openstack-dashboard/local_settings.py')}
|
||||
it { is_expected.to contain_concat__fragment('original_config').with({
|
||||
:target => '/etc/openstack-dashboard/local_settings.py',
|
||||
:source => '/etc/openstack-dashboard/local_settings.py',
|
||||
:order => 1,
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with({
|
||||
:target => '/etc/openstack-dashboard/local_settings.py',
|
||||
:order => 2,
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/MURANO_API_URL = 'http:\/\/127.0.0.1:8083'/)}
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/MURANO_REPO_URL = 'http:\/\/storage.apps.openstack.com'/)}
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/MAX_FILE_SIZE_MB = '5'/)}
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/METADATA_CACHE_DIR = '\/tmp\/muranodashboard-cache'/)}
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/LOGGING\['loggers'\]\['muranodashboard'\] = \{'handlers': \['syslog'\], 'level': 'DEBUG'\}/)}
|
||||
it { is_expected.to contain_concat__fragment('murano_dashboard_section').with_content(/LOGGING\['loggers'\]\['muranoclient'\] = \{'handlers': \['syslog'\], 'level': 'ERROR'\}/)}
|
||||
|
||||
it { is_expected.to contain_exec('clean_horizon_config').with({
|
||||
:command => 'sed -e \'/^## MURANO_CONFIG_BEGIN/,/^## MURANO_CONFIG_END ##/ d\' -i /etc/openstack-dashboard/local_settings.py',
|
||||
:onlyif => 'grep \'^## MURANO_CONFIG_BEGIN\' /etc/openstack-dashboard/local_settings.py',
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_exec('django_collectstatic').with({
|
||||
:command => '/bin/openstack-dashboard/manage.py collectstatic --noinput --clear'
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_exec('django_compressstatic').with({
|
||||
:command => '/bin/openstack-dashboard/manage.py compress --force'
|
||||
})}
|
||||
|
||||
it { is_expected.to contain_exec('django_syncdb').with({
|
||||
:command => '/bin/openstack-dashboard/manage.py syncdb --noinput'
|
||||
})}
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:concat_basedir => '/var/lib/puppet/concat'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'with default class parameters'
|
||||
it_configures 'with parameters override'
|
||||
end
|
||||
end
|
8
templates/local_settings.py.erb
Normal file
8
templates/local_settings.py.erb
Normal file
@ -0,0 +1,8 @@
|
||||
## MURANO_CONFIG_BEGIN ##
|
||||
MURANO_API_URL = '<%= @api_url %>'
|
||||
<% if @repo_url != nil %>MURANO_REPO_URL = '<%= @repo_url %>'<% end %>
|
||||
MAX_FILE_SIZE_MB = '<%= @max_file_size %>'
|
||||
METADATA_CACHE_DIR = '<%= @metadata_dir %>'
|
||||
LOGGING['loggers']['muranodashboard'] = {'handlers': ['syslog'], 'level': '<%= @dashboard_debug_level %>'}
|
||||
LOGGING['loggers']['muranoclient'] = {'handlers': ['syslog'], 'level': '<%= @client_debug_level %>'}
|
||||
## MURANO_CONFIG_END ##
|
Loading…
x
Reference in New Issue
Block a user