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.

backport note 1:
Because stable/train still uses absolute names to include puppet
classes, all usage of relative names are replaced.

backport note 2:
This change include the fix about the wrong client package name in unit
tests[1].
 [1] e1fedebded

Change-Id: I76eb105ca532e427e4f48f84ccb5c15532456fda
(cherry picked from commit 0a59d6767a)
(cherry picked from commit a8a9b300f5)
This commit is contained in:
Takashi Kajinami 2020-07-21 09:49:23 +09:00
parent 85948e4c45
commit d57a3d99cf
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' |>
~> 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
# before dbsync starts
Oslo::Db<||> -> Anchor['placement::dbsync::begin']

View File

@ -19,6 +19,7 @@ class placement::params {
$package_name = 'openstack-placement-api'
$common_package_name = 'openstack-placement-common'
$python_package_name = "python${pyvers_real}-placement"
$osc_package_name = "python${pyvers_real}-osc-placement"
$service_name = false
$public_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'
$common_package_name = 'placement-common'
$python_package_name = "python${pyvers_real}-placement"
$osc_package_name = "python${pyvers_real}-osc-placement"
case $::os_package_type {
'debian': {
$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 => 'python2-osc-placement' }
end
end
end
end
it_behaves_like 'placement client'
end
end
end