Add ability to deploy Murano CloudFoundry service broker API

Since Murano has new service CloudFoundry service broker API we need
to have an ability to deploy it using puppets

 - add new class for CloudFoundry service broker API called murano::cfapi
 - add tests for murano::cfapi class

Change-Id: I8e2993fabfe2cf59d982a0c58d0cfbc706a5309e
Co-Authored-By: Alexey Deryugin <aderyugin@mirantis.com>
This commit is contained in:
Nikolay Starodubtsev 2015-11-13 12:26:35 +03:00
parent 415b0f2d6f
commit 1fe809faaf
4 changed files with 140 additions and 0 deletions

68
manifests/cfapi.pp Normal file
View File

@ -0,0 +1,68 @@
# == Class: murano::cfapi
#
# murano service broker package & service
#
# === Parameters
#
# [*manage_service*]
# (Optional) Whether the service should be managed by Puppet
# Defaults to true
#
# [*enabled*]
# (Optional) Should the service be enabled
# Defaults to true
#
# [*package_ensure*]
# (Optional) Ensure state for package
# Defaults to 'present'
#
# [*host*]
# (Optional) Host on which murano cloudfoundry api should listen
# Defaults to $::os_service_default.
#
# [*port*]
# (Optional) Port on which murano cloudfoundry api should listen
# Defaults to $::os_service_default.
#
class murano::cfapi(
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$host = $::os_service_default,
$port = $::os_service_default,
) {
include ::murano::params
include ::murano::policy
Murano_config<||> ~> Service['murano-cfapi']
Class['murano::policy'] -> Service['murano-cfapi']
if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}
murano_config {
'DEFAULT/cfapi_bind_host': value => $host;
'DEFAULT/cfapi_bind_port': value => $port;
}
package { 'murano-cfapi':
ensure => $package_ensure,
name => $::murano::params::cfapi_package_name,
}
service { 'murano-cfapi':
ensure => $service_ensure,
name => $::murano::params::cfapi_service_name,
enable => $enabled,
require => Package['murano-cfapi'],
}
Package['murano-cfapi'] ~> Service['murano-cfapi']
Murano_paste_ini_config<||> ~> Service['murano-cfapi']
}

View File

@ -10,12 +10,14 @@ class murano::params {
'RedHat': {
# package names
$api_package_name = 'openstack-murano-api'
$cfapi_package_name = 'openstack-murano-cfapi'
$common_package_name = 'openstack-murano-common'
$engine_package_name = 'openstack-murano-engine'
$pythonclient_package_name = 'openstack-python-muranoclient'
$dashboard_package_name = 'openstack-murano-dashboard'
# service names
$api_service_name = 'murano-api'
$cfapi_service_name = 'murano-cfapi'
$engine_service_name = 'murano-engine'
# dashboard config file
$local_settings_path = '/etc/openstack-dashboard/local_settings'
@ -23,12 +25,14 @@ class murano::params {
'Debian': {
# package names
$api_package_name = 'murano-api'
$cfapi_package_name = 'murano-cfapi'
$common_package_name = 'murano-common'
$engine_package_name = 'murano-engine'
$pythonclient_package_name = 'python-muranoclient'
$dashboard_package_name = 'python-murano-dashboard'
# service names
$api_service_name = 'murano-api'
$cfapi_service_name = 'murano-cfapi'
$engine_service_name = 'murano-engine'
# dashboard config file
$local_settings_path = '/etc/openstack-dashboard/local_settings.py'

View File

@ -55,6 +55,7 @@ describe 'basic murano' do
}
class { '::murano::api': }
class { '::murano::engine': }
class { '::murano::cfapi': }
class { '::murano::keystone::auth':
password => 'a_big_secret',
}

View File

@ -0,0 +1,67 @@
require 'spec_helper'
describe 'murano::cfapi' do
shared_examples_for 'murano-cfapi' do
it { is_expected.to contain_class('murano::cfapi') }
end
shared_examples_for 'with default parameters' do
it { is_expected.to contain_class('murano::params') }
it { is_expected.to contain_class('murano::policy') }
it { is_expected.to contain_murano_config('DEFAULT/cfapi_bind_host').with_value('<SERVICE_DEFAULT>') }
it { is_expected.to contain_murano_config('DEFAULT/cfapi_bind_port').with_value('<SERVICE_DEFAULT>') }
end
shared_examples_for 'with parameters override' do
let :params do {
:host => '0.0.0.0',
:port => 8080,
}
end
it { is_expected.to contain_class('murano::params') }
it { is_expected.to contain_class('murano::policy') }
it { is_expected.to contain_murano_config('DEFAULT/cfapi_bind_host').with_value('0.0.0.0') }
it { is_expected.to contain_murano_config('DEFAULT/cfapi_bind_port').with_value(8080) }
end
context 'on a RedHat osfamily' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '7.0',
:concat_basedir => '/var/lib/puppet/concat'
}
end
it_configures 'murano-cfapi'
it_behaves_like 'generic murano service', {
:name => 'murano-cfapi',
:package_name => 'openstack-murano-cfapi',
:service_name => 'murano-cfapi'
}
end
context 'on a Debian osfamily' do
let :facts do
{
:operatingsystemrelease => '7.8',
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:concat_basedir => '/var/lib/puppet/concat'
}
end
it_configures 'murano-cfapi'
it_behaves_like 'generic murano service', {
:name => 'murano-cfapi',
:package_name => 'murano-cfapi',
:service_name => 'murano-cfapi'
}
end
end