Added parameter validation for socket_mem parameter

Change-Id: I886b08c4c7bf419313bece5f9e8b4c93a7e61aa1
Closes-Bug: #1689936
Signed-off-by: Karthik S <ksundara@redhat.com>
This commit is contained in:
Karthik S 2017-05-10 16:39:43 -04:00
parent 4f621646df
commit 74bac67ae3
2 changed files with 11 additions and 2 deletions

View File

@ -60,7 +60,10 @@ class vswitch::dpdk (
# DPDK_OPTIONS is no longer used in ovs 2.6, since it was a distribution
# specific hack to the ovs-ctl scripts. Instead dpdk information is
# pulled from the ovsdb.
if $socket_mem {
if $socket_mem and !empty($socket_mem) {
unless $socket_mem =~ /^(\d+\,?)+$/ {
fail( 'socket_mem is in incorrect format')
}
$socket_string = "--socket-mem ${socket_mem}"
}
else {

View File

@ -101,7 +101,6 @@ describe 'vswitch::dpdk' do
end
end
context 'when passing all params' do
before :each do
params.merge!(:host_core_list => '1,2')
@ -134,6 +133,13 @@ describe 'vswitch::dpdk' do
end
end
context 'when passing invalid socket_mem' do
before :each do
params.merge!(:socket_mem => "'1024'")
end
it { is_expected.to raise_error(Puppet::Error, /socket_mem is in incorrect format/) }
end
context 'when providing valid driver type facts' do
let :facts do
OSDefaults.get_facts({