From 5a02533d7cd52ec56d2294d05ebe9344925ebded Mon Sep 17 00:00:00 2001 From: Gael Chamoulaud Date: Sun, 29 Mar 2015 15:58:24 +0200 Subject: [PATCH] Use versioncmp for '::operatingsystemmajrelease' comparison Use the builtin versioncmp() function for comparisons of the '::operatingsystemmajrelease' fact. If that fact evaluates to a string, regular arithmetric comparisons will fail under the Puppet 4.x language. Change-Id: Ib55dabd3c33f5773ac3ca67955e0f85418ec0698 Closes-bug: 1425300 Signed-off-by: Gael Chamoulaud --- manifests/params.pp | 2 +- spec/classes/cinder_volume_iscsi_spec.rb | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 2a91a217..5bdb7bb5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -43,7 +43,7 @@ class cinder::params { case $::operatingsystem { 'RedHat', 'CentOS', 'Scientific': { - if $::operatingsystemmajrelease >= 7 { + if (versioncmp($::operatingsystemmajrelease, '7') >= 0) { $iscsi_helper = 'lioadm' } else { $iscsi_helper = 'tgtadm' diff --git a/spec/classes/cinder_volume_iscsi_spec.rb b/spec/classes/cinder_volume_iscsi_spec.rb index 90dff1e8..f2a75839 100644 --- a/spec/classes/cinder_volume_iscsi_spec.rb +++ b/spec/classes/cinder_volume_iscsi_spec.rb @@ -43,7 +43,7 @@ describe 'cinder::volume::iscsi' do it_raises 'a Puppet::Error', /Unsupported iscsi helper: fooboozoo/ end - describe 'with RedHat' do + describe 'on RHEL Platforms' do let :params do req_params @@ -52,6 +52,7 @@ describe 'cinder::volume::iscsi' do let :facts do {:osfamily => 'RedHat', :operatingsystem => 'RedHat', + :operatingsystemrelease => 6.5, :operatingsystemmajrelease => '6'} end @@ -66,12 +67,15 @@ describe 'cinder::volume::iscsi' do let :params do { :iscsi_ip_address => '127.0.0.2', - :iscsi_helper => 'lioadm' + :iscsi_helper => 'lioadm' } end let :facts do - {:osfamily => 'RedHat'} + {:osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => 7.0, + :operatingsystemmajrelease => '7'} end it { is_expected.to contain_package('targetcli').with_ensure('present')}