Skip to content

Commit

Permalink
handle Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoll committed May 17, 2020
1 parent 640f347 commit 795fbae
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifests/plugin/cuda.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
include collectd

$_manage_package = pick($manage_package, $collectd::manage_package)
if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' {
if ($facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8') or ($facts['os']['name'] == 'Ubuntu' and $facts['os']['release']['major'] == '20.04') {
$_python_pip_package = 'python3-pip'
if $package_provider =~ Undef {
$_package_provider = 'pip3'
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/iscdhcp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

$_manage_package = pick($manage_package, $collectd::manage_package)

if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' {
if ($facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8') or ($facts['os']['name'] == 'Ubuntu' and $facts['os']['release']['major'] == '20.04') {
$_python_pip_package = 'python3-pip'
if $package_provider =~ Undef {
$_package_provider = 'pip3'
Expand Down
2 changes: 1 addition & 1 deletion manifests/plugin/rabbitmq.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
) {
include collectd

if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'],'8') >= 0 {
if ($facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8') or ($facts['os']['name'] == 'Ubuntu' and $facts['os']['release']['major'] == '20.04') {
fail('https://pypi.org/project/collectd-rabbitmq/ does not support Python 3')
}

Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/class_plugin_python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class { 'collectd::plugin::csv':}
ensure => present,
}
}
if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8' {
if ($facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '8') or ($facts['os']['name'] == 'Ubuntu' and $facts['os']['release']['major'] == '20.04') {
$_python_pip_package = 'python3-pip'
$_pip_provider = 'pip3'
} else {
Expand Down
14 changes: 14 additions & 0 deletions spec/classes/collectd_plugin_rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
case [facts[:os]['family'], facts[:os]['release']['major']]
when %w[RedHat 8]
it { is_expected.to raise_error(%r{does not support Python 3}) }
when %w[Ubuntu 20.04]
it { is_expected.to raise_error(%r{does not support Python 3}) }
else
it 'import collectd_rabbitmq.collectd_plugin in python-config' do
is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_header').with_content(%r{Import "collectd_rabbitmq.collectd_plugin"})
Expand Down Expand Up @@ -69,6 +71,8 @@
case [facts[:os]['family'], facts[:os]['release']['major']]
when %w[RedHat 8]
it { is_expected.to raise_error(%r{does not support Python 3}) }
when %w[Ubuntu 20.04]
it { is_expected.to raise_error(%r{does not support Python 3}) }
else
it 'override custom TypesDB' do
is_expected.to contain_file('rabbitmq.load').with_content(%r{TypesDB "/var/custom/types.db"})
Expand All @@ -84,6 +88,8 @@
case [facts[:os]['family'], facts[:os]['release']['major']]
when %w[RedHat 8]
it { is_expected.to raise_error(%r{does not support Python 3}) }
when %w[Ubuntu 20.04]
it { is_expected.to raise_error(%r{does not support Python 3}) }
else
it 'override Username to foo in python-config' do
is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Username "foo"})
Expand All @@ -99,6 +105,8 @@
case [facts[:os]['family'], facts[:os]['release']['major']]
when %w[RedHat 8]
it { is_expected.to raise_error(%r{does not support Python 3}) }
when %w[Ubuntu 20.04]
it { is_expected.to raise_error(%r{does not support Python 3}) }
else
it 'override Username to foo in python-config' do
is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Password "foo"})
Expand All @@ -114,6 +122,8 @@
case [facts[:os]['family'], facts[:os]['release']['major']]
when %w[RedHat 8]
it { is_expected.to raise_error(%r{does not support Python 3}) }
when %w[Ubuntu 20.04]
it { is_expected.to raise_error(%r{does not support Python 3}) }
else
it 'override Username to foo in python-config' do
is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with_content(%r{Scheme "https"})
Expand All @@ -130,6 +140,8 @@
case [facts[:os]['family'], facts[:os]['release']['major']]
when %w[RedHat 8]
it { is_expected.to raise_error(%r{does not support Python 3}) }
when %w[Ubuntu 20.04]
it { is_expected.to raise_error(%r{does not support Python 3}) }
else
it 'Will remove python-config' do
is_expected.not_to contain_concat__fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin_config').with(ensure: 'present')
Expand Down Expand Up @@ -157,6 +169,8 @@
case [facts[:os]['family'], facts[:os]['release']['major']]
when %w[RedHat 8]
it { is_expected.to raise_error(%r{does not support Python 3}) }
when %w[Ubuntu 20.04]
it { is_expected.to raise_error(%r{does not support Python 3}) }
else
it do
is_expected.to contain_package(packagename).with(
Expand Down

0 comments on commit 795fbae

Please sign in to comment.