Manila hooks support

This code moves all deps to an external class so that Manila can be
installed with mechanisms besides packages (like venv or docker). This
also cleans-up the dependency tree by removing false or confusing
dependencies.

Change-Id: I053dbef10d51664d99e633abb714b3520a681e96
This commit is contained in:
root 2016-10-20 18:02:13 +00:00 committed by cdelatte
parent 7f5ced9e72
commit 5b720d66d6
31 changed files with 166 additions and 28 deletions

View File

@ -45,8 +45,8 @@ Puppet::Type.newtype(:manila_api_paste_ini) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'manila'
autorequire(:anchor) do
['manila::install::end']
end
end

View File

@ -46,8 +46,8 @@ Puppet::Type.newtype(:manila_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'manila'
autorequire(:anchor) do
['manila::install::end']
end
end

View File

@ -126,6 +126,7 @@ class manila::api (
$service_port = undef,
) {
include ::manila::deps
include ::manila::params
require ::keystone::python

View File

@ -38,6 +38,8 @@ define manila::backend::cephfsnative (
$cephfs_enable_snapshots = true,
) {
include ::manila::deps
$share_driver = 'manila.share.drivers.cephfs.cephfs_native.CephFSNativeDriver'
manila_config {

View File

@ -88,6 +88,8 @@ define manila::backend::generic (
$automatic_share_server_cleanup = 'True',
) {
include ::manila::deps
$share_driver = 'manila.share.drivers.generic.GenericShareDriver'
manila_config {

View File

@ -28,6 +28,7 @@ define manila::backend::glusterfs (
$glusterfs_mount_point_base = '$state_path/mnt',
) {
include ::manila::deps
$share_driver = 'manila.share.drivers.glusterfs.GlusterfsShareDriver'
manila_config {

View File

@ -31,6 +31,7 @@ define manila::backend::glusternative (
$package_ensure = 'present',
) {
include ::manila::deps
include ::manila::params
$share_driver = 'manila.share.drivers.glusterfs_native.GlusterfsNativeShareDriver'
@ -45,8 +46,10 @@ define manila::backend::glusternative (
package { $::manila::params::gluster_package_name:
ensure => $package_ensure,
tag => 'manila-support-package',
}
package { $::manila::params::gluster_client_package_name:
ensure => $package_ensure,
tag => 'manila-support-package',
}
}

View File

@ -42,6 +42,7 @@ define manila::backend::glusternfs (
$package_ensure = 'present',
) {
include ::manila::deps
include ::manila::params
$share_driver = 'manila.share.drivers.glusterfs.GlusterfsShareDriver'
@ -58,8 +59,10 @@ define manila::backend::glusternfs (
package { $::manila::params::gluster_package_name:
ensure => $package_ensure,
tag => 'manila-support-package',
}
package { $::manila::params::gluster_client_package_name:
ensure => $package_ensure,
tag => 'manila-support-package',
}
}

View File

@ -85,6 +85,9 @@
# include method and api) that controls which trace info is written to the
# Manila logs when the debug level is set to True
#
# [*package_ensure*]
# (optional) Ensure state for package. Defaults to 'present'.
#
# === Examples
#
# manila::backend::netapp { 'myBackend':
@ -114,8 +117,11 @@ define manila::backend::netapp (
$netapp_root_volume_name = 'root',
$netapp_port_name_search_pattern = '(.*)',
$netapp_trace_flags = undef,
$package_ensure = 'present',
) {
include ::manila::deps
validate_string($netapp_password)
$netapp_share_driver = 'manila.share.drivers.netapp.common.NetAppDriver'
@ -141,5 +147,8 @@ define manila::backend::netapp (
"${share_backend_name}/netapp_trace_flags": value => $netapp_trace_flags;
}
package { 'nfs-utils': ensure => present }
package { 'nfs-utils':
ensure => $package_ensure,
tag => 'manila-support-package',
}
}

View File

@ -14,6 +14,8 @@ class manila::backends (
$enabled_share_backends = undef
) {
include ::manila::deps
# Maybe this could be extended to dynamically find the enabled names
manila_config {
'DEFAULT/enabled_share_backends': value => join($enabled_share_backends, ',');

View File

@ -11,11 +11,12 @@ class manila::client (
$package_ensure = 'present'
) {
include ::manila::deps
include ::manila::params
package { 'python-manilaclient':
ensure => $package_ensure,
name => $::manila::params::client_package,
tag => 'openstack'
tag => ['openstack', 'manila-support-package']
}
}

View File

@ -31,6 +31,9 @@ class manila::config (
$manila_config = {},
$api_paste_ini_config = {},
) {
include ::manila::deps
validate_hash($manila_config)
validate_hash($api_paste_ini_config)

View File

@ -49,6 +49,8 @@ class manila::db (
$database_db_max_retries = $::os_service_default,
) {
include ::manila::deps
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
# to use manila::<myparam> if manila::db::<myparam> isn't specified.
$database_connection_real = pick($::manila::sql_connection, $database_connection)

71
manifests/deps.pp Normal file
View File

@ -0,0 +1,71 @@
# == Class: manila::deps
#
# manila anchors and dependency management
#
class manila::deps {
# Setup anchors for install, config and service phases of the module. These
# anchors allow external modules to hook the begin and end of any of these
# phases. Package or service management can also be replaced by ensuring the
# package is absent or turning off service management and having the
# replacement depend on the appropriate anchors. When applicable, end tags
# should be notified so that subscribers can determine if installation,
# config or service state changed and act on that if needed.
anchor { 'manila::install::begin': }
-> Package<| tag == 'manila-package'|>
~> anchor { 'manila::install::end': }
-> anchor { 'manila::config::begin': }
-> Manila_config<||>
~> anchor { 'manila::config::end': }
-> anchor { 'manila::db::begin': }
-> anchor { 'manila::db::end': }
~> anchor { 'manila::dbsync::begin': }
-> anchor { 'manila::dbsync::end': }
~> anchor { 'manila::service::begin': }
~> Service<| tag == 'manila-service' |>
~> anchor { 'manila::service::end': }
# paste-api.ini config should occur in the config block also.
Anchor['manila::config::begin']
-> Manila_api_paste_ini<||>
~> Anchor['manila::config::end']
# policy config should occur in the config block also.
Anchor['manila::config::begin']
-> Openstacklib::Policy::Base<||>
~> Anchor['manila::config::end']
# Support packages need to be installed in the install phase, but we don't
# put them in the chain above because we don't want any false dependencies
# between packages with the manila-package tag and the manila-support-package
# tag. Note: the package resources here will have a 'before' relationshop on
# the manila::install::end anchor. The line between manila-support-package and
# manila-package should be whether or not manila services would need to be
# restarted if the package state was changed.
Anchor['manila::install::begin']
-> Package<| tag == 'manila-support-package'|>
-> Anchor['manila::install::end']
# Support services need to be started in the service phase, but we don't
# put them in the chain above because we don't want any false dependencies
# between them and manila services. Note: the service resources here will
# have a 'before' relationshop on the manila::service::end anchor.
# The line between manila-support-service and manila-service should be
# whether or not manila services would need to be restarted if the service
# state was changed.
Anchor['manila::service::begin']
-> Service<| tag == 'manila-support-service'|>
-> Anchor['manila::service::end']
# We need openstackclient before marking service end so that manila
# will have clients available to create resources. This tag handles the
# openstackclient but indirectly since the client is not available in
# all catalogs that don't need the client class (like many spec tests)
Package<| tag == 'openstack'|>
~> Anchor['manila::service::end']
# Installation or config changes will always restart services.
Anchor['manila::install::end'] ~> Anchor['manila::service::begin']
Anchor['manila::config::end'] ~> Anchor['manila::service::begin']
}

View File

@ -39,6 +39,8 @@ class manila::ganesha (
$ganesha_export_template_dir = '/etc/manila/ganesha-export-templ.d',
) {
include ::manila::deps
manila_config {
'DEFAULT/ganesha_config_dir': value => $ganesha_config_dir;
'DEFAULT/ganesha_config_path': value => $ganesha_config_path;
@ -50,7 +52,8 @@ class manila::ganesha (
if ($::osfamily == 'RedHat') {
package { 'nfs-ganesha':
ensure => present
ensure => present,
tag => ['openstack', 'manila-support-package'],
}
} else {
warning("Unsupported osfamily ${::osfamily}, Red Hat is the only supported platform.")

View File

@ -300,6 +300,7 @@ class manila (
$purge_config = false,
) {
include ::manila::deps
include ::manila::db
include ::manila::logging
include ::manila::params
@ -313,13 +314,10 @@ class manila (
}
}
# allowing a resource to serve as a point where the configuration of manila begins
anchor { 'manila-start': }
package { 'manila':
ensure => $package_ensure,
name => $::manila::params::package_name,
require => Anchor['manila-start'],
require => Anchor['manila::install::begin'],
tag => ['openstack', 'manila-package'],
}

View File

@ -104,6 +104,8 @@ class manila::logging(
$log_date_format = $::os_service_default,
) {
include ::manila::deps
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
# to use manila::<myparam> first then manila::logging::<myparam>.
$use_syslog_real = pick($::manila::use_syslog,$use_syslog)

View File

@ -1,5 +1,6 @@
#
class manila::params {
include ::openstacklib::defaults
$manila_conf = '/etc/manila/manila.conf'

View File

@ -50,6 +50,8 @@ class manila::quota (
$max_age = 0,
) {
include ::manila::deps
manila_config {
'DEFAULT/quota_shares': value => $quota_shares;
'DEFAULT/quota_snapshots': value => $quota_snapshots;

View File

@ -37,6 +37,8 @@ class manila::rabbitmq(
$port = '5672',
) {
include ::manila::deps
warning('manila::rabbitmq class is deprecated and will be removed in next release. Make other plans to configure rabbitmq resources.')
if ($enabled) {
@ -55,7 +57,7 @@ class manila::rabbitmq(
write_permission => '.*',
read_permission => '.*',
provider => 'rabbitmqctl',
}->Anchor<| title == 'manila-start' |>
}->Anchor<| title == 'manila::service::begin' |>
}
rabbitmq_vhost { $virtual_host:
provider => 'rabbitmqctl',

View File

@ -27,6 +27,7 @@ class manila::scheduler (
$manage_service = true
) {
include ::manila::deps
include ::manila::params
Manila_config<||> ~> Service['manila-scheduler']
@ -61,7 +62,6 @@ class manila::scheduler (
name => $::manila::params::scheduler_service,
enable => $enabled,
hasstatus => true,
require => Package['manila'],
tag => 'manila-service',
}
}

View File

@ -100,6 +100,9 @@ define manila::service_instance (
$service_instance_network_helper_type = 'neutron',
) {
include ::manila::deps
if $create_service_image {
if $service_image_location {
glance_image { $service_image_name:

View File

@ -21,6 +21,7 @@ class manila::share (
$manage_service = true
) {
include ::manila::deps
include ::manila::params
Manila_config<||> ~> Service['manila-share']

View File

@ -45,6 +45,7 @@ define manila::type (
$volume_name = $name
include ::manila::deps
include ::manila::client
# TODO: (xarses) This should be moved to a ruby provider so that among other

View File

@ -38,6 +38,7 @@ define manila::type_set (
$os_region_name = undef,
) {
include ::manila::deps
include ::manila::client
# TODO: (xarses) This should be moved to a ruby provider so that among other
@ -61,6 +62,6 @@ define manila::type_set (
path => ['/usr/bin', '/bin'],
command => "manila type-key ${type} set ${key}=${name}",
environment => concat($manila_env, $region_env),
require => Package['python-manilaclient'],
require => Anchor['manila-support-package'],
}
}

View File

@ -0,0 +1,5 @@
---
features:
- moves all dependencies to an external class.
This allows keystone to be installed and managed
via external mechanisms like venvs or docker.

View File

@ -1,10 +1,32 @@
require 'spec_helper'
describe 'manila::client' do
it { is_expected.to contain_package('python-manilaclient').with(
:ensure => 'present',
:tag => 'openstack',
)}
let :params do
{}
end
let :default_params do
{ :package_ensure => 'present' }
end
shared_examples_for 'manila client' do
let :p do
default_params.merge(params)
end
it { is_expected.to contain_class('manila::params') }
it 'installs manila client package' do
it is_expected.to contain_package('python-manilaclient').with(
:name => 'python-manilaclient',
:ensure => p[:package_ensure],
:tag => ['openstack', 'manila-support-package'],
)
end
end
let :facts do
@default_facts.merge({:osfamily => 'Debian'})
end

View File

@ -15,7 +15,6 @@ describe 'manila::scheduler' do
it { is_expected.to contain_package('manila-scheduler').with(
:name => 'manila-scheduler',
:ensure => 'present',
:before => ["Service[manila-scheduler]"],
:tag => ['openstack', 'manila-package'],
) }
@ -23,7 +22,6 @@ describe 'manila::scheduler' do
:name => 'manila-scheduler',
:enable => true,
:ensure => 'running',
:require => 'Package[manila]',
:hasstatus => true,
:tag => 'manila-service',
) }
@ -67,7 +65,6 @@ describe 'manila::scheduler' do
:name => 'openstack-manila-scheduler',
:enable => true,
:ensure => 'running',
:require => 'Package[manila]',
:tag => 'manila-service',
) }
end

View File

@ -27,7 +27,7 @@ describe 'manila::type_set' do
'OS_USERNAME=admin',
'OS_PASSWORD=asdf',
'OS_AUTH_URL=http://127.127.127.1:5000/v2.0/'],
:require => 'Package[python-manilaclient]')
:require => 'Anchor[manila-support-package]')
end
end

View File

@ -57,12 +57,12 @@ describe 'Puppet::Type.type(:manila_api_paste_ini)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'manila')
catalog.add_resource package, @manila_api_paste_ini
anchor = Puppet::Type.type(:anchor).new(:name => 'manila::install::end')
catalog.add_resource anchor, @manila_api_paste_ini
dependency = @manila_api_paste_ini.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@manila_api_paste_ini)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end

View File

@ -53,12 +53,12 @@ describe 'Puppet::Type.type(:manila_config)' do
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'manila')
catalog.add_resource package, @manila_config
anchor = Puppet::Type.type(:anchor).new(:name => 'manila::install::end')
catalog.add_resource anchor, @manila_config
dependency = @manila_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@manila_config)
expect(dependency[0].source).to eq(package)
expect(dependency[0].source).to eq(anchor)
end
end