Add support for IPv6 Deployment 91/68491/16
authorJanki Chhatbar <jankihchhatbar@gmail.com>
Mon, 23 Jul 2018 18:49:52 +0000 (00:19 +0530)
committerJanki Chhatbar <jchhatba@redhat.com>
Fri, 21 Sep 2018 11:50:50 +0000 (11:50 +0000)
Till now, only IPv4 deployment of ODL was supported.
With this patch IPv6 will be supported. EXTRA_JAVA_OPTS
property is set accordingly java.net.preferIPv4Stack=true
to allow only IPv4 addresses. java.net.preferIPv6Addresses=true
to allow both IPv4 and IPv6 address.

Change-Id: I760681e447f6bec4f249f75501b9363793b41ccc
Signed-Off-By: Janki Chhatbar <jchhatba@redhat.com>
CHANGELOG
README.markdown
manifests/config.pp
manifests/init.pp
manifests/params.pp
metadata.json
spec/acceptance/class_spec.rb
spec/classes/opendaylight_spec.rb
spec/spec_helper.rb
spec/spec_helper_acceptance.rb
templates/akka.conf.erb

index 2f7d3aa5b42c59f2b39baa58b16e872d1ecc5894..0347d416178e8ad95d0b16d0057c7c2da7829884 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -80,3 +80,5 @@
 - Bind karaf shell to ODL bind IP
 2018-07-16 Release 8.3.0
 - Disable regular polling of OF statistics
+2018-07-23 Release 8.4.0
+- Enable IPv6 deployment
index 97ed481c96a74edc9ec926b43fc67c4be55afbb3..1c7f932e2948ff9b214299ea76083b3e0bf5de23 100644 (file)
@@ -395,9 +395,10 @@ 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. Note, these options
-are in addition to the default Java options set by the karaf/ODL boot scripts.
+are in addition to the default Java options set by the karaf/ODL boot scripts
+and IP version based flag set by 'opendaylight' class.
 
-Default: `'-Djava.net.preferIPv4Stack=true'`
+Default: `''`
 
 Valid options: A string of valid Java options.
 
index f76f31ed0c1f43ec6650a175cbd50e9e9953d7e7..ebf9cc3f1cac682414dcc81620974a4918d059a2 100644 (file)
@@ -23,7 +23,7 @@ class opendaylight::config {
   file_line {'Karaf Java Options':
     ensure => present,
     path   => '/opt/opendaylight/bin/karaf',
-    line   => "EXTRA_JAVA_OPTS=${opendaylight::java_opts}",
+    line   => "EXTRA_JAVA_OPTS=${opendaylight::java_options}",
     match  => '^EXTRA_JAVA_OPTS=.*$',
     after  => '^PROGNAME=.*$'
   }
index 308e1cafeffe09277c1b5b5ec15f432a09ccb56d..42ef3272cc339a70123299780714ff5880e4d458 100644 (file)
@@ -30,7 +30,7 @@
 # [*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'.
+#   Sets Java options for ODL in a string format. Defaults to ''.
 # [*manage_repositories*]
 #   (Boolean) Should this module manage the apt or yum repositories for the
 #   package installation.
@@ -67,6 +67,7 @@
 # [*stats_polling_enabled*]
 #   Enables statistics polling of OpenFlow entities like table, groups.
 #   Defaults to false
+#
 # === Deprecated Parameters
 #
 # [*ha_node_index*]
@@ -83,9 +84,9 @@ class opendaylight (
   $enable_ha             = $::opendaylight::params::enable_ha,
   $ha_node_ips           = $::opendaylight::params::ha_node_ips,
   $ha_node_index         = $::opendaylight::params::ha_node_index,
+  $java_opts             = $::opendaylight::params::java_opts,
   $ha_db_modules         = $::opendaylight::params::ha_db_modules,
   $vpp_routing_node      = $::opendaylight::params::vpp_routing_node,
-  $java_opts             = $::opendaylight::params::java_opts,
   $manage_repositories   = $::opendaylight::params::manage_repositories,
   $username              = $::opendaylight::params::username,
   $password              = $::opendaylight::params::password,
@@ -144,6 +145,15 @@ class opendaylight (
   # Build full list of features to install
   $features = union($default_features, $extra_features)
 
+  if $opendaylight::odl_bind_ip =~ Stdlib::Compat::Ipv6 {
+    $enable_ipv6 = true
+    $java_options = join(union(['-Djava.net.preferIPv6Addresses=true'], any2array($opendaylight::java_opts)), ' ')
+  }
+  else {
+    $enable_ipv6 = false
+    $java_options = join(union(['-Djava.net.preferIPv4Stack=true'], any2array($opendaylight::java_opts)), ' ')
+  }
+
   class { '::opendaylight::install': }
   -> class { '::opendaylight::config': }
   ~> class { '::opendaylight::service': }
index a3b4de45ae5aa4a6bbcaa50ab34b271519859883..9b2acd5466e6610e7a769ed70d75378e81b066fa 100644 (file)
@@ -20,7 +20,7 @@ class opendaylight::params {
   $ha_node_index = 0
   $ha_db_modules = { 'default' => false }
   $vpp_routing_node = ''
-  $java_opts = '-Djava.net.preferIPv4Stack=true'
+  $java_opts = ''
   $manage_repositories = true
   $username = 'admin'
   $password = 'admin'
index 12ed99dc51f760c4e3db75b4db009c0cb64b8a74..1db9942459d5278ad2d49fa94efa55e3163ba343 100644 (file)
@@ -1,6 +1,6 @@
 {
     "name": "opendaylight-opendaylight",
-    "version": "8.3.0",
+    "version": "8.4.0",
     "author": "Daniel Farrell",
     "summary": "Puppet module that installs and configures the OpenDaylight SDN controller",
     "license": "BSD-2-Clause",
index e223a4a54eddedfd4d937f1d3ba5fcb56fa835cf..a233f343790401766bd799b7c7ac0be22a99dad7 100644 (file)
@@ -306,6 +306,23 @@ describe 'opendaylight class' do
       # Call specialized helper fn for polling enablement validations
       stats_polling_validations
     end
+  end
+
+  describe 'testing different IPv deployments' do
+    context 'IPv6 support tests' do
+      # Call specialized helper fn to install OpenDaylight
+      install_odl(odl_bind_ip: '::1')
+
+      # Call specialized helper fn for polling enablement validations
+      generic_validations(odl_bind_ip: '::1')
+    end
 
+    context 'IPv4 support test' do
+      # Call specialized helper fn to install OpenDaylight
+      install_odl(odl_bind_ip: '127.0.0.1')
+
+      # Call specialized helper fn for polling enablement validations
+      generic_validations(odl_bind_ip: '127.0.0.1')
+    end
   end
 end
index 76bbb16d4fef0f9bbf4457d40d16c76a097e6429..98ab84dc33de3bf541674b0a96443ed90451ffb9 100644 (file)
@@ -1130,4 +1130,45 @@ describe 'opendaylight' do
       stats_polling_enablement_tests(stats_polling_enabled:true)
     end
   end
+
+  describe 'Different IPv support tests' do
+    # Non-OS-type tests assume CentOS 7
+    #   See issue #43 for reasoning:
+    #   https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
+    osfamily = 'RedHat'
+    operatingsystem = 'CentOS'
+    operatingsystemmajrelease = '7'
+
+    context 'IPv6 deployment' do
+      let(:facts) {{
+        :osfamily => osfamily,
+        :operatingsystem => operatingsystem,
+        :operatingsystemmajrelease => operatingsystemmajrelease,
+      }}
+
+      let(:params) {{
+        :odl_bind_ip => '::1'
+        }}
+
+      # Run shared tests applicable to all supported OSs
+      # Note that this function is defined in spec_helper
+      generic_tests(odl_bind_ip:'::1')
+    end
+
+    context 'IPv4 deployment' do
+      let(:facts) {{
+        :osfamily => osfamily,
+        :operatingsystem => operatingsystem,
+        :operatingsystemmajrelease => operatingsystemmajrelease,
+      }}
+
+      let(:params) {{
+        :odl_bind_ip => '127.0.0.1'
+        }}
+
+      # Run shared tests applicable to all supported OSs
+      # Note that this function is defined in spec_helper
+      generic_tests(odl_bind_ip:'127.0.0.1')
+    end
+  end
 end
index eb5c4693c2b10a2e2e459de3d2289f6c6533620b..f17990ea3b2564c9d142e667b437b342613ed643 100644 (file)
@@ -14,7 +14,8 @@ RSpec::Puppet::Coverage.filters.push(*custom_filters)
 
 # Tests that are common to all possible configurations
 def generic_tests(options = {})
-  java_opts = options.fetch(:java_opts, '-Djava.net.preferIPv4Stack=true')
+  java_opts = options.fetch(:java_opts, '')
+  odl_bind_ip = options.fetch(:odl_bind_ip, '127.0.0.1')
 
   # Confirm that module compiles
   it { should compile }
@@ -63,10 +64,16 @@ def generic_tests(options = {})
   }
 
   it {
+    if odl_bind_ip =~ /.*:.*/
+        java_options = '-Djava.net.preferIPv6Addresses=true'
+    else
+        java_options = '-Djava.net.preferIPv4Stack=true'
+    end
+
     should contain_file_line('Karaf Java Options').with(
       'ensure' => 'present',
       'path'   => '/opt/opendaylight/bin/karaf',
-      'line'   => "EXTRA_JAVA_OPTS=#{java_opts}",
+      'line'   => "EXTRA_JAVA_OPTS=#{java_options}",
       'match'  => '^EXTRA_JAVA_OPTS=.*$',
       'after'  => '^PROGNAME=.*$'
     )
index 34b526b0651f663f310066f1dacfd62982a2beab..86b43645fb79b30947360d89d5e23ed8685da3a0 100644 (file)
@@ -118,8 +118,7 @@ end
 # Shared function that handles generic validations
 # These should be common for all odl class param combos
 def generic_validations(options = {})
-  java_opts = options.fetch(:java_opts, '-Djava.net.preferIPv4Stack=true')
-
+  java_opts = options.fetch(:java_opts, [])
   # Verify ODL's directory
   describe file('/opt/opendaylight/') do
     it { should be_directory }
@@ -170,12 +169,19 @@ def generic_validations(options = {})
     it { should be_grouped_into 'odl' }
   end
 
+  odl_bind_ip = options.fetch(:odl_bind_ip, '127.0.0.1')
+  if odl_bind_ip == '127.0.0.1'
+    java_options = ['-Djava.net.preferIPv4Stack=true'] + java_opts
+  else
+    java_options = ['-Djava.net.preferIPv6Addresses=true'] + java_opts
+  end
+
   # Should contain karaf file with Java options set
   describe file('/opt/opendaylight/bin/karaf') do
     it { should be_file }
     it { should be_owned_by 'odl' }
     it { should be_grouped_into 'odl' }
-    its(:content) { should match /^EXTRA_JAVA_OPTS=#{java_opts}$/ }
+    its(:content) { should match /^EXTRA_JAVA_OPTS=#{java_options.join(" ")}/ }
   end
 
   # Should contain ODL NB port config file
index 99ea577881c0761be695303cceef379221db9802..8f2fddda463cdb17111735245a4885a0bf48d2be 100644 (file)
@@ -4,11 +4,19 @@ odl-cluster-data {
     remote {
       artery {
         enabled = off
+        <%- if scope.lookupvar('opendaylight::enable_ipv6') -%>
+        canonical.hostname = "[<%= scope.lookupvar('opendaylight::odl_bind_ip') %>]"
+        <%- else -%>
         canonical.hostname = "<%= scope.lookupvar('opendaylight::odl_bind_ip') %>"
+        <% end -%>
         canonical.port = 2550
       }
       netty.tcp {
+        <%- if scope.lookupvar('opendaylight::enable_ipv6') -%>
+        hostname = "[<%= scope.lookupvar('opendaylight::odl_bind_ip') %>]"
+        <%- else -%>
         hostname = "<%= scope.lookupvar('opendaylight::odl_bind_ip') %>"
+        <% end -%>
         port = 2550
       }
     }
@@ -17,8 +25,12 @@ odl-cluster-data {
       # Remove ".tcp" when using artery.
       seed-nodes = [
         <% scope.lookupvar('opendaylight::ha_node_ips').each do |ha_ip| -%>
+        <%- if scope.lookupvar('opendaylight::enable_ipv6') -%>
+        "akka.tcp://opendaylight-cluster-data@[<%= ha_ip %>]:2550",
+        <%- else -%>
         "akka.tcp://opendaylight-cluster-data@<%= ha_ip %>:2550",
         <% end -%>
+        <% end -%>
         ]
 
       roles = ["member-<%=scope.lookupvar('opendaylight::ha_node_ips').index(scope.lookupvar('opendaylight::odl_bind_ip'))%>"]