Add support for management of osc-placement package

This patch introduces a new class, placement::client, so that operators
can manage pythonN-osc-placement package.

Change-Id: I76eb105ca532e427e4f48f84ccb5c15532456fda
This commit is contained in:
Takashi Kajinami 2020-07-21 09:49:23 +09:00
parent ac6e4e999b
commit 0a59d6767a
5 changed files with 93 additions and 0 deletions

24
manifests/client.pp Normal file
View File

@ -0,0 +1,24 @@
# == Class placement::client
#
# installs placement client
#
# === Parameters:
#
# [*ensure*]
# (optional) The state for the placement client package
# Defaults to 'present'
#
class placement::client(
$ensure = 'present'
) {
include placement::deps
include placement::params
package { 'python-osc-placement':
ensure => $ensure,
name => $::placement::params::osc_package_name,
tag => ['openstack', 'placement-support-package'],
}
include 'openstacklib::openstackclient'
}

View File

@ -24,6 +24,17 @@ class placement::deps {
~> Service<| tag == 'placement-service' |> ~> Service<| tag == 'placement-service' |>
~> anchor { 'placement::service::end': } ~> anchor { 'placement::service::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 placement-package tag and the placement-support-package
# tag. Note: the package resources here will have a 'before' relationship on
# the placement::install::end anchor. The line between placement-support-package
# and placement-package should be whether or not placement services would
# need to be restarted if the package state was changed.
Anchor['placement::install::begin']
-> Package<| tag == 'placement-support-package'|>
-> Anchor['placement::install::end']
# all db settings should be applied and all packages should be installed # all db settings should be applied and all packages should be installed
# before dbsync starts # before dbsync starts
Oslo::Db<||> -> Anchor['placement::dbsync::begin'] Oslo::Db<||> -> Anchor['placement::dbsync::begin']

View File

@ -19,6 +19,7 @@ class placement::params {
$package_name = 'openstack-placement-api' $package_name = 'openstack-placement-api'
$common_package_name = 'openstack-placement-common' $common_package_name = 'openstack-placement-common'
$python_package_name = "python${pyvers_real}-placement" $python_package_name = "python${pyvers_real}-placement"
$osc_package_name = "python${pyvers_real}-osc-placement"
$service_name = false $service_name = false
$public_url = 'http://127.0.0.1/placement' $public_url = 'http://127.0.0.1/placement'
$internal_url = 'http://127.0.0.1/placement' $internal_url = 'http://127.0.0.1/placement'
@ -31,6 +32,7 @@ class placement::params {
$package_name = 'placement-api' $package_name = 'placement-api'
$common_package_name = 'placement-common' $common_package_name = 'placement-common'
$python_package_name = "python${pyvers_real}-placement" $python_package_name = "python${pyvers_real}-placement"
$osc_package_name = "python${pyvers_real}-osc-placement"
case $::os_package_type { case $::os_package_type {
'debian': { 'debian': {
$service_name = 'placement-api' $service_name = 'placement-api'

View File

@ -0,0 +1,5 @@
---
features:
- |
The new ``placement::client`` class has been added to manage osc-placement
package.

View File

@ -0,0 +1,51 @@
require 'spec_helper'
describe 'placement::client' do
shared_examples_for 'placement client' do
it { is_expected.to contain_class('placement::deps') }
it { is_expected.to contain_class('placement::params') }
it 'installs placement client package' do
is_expected.to contain_package('python-osc-placement').with(
:ensure => 'present',
:name => platform_params[:client_package_name],
:tag => ['openstack', 'placement-support-package']
)
end
it { is_expected.to contain_class('openstacklib::openstackclient') }
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :client_package_name => 'python3-osc-placement' }
when 'RedHat'
if facts[:operatingsystem] == 'Fedora'
{ :client_package_name => 'python3-osc-placement' }
else
if facts[:operatingsystemmajrelease] > '7'
{ :client_package_name => 'python3-osc-placement' }
else
{ :client_package_name => 'python-osc-placement' }
end
end
end
end
it_behaves_like 'placement client'
end
end
end