Avoid usage of custom os_package_type fact

Currently the os_package_type fact is used to distinguish Ubuntu and
Debian but it's redundant and built-in $::operatingsystem should be
enough. What is worse the custom fact is not injected while composing
facts data in unit tests and has never been tested properly.

Change-Id: Ie1d6006020970ade3e1597dc9f68f9a5503283b4
This commit is contained in:
Takashi Kajinami 2021-11-04 22:31:33 +09:00
parent 76c5e9b955
commit 4b553afc8c
8 changed files with 12 additions and 25 deletions

View File

@ -95,8 +95,8 @@ class nova::params {
# debian specific nova config # debian specific nova config
$root_helper = 'sudo nova-rootwrap' $root_helper = 'sudo nova-rootwrap'
$lock_path = '/var/lock/nova' $lock_path = '/var/lock/nova'
case $::os_package_type { case $::operatingsystem {
'debian': { 'Debian': {
$api_metadata_service_name = 'nova-api-metadata' $api_metadata_service_name = 'nova-api-metadata'
$spicehtml5proxy_package_name = 'nova-consoleproxy' $spicehtml5proxy_package_name = 'nova-consoleproxy'
$spicehtml5proxy_service_name = 'nova-spicehtml5proxy' $spicehtml5proxy_service_name = 'nova-spicehtml5proxy'

View File

@ -56,7 +56,7 @@ class nova::spicehtml5proxy(
# 3/ Start the service # 3/ Start the service
# Other OS don't need this scheduling and can use # Other OS don't need this scheduling and can use
# the standard nova::generic_service # the standard nova::generic_service
if $::os_package_type == 'debian' { if $::operatingsystem == 'Debian' {
if $enabled { if $enabled {
file_line { '/etc/default/nova-consoleproxy:NOVA_CONSOLE_PROXY_TYPE': file_line { '/etc/default/nova-consoleproxy:NOVA_CONSOLE_PROXY_TYPE':
path => '/etc/default/nova-consoleproxy', path => '/etc/default/nova-consoleproxy',

View File

@ -120,7 +120,7 @@ class nova::vncproxy(
# 3/ Start the service # 3/ Start the service
# Other OS don't need this scheduling and can use # Other OS don't need this scheduling and can use
# the standard nova::generic_service # the standard nova::generic_service
if $::os_package_type == 'debian' { if $::operatingsystem == 'Debian' {
if $enabled { if $enabled {
file_line { '/etc/default/nova-consoleproxy:NOVA_CONSOLE_PROXY_TYPE': file_line { '/etc/default/nova-consoleproxy:NOVA_CONSOLE_PROXY_TYPE':
path => '/etc/default/nova-consoleproxy', path => '/etc/default/nova-consoleproxy',

View File

@ -319,7 +319,7 @@ describe 'nova::api' do
shared_examples 'nova-api on Debian' do shared_examples 'nova-api on Debian' do
context 'with default parameters' do context 'with default parameters' do
it { is_expected.to contain_service('nova-api- metadata').with( it { is_expected.to contain_service('nova-api-metadata').with(
:name => 'nova-api-metadata', :name => 'nova-api-metadata',
:ensure => 'running', :ensure => 'running',
:hasstatus => true, :hasstatus => true,
@ -348,7 +348,7 @@ describe 'nova::api' do
end end
end end
it_behaves_like 'nova-api' it_behaves_like 'nova-api'
if facts[:os_package_type] == 'debian' if facts[:operatingsystem] == 'Debian'
it_behaves_like 'nova-api on Debian' it_behaves_like 'nova-api on Debian'
end end
end end

View File

@ -74,9 +74,6 @@ describe 'nova::compute::libvirt_guests' do
case [:osfamily] case [:osfamily]
when 'RedHat' when 'RedHat'
let (:facts) do
facts.merge!(OSDefaults.get_facts({ :os_package_type => 'rpm' }))
end
it_behaves_like 'redhat-nova-compute-libvirt-guests' it_behaves_like 'redhat-nova-compute-libvirt-guests'
end end
end end

View File

@ -59,7 +59,7 @@ describe 'nova::serialproxy' do
let (:platform_params) do let (:platform_params) do
case facts[:osfamily] case facts[:osfamily]
when 'Debian' when 'Debian'
if facts[:os_package_type] == 'debian' if facts[:operatingsystem] == 'Debian'
{ :serialproxy_package_name => 'nova-consoleproxy', { :serialproxy_package_name => 'nova-consoleproxy',
:serialproxy_service_name => 'nova-serialproxy' } :serialproxy_service_name => 'nova-serialproxy' }
else else

View File

@ -67,19 +67,13 @@ describe 'nova::spicehtml5proxy' do
}).each do |os,facts| }).each do |os,facts|
context "on #{os}" do context "on #{os}" do
let (:facts) do let (:facts) do
if facts[:operatingsystem] == 'Debian' facts.merge!(OSDefaults.get_facts())
extra = { :os_package_type => 'debian' }
else
extra = {}
end
facts.merge!(OSDefaults.get_facts(extra))
end end
let (:platform_params) do let (:platform_params) do
case facts[:osfamily] case facts[:osfamily]
when 'Debian' when 'Debian'
if facts[:os_package_type] == 'debian' then if facts[:operatingsystem] == 'Debian' then
package_name = 'nova-consoleproxy' package_name = 'nova-consoleproxy'
service_name = 'nova-spicehtml5proxy' service_name = 'nova-spicehtml5proxy'
else else
@ -100,7 +94,7 @@ describe 'nova::spicehtml5proxy' do
it_behaves_like 'nova::spicehtml5proxy' it_behaves_like 'nova::spicehtml5proxy'
if facts[:os_package_type] == 'debian' if facts[:operatingsystem] == 'Debian'
it_behaves_like 'nova::spicehtml5proxy on Debian' it_behaves_like 'nova::spicehtml5proxy on Debian'
end end
end end

View File

@ -135,10 +135,6 @@ describe 'nova::vncproxy' do
'include nova' 'include nova'
end end
before do
facts.merge!( :os_package_type => 'debian' )
end
it { is_expected.to contain_file_line('/etc/default/nova-consoleproxy:NOVA_CONSOLE_PROXY_TYPE').with( it { is_expected.to contain_file_line('/etc/default/nova-consoleproxy:NOVA_CONSOLE_PROXY_TYPE').with(
:path => '/etc/default/nova-consoleproxy', :path => '/etc/default/nova-consoleproxy',
:match => '^NOVA_CONSOLE_PROXY_TYPE=(.*)$', :match => '^NOVA_CONSOLE_PROXY_TYPE=(.*)$',
@ -160,7 +156,7 @@ describe 'nova::vncproxy' do
let (:platform_params) do let (:platform_params) do
case facts[:osfamily] case facts[:osfamily]
when 'Debian' when 'Debian'
if facts[:os_package_type] == 'debian' if facts[:operatingsystem] == 'Debian'
{ :nova_vncproxy_package => 'nova-consoleproxy', { :nova_vncproxy_package => 'nova-consoleproxy',
:nova_vncproxy_service => 'nova-novncproxy' } :nova_vncproxy_service => 'nova-novncproxy' }
else else
@ -175,7 +171,7 @@ describe 'nova::vncproxy' do
it_behaves_like 'nova_vnc_proxy' it_behaves_like 'nova_vnc_proxy'
if facts[:os_package_type] == 'debian' if facts[:operatingsystem] == 'Debian'
it_behaves_like 'nova_vnc_proxy debian package' it_behaves_like 'nova_vnc_proxy debian package'
end end