aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeng Pan <fpan@redhat.com>2017-09-20 07:50:44 -0400
committerFeng Pan <fpan@redhat.com>2017-09-21 14:36:15 -0400
commitb719cbb990b1c6f56eefb08170fe7d36eb6fbee1 (patch)
treecc74e998a65b2643b1d0135345d2019e6726eaf5
parent19fa56176090ca9a1dbce1dff944d8946d15b20a (diff)
Add startup exec commands support
This patch adds support for configuring VPP startup exec commands. The commands specified will be appeneded to the exec file specified if the file already exists. JIRA: PUP-6 Change-Id: Ief8097041473573bfdb9c8460b99e14723eaa36d Signed-off-by: Feng Pan <fpan@redhat.com>
-rw-r--r--manifests/config.pp12
-rw-r--r--manifests/config/vpp_exec_line.pp20
-rw-r--r--manifests/init.pp11
-rw-r--r--manifests/params.pp2
-rw-r--r--spec/acceptance/fdio_spec.rb7
-rw-r--r--spec/classes/fdio_spec.rb15
6 files changed, 67 insertions, 0 deletions
diff --git a/manifests/config.pp b/manifests/config.pp
index 7a2a2b3..9f5fc58 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -50,6 +50,18 @@ class fdio::config {
}
}
+ if !empty($fdio::vpp_exec_commands) {
+ file { $fdio::vpp_exec_file:
+ ensure => present,
+ }
+ fdio::config::vpp_exec_line { $fdio::vpp_exec_commands:
+ path => $fdio::vpp_exec_file,
+ }
+ vpp_config {
+ 'unix/exec': value => $fdio::vpp_exec_file;
+ }
+ }
+
vpp_config {
'cpu/main-core': value => $fdio::vpp_cpu_main_core;
'cpu/corelist-workers': value => $fdio::vpp_cpu_corelist_workers;
diff --git a/manifests/config/vpp_exec_line.pp b/manifests/config/vpp_exec_line.pp
new file mode 100644
index 0000000..5c64487
--- /dev/null
+++ b/manifests/config/vpp_exec_line.pp
@@ -0,0 +1,20 @@
+# == Define: fdio::config::vpp_exec_line
+#
+# Defined type to configure VPP startup exec line
+#
+# === Parameters:
+# [*path*]
+# (required) Path of VPP exec file path
+#
+# [*line*]
+# (required) VPP exec command
+#
+define fdio::config::vpp_exec_line (
+ $path,
+ $line = $title,
+) {
+ file_line { "${line}":
+ path => $path,
+ line => $line
+ }
+} \ No newline at end of file
diff --git a/manifests/init.pp b/manifests/init.pp
index 1f031e7..cdd9499 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -8,6 +8,15 @@
# Valid values are 'release', 'master' and stable branch like 'stable.1609'.
# Defaults to 'release'.
#
+# [*vpp_exec_commands*]
+# (optional) array of VPP startup exec commands
+# Defaults to undef
+#
+# [*vpp_exec_file*]
+# (optional) VPP startup exec file path. Existing config file will not be
+# overwritten, vpp_exec_commands will be appended.
+# Defaults to '/etc/vpp/vpp-exec'
+#
# [*vpp_dpdk_support*]
# (optional) Enable DPDK support for VPP
# Defaults to true
@@ -76,6 +85,8 @@
#
class fdio (
$repo_branch = $::fdio::params::repo_branch,
+ $vpp_exec_commands = $::fdio::params::vpp_exec_commands,
+ $vpp_exec_file = $::fdio::params::vpp_exec_file,
$vpp_dpdk_support = $::fdio::params::vpp_dpdk_support,
$vpp_dpdk_devs = $::fdio::params::vpp_dpdk_devs,
$vpp_dpdk_uio_driver = $::fdio::params::vpp_dpdk_uio_driver,
diff --git a/manifests/params.pp b/manifests/params.pp
index 3df8175..4528e6a 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -4,6 +4,8 @@
#
class fdio::params {
$repo_branch = 'release'
+ $vpp_exec_commands = undef
+ $vpp_exec_file = '/etc/vpp/vpp-exec'
$vpp_dpdk_support = true
$vpp_dpdk_devs = []
$vpp_dpdk_uio_driver = 'uio_pci_generic'
diff --git a/spec/acceptance/fdio_spec.rb b/spec/acceptance/fdio_spec.rb
index 4be1865..250de9a 100644
--- a/spec/acceptance/fdio_spec.rb
+++ b/spec/acceptance/fdio_spec.rb
@@ -44,6 +44,8 @@ describe 'fdio' do
vpp_tuntap_enable => true,
vpp_tuntap_mtu => 9000,
vpp_tapcli_mtu => 8000,
+ vpp_exec_commands => 'test line 1',
+ vpp_exec_file => '/etc/vpp/vpp-exec'
}
EOS
@@ -60,6 +62,11 @@ describe 'fdio' do
its(:content) { should match /enable/ }
its(:content) { should match /mtu 9000/ }
its(:content) { should match /mtu 8000/ }
+ its(:content) { should match /\/etc\/vpp\/vpp-exec/ }
+ end
+
+ describe file('/etc/vpp/vpp-exec') do
+ its(:content) { should match /test line 1/ }
end
end
end
diff --git a/spec/classes/fdio_spec.rb b/spec/classes/fdio_spec.rb
index 3b260ca..b543246 100644
--- a/spec/classes/fdio_spec.rb
+++ b/spec/classes/fdio_spec.rb
@@ -101,6 +101,21 @@ describe 'fdio' do
is_expected.to contain_vpp_config('tapcli/mtu').with_value('9000')
end
end
+
+ context 'with exec commands' do
+ before :each do
+ params.merge!(
+ :vpp_exec_commands => ['test line 1', 'test line 2'],
+ :vpp_exec_file => '/etc/vpp/test_exec_file'
+ )
+ end
+ it 'should configure exec lines' do
+ is_expected.to contain_file('/etc/vpp/test_exec_file').with_ensure('present')
+ is_expected.to contain_vpp_config('unix/exec').with_value('/etc/vpp/test_exec_file')
+ is_expected.to contain_fdio__config__vpp_exec_line('test line 1')
+ is_expected.to contain_fdio__config__vpp_exec_line('test line 2')
+ end
+ end
end
shared_examples_for 'fdio - service' do