Adds ability to pass Java options to ODL startup 55/55655/1
authorTim Rozet <tdrozet@gmail.com>
Thu, 23 Feb 2017 19:35:22 +0000 (14:35 -0500)
committerDaniel Farrell <dfarrell@redhat.com>
Wed, 19 Apr 2017 19:18:40 +0000 (15:18 -0400)
Previously we always set the Java options to a single value which will
only run Java with ipv4 stack.  There is a requirement to be able to set
other parameters like heap seize or enable garbage collection.  This
change exposes a parameter where many Java options can be set via a
string.

Change-Id: Ib79a83dd59f65a61912a4917e18e41196e7f91cd
Signed-off-by: Tim Rozet <tdrozet@gmail.com>
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
README.markdown
manifests/init.pp
manifests/install.pp
manifests/params.pp
spec/spec_helper.rb

index c0d3508dadd075ed5f4043c4f1edc86a29bc051e..444381ffa54582bd486a16889cf9ada63cd2d991 100644 (file)
@@ -377,7 +377,7 @@ Specifies the mode to use for security groups.
 
 Default: `stateful`
 
-Valid options: `transparent`, `learn`, `statless`
+Valid options: `transparent`, `learn`, `stateless`
 
 ##### `vpp_routing_node`
 
@@ -388,6 +388,14 @@ Default: `''`
 
 Valid options: A valid host name to a VPP node handling routing.
 
+##### `java_opts`
+
+Specifies the Java options to run ODL with as a string.
+
+Default: `'-Djava.net.preferIPv4Stack=true'`
+
+Valid options: A string of valid Java options.
+
 ## Limitations
 
 - Tested on Fedora 22, 23, CentOS 7 and Ubuntu 14.04.
index 0aef0f92d86b57ccfe60beed7a5fff537b811d4e..d31ffb467202718abe054af945ded59120f98d98 100644 (file)
@@ -36,6 +36,8 @@
 #   Sets the mode to use for security groups (stateful, learn, stateless, transparent)
 # [*vpp_routing_node*]
 #   Sets routing node for VPP deployments. Defaults to ''.
+# [*java_opts*]
+#   Sets Java options for ODL in a string format. Defaults to '-Djava.net.preferIPv4Stack=true'.
 #
 class opendaylight (
   $default_features    = $::opendaylight::params::default_features,
@@ -52,6 +54,7 @@ class opendaylight (
   $ha_node_index       = $::opendaylight::params::ha_node_index,
   $security_group_mode = $::opendaylight::params::security_group_mode,
   $vpp_routing_node    = $::opendaylight::params::vpp_routing_node,
+  $java_opts           = $::opendaylight::params::java_opts,
 ) inherits ::opendaylight::params {
 
   # Validate OS family
index f89a1fb33588b2f3aadc08dffdbaee6ba6bbadc3..c45d5f3dc3b855a2500c3c6fd4d5895e1134cefd 100644 (file)
@@ -29,11 +29,12 @@ class opendaylight::install {
       require => Yumrepo[$opendaylight::rpm_repo],
     }
     ->
-    # Configure the systemd file to force ipv4 binds (instead of ipv6)
-    file_line { 'odl_start_ipv4':
+    # Configure the systemd file with Java options
+    file_line { 'java_options_systemd':
       ensure => present,
       path   => '/usr/lib/systemd/system/opendaylight.service',
-      line   => 'Environment=_JAVA_OPTIONS=\'-Djava.net.preferIPv4Stack=true\'',
+      line   => "Environment=_JAVA_OPTIONS=\'${opendaylight::java_opts}\'",
+      match  => '^Environment.*',
       after  => 'ExecStart=/opt/opendaylight/bin/start',
     }
     ->
index 51d0d2fc99040c343dd04358525a8fb3e91c04bf..1e0aa68be77fb74789c60c4b86317cacef477832 100644 (file)
@@ -22,4 +22,5 @@ class opendaylight::params {
   $ha_node_index = 0
   $security_group_mode = 'stateful'
   $vpp_routing_node = ''
+  $java_opts = '-Djava.net.preferIPv4Stack=true'
 }
index ce67018c0c6348f582eb6960491e48cabc87c042..7b130b13acd861947a6fecbf75be1399bc9374aa 100644 (file)
@@ -347,6 +347,7 @@ end
 def rpm_install_tests(options = {})
   # Extract params
   rpm_repo = options.fetch(:rpm_repo, 'opendaylight-5-testing')
+  java_opts = options.fetch(:java_opts, '-Djava.net.preferIPv4Stack=true')
 
   # Default to CentOS 7 Yum repo URL
 
@@ -376,10 +377,10 @@ def rpm_install_tests(options = {})
   }
 
   it {
-    should contain_file_line('odl_start_ipv4').with(
+    should contain_file_line('java_options_systemd').with(
       'ensure' => 'present',
       'path' => '/usr/lib/systemd/system/opendaylight.service',
-      'line' => 'Environment=_JAVA_OPTIONS=\'-Djava.net.preferIPv4Stack=true\'',
+      'line' => "Environment=_JAVA_OPTIONS=\'#{java_opts}\'",
       'after' => 'ExecStart=/opt/opendaylight/bin/start',
     )
   }